public OSXHIDInterface()
        {
            __drivers = new List <IDriver>();

            __ports = new string[20];



            HandleHIDDeviceAdded   = HidDeviceAdded;
            HandleHIDDeviceRemoved = HidDeviceRemoved;
            HandleDeviceRemoved    = DeviceRemoved;

            CFDictionaryRef[] dictionaries;



            dictionaries = new CFDictionaryRef[3];

            //create 3 search patterns by Joystick,GamePad and MulitAxisController

            // base.typeRef = CFLibrary.CFDictionaryCreate(IntPtr.Zero,keyz,values,keys.Length,ref kcall,ref vcall);



            dictionaries[0] = CreateDeviceMatchingDictionary((uint)Native.HIDPage.GenericDesktop, (uint)Native.HIDUsageGD.Joystick);

            dictionaries[1] = CreateDeviceMatchingDictionary((uint)Native.HIDPage.GenericDesktop, (uint)Native.HIDUsageGD.GamePad);

            dictionaries[2] = CreateDeviceMatchingDictionary((uint)Native.HIDPage.GenericDesktop, (uint)Native.HIDUsageGD.MultiAxisController);



            DeviceTypes = new Native.CFArray(dictionaries);


            //create Hid manager
            hidmanager = Native.IOHIDManagerCreate(IntPtr.Zero, (int)Native.IOHIDOptionsType.kIOHIDOptionsTypeNone);
        }
Exemplo n.º 2
0
 public static extern CFArrayRef IOHIDDeviceCopyMatchingElements(
     IOHIDDeviceRef  inIOHIDDeviceRef,       // IOHIDDeviceRef for the HID device
     CFDictionaryRef inMatchingCFDictRef,    // the matching dictionary
     IOOptionBits    inOptions);             // Option bits
Exemplo n.º 3
0
 public static extern void IOHIDManagerSetDeviceMatching(
     IOHIDManagerRef manager,
     CFDictionaryRef matching) ;
Exemplo n.º 4
0
		internal static extern long IOServiceGetMatchingService(
			IntPtr masterPort,
			CFDictionaryRef matching );
Exemplo n.º 5
0
		public static extern CFArrayRef IOHIDDeviceCopyMatchingElements(
			IOHIDDeviceRef device,
			CFDictionaryRef matching,
			IOOptionBits options);
Exemplo n.º 6
0
		internal static extern void CFDictionarySetValue (CFDictionaryRef theDict, IntPtr key, IntPtr value);
Exemplo n.º 7
0
 public static extern void IOHIDManagerSetDeviceMatching(
     IOHIDManagerRef manager,
     CFDictionaryRef matching);
Exemplo n.º 8
0
 internal static extern long IOServiceGetMatchingService(
     IntPtr masterPort,
     CFDictionaryRef matching);
		public OSXHIDInterface()
		{
			__drivers = new List<IDriver>();

			__ports = new string[20];


			
			HandleHIDDeviceAdded = HidDeviceAdded;
			HandleHIDDeviceRemoved = HidDeviceRemoved;
			HandleDeviceRemoved = DeviceRemoved;
			
			CFDictionaryRef[] dictionaries;
			
			
			
			
			
			
			dictionaries = new CFDictionaryRef[3];
			
			//create 3 search patterns by Joystick,GamePad and MulitAxisController
			
			// base.typeRef = CFLibrary.CFDictionaryCreate(IntPtr.Zero,keyz,values,keys.Length,ref kcall,ref vcall); 
			
			
			
			
			dictionaries[0] = CreateDeviceMatchingDictionary((uint)Native.HIDPage.GenericDesktop,(uint)Native.HIDUsageGD.Joystick);			
			
			dictionaries[1] = CreateDeviceMatchingDictionary((uint)Native.HIDPage.GenericDesktop,(uint)Native.HIDUsageGD.GamePad);
			
			dictionaries[2] = CreateDeviceMatchingDictionary((uint)Native.HIDPage.GenericDesktop,(uint)Native.HIDUsageGD.MultiAxisController);
			
			
			
			
			
			
			DeviceTypes= new Native.CFArray (dictionaries);
			
			
			//create Hid manager	
			hidmanager = Native.IOHIDManagerCreate(IntPtr.Zero,(int)Native.IOHIDOptionsType.kIOHIDOptionsTypeNone);
			
			

			
			
			
			
		}
Exemplo n.º 10
0
 public static extern CFArrayRef IOHIDDeviceCopyMatchingElements(
     IOHIDDeviceRef device,
     CFDictionaryRef matching,
     IOOptionBits options);
Exemplo n.º 11
0
 internal static extern void CFDictionarySetValue(CFDictionaryRef theDict, IntPtr key, IntPtr value);
Exemplo n.º 12
0
 private void ResetUI()
 {
     FirmLabel.Content = "No firmware selected";
     BrowseFirmButton.IsEnabled = true;
     BuildButton.IsEnabled = false;
     MainOptionsGroupBox.IsEnabled = true;
     OtherOptionsGroupBox.IsEnabled = true;
     ActivCheckBox.IsEnabled = false;
     ActivCheckBox.IsChecked = false;
     MultitaskCheckBox.IsEnabled = false;
     MultitaskCheckBox.IsChecked = false;
     WallpaperCheckBox.IsEnabled = false;
     WallpaperCheckBox.IsChecked = false;
     BattPercCheckBox.IsEnabled = false;
     BattPercCheckBox.IsChecked = false;
     CustBootLgCheckBox.IsEnabled = false;
     CustBootLgCheckBox.IsChecked = false;
     CustRecovLgCheckBox.IsEnabled = false;
     CustRecovLgCheckBox.IsChecked = false;
     PreInstalledPackagesCheckBox.IsChecked = true;
     RootFSSizeTextBox.Text = "1024";
     StatusLabel.Content = "Not working";
     FirmwareSHA1 = null;
     FirmwareBundlePath = null;
     FirmwareBundleInfoNode = null;
     RootFSPath = null;
     DecryptedRootFS = null;
     RootFSKey = null;
     RestoreRamdiskPath = null;
     IsUnziping = false;
     PartitionSize = 1024;
     ActivatePhone = false;
     EnableHomeWallpaper = false;
     EnableMultitasking = false;
     EnableBatteryPercentage = false;
     AddPreInstalledPackages = true;
     CustBootLgPath = null;
     CustRecovLgPath = null;
     SetProgressBarValue(0.0);
 }
Exemplo n.º 13
0
        private void ParseAndExecuteAction(CFDictionaryRef action)
        {
            string Action = action.GetValue("Action").ToString();
            if (Action == "Add")
            {
                string localPath = WinFormPath.Combine(FirmwareBundlePath, action.GetValue("File").ToString());
                string remotePath = "/" + action.GetValue("Path").ToString();
                bool alreadyExists = Pwn.hfsplus_FileExists(DecryptedRootFS, remotePath);
                if (alreadyExists)
                {
                    if (remotePath == "/sbin/launchd")
                        Pwn.hfsplus_mv(DecryptedRootFS, remotePath, "/sbin/crunchd");
                    else
                        Pwn.hfsplus_mv(DecryptedRootFS, remotePath, remotePath + "_orig");
                }
                Pwn.hfsplus_add(DecryptedRootFS, localPath, remotePath);
                if (alreadyExists)
                {
                    if (remotePath != "/sbin/launchd")
                    {
                        Pwn.hfsplus_chown(DecryptedRootFS, remotePath, Pwn.hfsplus_GETowner(DecryptedRootFS, remotePath + "_orig"), Pwn.hfsplus_GETgroup(DecryptedRootFS, remotePath + "_orig"));
                        Pwn.hfsplus_chmod(DecryptedRootFS, remotePath, Pwn.hfsplus_GETchmod(DecryptedRootFS, remotePath + "_orig"));
                    }
                }
            }
            else if (Action == "Patch")
            {
                string remotePath = "/" + action.GetValue("File").ToString();
                string localPath = WinFormPath.Combine(FIRMWARE_EXTRACT_PATH, WinFormPath.GetFileName(action.GetValue("File").ToString()));
                string localPathPatched = localPath + ".patched";
                string patchPath = WinFormPath.Combine(FirmwareBundlePath, action.GetValue("Patch").ToString());
                Pwn.hfsplus_extract(DecryptedRootFS, remotePath, localPath);
                if (!File.Exists(localPath))
                {
                    Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal,new StatusLabelUpdateDelegate(StatusLabelUpdate), "ERROR: Unable to extract " + remotePath + " from Root Filesystem");
                    return;
                }
                Pwn.bspatch(localPath, localPathPatched, patchPath);
                if (!File.Exists(localPathPatched))
                {
                    Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal,new StatusLabelUpdateDelegate(StatusLabelUpdate), "ERROR: Unable to patch " + WinFormPath.GetFileName(localPath));
                    return;
                }
                Pwn.hfsplus_mv(DecryptedRootFS, remotePath, remotePath + "_orig");
                Pwn.hfsplus_add(DecryptedRootFS, localPathPatched, remotePath);
                Pwn.hfsplus_chown(DecryptedRootFS, remotePath, Pwn.hfsplus_GETowner(DecryptedRootFS, remotePath + "_orig"), Pwn.hfsplus_GETgroup(DecryptedRootFS, remotePath + "_orig"));
                Pwn.hfsplus_chmod(DecryptedRootFS, remotePath, Pwn.hfsplus_GETchmod(DecryptedRootFS, remotePath + "_orig"));
                File.Delete(localPath);
                File.Delete(localPathPatched);
            }
            else if (Action == "SetPermission")
            {
                string remoteFile = "/" + action.GetValue("File").ToString();
                string permission = action.GetValue("Permission").ToString();
                Pwn.hfsplus_chmod(DecryptedRootFS, remoteFile, permission.Length == 3 ? "100" + permission : permission);
            }
            else if (Action == "SetOwner")
            {
                string remoteFile = "/" + action.GetValue("File").ToString();
                string owner = action.GetValue("Owner").ToString();
                Pwn.hfsplus_chown(DecryptedRootFS, remoteFile, owner.Split(':')[0], owner.Split(':')[1]);

            }
            else if (Action == "ReplaceKernel")
            {
                string remotePath = "/" + action.GetValue("Path").ToString();
                string localPath = WinFormPath.Combine(FIRMWARE_EXTRACT_PATH, WinFormPath.GetFileName(action.GetValue("File").ToString()));
                Pwn.hfsplus_mv(DecryptedRootFS, remotePath, remotePath + "_orig");
                Pwn.hfsplus_add(DecryptedRootFS, localPath, remotePath);
                Pwn.hfsplus_chown(DecryptedRootFS, remotePath, Pwn.hfsplus_GETowner(DecryptedRootFS, remotePath + "_orig"), Pwn.hfsplus_GETgroup(DecryptedRootFS, remotePath + "_orig"));
                Pwn.hfsplus_chmod(DecryptedRootFS, remotePath, Pwn.hfsplus_GETchmod(DecryptedRootFS, remotePath + "_orig"));

            }
            if (action.ContainsKey("MoreActions"))
            {
                foreach (CFDictionaryRef moreAction in ((CFArrayRef)action.GetValue("MoreActions")).Values)
                    ParseAndExecuteAction(moreAction);
            }
        }
Exemplo n.º 14
0
 private bool IsFirmwareBundleValid(string bundlePath)
 {
     if (!WinFormFile.Exists(bundlePath))
     {
         Dispatcher.Invoke(DispatcherPriority.Normal,new StatusLabelUpdateDelegate(StatusLabelUpdate), "ERROR: Bundle " + WinFormPath.GetFileName(bundlePath) + " is invalid !");
         return false;
     }
     FirmwareBundleInfoNode = (CFDictionaryRef)CFPropertyListRef.CreateWithData(new CFDataRef(WinFormFile.ReadAllBytes(bundlePath)), CFPropertyListMutabilityOptions.kCFPropertyListImmutable);
     if (FirmwareBundleInfoNode.GetValue("SHA1").ToString() == FirmwareSHA1)
     {
         FirmwareBundlePath = bundlePath.Remove(bundlePath.Length - "\\Info.plist".Length);
         return true;
     }
     return false;
 }