Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions idevice-app-runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>

#ifdef WIN32
# include <windows.h>
# define sleep(x) Sleep(x*1000)
#endif

#ifdef WIN32
# define __strdup _strdup
#else
# define __strdup strdup
#endif

char *udid = NULL;
char *apppath = NULL;

Expand Down Expand Up @@ -95,11 +106,11 @@ static void parse_opts(int argc, char **argv)
print_usage(argc, argv);
exit(2);
}
udid = strdup(optarg);
udid = __strdup(optarg);
break;
case 'r':
run_mode = 1;
apppath = strdup(optarg);
apppath = __strdup(optarg);
break;
case 'd':
idevice_set_debug_level(1);
Expand Down Expand Up @@ -147,7 +158,7 @@ void recv_pkt(idevice_connection_t connection)
{
int bytes = 0;
char buf[16*1024];
idevice_connection_receive_timeout(connection, buf, sizeof(buf)-1, &bytes, 1000);
idevice_connection_receive_timeout(connection, buf, sizeof(buf)-1, (uint32_t*)&bytes, 1000);
#ifdef WITH_DEBUG
printf("recv: bytes=%d\n", bytes);
#endif
Expand Down Expand Up @@ -181,7 +192,7 @@ void send_pkt(char* buf, idevice_connection_t connection)
{
int i;
unsigned char csum = 0;
char *buf2 = malloc (32*1024);
char *buf2 = (char *)malloc (32*1024);
int cnt = strlen (buf);
char *p;

Expand Down Expand Up @@ -217,7 +228,6 @@ int main(int argc, char **argv)
idevice_t phone = NULL;
lockdownd_client_t client = NULL;
idevice_connection_t connection = NULL;
uint16_t port = 0;
int res = 0;

signal(SIGINT, clean_exit);
Expand Down Expand Up @@ -247,16 +257,16 @@ int main(int argc, char **argv)
goto leave_cleanup;
}

uint16_t port2 = 0;
lockdownd_service_descriptor_t service_descriptor = NULL;
if ((lockdownd_start_service
(client, "com.apple.debugserver",
&port2) != LOCKDOWN_E_SUCCESS) || !port2) {
&service_descriptor) != LOCKDOWN_E_SUCCESS) || !service_descriptor->port) {
fprintf(stderr,
"Could not start com.apple.debugserver!\n");
goto leave_cleanup;
}

if (idevice_connect(phone, port2, &connection) != IDEVICE_E_SUCCESS) {
if (idevice_connect(phone, service_descriptor->port, &connection) != IDEVICE_E_SUCCESS) {
fprintf(stderr, "idevice_connect failed!\n");
goto leave_cleanup;
}
Expand All @@ -277,7 +287,7 @@ int main(int argc, char **argv)
NULL,
};

cmds[0] = malloc(2000);
cmds[0] = (char *)malloc(2000);
char* p = cmds[0];
sprintf(p, "A%d,0,", strlen(apppath)*2/* +4 */);
p += strlen(p);
Expand Down