summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libirecovery.h114
-rw-r--r--src/libirecovery.c73
2 files changed, 72 insertions, 115 deletions
diff --git a/include/libirecovery.h b/include/libirecovery.h
index 8c17167..a405005 100644
--- a/include/libirecovery.h
+++ b/include/libirecovery.h
@@ -26,11 +26,6 @@ extern "C" {
#include <stdint.h>
-
-#define APPLE_VENDOR_ID 0x05AC
-#define CPID_UNKNOWN -1
-#define BDID_UNKNOWN -1
-
enum {
IRECV_K_RECOVERY_MODE_1 = 0x1280,
IRECV_K_RECOVERY_MODE_2 = 0x1281,
@@ -72,119 +67,16 @@ typedef struct {
irecv_event_type type;
} irecv_event_t;
-struct irecv_client;
-typedef struct irecv_client* irecv_client_t;
-typedef struct irecv_device* irecv_device_t;
-
-struct irecv_client {
- int debug;
- int config;
- int interface;
- int alt_interface;
- unsigned short mode;
- char serial[256];
-
-#ifndef WIN32
- libusb_device_handle* handle;
-#else
- HANDLE handle;
- HANDLE hDFU;
- HANDLE hIB;
- LPSTR iBootPath;
- LPSTR DfuPath;
-#endif
-
- irecv_event_cb_t progress_callback;
- irecv_event_cb_t received_callback;
- irecv_event_cb_t connected_callback;
- irecv_event_cb_t precommand_callback;
- irecv_event_cb_t postcommand_callback;
- irecv_event_cb_t disconnected_callback;
-};
-
-#define DEVICE_UNKNOWN -1
-#define DEVICE_IPHONE2G 0
-#define DEVICE_IPHONE3G 1
-#define DEVICE_IPHONE3GS 2
-#define DEVICE_IPHONE4 3
-#define DEVICE_IPHONE4REVA 4
-#define DEVICE_IPHONE4CDMA 5
-#define DEVICE_IPHONE4S 6
-#define DEVICE_IPHONE51 7
-#define DEVICE_IPHONE52 8
-#define DEVICE_IPHONE53 9
-#define DEVICE_IPHONE54 10
-#define DEVICE_IPHONE61 11
-#define DEVICE_IPHONE62 12
-#define DEVICE_IPOD1G 13
-#define DEVICE_IPOD2G 14
-#define DEVICE_IPOD3G 15
-#define DEVICE_IPOD4G 16
-#define DEVICE_IPOD5G 17
-#define DEVICE_IPAD1G 18
-#define DEVICE_IPAD21 19
-#define DEVICE_IPAD22 20
-#define DEVICE_IPAD23 21
-#define DEVICE_IPAD24 22
-#define DEVICE_IPAD25 23
-#define DEVICE_IPAD26 24
-#define DEVICE_IPAD27 25
-#define DEVICE_IPAD31 26
-#define DEVICE_IPAD32 27
-#define DEVICE_IPAD33 28
-#define DEVICE_IPAD34 29
-#define DEVICE_IPAD35 30
-#define DEVICE_IPAD36 31
-#define DEVICE_APPLETV2 32
-#define DEVICE_APPLETV31 33
-#define DEVICE_APPLETV32 34
-
struct irecv_device {
- int index;
const char* product;
const char* model;
unsigned int board_id;
unsigned int chip_id;
};
+typedef struct irecv_device* irecv_device_t;
-static struct irecv_device irecv_devices[] = {
- { 0, "iPhone1,1", "m68ap", 0x00, 0x8900 },
- { 1, "iPhone1,2", "n82ap", 0x04, 0x8900 },
- { 2, "iPhone2,1", "n88ap", 0x00, 0x8920 },
- { 3, "iPhone3,1", "n90ap", 0x00, 0x8930 },
- { 4, "iPhone3,2", "n90bap", 0x04, 0x8930 },
- { 5, "iPhone3,3", "n92ap", 0x06, 0x8930 },
- { 6, "iPhone4,1", "n94ap", 0x08, 0x8940 },
- { 7, "iPhone5,1", "n41ap", 0x00, 0x8950 },
- { 8, "iPhone5,2", "n42ap", 0x02, 0x8950 },
- { 9, "iPhone5,3", "n48ap", 0x0a, 0x8950 },
- { 10, "iPhone5,4", "n49ap", 0x0e, 0x8950 },
- { 11, "iPhone6,1", "n51ap", 0x00, 0x8960 },
- { 12, "iPhone6,2", "n53ap", 0x02, 0x8960 },
- { 13, "iPod1,1", "n45ap", 0x02, 0x8900 },
- { 14, "iPod2,1", "n72ap", 0x00, 0x8720 },
- { 15, "iPod3,1", "n18ap", 0x02, 0x8922 },
- { 16, "iPod4,1", "n81ap", 0x08, 0x8930 },
- { 17, "iPod5,1", "n78ap", 0x00, 0x8942 },
- { 18, "iPad1,1", "k48ap", 0x02, 0x8930 },
- { 19, "iPad2,1", "k93ap", 0x04, 0x8940 },
- { 20, "iPad2,2", "k94ap", 0x06, 0x8940 },
- { 21, "iPad2,3", "k95ap", 0x02, 0x8940 },
- { 22, "iPad2,4", "k93aap", 0x06, 0x8942 },
- { 23, "iPad2,5", "p105ap", 0x0a, 0x8942 },
- { 24, "iPad2,6", "p106ap", 0x0c, 0x8942 },
- { 25, "iPad2,7", "p107ap", 0x0e, 0x8942 },
- { 26, "iPad3,1", "j1ap", 0x00, 0x8945 },
- { 27, "iPad3,2", "j2ap", 0x02, 0x8945 },
- { 28, "iPad3,3", "j2aap", 0x04, 0x8945 },
- { 29, "iPad3,4", "p101ap", 0x00, 0x8955 },
- { 30, "iPad3,5", "p102ap", 0x02, 0x8955 },
- { 31, "iPad3,6", "p103ap", 0x04, 0x8955 },
- { 32, "AppleTV2,1", "k66ap", 0x10, 0x8930 },
- { 33, "AppleTV3,1", "j33ap", 0x08, 0x8942 },
- { 34, "AppleTV3,2","j33iap", 0x00, 0x8947 },
- { -1, NULL, NULL, -1, -1 }
-};
+typedef struct irecv_client_private irecv_client_private;
+typedef irecv_client_private* irecv_client_t;
/* library */
void irecv_set_debug_level(int level);
diff --git a/src/libirecovery.c b/src/libirecovery.c
index a9369dc..1429237 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -42,7 +42,32 @@
#include "libirecovery.h"
+struct irecv_client_private {
+ int debug;
+ int config;
+ int interface;
+ int alt_interface;
+ unsigned short mode;
+ char serial[256];
+#ifndef WIN32
+ libusb_device_handle* handle;
+#else
+ HANDLE handle;
+ HANDLE hDFU;
+ HANDLE hIB;
+ LPSTR iBootPath;
+ LPSTR DfuPath;
+#endif
+ irecv_event_cb_t progress_callback;
+ irecv_event_cb_t received_callback;
+ irecv_event_cb_t connected_callback;
+ irecv_event_cb_t precommand_callback;
+ irecv_event_cb_t postcommand_callback;
+ irecv_event_cb_t disconnected_callback;
+};
+
#define USB_TIMEOUT 10000
+#define APPLE_VENDOR_ID 0x05AC
#define BUFFER_SIZE 0x1000
#define debug(...) if(libirecovery_debug) fprintf(stderr, __VA_ARGS__)
@@ -52,6 +77,44 @@ static int libirecovery_debug = 0;
static libusb_context* libirecovery_context = NULL;
#endif
+static struct irecv_device irecv_devices[] = {
+ {"iPhone1,1", "m68ap", 0x00, 0x8900 },
+ {"iPhone1,2", "n82ap", 0x04, 0x8900 },
+ {"iPhone2,1", "n88ap", 0x00, 0x8920 },
+ {"iPhone3,1", "n90ap", 0x00, 0x8930 },
+ {"iPhone3,2", "n90bap", 0x04, 0x8930 },
+ {"iPhone3,3", "n92ap", 0x06, 0x8930 },
+ {"iPhone4,1", "n94ap", 0x08, 0x8940 },
+ {"iPhone5,1", "n41ap", 0x00, 0x8950 },
+ {"iPhone5,2", "n42ap", 0x02, 0x8950 },
+ {"iPhone5,3", "n48ap", 0x0a, 0x8950 },
+ {"iPhone5,4", "n49ap", 0x0e, 0x8950 },
+ {"iPhone6,1", "n51ap", 0x00, 0x8960 },
+ {"iPhone6,2", "n53ap", 0x02, 0x8960 },
+ {"iPod1,1", "n45ap", 0x02, 0x8900 },
+ {"iPod2,1", "n72ap", 0x00, 0x8720 },
+ {"iPod3,1", "n18ap", 0x02, 0x8922 },
+ {"iPod4,1", "n81ap", 0x08, 0x8930 },
+ {"iPod5,1", "n78ap", 0x00, 0x8942 },
+ {"iPad1,1", "k48ap", 0x02, 0x8930 },
+ {"iPad2,1", "k93ap", 0x04, 0x8940 },
+ {"iPad2,2", "k94ap", 0x06, 0x8940 },
+ {"iPad2,3", "k95ap", 0x02, 0x8940 },
+ {"iPad2,4", "k93aap", 0x06, 0x8942 },
+ {"iPad2,5", "p105ap", 0x0a, 0x8942 },
+ {"iPad2,6", "p106ap", 0x0c, 0x8942 },
+ {"iPad2,7", "p107ap", 0x0e, 0x8942 },
+ {"iPad3,1", "j1ap", 0x00, 0x8945 },
+ {"iPad3,2", "j2ap", 0x02, 0x8945 },
+ {"iPad3,3", "j2aap", 0x04, 0x8945 },
+ {"iPad3,4", "p101ap", 0x00, 0x8955 },
+ {"iPad3,5", "p102ap", 0x02, 0x8955 },
+ {"iPad3,6", "p103ap", 0x04, 0x8955 },
+ {"AppleTV2,1", "k66ap", 0x10, 0x8930 },
+ {"AppleTV3,1", "j33ap", 0x08, 0x8942 },
+ {"AppleTV3,2","j33iap", 0x00, 0x8947 },
+ { NULL, NULL, -1, -1 }
+};
static unsigned int dfu_hash_t1[256] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
@@ -148,8 +211,8 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec
SP_DEVICE_INTERFACE_DATA currentInterface;
HDEVINFO usbDevices;
DWORD i;
- irecv_client_t _client = (irecv_client_t) malloc(sizeof(struct irecv_client));
- memset(_client, 0, sizeof(struct irecv_client));
+ irecv_client_t _client = (irecv_client_t) malloc(sizeof(struct irecv_client_private));
+ memset(_client, 0, sizeof(struct irecv_client_private));
// Get DFU paths
usbDevices = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DFU, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
@@ -561,7 +624,7 @@ irecv_error_t irecv_open_with_ecid(irecv_client_t* pclient, unsigned long long e
return IRECV_E_UNABLE_TO_CONNECT;
}
- irecv_client_t client = (irecv_client_t) malloc(sizeof(struct irecv_client));
+ irecv_client_t client = (irecv_client_t) malloc(sizeof(struct irecv_client_private));
if (client == NULL) {
libusb_free_device_list(usb_device_list, 1);
libusb_close(usb_handle);
@@ -569,7 +632,7 @@ irecv_error_t irecv_open_with_ecid(irecv_client_t* pclient, unsigned long long e
return IRECV_E_OUT_OF_MEMORY;
}
- memset(client, '\0', sizeof(struct irecv_client));
+ memset(client, '\0', sizeof(struct irecv_client_private));
client->interface = 0;
client->handle = usb_handle;
client->mode = usb_descriptor.idProduct;
@@ -1446,6 +1509,8 @@ irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_de
uint32_t cpid = 0;
int i = 0;
+ *device = NULL;
+
if (irecv_get_cpid(client, &cpid) < 0) {
return IRECV_E_UNKNOWN_ERROR;
}