1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*
* libirecovery.h
* Communication to iBoot/iBSS on Apple iOS devices via USB
*
* Copyright (c) 2012-2013 Martin Szulecki <m.szulecki@libimobiledevice.org>
* Copyright (c) 2010 Chronic-Dev Team
* Copyright (c) 2010 Joshua Hill
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#ifndef LIBIRECOVERY_H
#define LIBIRECOVERY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
enum {
IRECV_K_RECOVERY_MODE_1 = 0x1280,
IRECV_K_RECOVERY_MODE_2 = 0x1281,
IRECV_K_RECOVERY_MODE_3 = 0x1282,
IRECV_K_RECOVERY_MODE_4 = 0x1283,
IRECV_K_WTF_MODE = 0x1222,
IRECV_K_DFU_MODE = 0x1227
};
typedef enum {
IRECV_E_SUCCESS = 0,
IRECV_E_NO_DEVICE = -1,
IRECV_E_OUT_OF_MEMORY = -2,
IRECV_E_UNABLE_TO_CONNECT = -3,
IRECV_E_INVALID_INPUT = -4,
IRECV_E_FILE_NOT_FOUND = -5,
IRECV_E_USB_UPLOAD = -6,
IRECV_E_USB_STATUS = -7,
IRECV_E_USB_INTERFACE = -8,
IRECV_E_USB_CONFIGURATION = -9,
IRECV_E_PIPE = -10,
IRECV_E_TIMEOUT = -11,
IRECV_E_UNKNOWN_ERROR = -255
} irecv_error_t;
typedef enum {
IRECV_RECEIVED = 1,
IRECV_PRECOMMAND = 2,
IRECV_POSTCOMMAND = 3,
IRECV_CONNECTED = 4,
IRECV_DISCONNECTED = 5,
IRECV_PROGRESS = 6
} irecv_event_type;
typedef struct {
int size;
const char* data;
double progress;
irecv_event_type type;
} irecv_event_t;
struct irecv_device {
const char* product_type;
const char* hardware_model;
unsigned int board_id;
unsigned int chip_id;
};
typedef struct irecv_device* irecv_device_t;
typedef struct irecv_client_private irecv_client_private;
typedef irecv_client_private* irecv_client_t;
/* library */
void irecv_set_debug_level(int level);
const char* irecv_strerror(irecv_error_t error);
void irecv_init();
void irecv_exit();
/* device connectivity */
irecv_error_t irecv_open_with_ecid(irecv_client_t* client, unsigned long long ecid);
irecv_error_t irecv_open_with_ecid_and_attempts(irecv_client_t* pclient, unsigned long long ecid, int attempts);
irecv_error_t irecv_reset(irecv_client_t client);
irecv_error_t irecv_close(irecv_client_t client);
irecv_client_t irecv_reconnect(irecv_client_t client, int initial_pause);
/* misc */
irecv_error_t irecv_receive(irecv_client_t client);
irecv_error_t irecv_execute_script(irecv_client_t client, const char* script);
irecv_error_t irecv_reset_counters(irecv_client_t client);
irecv_error_t irecv_finish_transfer(irecv_client_t client);
irecv_error_t irecv_trigger_limera1n_exploit(irecv_client_t client);
/* usb helpers */
irecv_error_t irecv_usb_set_configuration(irecv_client_t client, int configuration);
irecv_error_t irecv_usb_set_interface(irecv_client_t client, int interface, int alt_interface);
int irecv_usb_control_transfer(irecv_client_t client, uint8_t bm_request_type, uint8_t b_request, uint16_t w_value, uint16_t w_index, unsigned char *data, uint16_t w_length, unsigned int timeout);
int irecv_usb_bulk_transfer(irecv_client_t client, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout);
/* events */
typedef int(*irecv_event_cb_t)(irecv_client_t client, const irecv_event_t* event);
irecv_error_t irecv_event_subscribe(irecv_client_t client, irecv_event_type type, irecv_event_cb_t callback, void *user_data);
irecv_error_t irecv_event_unsubscribe(irecv_client_t client, irecv_event_type type);
/* I/O */
irecv_error_t irecv_send_file(irecv_client_t client, const char* filename, int dfu_notify_finished);
irecv_error_t irecv_send_command(irecv_client_t client, const char* command);
irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, unsigned long length, int dfu_notify_finished);
irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned long length);
/* commands */
irecv_error_t irecv_saveenv(irecv_client_t client);
irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** value);
irecv_error_t irecv_setenv(irecv_client_t client, const char* variable, const char* value);
irecv_error_t irecv_reboot(irecv_client_t client);
irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value);
/* device information */
irecv_error_t irecv_get_mode(irecv_client_t client, int* mode);
irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid);
irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid);
irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid);
irecv_error_t irecv_get_nonce(irecv_client_t client, unsigned char** nonce, int* nonce_size);
irecv_error_t irecv_get_srnm(irecv_client_t client, char* srnm);
irecv_error_t irecv_get_imei(irecv_client_t client, char* imei);
/* device database queries */
irecv_device_t irecv_devices_get_all();
irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_device_t* device);
irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_device_t* device);
irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_model, irecv_device_t* device);
#ifdef __cplusplus
}
#endif
#endif
|