diff options
author | Nikias Bassen | 2013-11-19 21:38:31 +0100 |
---|---|---|
committer | Nikias Bassen | 2013-11-19 21:38:31 +0100 |
commit | 3f8dea9bd12c4b4c52224b1a84835fa56df53fb2 (patch) | |
tree | 4a5ee3b9be4d6a521899e4342c49e9decb1c5a08 /src/normal.c | |
parent | aee53bef0385841109432948dbf814907a7d2dca (diff) | |
download | idevicerestore-3f8dea9bd12c4b4c52224b1a84835fa56df53fb2.tar.gz idevicerestore-3f8dea9bd12c4b4c52224b1a84835fa56df53fb2.tar.bz2 |
Add helper function to check if device supports image4 format
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/normal.c b/src/normal.c index 15bbc01..3b536ed 100644 --- a/src/normal.c +++ b/src/normal.c @@ -391,6 +391,51 @@ int normal_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** return normal_get_nonce_by_key(client, "SEPNonce", nonce, nonce_size); } +int normal_is_image4_supported(struct idevicerestore_client_t* client) +{ + idevice_t device = NULL; + plist_t node = NULL; + lockdownd_client_t lockdown = NULL; + idevice_error_t device_error = IDEVICE_E_SUCCESS; + lockdownd_error_t lockdown_error = IDEVICE_E_SUCCESS; + + device_error = idevice_new(&device, client->udid); + if (device_error != IDEVICE_E_SUCCESS) { + return 0; + } + + lockdown_error = lockdownd_client_new(device, &lockdown, "idevicerestore"); + if (lockdown_error != LOCKDOWN_E_SUCCESS) { + error("ERROR: Unable to connect to lockdownd\n"); + idevice_free(device); + return 0; + } + + lockdown_error = lockdownd_get_value(lockdown, NULL, "Image4Supported", &node); + if (lockdown_error != LOCKDOWN_E_SUCCESS) { + lockdownd_client_free(lockdown); + idevice_free(device); + return 0; + } + + if (!node || plist_get_node_type(node) != PLIST_BOOLEAN) { + lockdownd_client_free(lockdown); + idevice_free(device); + return 0; + } + + uint8_t bval = 0; + plist_get_bool_val(node, &bval); + plist_free(node); + + lockdownd_client_free(lockdown); + idevice_free(device); + lockdown = NULL; + device = NULL; + + return bval; +} + int normal_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) { idevice_t device = NULL; plist_t unique_chip_node = NULL; |