private void method_0(string string_0) { this.m_hHandle = Win32Usb.CreateFile(string_0, 3221225472u, 3u, IntPtr.Zero, 3u, 1073741824u, IntPtr.Zero); if (this.m_hHandle != Win32Usb.InvalidHandleValue) { IntPtr lpData = default(IntPtr); if (Win32Usb.HidD_GetPreparsedData(this.m_hHandle, out lpData)) { try { HidCaps hidCaps = default(HidCaps); Win32Usb.HidP_GetCaps(lpData, out hidCaps); this.m_nInputReportLength = hidCaps.InputReportByteLength; this.m_nOutputReportLength = hidCaps.OutputReportByteLength; this.m_oFile = new FileStream(new SafeFileHandle(this.m_hHandle, false), FileAccess.ReadWrite, this.m_nInputReportLength, true); } catch (Exception ex) { Console.WriteLine(ex.Message); throw GException0.GenerateWithWinError("Failed to get the detailed data from the hid."); } finally { Win32Usb.HidD_FreePreparsedData(ref lpData); } return; } throw GException0.GenerateWithWinError("GetPreparsedData failed"); } this.m_hHandle = IntPtr.Zero; throw GException0.GenerateWithWinError("Failed to create device file"); }
static bool HidP_GetCaps_hook(IntPtr lpData, out HidCaps oCaps) { try { XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback; //TODO lock (This.Queue) { if (This.Queue.Count < 1000) { This.Queue.Push("HidP_GetCaps"); } } } catch { } return(HidP_GetCaps(lpData, out oCaps)); }
static void QueryDeviceCapabilities(SafeFileHandle deviceHandle, out HidCaps capabilities) { IntPtr preparsedData; if (!HidD_GetPreparsedData(deviceHandle, out preparsedData)) { throw new Win32Exception(Marshal.GetLastWin32Error()) { Source = "WinUSB.HidD_GetPreparsedData" }; } if (!HidP_GetCaps(preparsedData, out capabilities)) { HidD_FreePreparsedData(ref preparsedData); throw new Win32Exception(Marshal.GetLastWin32Error()) { Source = "WinUSB.HidP_GetCaps" }; } HidD_FreePreparsedData(ref preparsedData); }
protected static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
/// <summary> /// Gets a device's capabilities from the preparsed data. /// </summary> /// <param name="lpData">Preparsed data reference</param> /// <param name="oCaps">HidCaps structure to receive the capabilities</param> /// <returns>True if successful</returns> [DllImport("hid.dll", SetLastError = true)] protected static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
internal static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
public static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
/// <summary> /// Gets a device's capabilities from the preparsed data. /// </summary> /// <param name="lpData">Preparsed data reference</param> /// <param name="oCaps">HidCaps structure to receive the capabilities</param> /// <returns>True if successful</returns> [DllImport("hid", SetLastError = true)] public static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
public static extern bool HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
public static extern int HidP_GetCaps(IntPtr preparsedData, out HidCaps hitcaps);