From b4af2e2d79d11c0cb6869d111ae7eca02c9e5c0b Mon Sep 17 00:00:00 2001 From: Rudolf Tammekivi Date: Wed, 16 Jan 2019 03:16:02 +0100 Subject: recovery: Add support for IsLoadedByiBoot:true components --- src/recovery.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/recovery.h | 1 + 2 files changed, 53 insertions(+) diff --git a/src/recovery.c b/src/recovery.c index 2871773..b54a8b2 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -203,6 +203,12 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build return -1; } + /* send components loaded by iBoot */ + if (recovery_send_loaded_by_iboot(client, build_identity) < 0) { + error("ERROR: Unable to send components supposed to be loaded by iBoot\n"); + return -1; + } + /* send ramdisk and run it */ if (recovery_send_ramdisk(client, build_identity) < 0) { error("ERROR: Unable to send Ramdisk\n"); @@ -383,6 +389,52 @@ int recovery_send_devicetree(struct idevicerestore_client_t* client, plist_t bui return 0; } +int recovery_send_loaded_by_iboot(struct idevicerestore_client_t* client, plist_t build_identity) { + if (client->recovery == NULL) { + if (recovery_client_new(client) < 0) { + return -1; + } + } + + plist_t manifest_node = plist_dict_get_item(build_identity, "Manifest"); + if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) { + error("ERROR: Unable to find manifest node\n"); + return -1; + } + + plist_dict_iter iter = NULL; + plist_dict_new_iter(manifest_node, &iter); + int err = 0; + while (iter) { + char *key = NULL; + plist_t node = NULL; + plist_dict_next_item(manifest_node, iter, &key, &node); + if (key == NULL) + break; + plist_t iboot_node = plist_access_path(node, 2, "Info", "IsLoadedByiBoot"); + if (iboot_node && plist_get_node_type(iboot_node) == PLIST_BOOLEAN) { + uint8_t b = 0; + plist_get_bool_val(iboot_node, &b); + if (b) { + debug("DEBUG: %s is loaded by iBoot.\n", key); + if (recovery_send_component(client, build_identity, key) < 0) { + error("ERROR: Unable to send component '%s' to device.\n", key); + err++; + } else { + if (irecv_send_command(client->recovery->client, "firmware") != IRECV_E_SUCCESS) { + error("ERROR: iBoot command 'firmware' failed for component '%s'\n", key); + err++; + } + } + } + } + free(key); + } + free(iter); + + return (err) ? -1 : 0; +} + int recovery_send_ramdisk(struct idevicerestore_client_t* client, plist_t build_identity) { const char *component = "RestoreRamDisk"; irecv_error_t recovery_error = IRECV_E_SUCCESS; diff --git a/src/recovery.h b/src/recovery.h index 7da2432..872b0be 100644 --- a/src/recovery.h +++ b/src/recovery.h @@ -50,6 +50,7 @@ int recovery_send_applelogo(struct idevicerestore_client_t* client, plist_t buil int recovery_send_devicetree(struct idevicerestore_client_t* client, plist_t build_identity); int recovery_send_ramdisk(struct idevicerestore_client_t* client, plist_t build_identity); int recovery_send_kernelcache(struct idevicerestore_client_t* client, plist_t build_identity); +int recovery_send_loaded_by_iboot(struct idevicerestore_client_t* client, plist_t build_identity); int recovery_send_reset(struct idevicerestore_client_t* client); int recovery_send_ticket(struct idevicerestore_client_t* client); int recovery_set_autoboot(struct idevicerestore_client_t* client, int enable); -- cgit v1.1-32-gdbae