diff options
author | Nikias Bassen | 2022-04-10 00:09:08 +0200 |
---|---|---|
committer | Nikias Bassen | 2022-04-10 00:09:08 +0200 |
commit | 190473b75b1f0f142cf878f79d19ae53e0cf8146 (patch) | |
tree | 44be295eec4c16978d6c1e825e96a245c68438fd /src | |
parent | e833a301287246b3d5c61ca181e4283b2b5ff488 (diff) | |
download | idevicerestore-190473b75b1f0f142cf878f79d19ae53e0cf8146.tar.gz idevicerestore-190473b75b1f0f142cf878f79d19ae53e0cf8146.tar.bz2 |
restore: Fixed a problem that nobody even knew existed
At least this has been going unnoticed until recently. For quite some time
we have been sending NorImageData as array to the device, but it turned out
that this was only expected for iOS < 7.0 and from then on it was supposed
to be a dictionary with the components.
Now we should correctly handle it.
Diffstat (limited to 'src')
-rw-r--r-- | src/restore.c | 16 | ||||
-rw-r--r-- | src/restore.h | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/restore.c b/src/restore.c index cdbd791..d2611a5 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1109,7 +1109,7 @@ int restore_send_component(restored_client_t restore, struct idevicerestore_clie return 0; } -int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity) +int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity, plist_t message) { char* llb_path = NULL; char* llb_filename = NULL; @@ -1127,9 +1127,15 @@ int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* unsigned char* nor_data = NULL; plist_t norimage = NULL; plist_t firmware_files = NULL; + int flash_version_1 = 0; info("About to send NORData...\n"); + plist_t arguments = plist_dict_get_item(message, "Arguments"); + if (arguments && plist_get_node_type(arguments) == PLIST_DICT) { + flash_version_1 = plist_dict_get_item(arguments, "FlashVersion1") ? 1 : 0; + } + if (client->tss) { if (tss_response_get_path_by_entry(client->tss, "LLB", &llb_path) < 0) { debug("NOTE: Could not get LLB path from TSS data, will fetch from build identity\n"); @@ -1249,9 +1255,7 @@ int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* plist_dict_set_item(dict, "LlbImageData", plist_new_data((char*)llb_data, (uint64_t) llb_size)); free(llb_data); - if (client->build_major >= 20) { - // Starting with M1 macs, it seems that NorImageData is now a dict. - // Sending an array like previous versions results in restore success but the machine will SOS after rebooting. + if (flash_version_1) { norimage = plist_new_dict(); } else { norimage = plist_new_array(); @@ -1307,7 +1311,7 @@ int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* component_data = NULL; component_size = 0; - if (client->build_major >= 20) { + if (flash_version_1) { plist_dict_set_item(norimage, component, plist_new_data((char*)nor_data, (uint64_t)nor_size)); } else { /* make sure iBoot is the first entry in the array */ @@ -3633,7 +3637,7 @@ int restore_handle_data_request_msg(struct idevicerestore_client_t* client, idev else if (!strcmp(type, "NORData")) { if((client->flags & FLAG_EXCLUDE) == 0) { - if(restore_send_nor(restore, client, build_identity) < 0) { + if(restore_send_nor(restore, client, build_identity, message) < 0) { error("ERROR: Unable to send NOR data\n"); return -1; } diff --git a/src/restore.h b/src/restore.h index c93e325..ad3b721 100644 --- a/src/restore.h +++ b/src/restore.h @@ -53,7 +53,7 @@ const char* restore_progress_string(unsigned int operation); int restore_handle_status_msg(restored_client_t client, plist_t msg); int restore_handle_progress_msg(struct idevicerestore_client_t* client, plist_t msg); int restore_handle_data_request_msg(struct idevicerestore_client_t* client, idevice_t device, restored_client_t restore, plist_t message, plist_t build_identity, const char* filesystem); -int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity); +int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity, plist_t message); int restore_send_root_ticket(restored_client_t restore, struct idevicerestore_client_t* client); int restore_send_component(restored_client_t restore, struct idevicerestore_client_t* client, plist_t build_identity, const char* component, const char* component_name); int restore_device(struct idevicerestore_client_t* client, plist_t build_identity, const char* filesystem); |