summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/mobile_image_mounter.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libimobiledevice/mobile_image_mounter.h')
-rw-r--r--include/libimobiledevice/mobile_image_mounter.h256
1 files changed, 236 insertions, 20 deletions
diff --git a/include/libimobiledevice/mobile_image_mounter.h b/include/libimobiledevice/mobile_image_mounter.h
index 04c65d5..76bb61a 100644
--- a/include/libimobiledevice/mobile_image_mounter.h
+++ b/include/libimobiledevice/mobile_image_mounter.h
@@ -3,7 +3,8 @@
3 * @brief Mount developer/debug disk images on the device. 3 * @brief Mount developer/debug disk images on the device.
4 * \internal 4 * \internal
5 * 5 *
6 * Copyright (c) 2010 Nikias Bassen All Rights Reserved. 6 * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
7 * Copyright (c) 2010-2014 Nikias Bassen All Rights Reserved.
7 * 8 *
8 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
@@ -20,37 +21,252 @@
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */ 22 */
22 23
23#ifndef MOBILE_IMAGE_MOUNTER_H 24#ifndef IMOBILE_IMAGE_MOUNTER_H
24#define MOBILE_IMAGE_MOUNTER_H 25#define IMOBILE_IMAGE_MOUNTER_H
25 26
26#ifdef __cplusplus 27#ifdef __cplusplus
27extern "C" { 28extern "C" {
28#endif 29#endif
29 30
30#include <libimobiledevice/libimobiledevice.h> 31#include <libimobiledevice/libimobiledevice.h>
32#include <libimobiledevice/lockdown.h>
31 33
32/** @name Error Codes */ 34/** Service identifier passed to lockdownd_start_service() to start the mobile image mounter service */
33/*@{*/ 35#define MOBILE_IMAGE_MOUNTER_SERVICE_NAME "com.apple.mobile.mobile_image_mounter"
34#define MOBILE_IMAGE_MOUNTER_E_SUCCESS 0
35#define MOBILE_IMAGE_MOUNTER_E_INVALID_ARG -1
36#define MOBILE_IMAGE_MOUNTER_E_PLIST_ERROR -2
37#define MOBILE_IMAGE_MOUNTER_E_CONN_FAILED -3
38 36
39#define MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR -256 37/** Error Codes */
40/*@}*/ 38typedef enum {
39 MOBILE_IMAGE_MOUNTER_E_SUCCESS = 0,
40 MOBILE_IMAGE_MOUNTER_E_INVALID_ARG = -1,
41 MOBILE_IMAGE_MOUNTER_E_PLIST_ERROR = -2,
42 MOBILE_IMAGE_MOUNTER_E_CONN_FAILED = -3,
43 MOBILE_IMAGE_MOUNTER_E_COMMAND_FAILED = -4,
44 MOBILE_IMAGE_MOUNTER_E_DEVICE_LOCKED = -5,
45 MOBILE_IMAGE_MOUNTER_E_NOT_SUPPORTED = -6,
46 MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR = -256
47} mobile_image_mounter_error_t;
41 48
42/** Represents an error code. */ 49typedef struct mobile_image_mounter_client_private mobile_image_mounter_client_private; /**< \private */
43typedef int16_t mobile_image_mounter_error_t;
44
45typedef struct mobile_image_mounter_client_private mobile_image_mounter_client_private;
46typedef mobile_image_mounter_client_private *mobile_image_mounter_client_t; /**< The client handle. */ 50typedef mobile_image_mounter_client_private *mobile_image_mounter_client_t; /**< The client handle. */
47 51
52/** callback for image upload */
53typedef ssize_t (*mobile_image_mounter_upload_cb_t) (void* buffer, size_t length, void *user_data);
54
48/* Interface */ 55/* Interface */
49mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, uint16_t port, mobile_image_mounter_client_t *client); 56
50mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client); 57/**
51mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result); 58 * Connects to the mobile_image_mounter service on the specified device.
52mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result); 59 *
53mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client); 60 * @param device The device to connect to.
61 * @param service The service descriptor returned by lockdownd_start_service.
62 * @param client Pointer that will be set to a newly allocated
63 * mobile_image_mounter_client_t upon successful return.
64 *
65 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
66 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if device is NULL,
67 * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
68 * device could not be established.
69 */
70LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client);
71
72/**
73 * Starts a new mobile_image_mounter service on the specified device and connects to it.
74 *
75 * @param device The device to connect to.
76 * @param client Pointer that will point to a newly allocated
77 * mobile_image_mounter_t upon successful return. Must be freed using
78 * mobile_image_mounter_free() after use.
79 * @param label The label to use for communication. Usually the program name.
80 * Pass NULL to disable sending the label in requests to lockdownd.
81 *
82 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error
83 * code otherwise.
84 */
85LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label);
86
87/**
88 * Disconnects a mobile_image_mounter client from the device and frees up the
89 * mobile_image_mounter client data.
90 *
91 * @param client The mobile_image_mounter client to disconnect and free.
92 *
93 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
94 * or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL.
95 */
96LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client);
97
98
99/**
100 * Tells if the image of ImageType is already mounted.
101 *
102 * @param client The client use
103 * @param image_type The type of the image to look up
104 * @param result Pointer to a plist that will receive the result of the
105 * operation.
106 *
107 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
108 * operation has failed. Check the resulting plist for further information.
109 *
110 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error
111 */
112LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result);
113
114/**
115 * Uploads an image with an optional signature to the device.
116 *
117 * @param client The connected mobile_image_mounter client.
118 * @param image_type Type of image that is being uploaded.
119 * @param image_size Total size of the image.
120 * @param signature Buffer with a signature of the image being uploaded. If
121 * NULL, no signature will be used.
122 * @param signature_size Total size of the image signature buffer. If 0, no
123 * signature will be used.
124 * @param upload_cb Callback function that gets the data chunks for uploading
125 * the image.
126 * @param userdata User defined data for the upload callback function.
127 *
128 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a
129 * MOBILE_IMAGE_MOUNTER_E_* error code otherwise.
130 */
131LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const unsigned char *signature, unsigned int signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata);
132
133/**
134 * Mounts an image on the device.
135 *
136 * @param client The connected mobile_image_mounter client.
137 * @param image_path The absolute path of the image to mount. The image must
138 * be present before calling this function.
139 * @param signature Pointer to a buffer holding the images' signature
140 * @param signature_size Length of the signature image_signature points to
141 * @param image_type Type of image to mount
142 * @param options A dictionary containing additional key/value pairs to add
143 * @param result Pointer to a plist that will receive the result of the
144 * operation.
145 *
146 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
147 * operation has failed. Check the resulting plist for further information.
148 *
149 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
150 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
151 * invalid, or another error code otherwise.
152 */
153LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_mount_image_with_options(mobile_image_mounter_client_t client, const char *image_path, const unsigned char *signature, unsigned int signature_size, const char *image_type, plist_t options, plist_t *result);
154
155/**
156 * Mounts an image on the device.
157 *
158 * @param client The connected mobile_image_mounter client.
159 * @param image_path The absolute path of the image to mount. The image must
160 * be present before calling this function.
161 * @param signature Pointer to a buffer holding the images' signature
162 * @param signature_size Length of the signature image_signature points to
163 * @param image_type Type of image to mount
164 * @param result Pointer to a plist that will receive the result of the
165 * operation.
166 *
167 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
168 * operation has failed. Check the resulting plist for further information.
169 *
170 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
171 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
172 * invalid, or another error code otherwise.
173 */
174LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const unsigned char *signature, unsigned int signature_size, const char *image_type, plist_t *result);
175
176/**
177 * Unmount a mounted image at given path on the device.
178 *
179 * @param client The connected mobile_image_mounter client.
180 * @param mount_path The mount path of the mounted image on the device.
181 *
182 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
183 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
184 */
185LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_unmount_image(mobile_image_mounter_client_t client, const char *mount_path);
186
187/**
188 * Hangs up the connection to the mobile_image_mounter service.
189 * This functions has to be called before freeing up a mobile_image_mounter
190 * instance. If not, errors appear in the device's syslog.
191 *
192 * @param client The client to hang up
193 *
194 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
195 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid,
196 * or another error code otherwise.
197 */
198LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client);
199
200/**
201 * Query the developer mode status of the given device.
202 *
203 * @param client The connected mobile_image_mounter client.
204 * @param result A pointer to a plist_t that will be set to the resulting developer mode status dictionary.
205 *
206 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
207 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
208 */
209LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_query_developer_mode_status(mobile_image_mounter_client_t client, plist_t *result);
210
211/**
212 * Query a personalization nonce for the given image type, used for personalized disk images (iOS 17+).
213 * This nonce is supposed to be added to the TSS request for the corresponding image.
214 *
215 * @param client The connected mobile_image_mounter client.
216 * @param image_type The image_type to get the personalization nonce for, usually `DeveloperDiskImage`.
217 * @param nonce Pointer that will be set to an allocated buffer with the nonce value.
218 * @param nonce_size Pointer to an unsigned int that will receive the size of the nonce value.
219 *
220 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
221 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
222 */
223LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_query_nonce(mobile_image_mounter_client_t client, const char* image_type, unsigned char** nonce, unsigned int* nonce_size);
224
225/**
226 * Query personalization identitifers for the given image_type.
227 *
228 * @param client The connected mobile_image_mounter client.
229 * @param image_type The image_type to get the personalization identifiers for. Can be NULL.
230 * @param result A pointer to a plist_t that will be set to the resulting identifier dictionary.
231 *
232 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
233 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
234 */
235LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_query_personalization_identifiers(mobile_image_mounter_client_t client, const char* image_type, plist_t *result);
236
237/**
238 *
239 * @param client The connected mobile_image_mounter client.
240 * @param image_type The image_type to get the personalization identifiers for. Can be NULL.
241 * @param signature The signature of the corresponding personalized image.
242 * @param signature_size The size of signature.
243 * @param manifest Pointer that will be set to an allocated buffer with the manifest data.
244 * @param manifest_size Pointer to an unsigned int that will be set to the size of the manifest data.
245 *
246 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
247 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
248 */
249LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_query_personalization_manifest(mobile_image_mounter_client_t client, const char* image_type, const unsigned char* signature, unsigned int signature_size, unsigned char** manifest, unsigned int* manifest_size);
250
251/**
252 * Roll the personalization nonce.
253 *
254 * @param client The connected mobile_image_mounter client.
255 *
256 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
257 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
258 */
259LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_roll_personalization_nonce(mobile_image_mounter_client_t client);
260
261/**
262 * Roll the Cryptex nonce.
263 *
264 * @param client The connected mobile_image_mounter client.
265 *
266 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
267 * or a MOBILE_IMAGE_MOUNTER_E_* error code on error.
268 */
269LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_roll_cryptex_nonce(mobile_image_mounter_client_t client);
54 270
55#ifdef __cplusplus 271#ifdef __cplusplus
56} 272}