summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicebackup.c54
-rw-r--r--tools/idevicebackup2.c54
-rw-r--r--tools/idevicedebugserverproxy.c15
-rw-r--r--tools/idevicediagnostics.c17
-rw-r--r--tools/ideviceimagemounter.c24
-rw-r--r--tools/ideviceprovision.c11
-rw-r--r--tools/idevicescreenshot.c14
-rw-r--r--tools/idevicesyslog.c13
8 files changed, 136 insertions, 66 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index abd269a..95c5694 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -745,7 +745,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const
745 745
746static void do_post_notification(const char *notification) 746static void do_post_notification(const char *notification)
747{ 747{
748 uint16_t nport = 0; 748 lockdownd_service_descriptor_t service = NULL;
749 np_client_t np; 749 np_client_t np;
750 750
751 if (!client) { 751 if (!client) {
@@ -754,9 +754,9 @@ static void do_post_notification(const char *notification)
754 } 754 }
755 } 755 }
756 756
757 lockdownd_start_service(client, NP_SERVICE_NAME, &nport); 757 lockdownd_start_service(client, NP_SERVICE_NAME, &service);
758 if (nport) { 758 if (service->port) {
759 np_client_new(device, nport, &np); 759 np_client_new(device, service, &np);
760 if (np) { 760 if (np) {
761 np_post_notification(np, notification); 761 np_post_notification(np, notification);
762 np_client_free(np); 762 np_client_free(np);
@@ -764,6 +764,11 @@ static void do_post_notification(const char *notification)
764 } else { 764 } else {
765 printf("Could not start %s\n", NP_SERVICE_NAME); 765 printf("Could not start %s\n", NP_SERVICE_NAME);
766 } 766 }
767
768 if (service) {
769 lockdownd_service_descriptor_free(service);
770 service = NULL;
771 }
767} 772}
768 773
769static void print_progress(double progress) 774static void print_progress(double progress)
@@ -819,7 +824,7 @@ int main(int argc, char *argv[])
819 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 824 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
820 int i; 825 int i;
821 char* udid = NULL; 826 char* udid = NULL;
822 uint16_t port = 0; 827 lockdownd_service_descriptor_t service = NULL;
823 int cmd = -1; 828 int cmd = -1;
824 int is_full_backup = 0; 829 int is_full_backup = 0;
825 char *backup_directory = NULL; 830 char *backup_directory = NULL;
@@ -931,9 +936,9 @@ int main(int argc, char *argv[])
931 936
932 /* start notification_proxy */ 937 /* start notification_proxy */
933 np_client_t np = NULL; 938 np_client_t np = NULL;
934 ret = lockdownd_start_service(client, NP_SERVICE_NAME, &port); 939 ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service);
935 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 940 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
936 np_client_new(device, port, &np); 941 np_client_new(device, service, &np);
937 np_set_notify_callback(np, notify_cb, NULL); 942 np_set_notify_callback(np, notify_cb, NULL);
938 const char *noties[5] = { 943 const char *noties[5] = {
939 NP_SYNC_CANCEL_REQUEST, 944 NP_SYNC_CANCEL_REQUEST,
@@ -947,22 +952,37 @@ int main(int argc, char *argv[])
947 printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); 952 printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME);
948 } 953 }
949 954
955 if (service) {
956 lockdownd_service_descriptor_free(service);
957 service = NULL;
958 }
959
950 afc_client_t afc = NULL; 960 afc_client_t afc = NULL;
951 if (cmd == CMD_BACKUP) { 961 if (cmd == CMD_BACKUP) {
952 /* start AFC, we need this for the lock file */ 962 /* start AFC, we need this for the lock file */
953 port = 0; 963 service->port = 0;
954 ret = lockdownd_start_service(client, "com.apple.afc", &port); 964 service->ssl_enabled = 0;
955 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 965 ret = lockdownd_start_service(client, "com.apple.afc", &service);
956 afc_client_new(device, port, &afc); 966 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
967 afc_client_new(device, service, &afc);
957 } 968 }
958 } 969 }
959 970
971 if (service) {
972 lockdownd_service_descriptor_free(service);
973 service = NULL;
974 }
975
960 /* start mobilebackup service and retrieve port */ 976 /* start mobilebackup service and retrieve port */
961 port = 0; 977 ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &service);
962 ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &port); 978 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
963 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 979 printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, service->port);
964 printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, port); 980 mobilebackup_client_new(device, service, &mobilebackup);
965 mobilebackup_client_new(device, port, &mobilebackup); 981
982 if (service) {
983 lockdownd_service_descriptor_free(service);
984 service = NULL;
985 }
966 986
967 /* check abort conditions */ 987 /* check abort conditions */
968 if (quit_flag > 0) { 988 if (quit_flag > 0) {
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index a0e732d..0353c9b 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -479,7 +479,7 @@ static int mb2_status_check_snapshot_state(const char *path, const char *udid, c
479 479
480static void do_post_notification(idevice_t device, const char *notification) 480static void do_post_notification(idevice_t device, const char *notification)
481{ 481{
482 uint16_t nport = 0; 482 lockdownd_service_descriptor_t service = NULL;
483 np_client_t np; 483 np_client_t np;
484 484
485 lockdownd_client_t lockdown = NULL; 485 lockdownd_client_t lockdown = NULL;
@@ -488,9 +488,9 @@ static void do_post_notification(idevice_t device, const char *notification)
488 return; 488 return;
489 } 489 }
490 490
491 lockdownd_start_service(lockdown, NP_SERVICE_NAME, &nport); 491 lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
492 if (nport) { 492 if (service->port) {
493 np_client_new(device, nport, &np); 493 np_client_new(device, service, &np);
494 if (np) { 494 if (np) {
495 np_post_notification(np, notification); 495 np_post_notification(np, notification);
496 np_client_free(np); 496 np_client_free(np);
@@ -498,6 +498,11 @@ static void do_post_notification(idevice_t device, const char *notification)
498 } else { 498 } else {
499 printf("Could not start %s\n", NP_SERVICE_NAME); 499 printf("Could not start %s\n", NP_SERVICE_NAME);
500 } 500 }
501
502 if (service) {
503 lockdownd_service_descriptor_free(service);
504 service = NULL;
505 }
501} 506}
502 507
503static void print_progress_real(double progress, int flush) 508static void print_progress_real(double progress, int flush)
@@ -1277,7 +1282,7 @@ int main(int argc, char *argv[])
1277 int i; 1282 int i;
1278 char* udid = NULL; 1283 char* udid = NULL;
1279 char* source_udid = NULL; 1284 char* source_udid = NULL;
1280 uint16_t port = 0; 1285 lockdownd_service_descriptor_t service = NULL;
1281 int cmd = -1; 1286 int cmd = -1;
1282 int cmd_flags = 0; 1287 int cmd_flags = 0;
1283 int is_full_backup = 0; 1288 int is_full_backup = 0;
@@ -1551,9 +1556,9 @@ int main(int argc, char *argv[])
1551 1556
1552 /* start notification_proxy */ 1557 /* start notification_proxy */
1553 np_client_t np = NULL; 1558 np_client_t np = NULL;
1554 ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &port); 1559 ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
1555 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 1560 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
1556 np_client_new(device, port, &np); 1561 np_client_new(device, service, &np);
1557 np_set_notify_callback(np, notify_cb, NULL); 1562 np_set_notify_callback(np, notify_cb, NULL);
1558 const char *noties[5] = { 1563 const char *noties[5] = {
1559 NP_SYNC_CANCEL_REQUEST, 1564 NP_SYNC_CANCEL_REQUEST,
@@ -1567,23 +1572,38 @@ int main(int argc, char *argv[])
1567 printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); 1572 printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME);
1568 } 1573 }
1569 1574
1575 if (service) {
1576 lockdownd_service_descriptor_free(service);
1577 service = NULL;
1578 }
1579
1570 afc_client_t afc = NULL; 1580 afc_client_t afc = NULL;
1571 if (cmd == CMD_BACKUP) { 1581 if (cmd == CMD_BACKUP) {
1572 /* start AFC, we need this for the lock file */ 1582 /* start AFC, we need this for the lock file */
1573 port = 0; 1583 service->port = 0;
1574 ret = lockdownd_start_service(lockdown, "com.apple.afc", &port); 1584 service->ssl_enabled = 0;
1575 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 1585 ret = lockdownd_start_service(lockdown, "com.apple.afc", &service);
1576 afc_client_new(device, port, &afc); 1586 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
1587 afc_client_new(device, service, &afc);
1577 } 1588 }
1578 } 1589 }
1579 1590
1591 if (service) {
1592 lockdownd_service_descriptor_free(service);
1593 service = NULL;
1594 }
1595
1580 /* start mobilebackup service and retrieve port */ 1596 /* start mobilebackup service and retrieve port */
1581 mobilebackup2_client_t mobilebackup2 = NULL; 1597 mobilebackup2_client_t mobilebackup2 = NULL;
1582 port = 0; 1598 ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &service);
1583 ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &port); 1599 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
1584 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 1600 PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, service->port);
1585 PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, port); 1601 mobilebackup2_client_new(device, service, &mobilebackup2);
1586 mobilebackup2_client_new(device, port, &mobilebackup2); 1602
1603 if (service) {
1604 lockdownd_service_descriptor_free(service);
1605 service = NULL;
1606 }
1587 1607
1588 /* send Hello message */ 1608 /* send Hello message */
1589 double local_versions[2] = {2.0, 2.1}; 1609 double local_versions[2] = {2.0, 2.1};
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c
index 3253e6a..32438ad 100644
--- a/tools/idevicedebugserverproxy.c
+++ b/tools/idevicedebugserverproxy.c
@@ -228,7 +228,7 @@ int main(int argc, char *argv[])
228 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 228 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
229 thread_t th; 229 thread_t th;
230 const char* udid = NULL; 230 const char* udid = NULL;
231 uint16_t port = 0; 231 lockdownd_service_descriptor_t service = NULL;
232 uint16_t local_port = 0; 232 uint16_t local_port = 0;
233 int result = EXIT_SUCCESS; 233 int result = EXIT_SUCCESS;
234 int i; 234 int i;
@@ -297,14 +297,14 @@ int main(int argc, char *argv[])
297 goto leave_cleanup; 297 goto leave_cleanup;
298 } 298 }
299 299
300 if ((lockdownd_start_service(lockdown, "com.apple.debugserver", &port) != LOCKDOWN_E_SUCCESS) || !port) { 300 if ((lockdownd_start_service(lockdown, "com.apple.debugserver", &service) != LOCKDOWN_E_SUCCESS) || !service->port) {
301 fprintf(stderr, "Could not start com.apple.debugserver!\nPlease make sure to mount the developer disk image first.\n"); 301 fprintf(stderr, "Could not start com.apple.debugserver!\nPlease make sure to mount the developer disk image first.\n");
302 result = EXIT_FAILURE; 302 result = EXIT_FAILURE;
303 goto leave_cleanup; 303 goto leave_cleanup;
304 } 304 }
305 305
306 if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) { 306 if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
307 fprintf(stderr, "Connection to debugserver port %d failed!\n", (int)port); 307 fprintf(stderr, "Connection to debugserver port %d failed!\n", (int)service->port);
308 result = EXIT_FAILURE; 308 result = EXIT_FAILURE;
309 goto leave_cleanup; 309 goto leave_cleanup;
310 } 310 }
@@ -320,7 +320,12 @@ int main(int argc, char *argv[])
320 320
321 socket_info.device_connection = connection; 321 socket_info.device_connection = connection;
322 socket_info.local_port = local_port; 322 socket_info.local_port = local_port;
323 socket_info.remote_port = port; 323 socket_info.remote_port = service->port;
324
325 if (service) {
326 lockdownd_service_descriptor_free(service);
327 service = NULL;
328 }
324 329
325 /* create local socket */ 330 /* create local socket */
326 socket_info.server_fd = socket_create(socket_info.local_port); 331 socket_info.server_fd = socket_create(socket_info.local_port);
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c
index 10dab77..410d054 100644
--- a/tools/idevicediagnostics.c
+++ b/tools/idevicediagnostics.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
57 lockdownd_client_t lockdown_client = NULL; 57 lockdownd_client_t lockdown_client = NULL;
58 diagnostics_relay_client_t diagnostics_client = NULL; 58 diagnostics_relay_client_t diagnostics_client = NULL;
59 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; 59 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
60 uint16_t port = 0; 60 lockdownd_service_descriptor_t service = NULL;
61 int result = -1; 61 int result = -1;
62 int i; 62 int i;
63 const char *udid = NULL; 63 const char *udid = NULL;
@@ -173,23 +173,23 @@ int main(int argc, char **argv)
173 goto cleanup; 173 goto cleanup;
174 } 174 }
175 175
176 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lockdown_client, NULL)) { 176 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lockdown_client, "idevicediagnostics")) {
177 idevice_free(device); 177 idevice_free(device);
178 printf("Unable to connect to lockdownd.\n"); 178 printf("Unable to connect to lockdownd.\n");
179 goto cleanup; 179 goto cleanup;
180 } 180 }
181 181
182 /* attempt to use newer diagnostics service available on iOS 5 and later */ 182 /* attempt to use newer diagnostics service available on iOS 5 and later */
183 ret = lockdownd_start_service(lockdown_client, "com.apple.mobile.diagnostics_relay", &port); 183 ret = lockdownd_start_service(lockdown_client, "com.apple.mobile.diagnostics_relay", &service);
184 if (ret != LOCKDOWN_E_SUCCESS) { 184 if (ret != LOCKDOWN_E_SUCCESS) {
185 /* attempt to use older diagnostics service */ 185 /* attempt to use older diagnostics service */
186 ret = lockdownd_start_service(lockdown_client, "com.apple.iosdiagnostics.relay", &port); 186 ret = lockdownd_start_service(lockdown_client, "com.apple.iosdiagnostics.relay", &service);
187 } 187 }
188 188
189 lockdownd_client_free(lockdown_client); 189 lockdownd_client_free(lockdown_client);
190 190
191 if ((ret == LOCKDOWN_E_SUCCESS) && (port > 0)) { 191 if ((ret == LOCKDOWN_E_SUCCESS) && (service->port > 0)) {
192 if (diagnostics_relay_client_new(device, port, &diagnostics_client) != DIAGNOSTICS_RELAY_E_SUCCESS) { 192 if (diagnostics_relay_client_new(device, service, &diagnostics_client) != DIAGNOSTICS_RELAY_E_SUCCESS) {
193 printf("Could not connect to diagnostics_relay!\n"); 193 printf("Could not connect to diagnostics_relay!\n");
194 result = -1; 194 result = -1;
195 } else { 195 } else {
@@ -258,6 +258,11 @@ int main(int argc, char **argv)
258 printf("Could not start diagnostics service!\n"); 258 printf("Could not start diagnostics service!\n");
259 } 259 }
260 260
261 if (service) {
262 lockdownd_service_descriptor_free(service);
263 service = NULL;
264 }
265
261 idevice_free(device); 266 idevice_free(device);
262 267
263cleanup: 268cleanup:
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c
index 9b65a0e..57a2e27 100644
--- a/tools/ideviceimagemounter.c
+++ b/tools/ideviceimagemounter.c
@@ -267,7 +267,7 @@ int main(int argc, char **argv)
267 lockdownd_client_t lckd = NULL; 267 lockdownd_client_t lckd = NULL;
268 mobile_image_mounter_client_t mim = NULL; 268 mobile_image_mounter_client_t mim = NULL;
269 afc_client_t afc = NULL; 269 afc_client_t afc = NULL;
270 uint16_t port = 0; 270 lockdownd_service_descriptor_t service = NULL;
271 int res = -1; 271 int res = -1;
272 char *image_path = NULL; 272 char *image_path = NULL;
273 char *image_sig_path = NULL; 273 char *image_sig_path = NULL;
@@ -303,30 +303,38 @@ int main(int argc, char **argv)
303 goto leave; 303 goto leave;
304 } 304 }
305 305
306 lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &port); 306 lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &service);
307 307
308 if (port == 0) { 308 if (service->port == 0) {
309 printf("ERROR: Could not start mobile_image_mounter service!\n"); 309 printf("ERROR: Could not start mobile_image_mounter service!\n");
310 goto leave; 310 goto leave;
311 } 311 }
312 312
313 if (mobile_image_mounter_new(device, port, &mim) != MOBILE_IMAGE_MOUNTER_E_SUCCESS) { 313 if (mobile_image_mounter_new(device, service, &mim) != MOBILE_IMAGE_MOUNTER_E_SUCCESS) {
314 printf("ERROR: Could not connect to mobile_image_mounter!\n"); 314 printf("ERROR: Could not connect to mobile_image_mounter!\n");
315 goto leave; 315 goto leave;
316 } 316 }
317 317
318 if (service) {
319 lockdownd_service_descriptor_free(service);
320 service = NULL;
321 }
322
318 if (!list_mode) { 323 if (!list_mode) {
319 struct stat fst; 324 struct stat fst;
320 port = 0; 325 if ((lockdownd_start_service(lckd, "com.apple.afc", &service) !=
321 if ((lockdownd_start_service(lckd, "com.apple.afc", &port) != 326 LOCKDOWN_E_SUCCESS) || !service->port) {
322 LOCKDOWN_E_SUCCESS) || !port) {
323 fprintf(stderr, "Could not start com.apple.afc!\n"); 327 fprintf(stderr, "Could not start com.apple.afc!\n");
324 goto leave; 328 goto leave;
325 } 329 }
326 if (afc_client_new(device, port, &afc) != AFC_E_SUCCESS) { 330 if (afc_client_new(device, service, &afc) != AFC_E_SUCCESS) {
327 fprintf(stderr, "Could not connect to AFC!\n"); 331 fprintf(stderr, "Could not connect to AFC!\n");
328 goto leave; 332 goto leave;
329 } 333 }
334 if (service) {
335 lockdownd_service_descriptor_free(service);
336 service = NULL;
337 }
330 if (stat(image_path, &fst) != 0) { 338 if (stat(image_path, &fst) != 0) {
331 fprintf(stderr, "ERROR: stat: %s: %s\n", image_path, strerror(errno)); 339 fprintf(stderr, "ERROR: stat: %s: %s\n", image_path, strerror(errno));
332 goto leave; 340 goto leave;
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 1c6866d..13fd239 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -193,6 +193,7 @@ static plist_t profile_get_embedded_plist(plist_t profile)
193int main(int argc, char *argv[]) 193int main(int argc, char *argv[])
194{ 194{
195 lockdownd_client_t client = NULL; 195 lockdownd_client_t client = NULL;
196 lockdownd_service_descriptor_t service = NULL;
196 idevice_t device = NULL; 197 idevice_t device = NULL;
197 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 198 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
198 int i; 199 int i;
@@ -278,8 +279,7 @@ int main(int argc, char *argv[])
278 return -1; 279 return -1;
279 } 280 }
280 281
281 uint16_t port = 0; 282 if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.misagent", &service)) {
282 if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.misagent", &port)) {
283 fprintf(stderr, "Could not start service \"com.apple.misagent\"\n"); 283 fprintf(stderr, "Could not start service \"com.apple.misagent\"\n");
284 lockdownd_client_free(client); 284 lockdownd_client_free(client);
285 idevice_free(device); 285 idevice_free(device);
@@ -289,13 +289,18 @@ int main(int argc, char *argv[])
289 client = NULL; 289 client = NULL;
290 290
291 misagent_client_t mis = NULL; 291 misagent_client_t mis = NULL;
292 if (misagent_client_new(device, port, &mis) != MISAGENT_E_SUCCESS) { 292 if (misagent_client_new(device, service, &mis) != MISAGENT_E_SUCCESS) {
293 fprintf(stderr, "Could not connect to \"com.apple.misagent\" on device\n"); 293 fprintf(stderr, "Could not connect to \"com.apple.misagent\" on device\n");
294 if (service)
295 lockdownd_service_descriptor_free(service);
294 lockdownd_client_free(client); 296 lockdownd_client_free(client);
295 idevice_free(device); 297 idevice_free(device);
296 return -1; 298 return -1;
297 } 299 }
298 300
301 if (service)
302 lockdownd_service_descriptor_free(service);
303
299 switch (op) { 304 switch (op) {
300 case OP_INSTALL: 305 case OP_INSTALL:
301 { 306 {
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index cba62a2..23e7b41 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
36 idevice_t device = NULL; 36 idevice_t device = NULL;
37 lockdownd_client_t lckd = NULL; 37 lockdownd_client_t lckd = NULL;
38 screenshotr_client_t shotr = NULL; 38 screenshotr_client_t shotr = NULL;
39 uint16_t port = 0; 39 lockdownd_service_descriptor_t service = NULL;
40 int result = -1; 40 int result = -1;
41 int i; 41 int i;
42 const char *udid = NULL; 42 const char *udid = NULL;
@@ -81,10 +81,10 @@ int main(int argc, char **argv)
81 return -1; 81 return -1;
82 } 82 }
83 83
84 lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &port); 84 lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &service);
85 lockdownd_client_free(lckd); 85 lockdownd_client_free(lckd);
86 if (port > 0) { 86 if (service->port > 0) {
87 if (screenshotr_client_new(device, port, &shotr) != SCREENSHOTR_E_SUCCESS) { 87 if (screenshotr_client_new(device, service, &shotr) != SCREENSHOTR_E_SUCCESS) {
88 printf("Could not connect to screenshotr!\n"); 88 printf("Could not connect to screenshotr!\n");
89 } else { 89 } else {
90 char *imgdata = NULL; 90 char *imgdata = NULL;
@@ -113,8 +113,12 @@ int main(int argc, char **argv)
113 } else { 113 } else {
114 printf("Could not start screenshotr service! Remember that you have to mount the Developer disk image on your device if you want to use the screenshotr service.\n"); 114 printf("Could not start screenshotr service! Remember that you have to mount the Developer disk image on your device if you want to use the screenshotr service.\n");
115 } 115 }
116
117 if (service)
118 lockdownd_service_descriptor_free(service);
119
116 idevice_free(device); 120 idevice_free(device);
117 121
118 return result; 122 return result;
119} 123}
120 124
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index a17999c..6ce6d0e 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
49 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 49 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
50 int i; 50 int i;
51 const char* udid = NULL; 51 const char* udid = NULL;
52 uint16_t port = 0; 52 lockdownd_service_descriptor_t service = NULL;
53 53
54 signal(SIGINT, clean_exit); 54 signal(SIGINT, clean_exit);
55 signal(SIGTERM, clean_exit); 55 signal(SIGTERM, clean_exit);
@@ -99,13 +99,13 @@ int main(int argc, char *argv[])
99 } 99 }
100 100
101 /* start syslog_relay service and retrieve port */ 101 /* start syslog_relay service and retrieve port */
102 ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port); 102 ret = lockdownd_start_service(client, "com.apple.syslog_relay", &service);
103 if ((ret == LOCKDOWN_E_SUCCESS) && port) { 103 if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
104 lockdownd_client_free(client); 104 lockdownd_client_free(client);
105 105
106 /* connect to socket relay messages */ 106 /* connect to socket relay messages */
107 idevice_connection_t conn = NULL; 107 idevice_connection_t conn = NULL;
108 if ((idevice_connect(device, port, &conn) != IDEVICE_E_SUCCESS) || !conn) { 108 if ((idevice_connect(device, service->port, &conn) != IDEVICE_E_SUCCESS) || !conn) {
109 printf("ERROR: Could not open usbmux connection.\n"); 109 printf("ERROR: Could not open usbmux connection.\n");
110 } else { 110 } else {
111 while (!quit_flag) { 111 while (!quit_flag) {
@@ -126,6 +126,9 @@ int main(int argc, char *argv[])
126 printf("ERROR: Could not start service com.apple.syslog_relay.\n"); 126 printf("ERROR: Could not start service com.apple.syslog_relay.\n");
127 } 127 }
128 128
129 if (service)
130 lockdownd_service_descriptor_free(service);
131
129 idevice_free(device); 132 idevice_free(device);
130 133
131 return 0; 134 return 0;