/// <summary> /// Creates a new iPhone object. If an iPhone is connected to the computer, a connection will automatically be opened. /// </summary> public iPhone() { AMDeviceNotification notification; int ret = 0; dnc = new DeviceNotificationCallback(NotifyCallback); drn1 = new DeviceRestoreNotificationCallback(DfuConnectCallback); drn2 = new DeviceRestoreNotificationCallback(RecoveryConnectCallback); drn3 = new DeviceRestoreNotificationCallback(DfuDisconnectCallback); drn4 = new DeviceRestoreNotificationCallback(RecoveryDisconnectCallback); notification = new AMDeviceNotification(); ret = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, ref notification); if (ret != 0) { throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret); } ret = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, IntPtr.Zero); if (ret != 0) { throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + ret); } current_directory = "/"; }
private unsafe void doConstruction() { void *voidPtr; this.dnc = new DeviceNotificationCallback(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 = "/"; }
/// <summary> /// Initializes a new iPhone object. /// </summary> unsafe private void doConstruction() { dnc = new DeviceNotificationCallback(NotifyCallback); drn1 = new DeviceRestoreNotificationCallback(DfuConnectCallback); drn2 = new DeviceRestoreNotificationCallback(RecoveryConnectCallback); drn3 = new DeviceRestoreNotificationCallback(DfuDisconnectCallback); drn4 = new DeviceRestoreNotificationCallback(RecoveryDisconnectCallback); void *notification; int ret = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, out notification); if (ret != 0) { throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret); } ret = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, null); if (ret != 0) { throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + ret); } current_directory = "/"; }