Exemplo n.º 1
0
        public static Dictionary <string, object> ReadPlistDictFromNode(PlistHandle node, ICollection <string> keys = null)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            IPlistApi plist = LibiMobileDevice.Instance.Plist;

            if (plist.plist_get_node_type(node) != PlistType.Dict)
            {
                return(dictionary);
            }
            PlistHandle         val  = null;
            PlistDictIterHandle iter = null;

            plist.plist_dict_new_iter(node, out iter);
            string key;

            plist.plist_dict_next_item(node, iter, out key, out val);
            while (val != null && !val.IsInvalid)
            {
                if (keys == null || keys.Contains(key))
                {
                    dictionary[key] = ReadValueFromNode(val);
                }
                val.Close();
                plist.plist_dict_next_item(node, iter, out key, out val);
                ReadValueFromNode(val);
            }
            return(dictionary);
        }
 public LibiMobileDevice()
 {
     this.usbmuxd             = new UsbmuxdApi(this);
     this.plist               = new PlistApi(this);
     this.idevice             = new iDeviceApi(this);
     this.lockdown            = new LockdownApi(this);
     this.afc                 = new AfcApi(this);
     this.debugServer         = new DebugServerApi(this);
     this.diagnosticsRelay    = new DiagnosticsRelayApi(this);
     this.fileRelay           = new FileRelayApi(this);
     this.heartBeat           = new HeartBeatApi(this);
     this.houseArrest         = new HouseArrestApi(this);
     this.installationProxy   = new InstallationProxyApi(this);
     this.misagent            = new MisagentApi(this);
     this.mobileactivation    = new MobileactivationApi(this);
     this.mobileBackup        = new MobileBackupApi(this);
     this.mobileBackup2       = new MobileBackup2Api(this);
     this.mobileSync          = new MobileSyncApi(this);
     this.mobileImageMounter  = new MobileImageMounterApi(this);
     this.notificationProxy   = new NotificationProxyApi(this);
     this.pinvoke             = new PinvokeApi(this);
     this.propertyListService = new PropertyListServiceApi(this);
     this.restore             = new RestoreApi(this);
     this.springBoardServices = new SpringBoardServicesApi(this);
     this.screenshotr         = new ScreenshotrApi(this);
     this.service             = new ServiceApi(this);
     this.syslogRelay         = new SyslogRelayApi(this);
     this.webInspector        = new WebInspectorApi(this);
 }
Exemplo n.º 3
0
        public static List <DeviceInformation> GetDevices()
        {
            IiDeviceApi  iDevice  = LibiMobileDevice.Instance.iDevice;
            ILockdownApi lockdown = LibiMobileDevice.Instance.Lockdown;
            IPlistApi    plist    = LibiMobileDevice.Instance.Plist;
            int          count    = 0;
            ReadOnlyCollection <string> devices;

            if (iDevice.idevice_get_device_list(out devices, ref count) != 0)
            {
                return(new List <DeviceInformation>());
            }
            iDeviceHandle            device = null;
            LockdownClientHandle     client = null;
            PlistHandle              value  = null;
            List <DeviceInformation> list   = new List <DeviceInformation>();

            foreach (string item in devices.Distinct())
            {
                try
                {
                    string deviceName;
                    if (iDevice.idevice_new(out device, item) == iDeviceError.Success && lockdown.lockdownd_client_new_with_handshake(device, out client, "iFakeLocation") == LockdownError.Success && lockdown.lockdownd_get_device_name(client, out deviceName) == LockdownError.Success)
                    {
                        DeviceInformation deviceInformation = new DeviceInformation(deviceName, item);
                        if (lockdown.lockdownd_get_value(client, null, null, out value) == LockdownError.Success && plist.plist_get_node_type(value) == PlistType.Dict)
                        {
                            deviceInformation.ReadProperties(value);
                            if (!deviceInformation.Properties.ContainsKey("HostAttached") || (bool)deviceInformation.Properties["HostAttached"])
                            {
                                list.Add(deviceInformation);
                            }
                        }
                    }
                }
                finally
                {
                    if (value != null)
                    {
                        value.Close();
                    }
                    if (client != null)
                    {
                        client.Close();
                    }
                    if (device != null)
                    {
                        device.Close();
                    }
                }
            }
            return(list);
        }
Exemplo n.º 4
0
        private unsafe static object ReadValueFromNode(PlistHandle node)
        {
            if (node == null || node.IsInvalid)
            {
                return(null);
            }
            IPlistApi plist = LibiMobileDevice.Instance.Plist;

            switch (plist.plist_get_node_type(node))
            {
            case PlistType.Boolean:
            {
                char val2 = '\0';
                plist.plist_get_bool_val(node, ref val2);
                return(val2 != '\0');
            }

            case PlistType.Uint:
            {
                ulong val6 = 0uL;
                plist.plist_get_uint_val(node, ref val6);
                return(val6);
            }

            case PlistType.Real:
            {
                double val5 = 0.0;
                plist.plist_get_real_val(node, ref val5);
                return(val5);
            }

            case PlistType.String:
            {
                string val4;
                plist.plist_get_string_val(node, out val4);
                return(val4);
            }

            case PlistType.Key:
            {
                string val3;
                plist.plist_get_key_val(node, out val3);
                return(val3);
            }

            case PlistType.Data:
            {
                ulong  length = 0uL;
                string val;
                plist.plist_get_data_val(node, out val, ref length);
                byte[] array = new byte[length];
                fixed(char *value = &(val != null ? ref val.GetPinnableReference() : ref *(char *)null))
                {
                    Marshal.Copy((IntPtr)(void *)value, array, 0, array.Length);
                }

                return(array);
            }

            case PlistType.Date:
            {
                int sec  = 0;
                int usec = 0;
                plist.plist_get_date_val(node, ref sec, ref usec);
                return(new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(sec).ToLocalTime());
            }

            case PlistType.Dict:
                return(ReadPlistDictFromNode(node));

            default:
                return(null);
            }
        }