Exemplo n.º 1
0
 public static void ThrowOnError(this LockdownError value, string message)
 {
     if ((value != LockdownError.Success))
     {
         throw new LockdownException(value, message);
     }
 }
        public static LockdownError lockdownd_get_sync_data_classes(LockdownClientHandle client, out System.Collections.ObjectModel.ReadOnlyCollection <string> classes, ref int count)
        {
            System.Runtime.InteropServices.ICustomMarshaler classesMarshaler = LockdownMarshaler.GetInstance(null);
            System.IntPtr classesNative = System.IntPtr.Zero;
            LockdownError returnValue   = LockdownNativeMethods.lockdownd_get_sync_data_classes(client, out classesNative, ref count);

            classes = ((System.Collections.ObjectModel.ReadOnlyCollection <string>)classesMarshaler.MarshalNativeToManaged(classesNative));
            classesMarshaler.CleanUpNativeData(classesNative);
            return(returnValue);
        }
        public static LockdownError lockdownd_get_device_udid(LockdownClientHandle client, out string udid)
        {
            System.Runtime.InteropServices.ICustomMarshaler udidMarshaler = NativeStringMarshaler.GetInstance(null);
            System.IntPtr udidNative  = System.IntPtr.Zero;
            LockdownError returnValue = LockdownNativeMethods.lockdownd_get_device_udid(client, out udidNative);

            udid = ((string)udidMarshaler.MarshalNativeToManaged(udidNative));
            udidMarshaler.CleanUpNativeData(udidNative);
            return(returnValue);
        }
        public static LockdownError lockdownd_get_device_name(LockdownClientHandle client, out string deviceName)
        {
            System.Runtime.InteropServices.ICustomMarshaler deviceNameMarshaler = NativeStringMarshaler.GetInstance(null);
            System.IntPtr deviceNameNative = System.IntPtr.Zero;
            LockdownError returnValue      = LockdownNativeMethods.lockdownd_get_device_name(client, out deviceNameNative);

            deviceName = ((string)deviceNameMarshaler.MarshalNativeToManaged(deviceNameNative));
            deviceNameMarshaler.CleanUpNativeData(deviceNameNative);
            return(returnValue);
        }
        public static LockdownError lockdownd_query_type(LockdownClientHandle client, out string type)
        {
            System.Runtime.InteropServices.ICustomMarshaler typeMarshaler = NativeStringMarshaler.GetInstance(null);
            System.IntPtr typeNative  = System.IntPtr.Zero;
            LockdownError returnValue = LockdownNativeMethods.lockdownd_query_type(client, out typeNative);

            type = ((string)typeMarshaler.MarshalNativeToManaged(typeNative));
            typeMarshaler.CleanUpNativeData(typeNative);
            return(returnValue);
        }
        public static LockdownError lockdownd_start_session(LockdownClientHandle client, string hostId, out string sessionId, ref int sslEnabled)
        {
            System.Runtime.InteropServices.ICustomMarshaler sessionIdMarshaler = NativeStringMarshaler.GetInstance(null);
            System.IntPtr sessionIdNative = System.IntPtr.Zero;
            LockdownError returnValue     = LockdownNativeMethods.lockdownd_start_session(client, hostId, out sessionIdNative, ref sslEnabled);

            sessionId = ((string)sessionIdMarshaler.MarshalNativeToManaged(sessionIdNative));
            sessionIdMarshaler.CleanUpNativeData(sessionIdNative);
            return(returnValue);
        }
Exemplo n.º 7
0
        // Token: 0x06000024 RID: 36 RVA: 0x00002AD8 File Offset: 0x00000CD8
        public void ClearLocation()
        {
            bool flag = this.Devices.Count == 0;

            if (flag)
            {
                this.PrintMessage("修改失败! 未发现任何设备.");
            }
            else
            {
                this.iDevice.idevice_set_debug_level(1);
                this.PrintMessage("发起还原位置.");
                this.Devices.ForEach(delegate(DeviceModel itm)
                {
                    this.PrintMessage("开始还原设备 " + itm.Name + " " + itm.Version);
                    uint num = 0u;
                    iDeviceHandle device;
                    this.iDevice.idevice_new(out device, itm.UDID);
                    LockdownClientHandle client;
                    LockdownError lockdowndError = this.lockdown.lockdownd_client_new_with_handshake(device, out client, "com.alpha.jailout");
                    LockdownServiceDescriptorHandle service2;
                    lockdowndError = this.lockdown.lockdownd_start_service(client, "com.apple.dt.simulatelocation", out service2);
                    ServiceClientHandle client2;
                    ServiceError se = this.service.service_client_new(device, service2, out client2);
                    se = this.service.service_send(client2, new byte[4], 4u, ref num);
                    se = this.service.service_send(client2, new byte[]
                    {
                        0,
                        0,
                        0,
                        1
                    }, 4u, ref num);
                    device.Dispose();
                    client.Dispose();
                    this.PrintMessage(string.Concat(new string[]
                    {
                        "设备 ",
                        itm.Name,
                        " ",
                        itm.Version,
                        " 还原成功."
                    }));
                });
            }
        }
Exemplo n.º 8
0
        public static LockdownError GetProperties(IntPtr lockdownClient, out XDocument result)
        {
            IntPtr        resultPlist;
            LockdownError returnCode = lockdownd_get_value(lockdownClient, null, null, out resultPlist);

            result = new XDocument();
            if (returnCode != LockdownError.LOCKDOWN_E_SUCCESS)
            {
                return(returnCode);
            }

            else if (resultPlist == IntPtr.Zero)
            {
                return(LockdownError.LOCKDOWN_E_UNKNOWN_ERROR);
            }

            result = LibiMobileDevice.PlistToXml(resultPlist);
            return(returnCode);
        }
Exemplo n.º 9
0
        public static LockdownError Start(IntPtr device, out IntPtr client, out IntPtr service)
        {
            LockdownError returnCode = lockdownd_client_new_with_handshake(device, out client, "MK iToolkit");

            service = IntPtr.Zero;
            if (returnCode != LockdownError.LOCKDOWN_E_SUCCESS)
            {
                return(returnCode);
            }

            else if (client == IntPtr.Zero)
            {
                return(LockdownError.LOCKDOWN_E_UNKNOWN_ERROR);
            }

            returnCode = lockdownd_start_service(client, serviceIdentifier, out service);
            if (service == IntPtr.Zero)
            {
                return(LockdownError.LOCKDOWN_E_UNKNOWN_ERROR);
            }

            return(returnCode);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LockdownException"/> class with a specified error code and error message.
 /// </summary>
 /// <param name="error">
 /// The error code of the error that occurred.
 /// </param>
 /// <param name="message">
 /// A message which describes the error.
 /// </param>
 public LockdownException(LockdownError error, string message) :
     base(string.Format("An Lockdown error occurred. {1}. The error code was {0}", error, message))
 {
     this.errorCode = error;
 }
Exemplo n.º 11
0
 public static bool IsError(this LockdownError value)
 {
     return(value != LockdownError.Success);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Gets a readable error string for a given lockdown error code.
 /// </summary>
 /// <param name="err">
 /// A lockdownd error code
 /// </param>
 public virtual System.IntPtr lockdownd_strerror(LockdownError err)
 {
     return(LockdownNativeMethods.lockdownd_strerror(err));
 }
Exemplo n.º 13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ReadOnlyCollection <string> udids;
            int count = 0;

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

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

            if (ret == iDeviceError.NoDevice)
            {
                // Not actually an error in our case
                Console.WriteLine("No devices found");
                return;
            }

            ret.ThrowOnError();

            // Get the device name
            foreach (var udid in udids)
            {
                iDeviceHandle deviceHandle;
                idevice.idevice_new(out deviceHandle, udid).ThrowOnError();

                LockdownClientHandle lockdownHandle;
                lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();

                string deviceName;
                lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();


                Console.WriteLine($"{deviceName} ({udid})");

                {
                    LockdownServiceDescriptorHandle scrSvc;
                    LockdownError lde = lockdown.lockdownd_start_service(lockdownHandle, "com.apple.mobile.screenshotr", out scrSvc);
                    if (lde == LockdownError.Success)
                    {
                        ScreenshotrClientHandle client;
                        ScreenshotrError        err = screenshotr.screenshotr_client_new(deviceHandle, scrSvc, out client);
                        IntPtr           imgData    = new IntPtr();
                        ulong            imgSize    = 0;
                        ScreenshotrError result     = screenshotr.screenshotr_take_screenshot(client, ref imgData, ref imgSize);
                        if (result == ScreenshotrError.Success)
                        {
                            Console.WriteLine("截图成功!!!!");
                            String filename = GetScreenPicFileName();
                            Console.WriteLine($"filename:{filename}");

                            System.IO.FileStream file = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                            int  written;
                            bool writeResult = WriteFile(file.Handle, imgData, (int)imgSize, out written, IntPtr.Zero);
                            file.Close();
                        }
                    }
                    else
                    {
                        Console.WriteLine("截图失败!!!");
                    }
                }

                deviceHandle.Dispose();
                lockdownHandle.Dispose();
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LockdownException"/> class, using a
 /// <see cref="LockdownError"/> code.
 /// </summary>
 /// <param name="error">
 /// A <see cref="LockdownError"/> code which describes the error.
 /// </param>
 public LockdownException(LockdownError error)
     : this($"An unexpected lockdown error occurred: {error}")
 {
     this.HResult = (int)error;
     this.Error   = error;
 }
 public static extern System.IntPtr lockdownd_strerror(LockdownError err);