/// <summary> /// 修改定位 /// </summary> /// <param name="location"></param> public void UpdateLocation(Location location) { if (Devices.Count == 0) { PrintMessage($"修改失败! 未发现任何设备."); return; } iDevice.idevice_set_debug_level(1); PrintMessage($"发起位置修改."); PrintMessage($"经纬度: {location.Longitude},{location.Latitude}"); //location = bd09_To_Gcj02(location.Latitude, location.Longitude); //PrintMessage($"gcj02经度: {location.Longitude}"); //PrintMessage($"gcj02纬度: {location.Latitude}"); //location = gcj_To_Gps84(location.Latitude, location.Longitude); //PrintMessage($"gps84经度: {location.Longitude}"); //PrintMessage($"gps84纬度: {location.Latitude}"); var Longitude = location.Longitude.ToString(); var Latitude = location.Latitude.ToString(); var size = BitConverter.GetBytes(0u); Array.Reverse(size); Devices.ForEach(itm => { PrintMessage($"开始修改设备 {itm.Name} {itm.Version}"); var num = 0u; iDevice.idevice_new(out var device, itm.UDID); lockdown.lockdownd_client_new_with_handshake(device, out var client, "com.alpha.jailout").ThrowOnError(); //com.alpha.jailout lockdown.lockdownd_start_service(client, "com.apple.dt.simulatelocation", out var service2).ThrowOnError(); //com.apple.dt.simulatelocation var se = service.service_client_new(device, service2, out var client2); // 先置空 se = service.service_send(client2, size, 4u, ref num); num = 0u; var bytesLocation = Encoding.ASCII.GetBytes(Latitude); size = BitConverter.GetBytes((uint)Latitude.Length); Array.Reverse(size); se = service.service_send(client2, size, 4u, ref num); se = service.service_send(client2, bytesLocation, (uint)bytesLocation.Length, ref num); bytesLocation = Encoding.ASCII.GetBytes(Longitude); size = BitConverter.GetBytes((uint)Longitude.Length); Array.Reverse(size); se = service.service_send(client2, size, 4u, ref num); se = service.service_send(client2, bytesLocation, (uint)bytesLocation.Length, ref num); //device.Dispose(); //client.Dispose(); PrintMessage($"设备 {itm.Name} {itm.Version} 修改完成."); }); }
private void UpdateLocation(string Longitude, string Latitude, string Altitude, DeviceModel itm) { var size = BitConverter.GetBytes(0u); Array.Reverse(size); var num = 0u; iDevice.idevice_new(out var device, itm.UDID); var ret_handshake = lockdown.lockdownd_client_new_with_handshake(device, out var client, "devicelocation"); if (ret_handshake != 0) { return; } if (!itm.isDevMode) { return; } var ret_start_service = lockdown.lockdownd_start_service(client, "com.apple.dt.simulatelocation", out var service2); if (ret_start_service != 0) { return; } var se = service.service_client_new(device, service2, out var client2); if (se != 0) { return; } se = service.service_send(client2, size, 4u, ref num); if (se != 0) { return; } num = 0u; var bytesLocation = Encoding.ASCII.GetBytes(Latitude); size = BitConverter.GetBytes((uint)Latitude.Length); Array.Reverse(size); se = service.service_send(client2, size, 4u, ref num); se = service.service_send(client2, bytesLocation, (uint)bytesLocation.Length, ref num); bytesLocation = Encoding.ASCII.GetBytes(Longitude); size = BitConverter.GetBytes((uint)Longitude.Length); Array.Reverse(size); se = service.service_send(client2, size, 4u, ref num); se = service.service_send(client2, bytesLocation, (uint)bytesLocation.Length, ref num); bytesLocation = Encoding.ASCII.GetBytes(Altitude); size = BitConverter.GetBytes((uint)Altitude.Length); Array.Reverse(size); se = service.service_send(client2, size, 4u, ref num); se = service.service_send(client2, bytesLocation, (uint)bytesLocation.Length, ref num); device.Close(); device.Dispose(); client.Dispose(); client2.Dispose(); service2.Dispose(); }
private static void SetLocation(DeviceInformation deviceInfo, PointLatLng?target) { iDeviceHandle device = null; LockdownClientHandle client = null; LockdownServiceDescriptorHandle service = null; ServiceClientHandle client2 = null; IiDeviceApi iDevice = LibiMobileDevice.Instance.iDevice; ILockdownApi lockdown = LibiMobileDevice.Instance.Lockdown; IServiceApi service2 = LibiMobileDevice.Instance.Service; try { if (iDevice.idevice_new(out device, deviceInfo.UDID) != 0) { throw new Exception("Unable to connect to the device. Make sure it is connected."); } if (lockdown.lockdownd_client_new_with_handshake(device, out client, "iFakeLocation") != 0) { throw new Exception("Unable to connect to lockdownd."); } if (lockdown.lockdownd_start_service(client, "com.apple.dt.simulatelocation", out service) != 0 || service.IsInvalid) { throw new Exception("Unable to start simulatelocation service."); } if (service2.service_client_new(device, service, out client2) != 0) { throw new Exception("Unable to create simulatelocation service client."); } if (!target.HasValue) { byte[] array = ToBytesBE(1); uint sent = 0u; if (service2.service_send(client2, array, (uint)array.Length, ref sent) != 0) { throw new Exception("Unable to send stop message to device."); } } else { byte[] array2 = ToBytesBE(0); byte[] bytes = Encoding.ASCII.GetBytes(target.Value.Lat.ToString(CultureInfo.InvariantCulture)); byte[] bytes2 = Encoding.ASCII.GetBytes(target.Value.Lng.ToString(CultureInfo.InvariantCulture)); byte[] array3 = ToBytesBE(bytes.Length); byte[] array4 = ToBytesBE(bytes2.Length); uint sent2 = 0u; if (service2.service_send(client2, array2, (uint)array2.Length, ref sent2) != 0 || service2.service_send(client2, array3, (uint)array3.Length, ref sent2) != 0 || service2.service_send(client2, bytes, (uint)bytes.Length, ref sent2) != 0 || service2.service_send(client2, array4, (uint)array4.Length, ref sent2) != 0 || service2.service_send(client2, bytes2, (uint)bytes2.Length, ref sent2) != 0) { throw new Exception("Unable to send co-ordinates to device."); } } } finally { if (client2 != null) { client2.Close(); } if (service != null) { service.Close(); } if (client != null) { client.Close(); } if (device != null) { device.Close(); } } }