public static extern void instproxy_status_get_current_list(PlistHandle status, ref ulong total, ref ulong currentIndex, ref ulong currentAmount, out PlistHandle list);
public static extern DiagnosticsRelayError diagnostics_relay_query_ioregistry_plane(DiagnosticsRelayClientHandle client, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string plane, out PlistHandle result);
public static extern MisagentError misagent_copy_all(MisagentClientHandle client, out PlistHandle profiles);
/// <summary> /// Send a request to the connected mobilebackup2 service. /// </summary> /// <param name="request"> /// The request to send to the backup service. /// Currently, this is one of "Backup", "Restore", "Info", or "List". /// </param> /// <param name="target_identifier"> /// UDID of the target device. /// </param> /// <param name="source_identifier"> /// UDID of backup data? /// </param> /// <param name="options"> /// Additional options in a plist of type PLIST_DICT. /// </param> /// <returns> /// MOBILEBACKUP2_E_SUCCESS if the request was successfully sent, /// or a MOBILEBACKUP2_E_* error value otherwise. /// </returns> public virtual MobileBackup2Error mobilebackup2_send_request(MobileBackup2ClientHandle client, string request, string targetIdentifier, string sourceIdentifier, PlistHandle options) { return(MobileBackup2NativeMethods.mobilebackup2_send_request(client, request, targetIdentifier, sourceIdentifier, options)); }
public static extern DiagnosticsRelayError diagnostics_relay_request_diagnostics(DiagnosticsRelayClientHandle client, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string type, out PlistHandle diagnostics);
public static extern RestoreError restored_receive(RestoreClientHandle client, out PlistHandle plist);
/// <summary> /// Sends a backup message plist. /// </summary> /// <param name="client"> /// The connected MobileBackup client to use. /// </param> /// <param name="message"> /// The message to send. This will be inserted into the request /// plist as value for MessageName. If this parameter is NULL, /// the plist passed in the options parameter will be sent directly. /// </param> /// <param name="options"> /// Additional options as PLIST_DICT to add to the request. /// The MessageName key with the value passed in the message parameter /// will be inserted into this plist before sending it. This parameter /// can be NULL if message is not NULL. /// </param> public virtual MobileBackup2Error mobilebackup2_send_message(MobileBackup2ClientHandle client, string message, PlistHandle options) { return(MobileBackup2NativeMethods.mobilebackup2_send_message(client, message, options)); }
/// <summary> /// Receives a plist from the service. /// </summary> /// <param name="client"> /// The heartbeat client /// </param> /// <param name="plist"> /// The plist to store the received data /// </param> /// <returns> /// HEARTBEAT_E_SUCCESS on success, /// HEARTBEAT_E_INVALID_ARG when client or plist is NULL /// </returns> public virtual HeartBeatError heartbeat_receive(HeartBeatClientHandle client, out PlistHandle plist) { HeartBeatError returnValue; returnValue = HeartBeatNativeMethods.heartbeat_receive(client, out plist); plist.Api = this.Parent; return(returnValue); }
/// <summary> /// Receives a plist using the given heartbeat client. /// </summary> /// <param name="client"> /// The heartbeat client to use for receiving /// </param> /// <param name="plist"> /// pointer to a plist_t that will point to the received plist /// upon successful return /// </param> /// <param name="timeout"> /// Maximum time in milliseconds to wait for data. /// </param> /// <returns> /// HEARTBEAT_E_SUCCESS on success, /// HEARTBEAT_E_INVALID_ARG when client or *plist is NULL, /// HEARTBEAT_E_PLIST_ERROR when the received data cannot be /// converted to a plist, HEARTBEAT_E_MUX_ERROR when a /// communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR /// when an unspecified error occurs. /// </returns> public virtual HeartBeatError heartbeat_receive_with_timeout(HeartBeatClientHandle client, out PlistHandle plist, uint timeoutMs) { HeartBeatError returnValue; returnValue = HeartBeatNativeMethods.heartbeat_receive_with_timeout(client, out plist, timeoutMs); plist.Api = this.Parent; return(returnValue); }
public static extern void instproxy_client_options_add(PlistHandle client_options, string key, string value, byte term);
/// <summary> /// Sends a plist to the service. /// </summary> /// <param name="client"> /// The heartbeat client /// </param> /// <param name="plist"> /// The plist to send /// </param> /// <returns> /// HEARTBEAT_E_SUCCESS on success, /// HEARTBEAT_E_INVALID_ARG when client or plist is NULL /// </returns> public virtual HeartBeatError heartbeat_send(HeartBeatClientHandle client, PlistHandle plist) { return(HeartBeatNativeMethods.heartbeat_send(client, plist)); }
public static extern void instproxy_client_options_free(PlistHandle clientOptions);
public static extern void instproxy_client_options_set_return_attributes(PlistHandle clientOptions);
public static extern void instproxy_status_get_percent_complete(PlistHandle status, ref int percent);
public static extern RestoreError restored_get_value(RestoreClientHandle client, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string key, out PlistHandle value);
public static extern HouseArrestError house_arrest_send_request(HouseArrestClientHandle client, PlistHandle dict);
public static extern RestoreError restored_send(RestoreClientHandle client, PlistHandle plist);
public static extern HouseArrestError house_arrest_get_result(HouseArrestClientHandle client, out PlistHandle dict);
public static extern RestoreError restored_start_restore(RestoreClientHandle client, PlistHandle options, ulong version);
private void ReadProperties(PlistHandle node) { Properties = PlistReader.ReadPlistDictFromNode(node, new[] { "ProductType", "ProductVersion", "HostAttached" }); }
/// <summary> /// Receives a DL* message plist from the device. /// This function is a wrapper around device_link_service_receive_message. /// </summary> /// <param name="client"> /// The connected MobileBackup client to use. /// </param> /// <param name="msg_plist"> /// Pointer to a plist that will be set to the contents of the /// message plist upon successful return. /// </param> /// <param name="dlmessage"> /// A pointer that will be set to a newly allocated char* /// containing the DL* string from the given plist. It is up to the caller /// to free the allocated memory. If this parameter is NULL /// it will be ignored. /// </param> /// <returns> /// MOBILEBACKUP2_E_SUCCESS if a DL* message was received, /// MOBILEBACKUP2_E_INVALID_ARG if client or message is invalid, /// MOBILEBACKUP2_E_PLIST_ERROR if the received plist is invalid /// or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if /// receiving from the device failed. /// </returns> public virtual MobileBackup2Error mobilebackup2_receive_message(MobileBackup2ClientHandle client, out PlistHandle msgPlist, out string dlmessage) { MobileBackup2Error returnValue; returnValue = MobileBackup2NativeMethods.mobilebackup2_receive_message(client, out msgPlist, out dlmessage); msgPlist.Api = this.Parent; return(returnValue); }
public void EnableDeveloperMode(string deviceImagePath, string deviceImageSignaturePath) { if (!File.Exists(deviceImagePath) || !File.Exists(deviceImageSignaturePath)) { throw new FileNotFoundException("The specified device image files do not exist."); } iDeviceHandle deviceHandle = null; LockdownClientHandle lockdownHandle = null; LockdownServiceDescriptorHandle serviceDescriptor = null; MobileImageMounterClientHandle mounterHandle = null; AfcClientHandle afcHandle = null; PlistHandle plistHandle = null; FileStream imageStream = null; // Use upload image for iOS 7 and above, otherwise use AFC DiskImageUploadMode mode = int.Parse(((string)Properties["ProductVersion"]).Split('.')[0]) >= 7 ? DiskImageUploadMode.UploadImage : DiskImageUploadMode.AFC; var idevice = LibiMobileDevice.Instance.iDevice; var lockdown = LibiMobileDevice.Instance.Lockdown; var service = LibiMobileDevice.Instance.Service; var mounter = LibiMobileDevice.Instance.MobileImageMounter; var afc = LibiMobileDevice.Instance.Afc; try { // Get device handle if (idevice.idevice_new(out deviceHandle, UDID) != iDeviceError.Success) { throw new Exception("Unable to open device, is it connected?"); } // Get lockdownd handle if (lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "iFakeLocation") != LockdownError.Success) { throw new Exception("Unable to connect to lockdownd."); } // Start image mounter service if (lockdown.lockdownd_start_service(lockdownHandle, "com.apple.mobile.mobile_image_mounter", out serviceDescriptor) != LockdownError.Success) { throw new Exception("Unable to start the mobile image mounter service."); } // Create mounter instance if (mounter.mobile_image_mounter_new(deviceHandle, serviceDescriptor, out mounterHandle) != MobileImageMounterError.Success) { throw new Exception("Unable to create mobile image mounter instance."); } // Close service descriptor serviceDescriptor.Close(); serviceDescriptor = null; // Start the AFC service if (mode == DiskImageUploadMode.AFC) { if (lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc", out serviceDescriptor) != LockdownError.Success) { throw new Exception("Unable to start AFC service."); } if (afc.afc_client_new(deviceHandle, serviceDescriptor, out afcHandle) != AfcError.Success) { throw new Exception("Unable to connect to AFC service."); } serviceDescriptor.Close(); serviceDescriptor = null; } // Close lockdown handle lockdownHandle.Close(); lockdownHandle = null; // Check if the developer image has already been mounted const string imageType = "Developer"; if (mounter.mobile_image_mounter_lookup_image(mounterHandle, imageType, out plistHandle) == MobileImageMounterError.Success) { var results = PlistReader.ReadPlistDictFromNode(plistHandle, new[] { "ImagePresent", "ImageSignature" }); // Some iOS use ImagePresent to verify presence, while others use ImageSignature instead // Ensure to check the content of the ImageSignature value as iOS 14 returns a value even // if it is empty. if ((results.ContainsKey("ImagePresent") && results["ImagePresent"] is bool && (bool)results["ImagePresent"]) || (results.ContainsKey("ImageSignature") && results["ImageSignature"] is string && ((string)results["ImageSignature"]).IndexOf("<data>", StringComparison.InvariantCulture) >= 0)) { return; } } plistHandle.Close(); plistHandle = null; // Configure paths for upload const string PkgPath = "PublicStaging"; const string PathPrefix = "/private/var/mobile/Media"; var targetName = PkgPath + "/staging.dimage"; var mountName = PathPrefix + "/" + targetName; imageStream = new FileStream(deviceImagePath, FileMode.Open, FileAccess.Read, FileShare.Read); var sig = File.ReadAllBytes(deviceImageSignaturePath); switch (mode) { case DiskImageUploadMode.UploadImage: // Create stream for device image and wrap as a pointer for callback var handle = GCHandle.Alloc(imageStream); // Upload the image and then free unmanaged wrapper mounter.mobile_image_mounter_upload_image(mounterHandle, imageType, (uint)imageStream.Length, sig, (ushort)sig.Length, MounterUploadCallback, GCHandle.ToIntPtr(handle)); handle.Free(); break; case DiskImageUploadMode.AFC: // Create directory for package ReadOnlyCollection <string> strs; if (afc.afc_get_file_info(afcHandle, PkgPath, out strs) != AfcError.Success || afc.afc_make_directory(afcHandle, PkgPath) != AfcError.Success) { throw new Exception("Unable to create directory '" + PkgPath + "' on the device."); } // Create the target file ulong af = 0; if (afc.afc_file_open(afcHandle, targetName, AfcFileMode.FopenWronly, ref af) != AfcError.Success) { throw new Exception("Unable to create file '" + targetName + "'."); } // Read the file in chunks and write via AFC uint amount = 0; byte[] buf = new byte[8192]; do { amount = (uint)imageStream.Read(buf, 0, buf.Length); if (amount > 0) { uint written = 0, total = 0; while (total < amount) { // Write and ensure that it succeeded if (afc.afc_file_write(afcHandle, af, buf, amount, ref written) != AfcError.Success) { afc.afc_file_close(afcHandle, af); throw new Exception("An AFC write error occurred."); } total += written; } if (total != amount) { afc.afc_file_close(afcHandle, af); throw new Exception("The developer image was not written completely."); } } } while (amount > 0); afc.afc_file_close(afcHandle, af); break; } // Mount the image if (mounter.mobile_image_mounter_mount_image(mounterHandle, mountName, sig, (ushort)sig.Length, imageType, out plistHandle) != MobileImageMounterError.Success) { throw new Exception("掛載開發者映像檔失敗,請嘗試解鎖裝置。"); } // Parse the plist result var result = PlistReader.ReadPlistDictFromNode(plistHandle); if (!result.ContainsKey("Status") || result["Status"] as string != "Complete") { throw new Exception("Mount failed with status: " + (result.ContainsKey("Status") ? result["Status"] : "N/A") + " and error: " + (result.ContainsKey("Error") ? result["Error"] : "N/A")); } } finally { if (imageStream != null) { imageStream.Close(); } if (plistHandle != null) { plistHandle.Close(); } if (afcHandle != null) { afcHandle.Close(); } if (mounterHandle != null) { mounterHandle.Close(); } if (serviceDescriptor != null) { serviceDescriptor.Close(); } if (lockdownHandle != null) { lockdownHandle.Close(); } if (deviceHandle != null) { deviceHandle.Close(); } } }
/// <summary> /// Sends a DLMessageStatusResponse to the device. /// </summary> /// <param name="client"> /// The MobileBackup client to use. /// </param> /// <param name="status_code"> /// The status code to send. /// </param> /// <param name="status1"> /// A status message to send. Can be NULL if not required. /// </param> /// <param name="status2"> /// An additional status plist to attach to the response. /// Can be NULL if not required. /// </param> /// <returns> /// MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG /// if client is invalid, or another MOBILEBACKUP2_E_* otherwise. /// </returns> public virtual MobileBackup2Error mobilebackup2_send_status_response(MobileBackup2ClientHandle client, int statusCode, string status1, PlistHandle status2) { return(MobileBackup2NativeMethods.mobilebackup2_send_status_response(client, statusCode, status1, status2)); }
public static List <DeviceInformation> GetDevices() { var idevice = LibiMobileDevice.Instance.iDevice; var lockdown = LibiMobileDevice.Instance.Lockdown; var plist = LibiMobileDevice.Instance.Plist; // Retrieve list of unique device identifiers ReadOnlyCollection <string> uddids; int count = 0; var ret = idevice.idevice_get_device_list(out uddids, ref count); if (ret != iDeviceError.Success) { return(null); } iDeviceHandle deviceHandle = null; LockdownClientHandle lockdownHandle = null; PlistHandle plistHandle = null; var devices = new List <DeviceInformation>(); foreach (var udid in uddids.Distinct()) { try { // Attempt to get device handle of each uuid var err = idevice.idevice_new(out deviceHandle, udid); if (err != iDeviceError.Success) { continue; } // Obtain a lockdown client handle if (lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "iFakeLocation") != LockdownError.Success) { continue; } // Obtain the device name string name; DeviceInformation device; if (lockdown.lockdownd_get_device_name(lockdownHandle, out name) != LockdownError.Success) { continue; } device = new DeviceInformation(name, udid); // Get device details if (lockdown.lockdownd_get_value(lockdownHandle, null, null, out plistHandle) != LockdownError.Success || plist.plist_get_node_type(plistHandle) != PlistType.Dict) { continue; } device.ReadProperties(plistHandle); // Ensure device is attached if (!device.Properties.ContainsKey("HostAttached") || (bool)device.Properties["HostAttached"]) { devices.Add(device); } } finally { // Cleanup if (plistHandle != null) { plistHandle.Close(); } if (lockdownHandle != null) { lockdownHandle.Close(); } if (deviceHandle != null) { deviceHandle.Close(); } } } return(devices); }
public static extern DiagnosticsRelayError diagnostics_relay_query_mobilegestalt(DiagnosticsRelayClientHandle client, PlistHandle keys, out PlistHandle result);
/// <summary> /// Sends a binary plist. /// </summary> /// <param name="client"> /// The property list service client to use for sending. /// </param> /// <param name="plist"> /// plist to send /// </param> /// <returns> /// PROPERTY_LIST_SERVICE_E_SUCCESS on success, /// PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL, /// PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist, /// or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs. /// </returns> public virtual PropertyListServiceError property_list_service_send_binary_plist(PropertyListServiceClientHandle client, PlistHandle plist) { return(PropertyListServiceNativeMethods.property_list_service_send_binary_plist(client, plist)); }
public static extern MisagentError misagent_install(MisagentClientHandle client, PlistHandle profile);
/// <summary> /// Receives a plist using the given property list service client. /// Binary or XML plists are automatically handled. /// This function is like property_list_service_receive_plist_with_timeout /// using a timeout of 10 seconds. /// </summary> /// <param name="client"> /// The property list service client to use for receiving /// </param> /// <param name="plist"> /// pointer to a plist_t that will point to the received plist /// upon successful return /// </param> /// <returns> /// PROPERTY_LIST_SERVICE_E_SUCCESS on success, /// PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or *plist is NULL, /// PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be /// converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a /// communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when /// an unspecified error occurs. /// </returns> public virtual PropertyListServiceError property_list_service_receive_plist(PropertyListServiceClientHandle client, out PlistHandle plist) { PropertyListServiceError returnValue; returnValue = PropertyListServiceNativeMethods.property_list_service_receive_plist(client, out plist); plist.Api = this.Parent; return(returnValue); }
public static MobileBackup2Error mobilebackup2_receive_message(MobileBackup2ClientHandle client, out PlistHandle msgPlist, out string dlmessage) { System.Runtime.InteropServices.ICustomMarshaler dlmessageMarshaler = NativeStringMarshaler.GetInstance(null); System.IntPtr dlmessageNative = System.IntPtr.Zero; MobileBackup2Error returnValue = MobileBackup2NativeMethods.mobilebackup2_receive_message(client, out msgPlist, out dlmessageNative); dlmessage = ((string)dlmessageMarshaler.MarshalNativeToManaged(dlmessageNative)); dlmessageMarshaler.CleanUpNativeData(dlmessageNative); return(returnValue); }
public static extern InstallationProxyError instproxy_status_get_error(PlistHandle status, out System.IntPtr name, out System.IntPtr description, ref ulong code);