コード例 #1
0
        public unsafe Dictionary <string, string> GetFileInfo(string path)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            void *dict = null;

            if ((MobileDevice.AFCFileInfoOpen(this.hAFC, path, ref dict) == 0) && (dict != null))
            {
                void *voidPtr2;
                void *voidPtr3;
                while (((MobileDevice.AFCKeyValueRead(dict, out voidPtr2, out voidPtr3) == 0) && (voidPtr2 != null)) && (voidPtr3 != null))
                {
                    string key  = Marshal.PtrToStringAnsi(new IntPtr(voidPtr2));
                    string str2 = Marshal.PtrToStringAnsi(new IntPtr(voidPtr3));
                    dictionary.Add(key, str2);
                }
                MobileDevice.AFCKeyValueClose(dict);
            }
            return(dictionary);
        }
コード例 #2
0
        private unsafe void doConstruction()
        {
            void *voidPtr;

            this.dnc  = new ITMDDeviceNotificationCallback(this.NotifyCallback);
            this.drn1 = new DeviceRestoreNotificationCallback(this.DfuConnectCallback);
            this.drn2 = new DeviceRestoreNotificationCallback(this.RecoveryConnectCallback);
            this.drn3 = new DeviceRestoreNotificationCallback(this.DfuDisconnectCallback);
            this.drn4 = new DeviceRestoreNotificationCallback(this.RecoveryDisconnectCallback);
            int num = MobileDevice.AMDeviceNotificationSubscribe(this.dnc, 0, 0, 0, out voidPtr);

            if (num != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + num);
            }
            num = MobileDevice.AMRestoreRegisterForDeviceNotifications(this.drn1, this.drn2, this.drn3, this.drn4, 0, null);
            if (num != 0)
            {
                throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + num);
            }
            this.current_directory = "/";
        }
コード例 #3
0
        private unsafe bool ConnectToPhone()
        {
            if (MobileDevice.AMDeviceConnect(this.iPhoneHandle) == 1)
            {
                throw new Exception("Phone in recovery mode, support not yet implemented");
            }
            if (MobileDevice.AMDeviceIsPaired(this.iPhoneHandle) == 0)
            {
                return(false);
            }

            if (MobileDevice.AMDeviceValidatePairing(this.iPhoneHandle) != 0)
            {
                return(false);
            }
            if (MobileDevice.AMDeviceStartSession(this.iPhoneHandle) == 1)
            {
                return(false);
            }

            if (0 != MobileDevice.AMDeviceStartService(this.iPhoneHandle, MobileDevice.__CFStringMakeConstantString(MobileDevice.StringToCString("com.apple.afc2")), ref this.hService, null))
            {
                if (0 != MobileDevice.AMDeviceStartService(this.iPhoneHandle, MobileDevice.__CFStringMakeConstantString(MobileDevice.StringToCString("com.apple.afc")), ref this.hService, null))
                {
                    return(false);
                }
            }
            else
            {
                this.wasAFC2 = true;
            }
            if (MobileDevice.AFCConnectionOpen(this.hService, 0, ref this.hAFC) != 0)
            {
                return(false);
            }
            this.connected = true;
            return(true);
        }
コード例 #4
0
 public unsafe void EnterDFU()
 {
     MobileDevice.AMRestoreModeDeviceReboot(this.iPhoneHandle);
 }
コード例 #5
0
        /// <summary>
        /// Returns the size and type of the specified file or directory.
        /// </summary>
        /// <param name="path">The file or directory for which to retrieve information.</param>
        /// <param name="size">Returns the size of the specified file or directory</param>
        /// <param name="fileType">Returns the size of the specified file or directory</param>
        public unsafe void GetFileInfoDetails(string path, out int size, out FileTypes fileType)
        {
            IntPtr data;
            IntPtr current_data;
            uint   data_size;
            uint   offset;
            string name;
            string value;
            int    ret;

            data = IntPtr.Zero;

            size     = 0;
            fileType = FileTypes.Unknown;
            ret      = MobileDevice.AFCGetFileInfo(new IntPtr(hAFC), path, ref data, out data_size);
            if (ret != 0)
            {
                return;
            }

            offset = 0;
            while (offset < data_size)
            {
                current_data = new IntPtr(data.ToInt32() + offset);
                name         = Marshal.PtrToStringAnsi(current_data);
                offset      += (uint)name.Length + 1;

                current_data = new IntPtr(data.ToInt32() + offset);
                value        = Marshal.PtrToStringAnsi(current_data);
                offset      += (uint)value.Length + 1;
                switch (name)
                {
                case "st_size": size = Int32.Parse(value); break;

                case "st_blocks": break;

                case "st_ifmt":
                    //S_IFBLK  File (#rtl.baseunix.stat record) mode: Block device
                    //S_IFCHR  File (#rtl.baseunix.stat record) mode: Character device
                    //S_IFDIR  File (#rtl.baseunix.stat record) mode: Directory
                    //S_IFIFO  File (#rtl.baseunix.stat record) mode: FIFO
                    //S_IFLNK  File (#rtl.baseunix.stat record) mode: Link
                    //S_IFMT   File (#rtl.baseunix.stat record) mode: File type bit mask
                    //S_IFREG  File (#rtl.baseunix.stat record) mode: Regular file
                    //S_IFSOCK File (#rtl.baseunix.stat record) mode: Socket
                    switch (value)
                    {
                    case "S_IFDIR":
                        fileType = FileTypes.Folder;
                        break;

                    case "S_IFREG":
                        fileType = FileTypes.File;
                        break;

                    case "S_IFBLK":
                        fileType = FileTypes.BlockDevice;
                        break;

                    case "S_IFCHR":
                        fileType = FileTypes.CharDevice;
                        break;

                    case "S_IFIFO":
                        fileType = FileTypes.FIFO;
                        break;

                    case "S_IFLNK":
                        fileType = FileTypes.Link;
                        break;

                    case "S_IFMT":
                        fileType = FileTypes.FileMask;
                        break;

                    case "S_IFSOCK":
                        fileType = FileTypes.Socket;
                        break;
                    }
                    break;
                }
            }
        }
コード例 #6
0
 public unsafe void ExitRecovery()
 {
     MobileDevice.AMRecoveryModeDeviceSetAutoBoot(ref this.RecoveryDevice, 1, 1, 1, 1);
     MobileDevice.AMRecoveryModeDeviceReboot(ref this.RecoveryDevice);
 }
コード例 #7
0
 public unsafe void EnterRecovery()
 {
     MobileDevice.AMDeviceEnterRecovery(this.iPhoneHandle);
 }
コード例 #8
0
 public unsafe void sendCommandToDevice(string Command)
 {
     MobileDevice.sendCommandToDevice(this.iPhoneHandle, MobileDevice.__CFStringMakeConstantString(MobileDevice.StringToCFString(Command)), 0);
 }
コード例 #9
0
 public unsafe bool Rename(string sourceName, string destName)
 {
     return(MobileDevice.AFCRenamePath(this.hAFC, this.FullPath(this.current_directory, sourceName), this.FullPath(this.current_directory, destName)) == 0);
 }
コード例 #10
0
 public unsafe string RequestProperty(string domain, string key)
 {
     return(MobileDevice.AMDeviceCopyValue(iPhoneHandle, domain, key));
 }