Class LockdownNativeMethods
Inheritance
Inherited Members
Namespace: iMobileDevice.Lockdown
Assembly: iMobileDevice-net.dll
Syntax
public class LockdownNativeMethods
Methods
lockdownd_activate(LockdownClientHandle, PlistHandle)
Activates the device. Only works within an open session. The ActivationRecord plist dictionary must be obtained using the activation protocol requesting from Apple's https webservice.
Declaration
public static LockdownError lockdownd_activate(LockdownClientHandle client, PlistHandle activationRecord)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
PlistHandle | activationRecord |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or activation_record is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken, LOCKDOWN_E_ACTIVATION_FAILED if the activation failed, LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the activation_record is invalid |
lockdownd_client_free(IntPtr)
Closes the lockdownd client session if one is running and frees up the lockdownd_client struct.
Declaration
public static LockdownError lockdownd_client_free(IntPtr client)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | client | The lockdown client |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
lockdownd_client_new(iDeviceHandle, out LockdownClientHandle, String)
Creates a new lockdownd client for the device.
Declaration
public static LockdownError lockdownd_client_new(iDeviceHandle device, out LockdownClientHandle client, string label)
Parameters
Type | Name | Description |
---|---|---|
iDeviceHandle | device | The device to create a lockdownd client for |
LockdownClientHandle | client | The pointer to the location of the new lockdownd_client |
System.String | label | The label to use for communication. Usually the program name. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
Remarks
This function does not pair with the device or start a session. This has to be done manually by the caller after the client is created. The device disconnects automatically if the lockdown connection idles for more than 10 seconds. Make sure to call lockdownd_client_free() as soon as the connection is no longer needed.
lockdownd_client_new_with_handshake(iDeviceHandle, out LockdownClientHandle, String)
Creates a new lockdownd client for the device and starts initial handshake. The handshake consists out of query_type, validate_pair, pair and start_session calls. It uses the internal pairing record management.
Declaration
public static LockdownError lockdownd_client_new_with_handshake(iDeviceHandle device, out LockdownClientHandle client, string label)
Parameters
Type | Name | Description |
---|---|---|
iDeviceHandle | device | The device to create a lockdownd client for |
LockdownClientHandle | client | The pointer to the location of the new lockdownd_client |
System.String | label | The label to use for communication. Usually the program name. Pass NULL to disable sending the label in requests to lockdownd. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_INVALID_CONF if configuration data is wrong |
Remarks
The device disconnects automatically if the lockdown connection idles for more than 10 seconds. Make sure to call lockdownd_client_free() as soon as the connection is no longer needed.
lockdownd_client_set_label(LockdownClientHandle, String)
Sets the label to send for requests to lockdownd.
Declaration
public static void lockdownd_client_set_label(LockdownClientHandle client, string label)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
System.String | label | The label to set or NULL to disable sending a label |
lockdownd_data_classes_free(IntPtr)
Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes()
Declaration
public static LockdownError lockdownd_data_classes_free(IntPtr classes)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | classes | An array of class names to free. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success |
lockdownd_deactivate(LockdownClientHandle)
Deactivates the device, returning it to the locked “Activate with iTunes†screen.
Declaration
public static LockdownError lockdownd_deactivate(LockdownClientHandle client)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken |
lockdownd_enter_recovery(LockdownClientHandle)
Tells the device to immediately enter recovery mode.
Declaration
public static LockdownError lockdownd_enter_recovery(LockdownClientHandle client)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
lockdownd_get_device_name(LockdownClientHandle, out IntPtr)
Retrieves the name of the device from lockdownd set by the user.
Declaration
public static LockdownError lockdownd_get_device_name(LockdownClientHandle client, out IntPtr deviceName)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | An initialized lockdownd client. |
System.IntPtr | deviceName |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success |
lockdownd_get_device_name(LockdownClientHandle, out String)
Declaration
public static LockdownError lockdownd_get_device_name(LockdownClientHandle client, out string deviceName)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | |
System.String | deviceName |
Returns
Type | Description |
---|---|
LockdownError |
lockdownd_get_device_udid(LockdownClientHandle, out IntPtr)
Returns the unique id of the device from lockdownd.
Declaration
public static LockdownError lockdownd_get_device_udid(LockdownClientHandle client, out IntPtr udid)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | An initialized lockdownd client. |
System.IntPtr | udid | Holds the unique id of the device. The caller is responsible for freeing the memory. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success |
lockdownd_get_device_udid(LockdownClientHandle, out String)
Declaration
public static LockdownError lockdownd_get_device_udid(LockdownClientHandle client, out string udid)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | |
System.String | udid |
Returns
Type | Description |
---|---|
LockdownError |
lockdownd_get_sync_data_classes(LockdownClientHandle, out ReadOnlyCollection<String>, ref Int32)
Declaration
public static LockdownError lockdownd_get_sync_data_classes(LockdownClientHandle client, out ReadOnlyCollection<string> classes, ref int count)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | |
System.Collections.ObjectModel.ReadOnlyCollection<System.String> | classes | |
System.Int32 | count |
Returns
Type | Description |
---|---|
LockdownError |
lockdownd_get_sync_data_classes(LockdownClientHandle, out IntPtr, ref Int32)
Calculates and returns the data classes the device supports from lockdownd.
Declaration
public static LockdownError lockdownd_get_sync_data_classes(LockdownClientHandle client, out IntPtr classes, ref int count)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | An initialized lockdownd client. |
System.IntPtr | classes | A pointer to store an array of class names. The caller is responsible for freeing the memory which can be done using mobilesync_data_classes_free(). |
System.Int32 | count | The number of items in the classes array. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken |
lockdownd_get_value(LockdownClientHandle, String, String, out PlistHandle)
Retrieves a preferences plist using an optional domain and/or key name.
Declaration
public static LockdownError lockdownd_get_value(LockdownClientHandle client, string domain, string key, out PlistHandle value)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | An initialized lockdownd client. |
System.String | domain | The domain to query on or NULL for global domain |
System.String | key | The key name to request or NULL to query for all keys |
PlistHandle | value | A plist node representing the result value node |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
lockdownd_goodbye(LockdownClientHandle)
Sends the Goodbye request to lockdownd signaling the end of communication.
Declaration
public static LockdownError lockdownd_goodbye(LockdownClientHandle client)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the request |
lockdownd_pair(LockdownClientHandle, LockdownPairRecordHandle)
Pairs the device using the supplied pair record.
Declaration
public static LockdownError lockdownd_pair(LockdownClientHandle client, LockdownPairRecordHandle pairRecord)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
LockdownPairRecordHandle | pairRecord |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, LOCKDOWN_E_PAIRING_FAILED if the pairing failed, LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id |
lockdownd_pair_with_options(LockdownClientHandle, LockdownPairRecordHandle, PlistHandle, out PlistHandle)
Pairs the device using the supplied pair record and passing the given options.
Declaration
public static LockdownError lockdownd_pair_with_options(LockdownClientHandle client, LockdownPairRecordHandle pairRecord, PlistHandle options, out PlistHandle response)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
LockdownPairRecordHandle | pairRecord | |
PlistHandle | options | The pairing options to pass. Can be NULL for no options. |
PlistHandle | response | If non-NULL a pointer to lockdownd's response dictionary is returned. The caller is responsible to free the response dictionary with plist_free(). |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, LOCKDOWN_E_PAIRING_FAILED if the pairing failed, LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id |
lockdownd_query_type(LockdownClientHandle, out IntPtr)
Query the type of the service daemon. Depending on whether the device is queried in normal mode or restore mode, different types will be returned.
Declaration
public static LockdownError lockdownd_query_type(LockdownClientHandle client, out IntPtr type)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdownd client |
System.IntPtr | type | The type returned by the service daemon. Pass NULL to ignore. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
lockdownd_query_type(LockdownClientHandle, out String)
Declaration
public static LockdownError lockdownd_query_type(LockdownClientHandle client, out string type)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | |
System.String | type |
Returns
Type | Description |
---|---|
LockdownError |
lockdownd_receive(LockdownClientHandle, out PlistHandle)
Receives a plist from lockdownd.
Declaration
public static LockdownError lockdownd_receive(LockdownClientHandle client, out PlistHandle plist)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdownd client |
PlistHandle | plist | The plist to store the received data |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or plist is NULL |
lockdownd_remove_value(LockdownClientHandle, String, String)
Removes a preference node by domain and/or key name.
Declaration
public static LockdownError lockdownd_remove_value(LockdownClientHandle client, string domain, string key)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | An initialized lockdownd client. |
System.String | domain | The domain to query on or NULL for global domain |
System.String | key | The key name to remove or NULL remove all keys for the current domain |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
Remarks
: Use with caution as this could remove vital information on the device
lockdownd_send(LockdownClientHandle, PlistHandle)
Sends a plist to lockdownd.
Declaration
public static LockdownError lockdownd_send(LockdownClientHandle client, PlistHandle plist)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdownd client |
PlistHandle | plist | The plist to send |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or plist is NULL |
Remarks
This function is low-level and should only be used if you need to send a new type of message.
lockdownd_service_descriptor_free(IntPtr)
Frees memory of a service descriptor as returned by lockdownd_start_service()
Declaration
public static LockdownError lockdownd_service_descriptor_free(IntPtr service)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | service | A service descriptor instance to free. |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success |
lockdownd_set_value(LockdownClientHandle, String, String, PlistHandle)
Sets a preferences value using a plist and optional by domain and/or key name.
Declaration
public static LockdownError lockdownd_set_value(LockdownClientHandle client, string domain, string key, PlistHandle value)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | an initialized lockdownd client. |
System.String | domain | the domain to query on or NULL for global domain |
System.String | key | the key name to set the value or NULL to set a value dict plist |
PlistHandle | value | a plist node of any node type representing the value to set |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or value is NULL |
lockdownd_start_service(LockdownClientHandle, String, out LockdownServiceDescriptorHandle)
Requests to start a service and retrieve it's port on success.
Declaration
public static LockdownError lockdownd_start_service(LockdownClientHandle client, string identifier, out LockdownServiceDescriptorHandle service)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdownd client |
System.String | identifier | The identifier of the service to start |
LockdownServiceDescriptorHandle | service | The service descriptor on success or NULL on failure |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if a parameter is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not be started by the device |
lockdownd_start_service_with_escrow_bag(LockdownClientHandle, String, out LockdownServiceDescriptorHandle)
Requests to start a service and retrieve it's port on success. Sends the escrow bag from the device's pair record.
Declaration
public static LockdownError lockdownd_start_service_with_escrow_bag(LockdownClientHandle client, string identifier, out LockdownServiceDescriptorHandle service)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdownd client |
System.String | identifier | The identifier of the service to start |
LockdownServiceDescriptorHandle | service | The service descriptor on success or NULL on failure |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if a parameter is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because started by the device, LOCKDOWN_E_INVALID_CONF if the host id or escrow bag are missing from the device record. |
lockdownd_start_session(LockdownClientHandle, String, out IntPtr, ref Int32)
Opens a session with lockdownd and switches to SSL mode if device wants it.
Declaration
public static LockdownError lockdownd_start_session(LockdownClientHandle client, string hostId, out IntPtr sessionId, ref int sslEnabled)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdownd client |
System.String | hostId | |
System.IntPtr | sessionId | |
System.Int32 | sslEnabled |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when a client or host_id is NULL, LOCKDOWN_E_PLIST_ERROR if the response plist had errors, LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID, LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed |
lockdownd_start_session(LockdownClientHandle, String, out String, ref Int32)
Declaration
public static LockdownError lockdownd_start_session(LockdownClientHandle client, string hostId, out string sessionId, ref int sslEnabled)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | |
System.String | hostId | |
System.String | sessionId | |
System.Int32 | sslEnabled |
Returns
Type | Description |
---|---|
LockdownError |
lockdownd_stop_session(LockdownClientHandle, String)
Closes the lockdownd session by sending the StopSession request.
Declaration
public static LockdownError lockdownd_stop_session(LockdownClientHandle client, string sessionId)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
System.String | sessionId |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL |
lockdownd_unpair(LockdownClientHandle, LockdownPairRecordHandle)
Unpairs the device with the given HostID and removes the pairing records from the device and host if the internal pairing record management is used.
Declaration
public static LockdownError lockdownd_unpair(LockdownClientHandle client, LockdownPairRecordHandle pairRecord)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
LockdownPairRecordHandle | pairRecord |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, LOCKDOWN_E_PAIRING_FAILED if the pairing failed, LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id |
lockdownd_validate_pair(LockdownClientHandle, LockdownPairRecordHandle)
Validates if the device is paired with the given HostID. If successful the specified host will become trusted host of the device indicated by the lockdownd preference named TrustedHostAttached. Otherwise the host must be paired using lockdownd_pair() first.
Declaration
public static LockdownError lockdownd_validate_pair(LockdownClientHandle client, LockdownPairRecordHandle pairRecord)
Parameters
Type | Name | Description |
---|---|---|
LockdownClientHandle | client | The lockdown client |
LockdownPairRecordHandle | pairRecord |
Returns
Type | Description |
---|---|
LockdownError | LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, LOCKDOWN_E_PAIRING_FAILED if the pairing failed, LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id |