1

I am trying to get data from attached devices through C#. Specifically I need to get the serial number from iOS devices.

I see the data is available to me from the attached photo, but I am looking for a way to get this information in C#.

Does anyone know how to access this information in C#?

Properties from attached iOS device

piet.t
  • 11,718
  • 21
  • 43
  • 52
  • 1
    @stijn looks like the question was edited to clarify. in any case - https://github.com/0xFireball/MK.MobileDevice is all I could find, and maybe in the source code is the direct answer. – solenoid Sep 05 '17 at 23:49

2 Answers2

1

imobiledevice-net provides a C# API you can use to interact with iOS devices attached to a Windows, Linux or macOS machine.

There's sample code in the README which helps you list the UDIDs of all devices connected to your PC:

ReadOnlyCollection<string> udids;
int count = 0;

var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;

var ret = idevice.idevice_get_device_list(out udids, ref count);

if (ret == iDeviceError.NoDevice)
{
    // Not actually an error in our case
    return;
}

ret.ThrowOnError();

// Get the device name
foreach (var udid in udids)
{
    Console.WriteLine(udid);
}

Let me know if this helps!

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

Placing the code below after lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError(); you will be able to access values like the serial number or iOS version. This is only a crude example:

    string t1;
    string t2;

    PlistHandle tested1;
    PlistHandle tested2;

    //Find serial number in plist
    lockdown.lockdownd_get_value(lockdownHandle, null, "SerialNumber", out 
    tested1);

    //Find IOS version in plist
    lockdown.lockdownd_get_value(lockdownHandle, null, "ProductVersion", out 
     tested2);

    //Get string values from plist
    tested1.Api.Plist.plist_get_string_val(tested1, out t1);
    tested2.Api.Plist.plist_get_string_val(tested2, out t2);

    //Place data in textboxes
    serialTXT.Text = t1.Trim();
    verTXT.Text = t2.Trim();

You will need to have NativeLibraries.Load(); in your code first and pull in any necessary iMobileDevice using references.