Skip to content

Commit 0d465c7

Browse files
committed
feat: migrate to Secure Connections in order to support iOS13, Xcode11 and maybe the WIFI sync
1 parent db3c0db commit 0d465c7

File tree

8 files changed

+249
-193
lines changed

8 files changed

+249
-193
lines changed

IOSDeviceLib.xcodeproj/project.pbxproj

+1
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@
11431143
developmentRegion = English;
11441144
hasScannedForEncodings = 0;
11451145
knownRegions = (
1146+
English,
11461147
en,
11471148
);
11481149
mainGroup = 70F6ADA21DEEB71300DD4722;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

IOSDeviceLib/CommonFunctions.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
#include "PlistCpp/include/boost/any.hpp"
77
#include "Declarations.h"
88

9+
AFCConnectionRef start_house_arrest(std::string device_identifier, const char* application_identifier, std::string method_id);
910
inline bool has_complete_status(std::map<std::string, boost::any>& dict);
10-
HANDLE start_service(std::string device_identifier, const char* service_name, std::string method_id, bool should_log_error = true, bool skip_cache = false);
11+
ServiceInfo start_secure_service(std::string device_identifier, const char* service_name, std::string method_id, bool should_log_error = true, bool skip_cache = false);
1112
bool mount_image(std::string& device_identifier, std::string& image_path, std::string& method_id);
1213
std::string get_device_property_value(std::string& device_identifier, const char* property_name);
1314
int start_session(std::string& device_identifier);
1415
void stop_session(std::string& device_identifier);
15-
CFStringRef create_CFString(const char* str);
16+
CFStringRef create_CFString(const char* str);

IOSDeviceLib/Declarations.h

+45-26
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct LiveSyncApplicationInfo {
6363

6464
typedef unsigned long long afc_file_ref;
6565

66+
6667
struct afc_connection {
6768
unsigned int handle; /* 0 */
6869
unsigned int unknown0; /* 4 */
@@ -78,6 +79,8 @@ struct afc_connection {
7879
unsigned int context; /* 40 */
7980
};
8081

82+
typedef struct afc_connection * AFCConnectionRef;
83+
8184
struct afc_dictionary {
8285
unsigned char unknown[0]; /* size unknown */
8386
};
@@ -88,18 +91,27 @@ struct afc_directory {
8891

8992
struct afc_file {
9093
afc_file_ref file_ref;
91-
afc_connection* afc_conn_p;
94+
AFCConnectionRef afc_conn_p;
9295
};
9396

9497
struct ApplicationCache {
95-
afc_connection* afc_connection;
98+
AFCConnectionRef afc_connection;
9699
bool has_initialized_gdb;
97100
};
98101

102+
typedef HANDLE service_conn_t;
103+
typedef service_conn_t * ServiceConnRef;
104+
typedef struct DeviceInfo * AMDeviceRef;
105+
struct ServiceInfo {
106+
HANDLE socket;
107+
ServiceConnRef connection;
108+
int connection_id;
109+
};
110+
99111
struct DeviceData {
100112
DeviceInfo* device_info;
101113
struct DeviceServerData* device_server_data;
102-
std::map<const char*, HANDLE> services;
114+
std::map<const char*, ServiceInfo> services;
103115
int sessions;
104116
std::map<std::string, ApplicationCache> apps_cache;
105117

@@ -149,18 +161,18 @@ typedef CFDictionaryRef(__cdecl *cfdictionary_create)(void *, void*, void*, int,
149161
typedef void*(__cdecl *cfurl_create_with_string)(void *, CFStringRef, void*);
150162

151163
typedef unsigned(__cdecl *afc_connection_open)(HANDLE, const char*, void*);
152-
typedef unsigned(__cdecl *afc_connection_close)(afc_connection*);
153-
typedef unsigned(__cdecl *afc_file_info_open)(afc_connection*, const char*, afc_dictionary**);
154-
typedef unsigned(__cdecl *afc_directory_read)(afc_connection*, afc_directory*, char**);
155-
typedef unsigned(__cdecl *afc_directory_open)(afc_connection*, const char*, afc_directory**);
156-
typedef unsigned(__cdecl *afc_directory_close)(afc_connection*, afc_directory*);
157-
typedef unsigned(__cdecl *afc_directory_create)(afc_connection*, const char *);
158-
typedef unsigned(__cdecl *afc_remove_path)(afc_connection*, const char *);
159-
typedef unsigned(__cdecl *afc_fileref_open)(afc_connection*, const char *, unsigned long long, afc_file_ref*);
160-
typedef unsigned(__cdecl *afc_fileref_read)(afc_connection*, afc_file_ref, void *, size_t*);
161-
typedef unsigned(__cdecl *afc_get_device_info_key)(afc_connection*, const char *, char**);
162-
typedef unsigned(__cdecl *afc_fileref_write)(afc_connection*, afc_file_ref, const void*, size_t);
163-
typedef unsigned(__cdecl *afc_fileref_close)(afc_connection*, afc_file_ref);
164+
typedef unsigned(__cdecl *afc_connection_close)(AFCConnectionRef);
165+
typedef unsigned(__cdecl *afc_file_info_open)(AFCConnectionRef, const char*, afc_dictionary**);
166+
typedef unsigned(__cdecl *afc_directory_read)(AFCConnectionRef, afc_directory*, char**);
167+
typedef unsigned(__cdecl *afc_directory_open)(AFCConnectionRef, const char*, afc_directory**);
168+
typedef unsigned(__cdecl *afc_directory_close)(AFCConnectionRef, afc_directory*);
169+
typedef unsigned(__cdecl *afc_directory_create)(AFCConnectionRef, const char *);
170+
typedef unsigned(__cdecl *afc_remove_path)(AFCConnectionRef, const char *);
171+
typedef unsigned(__cdecl *afc_fileref_open)(AFCConnectionRef, const char *, unsigned long long, afc_file_ref*);
172+
typedef unsigned(__cdecl *afc_fileref_read)(AFCConnectionRef, afc_file_ref, void *, size_t*);
173+
typedef unsigned(__cdecl *afc_get_device_info_key)(AFCConnectionRef, const char *, char**);
174+
typedef unsigned(__cdecl *afc_fileref_write)(AFCConnectionRef, afc_file_ref, const void*, size_t);
175+
typedef unsigned(__cdecl *afc_fileref_close)(AFCConnectionRef, afc_file_ref);
164176
typedef unsigned(__cdecl *device_start_house_arrest)(const DeviceInfo*, CFStringRef, void*, HANDLE*, unsigned int*);
165177
typedef unsigned(__cdecl *device_lookup_applications)(const DeviceInfo*, CFDictionaryRef, CFDictionaryRef*);
166178
typedef int(__cdecl *usb_mux_connect_by_port)(int, int, long long*);
@@ -228,14 +240,21 @@ typedef int(__cdecl *usb_mux_connect_by_port)(int, int, long long*);
228240

229241
#include <CoreFoundation/CoreFoundation.h>
230242

243+
// TODO: handle Windows
244+
231245
extern "C"
232246
{
247+
CFSocketNativeHandle AMDServiceConnectionGetSocket(ServiceConnRef con);
248+
long AMDServiceConnectionReceive(ServiceConnRef, void *, long);
249+
long AMDServiceConnectionSendMessage(ServiceConnRef serviceConnection, CFDictionaryRef message, CFPropertyListFormat format);
250+
unsigned AMDeviceSecureStartService(AMDeviceRef device, CFStringRef service_name, unsigned int *unknown, ServiceConnRef * handle);
233251
unsigned AMDeviceNotificationSubscribe(void(*f)(const DevicePointer*), long, long, long, HANDLE*);
234252
CFStringRef AMDeviceCopyDeviceIdentifier(const DeviceInfo*);
235253
CFStringRef AMDeviceCopyValue(const DeviceInfo*, CFStringRef, CFStringRef);
236254
unsigned AMDeviceMountImage(const DeviceInfo*, CFStringRef, CFDictionaryRef, void(*f)(void*, int), void*);
237255
unsigned AMDeviceStartService(const DeviceInfo*, CFStringRef, HANDLE*, void*);
238256
unsigned AMDeviceLookupApplications(const DeviceInfo*, CFDictionaryRef, CFDictionaryRef*);
257+
unsigned AMDeviceCreateHouseArrestService(const DeviceInfo*, CFStringRef identifier, void * unknown, AFCConnectionRef * handle);
239258
int AMDeviceGetConnectionID(const DeviceInfo*);
240259
int AMDeviceGetInterfaceType(const DeviceInfo*);
241260
unsigned AMDeviceUninstallApplication(HANDLE, CFStringRef, void*, void(*f)(), void*);
@@ -251,17 +270,17 @@ extern "C"
251270
unsigned AMDeviceSecureInstallApplication(int, const DeviceInfo*, CFURLRef, CFDictionaryRef, void(*f)(), int);
252271
unsigned AMDeviceStartHouseArrestService(const DeviceInfo*, CFStringRef, void*, HANDLE*, unsigned int*);
253272
unsigned AFCConnectionOpen(HANDLE, const char*, void*);
254-
unsigned AFCConnectionClose(afc_connection*);
255-
unsigned AFCRemovePath(afc_connection*, const char*);
256-
unsigned AFCFileInfoOpen(afc_connection*, const char*, afc_dictionary**);
257-
unsigned AFCDirectoryRead(afc_connection*, afc_directory*, char**);
258-
unsigned AFCDirectoryOpen(afc_connection*, const char*, afc_directory**);
259-
unsigned AFCDirectoryClose(afc_connection*, afc_directory*);
260-
unsigned AFCDirectoryCreate(afc_connection*, const char*);
261-
unsigned AFCFileRefOpen(afc_connection*, const char*, unsigned long long, afc_file_ref*);
262-
unsigned AFCFileRefRead(afc_connection*, afc_file_ref, void*, size_t*);
263-
unsigned AFCFileRefWrite(afc_connection*, afc_file_ref, const void*, size_t);
264-
unsigned AFCFileRefClose(afc_connection*, afc_file_ref);
273+
unsigned AFCConnectionClose(AFCConnectionRef);
274+
unsigned AFCRemovePath(AFCConnectionRef, const char*);
275+
unsigned AFCFileInfoOpen(AFCConnectionRef, const char*, afc_dictionary**);
276+
unsigned AFCDirectoryRead(AFCConnectionRef, afc_directory*, char**);
277+
unsigned AFCDirectoryOpen(AFCConnectionRef, const char*, afc_directory**);
278+
unsigned AFCDirectoryClose(AFCConnectionRef, afc_directory*);
279+
unsigned AFCDirectoryCreate(AFCConnectionRef, const char*);
280+
unsigned AFCFileRefOpen(AFCConnectionRef, const char*, unsigned long long, afc_file_ref*);
281+
unsigned AFCFileRefRead(AFCConnectionRef, afc_file_ref, void*, size_t*);
282+
unsigned AFCFileRefWrite(AFCConnectionRef, afc_file_ref, const void*, size_t);
283+
unsigned AFCFileRefClose(AFCConnectionRef, afc_file_ref);
265284
unsigned USBMuxConnectByPort(int, int, long long*);
266285
}
267286

0 commit comments

Comments
 (0)