[AltServer] Updates libimobiledevice dependency

This commit is contained in:
Riley Testut
2021-05-19 16:21:07 -07:00
parent 983b8ebe38
commit bc2dae1b21
3 changed files with 51 additions and 37 deletions

View File

@@ -206,7 +206,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
} }
/* Find Device */ /* Find Device */
if (idevice_new(&device, udid.UTF8String) != IDEVICE_E_SUCCESS) if (idevice_new_with_options(&device, udid.UTF8String, (enum idevice_options)((int)IDEVICE_LOOKUP_NETWORK | (int)IDEVICE_LOOKUP_USBMUX)) != IDEVICE_E_SUCCESS)
{ {
return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]); return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]);
} }
@@ -544,7 +544,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
}; };
/* Find Device */ /* Find Device */
if (idevice_new(&device, udid.UTF8String) != IDEVICE_E_SUCCESS) if (idevice_new_with_options(&device, udid.UTF8String, (enum idevice_options)((int)IDEVICE_LOOKUP_NETWORK | (int)IDEVICE_LOOKUP_USBMUX)) != IDEVICE_E_SUCCESS)
{ {
return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]); return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]);
} }
@@ -621,7 +621,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
}; };
/* Find Device */ /* Find Device */
if (idevice_new(&device, udid.UTF8String) != IDEVICE_E_SUCCESS) if (idevice_new_with_options(&device, udid.UTF8String, (enum idevice_options)((int)IDEVICE_LOOKUP_NETWORK | (int)IDEVICE_LOOKUP_USBMUX)) != IDEVICE_E_SUCCESS)
{ {
return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]); return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]);
} }
@@ -709,7 +709,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
}; };
/* Find Device */ /* Find Device */
if (idevice_new(&device, udid.UTF8String) != IDEVICE_E_SUCCESS) if (idevice_new_with_options(&device, udid.UTF8String, (enum idevice_options)((int)IDEVICE_LOOKUP_NETWORK | (int)IDEVICE_LOOKUP_USBMUX)) != IDEVICE_E_SUCCESS)
{ {
return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]); return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]);
} }
@@ -995,7 +995,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
idevice_connection_t connection = NULL; idevice_connection_t connection = NULL;
/* Find Device */ /* Find Device */
if (idevice_new_ignore_network(&device, altDevice.identifier.UTF8String) != IDEVICE_E_SUCCESS) if (idevice_new_with_options(&device, altDevice.identifier.UTF8String, IDEVICE_LOOKUP_USBMUX) != IDEVICE_E_SUCCESS)
{ {
return finish(nil, [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]); return finish(nil, [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]);
} }
@@ -1030,7 +1030,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
np_client_t client = NULL; np_client_t client = NULL;
/* Find Device */ /* Find Device */
if (idevice_new_ignore_network(&device, altDevice.identifier.UTF8String) != IDEVICE_E_SUCCESS) if (idevice_new_with_options(&device, altDevice.identifier.UTF8String, IDEVICE_LOOKUP_USBMUX) != IDEVICE_E_SUCCESS)
{ {
return finish(nil, [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]); return finish(nil, [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorDeviceNotFound userInfo:nil]);
} }
@@ -1078,8 +1078,9 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
NSMutableSet *connectedDevices = [NSMutableSet set]; NSMutableSet *connectedDevices = [NSMutableSet set];
int count = 0; int count = 0;
char **udids = NULL; idevice_info_t *devices = NULL;
if (idevice_get_device_list(&udids, &count) < 0)
if (idevice_get_device_list_extended(&devices, &count) < 0)
{ {
fprintf(stderr, "ERROR: Unable to retrieve device list!\n"); fprintf(stderr, "ERROR: Unable to retrieve device list!\n");
return @[]; return @[];
@@ -1087,17 +1088,46 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
char *udid = udids[i]; idevice_info_t device_info = devices[i];
char *udid = device_info->udid;
idevice_t device = NULL; idevice_t device = NULL;
lockdownd_client_t client = NULL;
char *device_name = NULL;
char *device_type_string = NULL;
plist_t device_type_plist = NULL;
void (^cleanUp)(void) = ^{
if (device_type_plist) {
plist_free(device_type_plist);
}
if (device_type_string) {
free(device_type_string);
}
if (device_name) {
free(device_name);
}
if (client) {
lockdownd_client_free(client);
}
if (device) {
idevice_free(device);
}
};
if (includingNetworkDevices) if (includingNetworkDevices)
{ {
idevice_new(&device, udid); idevice_new_with_options(&device, udid, (enum idevice_options)((int)IDEVICE_LOOKUP_NETWORK | (int)IDEVICE_LOOKUP_USBMUX));
} }
else else
{ {
idevice_new_ignore_network(&device, udid); idevice_new_with_options(&device, udid, IDEVICE_LOOKUP_USBMUX);
} }
if (!device) if (!device)
@@ -1105,44 +1135,34 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
continue; continue;
} }
lockdownd_client_t client = NULL;
int result = lockdownd_client_new(device, &client, "altserver"); int result = lockdownd_client_new(device, &client, "altserver");
if (result != LOCKDOWN_E_SUCCESS) if (result != LOCKDOWN_E_SUCCESS)
{ {
fprintf(stderr, "ERROR: Connecting to device %s failed! (%d)\n", udid, result); fprintf(stderr, "ERROR: Connecting to device %s failed! (%d)\n", udid, result);
idevice_free(device); cleanUp();
continue; continue;
} }
char *device_name = NULL;
if (lockdownd_get_device_name(client, &device_name) != LOCKDOWN_E_SUCCESS || device_name == NULL) if (lockdownd_get_device_name(client, &device_name) != LOCKDOWN_E_SUCCESS || device_name == NULL)
{ {
fprintf(stderr, "ERROR: Could not get device name!\n"); fprintf(stderr, "ERROR: Could not get device name!\n");
lockdownd_client_free(client); cleanUp();
idevice_free(device);
continue; continue;
} }
plist_t device_type_plist = NULL;
if (lockdownd_get_value(client, NULL, "ProductType", &device_type_plist) != LOCKDOWN_E_SUCCESS) if (lockdownd_get_value(client, NULL, "ProductType", &device_type_plist) != LOCKDOWN_E_SUCCESS)
{ {
fprintf(stderr, "ERROR: Could not get device type for %s!\n", device_name); fprintf(stderr, "ERROR: Could not get device type for %s!\n", device_name);
lockdownd_client_free(client); cleanUp();
idevice_free(device);
continue; continue;
} }
ALTDeviceType deviceType = ALTDeviceTypeiPhone;
char *device_type_string = NULL;
plist_get_string_val(device_type_plist, &device_type_string); plist_get_string_val(device_type_plist, &device_type_string);
ALTDeviceType deviceType = ALTDeviceTypeiPhone;
if ([@(device_type_string) hasPrefix:@"iPhone"]) if ([@(device_type_string) hasPrefix:@"iPhone"])
{ {
deviceType = ALTDeviceTypeiPhone; deviceType = ALTDeviceTypeiPhone;
@@ -1159,28 +1179,20 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
{ {
fprintf(stderr, "ERROR: Unknown device type %s for %s!\n", device_type_string, device_name); fprintf(stderr, "ERROR: Unknown device type %s for %s!\n", device_type_string, device_name);
lockdownd_client_free(client); cleanUp();
idevice_free(device);
continue; continue;
} }
lockdownd_client_free(client);
idevice_free(device);
NSString *name = [NSString stringWithCString:device_name encoding:NSUTF8StringEncoding]; NSString *name = [NSString stringWithCString:device_name encoding:NSUTF8StringEncoding];
NSString *identifier = [NSString stringWithCString:udid encoding:NSUTF8StringEncoding]; NSString *identifier = [NSString stringWithCString:udid encoding:NSUTF8StringEncoding];
ALTDevice *altDevice = [[ALTDevice alloc] initWithName:name identifier:identifier type:deviceType]; ALTDevice *altDevice = [[ALTDevice alloc] initWithName:name identifier:identifier type:deviceType];
[connectedDevices addObject:altDevice]; [connectedDevices addObject:altDevice];
if (device_name != NULL) cleanUp();
{
free(device_name);
}
} }
idevice_device_list_free(udids); idevice_device_list_extended_free(devices);
return connectedDevices.allObjects; return connectedDevices.allObjects;
} }

View File

@@ -2805,6 +2805,7 @@
HAVE_VASPRINTF, HAVE_VASPRINTF,
HAVE_ASPRINTF, HAVE_ASPRINTF,
"\"PACKAGE_STRING=\\\"AltServer 1.0\\\"\"", "\"PACKAGE_STRING=\\\"AltServer 1.0\\\"\"",
HAVE_GETIFADDRS,
); );
GCC_WARN_INHIBIT_ALL_WARNINGS = YES; GCC_WARN_INHIBIT_ALL_WARNINGS = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@@ -2842,6 +2843,7 @@
HAVE_VASPRINTF, HAVE_VASPRINTF,
HAVE_ASPRINTF, HAVE_ASPRINTF,
"\"PACKAGE_STRING=\\\"AltServer 1.0\\\"\"", "\"PACKAGE_STRING=\\\"AltServer 1.0\\\"\"",
HAVE_GETIFADDRS,
); );
GCC_WARN_INHIBIT_ALL_WARNINGS = YES; GCC_WARN_INHIBIT_ALL_WARNINGS = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (