0

Using libimobiledevice I can get the ECID of a connected device from the command line by running

$ ideviceinfo -k UniqueChipID

Is there a way to do this using the C API?

airsquared
  • 571
  • 1
  • 8
  • 25
  • Why not look at how [ideviceinfo itself](https://github.com/libimobiledevice/libimobiledevice/blob/master/tools/ideviceinfo.c) does it? It's only two hundred lines of C, most of it command-line argument parsing; and it uses the C API. – Nominal Animal Jan 08 '19 at 02:53

1 Answers1

1

You're looking for lockdownd_get_value, which is part of the libimobiledevice C api. The declaration is:

/**
 * Retrieves a preferences plist using an optional domain and/or key name.
 *
 * @param client An initialized lockdownd client.
 * @param domain The domain to query on or NULL for global domain
 * @param key The key name to request or NULL to query for all keys
 * @param value A plist node representing the result value node
 *
 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
 */
LIBIMOBILEDEVICE_API_MSC lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value); 

You can create a lockdown_client_t using a lockdownd_client_new. Look at the ideviceinfo source code for more information on how to set up a lockdown client.

The domain and key parameters map to what you've provided on the command line. You didn't specify a domain, so set that to NULL. key should be the value of what you passed as the -k argument, hence UniqueChipID.

The output will be a plist_t. You can use the libplist API to convert this to XML or a string.

Frederik Carlier
  • 4,606
  • 1
  • 25
  • 36