Example #1
0
        // Token: 0x06000024 RID: 36 RVA: 0x00003CB0 File Offset: 0x00001EB0
        private void Initialise(string strPath)
        {
            this.m_hHandle = Win32Usb.CreateFile(strPath, 3221225472u, 0u, IntPtr.Zero, 3u, 1073741824u, IntPtr.Zero);
            if (!(this.m_hHandle != Win32Usb.InvalidHandleValue))
            {
                this.m_hHandle = IntPtr.Zero;
                throw HIDDeviceException.GenerateWithWinError("Failed to create device file");
            }
            IntPtr lpData;

            if (Win32Usb.HidD_GetPreparsedData(this.m_hHandle, out lpData))
            {
                try
                {
                    Win32Usb.HidCaps hidCaps;
                    Win32Usb.HidP_GetCaps(lpData, out hidCaps);
                    this.m_nInputReportLength  = (int)hidCaps.InputReportByteLength;
                    this.m_nOutputReportLength = (int)hidCaps.OutputReportByteLength;
                    HIDDevice.OutputLength     = this.m_nOutputReportLength;
                    HIDDevice.InputLength      = this.m_nInputReportLength;
                    this.m_oFile = new FileStream(new SafeFileHandle(this.m_hHandle, false), FileAccess.ReadWrite, this.m_nInputReportLength, true);
                    this.BeginAsyncRead();
                }
                catch (Exception ex)
                {
                    throw HIDDeviceException.GenerateWithWinError("Failed to get the detailed data from the hid." + ex.ToString());
                }
                finally
                {
                    Win32Usb.HidD_FreePreparsedData(ref lpData);
                }
                return;
            }
            throw HIDDeviceException.GenerateWithWinError("GetPreparsedData failed");
        }
Example #2
0
 private void Initialise(string strPath)
 {
     this.m_hHandle = Win32Usb.CreateFile(strPath, 0xc0000000, 3, IntPtr.Zero, 3, 0x40000000, IntPtr.Zero);
     if (this.m_hHandle != Win32Usb.InvalidHandleValue)
     {
         IntPtr ptr;
         if (Win32Usb.HidD_GetPreparsedData(this.m_hHandle, out ptr))
         {
             try
             {
                 try
                 {
                     Win32Usb.HidCaps caps;
                     Win32Usb.HidP_GetCaps(ptr, out caps);
                     this.m_nInputReportLength  = caps.InputReportByteLength;
                     this.m_nOutputReportLength = caps.OutputReportByteLength;
                     this.m_oFile = new FileStream(new SafeFileHandle(this.m_hHandle, false), FileAccess.ReadWrite, this.m_nInputReportLength, true);
                     this.BeginAsyncRead();
                 }
                 catch (Exception)
                 {
                     throw HIDDeviceException.GenerateWithWinError("Failed to get the detailed data from the hid.");
                 }
                 return;
             }
             finally
             {
                 Win32Usb.HidD_FreePreparsedData(ref ptr);
             }
         }
         throw HIDDeviceException.GenerateWithWinError("GetPreparsedData failed");
     }
     this.m_hHandle = IntPtr.Zero;
     throw HIDDeviceException.GenerateWithWinError("Failed to create device file");
 }
Example #3
0
 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");
 }