diff options
author | Nikias Bassen | 2015-10-09 03:05:21 +0200 |
---|---|---|
committer | Nikias Bassen | 2015-10-09 03:05:21 +0200 |
commit | 46ead9b3afd6e79fa05a391b94bc929e94101e33 (patch) | |
tree | d889975ee080fcd204cc408aa50a17205728c356 | |
parent | 54d97a24791dfa879dc2c47092e99e234ecb2952 (diff) | |
download | idevicerestore-46ead9b3afd6e79fa05a391b94bc929e94101e33.tar.gz idevicerestore-46ead9b3afd6e79fa05a391b94bc929e94101e33.tar.bz2 |
Use hardware model instead of product type to identify device correctly
-rw-r--r-- | src/dfu.c | 6 | ||||
-rw-r--r-- | src/dfu.h | 4 | ||||
-rw-r--r-- | src/idevicerestore.c | 24 | ||||
-rw-r--r-- | src/idevicerestore.h | 4 | ||||
-rw-r--r-- | src/normal.c | 46 | ||||
-rw-r--r-- | src/normal.h | 4 | ||||
-rw-r--r-- | src/restore.c | 6 | ||||
-rw-r--r-- | src/restore.h | 4 |
8 files changed, 29 insertions, 69 deletions
@@ -3,7 +3,7 @@ * Functions for handling idevices in DFU mode * * Copyright (c) 2010-2013 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -113,7 +113,7 @@ int dfu_check_mode(struct idevicerestore_client_t* client, int* mode) { return 0; } -const char* dfu_check_product_type(struct idevicerestore_client_t* client) { +const char* dfu_check_hardware_model(struct idevicerestore_client_t* client) { irecv_client_t dfu = NULL; irecv_error_t dfu_error = IRECV_E_SUCCESS; irecv_device_t device = NULL; @@ -131,7 +131,7 @@ const char* dfu_check_product_type(struct idevicerestore_client_t* client) { irecv_close(dfu); - return device->product_type; + return device->hardware_model; } int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size) @@ -3,7 +3,7 @@ * Functions for handling idevices in DFU mode * * Copyright (c) 2010-2013 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -40,7 +40,7 @@ struct dfu_client_t { int dfu_client_new(struct idevicerestore_client_t* client); void dfu_client_free(struct idevicerestore_client_t* client); int dfu_check_mode(struct idevicerestore_client_t* client, int* mode); -const char* dfu_check_product_type(struct idevicerestore_client_t* client); +const char* dfu_check_hardware_model(struct idevicerestore_client_t* client); int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size); int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component); int dfu_get_cpid(struct idevicerestore_client_t* client, unsigned int* cpid); diff --git a/src/idevicerestore.c b/src/idevicerestore.c index cc69bb1..f02e7b0 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -3,7 +3,7 @@ * Restore device firmware and filesystem * * Copyright (c) 2010-2015 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012-2013 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -280,12 +280,12 @@ int idevicerestore_start(struct idevicerestore_client_t* client) } // discover the device type - if (check_product_type(client) == NULL || client->device == NULL) { - error("ERROR: Unable to discover device type\n"); + if (check_hardware_model(client) == NULL || client->device == NULL) { + error("ERROR: Unable to discover device model\n"); return -1; } idevicerestore_progress(client, RESTORE_STEP_DETECT, 0.2); - info("Identified device as %s\n", client->device->product_type); + info("Identified device as %s, %s\n", client->device->hardware_model, client->device->product_type); if ((client->flags & FLAG_PWN) && (client->mode->index != MODE_DFU)) { error("ERROR: you need to put your device into DFU mode to pwn it.\n"); @@ -1180,31 +1180,31 @@ int check_mode(struct idevicerestore_client_t* client) { return mode; } -const char* check_product_type(struct idevicerestore_client_t* client) { - const char* product_type = NULL; +const char* check_hardware_model(struct idevicerestore_client_t* client) { + const char* hw_model = NULL; switch (client->mode->index) { case MODE_RESTORE: - product_type = restore_check_product_type(client); + hw_model = restore_check_hardware_model(client); break; case MODE_NORMAL: - product_type = normal_check_product_type(client); + hw_model = normal_check_hardware_model(client); break; case MODE_DFU: case MODE_RECOVERY: - product_type = dfu_check_product_type(client); + hw_model = dfu_check_hardware_model(client); break; default: break; } - if (product_type != NULL) { - irecv_devices_get_device_by_product_type(product_type, &client->device); + if (hw_model != NULL) { + irecv_devices_get_device_by_hardware_model(hw_model, &client->device); } - return product_type; + return hw_model; } int is_image4_supported(struct idevicerestore_client_t* client) diff --git a/src/idevicerestore.h b/src/idevicerestore.h index 1e2124a..931604c 100644 --- a/src/idevicerestore.h +++ b/src/idevicerestore.h @@ -3,7 +3,7 @@ * Restore device firmware and filesystem * * Copyright (c) 2010-2012 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -73,7 +73,7 @@ const char* idevicerestore_get_error(void); void usage(int argc, char* argv[]); int check_mode(struct idevicerestore_client_t* client); -const char* check_product_type(struct idevicerestore_client_t* client); +const char* check_hardware_model(struct idevicerestore_client_t* client); int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid); int is_image4_supported(struct idevicerestore_client_t* client); int get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size); diff --git a/src/normal.c b/src/normal.c index 0ca2dff..e019957 100644 --- a/src/normal.c +++ b/src/normal.c @@ -2,7 +2,7 @@ * normal.h * Functions for handling idevices in normal mode * - * Copyright (c) 2012-2013 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2012 Martin Szulecki. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * @@ -218,7 +218,7 @@ int normal_open_with_timeout(struct idevicerestore_client_t* client) { return 0; } -const char* normal_check_product_type(struct idevicerestore_client_t* client) { +const char* normal_check_hardware_model(struct idevicerestore_client_t* client) { idevice_t device = NULL; char* product_type = NULL; irecv_device_t irecv_device = NULL; @@ -247,9 +247,6 @@ const char* normal_check_product_type(struct idevicerestore_client_t* client) { plist_get_string_val(pval, &strval); if (strval) { irecv_devices_get_device_by_hardware_model(strval, &irecv_device); - if (irecv_device) { - product_type = strdup(irecv_device->product_type); - } free(strval); } } @@ -257,44 +254,7 @@ const char* normal_check_product_type(struct idevicerestore_client_t* client) { plist_free(pval); } - if (product_type == NULL) { - lockdown_error = lockdownd_get_value(lockdown, NULL, "ProductType", &product_type_node); - if (lockdown_error != LOCKDOWN_E_SUCCESS) { - lockdownd_client_free(lockdown); - idevice_free(device); - return product_type; - } - } - - lockdownd_client_free(lockdown); - idevice_free(device); - lockdown = NULL; - device = NULL; - - if (irecv_device) { - if (product_type) - free(product_type); - - return irecv_device->product_type; - } - - if (product_type_node != NULL) { - if (!product_type_node || plist_get_node_type(product_type_node) != PLIST_STRING) { - if (product_type_node) - plist_free(product_type_node); - return product_type; - } - plist_get_string_val(product_type_node, &product_type); - plist_free(product_type_node); - - irecv_devices_get_device_by_product_type(product_type, &irecv_device); - if (irecv_device && irecv_device->product_type) { - free(product_type); - return irecv_device->product_type; - } - } - - return product_type; + return (irecv_device) ? irecv_device->hardware_model : NULL; } int normal_enter_recovery(struct idevicerestore_client_t* client) { diff --git a/src/normal.h b/src/normal.h index 691f2d9..be3fa39 100644 --- a/src/normal.h +++ b/src/normal.h @@ -3,7 +3,7 @@ * Functions for handling idevices in normal mode * * Copyright (c) 2012 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -41,7 +41,7 @@ struct normal_client_t { int normal_check_mode(struct idevicerestore_client_t* client); -const char* normal_check_product_type(struct idevicerestore_client_t* client); +const char* normal_check_hardware_model(struct idevicerestore_client_t* client); int normal_client_new(struct idevicerestore_client_t* client); void normal_client_free(struct idevicerestore_client_t* client); int normal_open_with_timeout(struct idevicerestore_client_t* client); diff --git a/src/restore.c b/src/restore.c index f7b854c..7b4d315 100644 --- a/src/restore.c +++ b/src/restore.c @@ -3,7 +3,7 @@ * Functions for handling idevices in restore mode * * Copyright (c) 2010-2013 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012-2013 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -194,7 +194,7 @@ int restore_check_mode(struct idevicerestore_client_t* client) { return 0; } -const char* restore_check_product_type(struct idevicerestore_client_t* client) { +const char* restore_check_hardware_model(struct idevicerestore_client_t* client) { char* model = NULL; plist_t node = NULL; idevice_t device = NULL; @@ -257,7 +257,7 @@ const char* restore_check_product_type(struct idevicerestore_client_t* client) { irecv_devices_get_device_by_hardware_model(model, &irecv_device); if (irecv_device && irecv_device->product_type) { - return irecv_device->product_type; + return irecv_device->hardware_model; } return product_type; diff --git a/src/restore.h b/src/restore.h index 8dc9a45..f40100f 100644 --- a/src/restore.h +++ b/src/restore.h @@ -3,7 +3,7 @@ * Functions for handling idevices in restore mode * * Copyright (c) 2010-2012 Martin Szulecki. All Rights Reserved. - * Copyright (c) 2012 Nikias Bassen. All Rights Reserved. + * Copyright (c) 2012-2015 Nikias Bassen. All Rights Reserved. * Copyright (c) 2010 Joshua Hill. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -44,7 +44,7 @@ struct restore_client_t { }; int restore_check_mode(struct idevicerestore_client_t* client); -const char* restore_check_product_type(struct idevicerestore_client_t* client); +const char* restore_check_hardware_model(struct idevicerestore_client_t* client); int restore_client_new(struct idevicerestore_client_t* client); void restore_client_free(struct idevicerestore_client_t* client); int restore_reboot(struct idevicerestore_client_t* client); |