Skip to content

Commit a369ffe

Browse files
committed
fix: support ios13 on Windows
1 parent 0d465c7 commit a369ffe

File tree

5 files changed

+585
-553
lines changed

5 files changed

+585
-553
lines changed

IOSDeviceLib/Declarations.h

+24-2
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,27 @@ struct FileUploadData {
134134

135135
#pragma region Dll_Type_Definitions
136136

137-
typedef unsigned(__cdecl *device_notification_subscribe_ptr)(void(*f)(const DevicePointer*), long, long, long, HANDLE*);
138137

139138
#ifdef _WIN32
139+
typedef unsigned(__cdecl *device_notification_subscribe_ptr)(void(*f)(const DevicePointer*), long, long, long, HANDLE*);
140140
typedef void(__cdecl *run_loop_ptr)();
141+
typedef void* CFArrayRef;
141142
typedef void* CFStringRef;
142-
typedef void* CFURLRef;
143143
typedef void* CFDictionaryRef;
144+
typedef void* CFURLRef;
145+
typedef void* CFPropertyListFormat;
146+
extern CFPropertyListFormat kCFPropertyListXMLFormat_v1_0;
147+
typedef void* CFSocketNativeHandle;
148+
typedef unsigned(__cdecl *device_secure_start_service_ptr)(AMDeviceRef device, CFStringRef service_name, unsigned int *unknown, ServiceConnRef * handle);
149+
typedef CFSocketNativeHandle(__cdecl *service_connection_get_socket_ptr)(ServiceConnRef con);
150+
typedef long(__cdecl *service_connection_receive_ptr)(ServiceConnRef, void *, long);
151+
typedef long(__cdecl *service_connection_send_message_ptr)(ServiceConnRef serviceConnection, CFDictionaryRef message, CFPropertyListFormat format);
152+
153+
extern service_connection_send_message_ptr __AMDServiceConnectionSendMessage;
154+
extern service_connection_receive_ptr __AMDServiceConnectionReceive;
155+
156+
typedef unsigned(__cdecl *device_create_house_arrest_service_ptr)(const DeviceInfo*, CFStringRef identifier, void * unknown, AFCConnectionRef * handle);
157+
144158
typedef void*(__cdecl *device_copy_device_identifier)(const DeviceInfo*);
145159
typedef void*(__cdecl *device_copy_value)(const DeviceInfo*, CFStringRef, CFStringRef);
146160
typedef unsigned(__cdecl *device_uninstall_application)(HANDLE, CFStringRef, void*, void(*f)(), void*);
@@ -153,6 +167,7 @@ typedef unsigned long(__cdecl *cf_get_concrete_type_id)();
153167
typedef unsigned(__cdecl *cfdictionary_get_count)(CFDictionaryRef);
154168
typedef void(__cdecl *cfdictionary_get_keys_and_values)(CFDictionaryRef, const void**, const void**);
155169
typedef CFStringRef(__cdecl *cfstring_create_with_cstring)(void*, const char*, unsigned);
170+
typedef CFArrayRef(__cdecl *cfarray_create)(void*, const void**, long, void**);
156171
typedef unsigned(__cdecl *device_secure_operation_with_path)(int, const DeviceInfo*, CFURLRef, CFDictionaryRef, void(*f)(), int);
157172
typedef unsigned(__cdecl *device_secure_operation_with_bundle_id)(int, const DeviceInfo*, CFStringRef, int, void(*f)(), int);
158173
typedef void(__cdecl *cfrelease)(CFStringRef);
@@ -183,8 +198,14 @@ typedef int(__cdecl *usb_mux_connect_by_port)(int, int, long long*);
183198
#pragma region Dll_Method_Definitions
184199

185200
#ifdef _WIN32
201+
extern HINSTANCE mobile_device_dll;
186202
#define GET_IF_EXISTS(variable, type, dll, method_name) (variable ? variable : variable = (type)GetProcAddress(dll, method_name))
187203

204+
#define AMDeviceSecureStartService GET_IF_EXISTS(__AMDeviceSecureStartService, device_secure_start_service_ptr, mobile_device_dll, "AMDeviceSecureStartService")
205+
#define AMDServiceConnectionGetSocket GET_IF_EXISTS(__AMDServiceConnectionGetSocket, service_connection_get_socket_ptr, mobile_device_dll, "AMDServiceConnectionGetSocket")
206+
#define AMDServiceConnectionReceive GET_IF_EXISTS(__AMDServiceConnectionReceive, service_connection_receive_ptr, mobile_device_dll, "AMDServiceConnectionReceive")
207+
#define AMDServiceConnectionSendMessage GET_IF_EXISTS(__AMDServiceConnectionSendMessage, service_connection_send_message_ptr, mobile_device_dll, "AMDServiceConnectionSendMessage")
208+
#define AMDeviceCreateHouseArrestService GET_IF_EXISTS(__AMDeviceCreateHouseArrestService, device_create_house_arrest_service_ptr, mobile_device_dll, "AMDeviceCreateHouseArrestService")
188209
#define AMDeviceNotificationSubscribe GET_IF_EXISTS(__AMDeviceNotificationSubscribe, device_notification_subscribe_ptr, mobile_device_dll, "AMDeviceNotificationSubscribe")
189210
#define AMDeviceCopyDeviceIdentifier GET_IF_EXISTS(__AMDeviceCopyDeviceIdentifier, device_copy_device_identifier, mobile_device_dll, "AMDeviceCopyDeviceIdentifier")
190211
#define AMDeviceCopyValue GET_IF_EXISTS(__AMDeviceCopyValue, device_copy_value, mobile_device_dll, "AMDeviceCopyValue")
@@ -215,6 +236,7 @@ typedef int(__cdecl *usb_mux_connect_by_port)(int, int, long long*);
215236
#define CFDictionaryGetCount GET_IF_EXISTS(__CFDictionaryGetCount, cfdictionary_get_count, core_foundation_dll, "CFDictionaryGetCount")
216237
#define CFDictionaryGetKeysAndValues GET_IF_EXISTS(__CFDictionaryGetKeysAndValues, cfdictionary_get_keys_and_values, core_foundation_dll, "CFDictionaryGetKeysAndValues")
217238
#define CFStringCreateWithCString GET_IF_EXISTS(__CFStringCreateWithCString, cfstring_create_with_cstring, core_foundation_dll, "CFStringCreateWithCString")
239+
#define CFArrayCreate GET_IF_EXISTS(__CFArrayCreate, cfarray_create, core_foundation_dll, "CFArrayCreate")
218240
#define CFURLCreateWithString GET_IF_EXISTS(__CFURLCreateWithString, cfurl_create_with_string, core_foundation_dll, "CFURLCreateWithString")
219241
#define CFDictionaryCreate GET_IF_EXISTS(__CFDictionaryCreate, cfdictionary_create, core_foundation_dll, "CFDictionaryCreate")
220242
#define CFRelease GET_IF_EXISTS(__CFRelease, cfrelease, core_foundation_dll, "CFRelease")

IOSDeviceLib/IOSDeviceLib.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifdef _WIN32
2626
#pragma region Dll_Variable_Definitions
2727

28+
CFPropertyListFormat kCFPropertyListXMLFormat_v1_0 = (CFPropertyListFormat)100;
2829
device_notification_subscribe_ptr __AMDeviceNotificationSubscribe;
2930
HINSTANCE mobile_device_dll;
3031
HINSTANCE core_foundation_dll;
@@ -34,6 +35,11 @@ device_copy_value __AMDeviceCopyValue;
3435
device_start_service __AMDeviceStartService;
3536
device_uninstall_application __AMDeviceUninstallApplication;
3637
device_secure_operation_with_bundle_id __AMDeviceSecureUninstallApplication;
38+
device_secure_start_service_ptr __AMDeviceSecureStartService;
39+
service_connection_get_socket_ptr __AMDServiceConnectionGetSocket;
40+
service_connection_receive_ptr __AMDServiceConnectionReceive;
41+
service_connection_send_message_ptr __AMDServiceConnectionSendMessage;
42+
device_create_house_arrest_service_ptr __AMDeviceCreateHouseArrestService;
3743
device_connection_operation __AMDeviceStartSession;
3844
device_connection_operation __AMDeviceStopSession;
3945
device_connection_operation __AMDeviceConnect;
@@ -57,6 +63,7 @@ cf_get_concrete_type_id __CFDictionaryGetTypeID;
5763
cfdictionary_get_count __CFDictionaryGetCount;
5864
cfdictionary_get_keys_and_values __CFDictionaryGetKeysAndValues;
5965
cfstring_create_with_cstring __CFStringCreateWithCString;
66+
cfarray_create __CFArrayCreate;
6067
cfurl_create_with_string __CFURLCreateWithString;
6168
cfdictionary_create __CFDictionaryCreate;
6269
cfrelease __CFRelease;
@@ -365,7 +372,7 @@ std::mutex start_service_mutex;
365372
ServiceInfo start_secure_service(std::string device_identifier, const char* service_name, std::string method_id, bool should_log_error, bool skip_cache)
366373
{
367374
start_service_mutex.lock();
368-
ServiceInfo serviceInfoResult;
375+
ServiceInfo serviceInfoResult = {};
369376
if (!devices.count(device_identifier))
370377
{
371378
if (should_log_error)
@@ -454,10 +461,13 @@ AFCConnectionRef start_house_arrest(std::string device_identifier, const char* a
454461
HANDLE start_debug_server(std::string device_identifier, std::string ddi, std::string method_id)
455462
{
456463
ServiceInfo info = start_secure_service(device_identifier, kDebugServer, method_id, false, false);
464+
// mount_image is not available on Windows
465+
#ifndef _WIN32
457466
if (!info.socket && mount_image(device_identifier, ddi, method_id))
458467
{
459468
info = start_secure_service(device_identifier, kDebugServer, method_id, true, false);
460469
}
470+
#endif
461471

462472
return info.socket;
463473
}

0 commit comments

Comments
 (0)