internal static extern bool SetupDiGetDeviceRegistryProperty(
     IntPtr DeviceInfoSet,
     ref USBM.SP_DEVINFO_DATA DeviceInfoData,
     uint Property,
     ref uint PropertyRegDataType,
     IntPtr PropertyBuffer,
     uint PropertyBufferSize,
     ref uint RequiredSize);
 internal static extern bool SetupDiEnumDeviceInfo(
     IntPtr DeviceInfoSet,
     uint MemberIndex,
     ref USBM.SP_DEVINFO_DATA DeviceInterfaceData);
 private bool CheckIfPresentAndGetUSBDevicePath()
 {
     try
     {
         IntPtr zero1 = IntPtr.Zero;
         USBM.SP_DEVICE_INTERFACE_DATA        DeviceInterfaceData = new USBM.SP_DEVICE_INTERFACE_DATA();
         USBM.SP_DEVICE_INTERFACE_DETAIL_DATA interfaceDetailData = new USBM.SP_DEVICE_INTERFACE_DETAIL_DATA();
         USBM.SP_DEVINFO_DATA spDevinfoData = new USBM.SP_DEVINFO_DATA();
         uint   MemberIndex         = 0;
         uint   PropertyRegDataType = 0;
         uint   RequiredSize1       = 0;
         uint   RequiredSize2       = 0;
         uint   RequiredSize3       = 0;
         IntPtr zero2     = IntPtr.Zero;
         uint   num1      = 0;
         string str       = "Vid_04d8&Pid_fc39";
         IntPtr classDevs = USBM.SetupDiGetClassDevs(ref this.InterfaceClassGuid, IntPtr.Zero, IntPtr.Zero, 18U);
         if (!(classDevs != IntPtr.Zero))
         {
             return(false);
         }
         do
         {
             DeviceInterfaceData.cbSize = (uint)Marshal.SizeOf((object)DeviceInterfaceData);
             if (USBM.SetupDiEnumDeviceInterfaces(classDevs, IntPtr.Zero, ref this.InterfaceClassGuid, MemberIndex, ref DeviceInterfaceData))
             {
                 if (Marshal.GetLastWin32Error() == 259)
                 {
                     USBM.SetupDiDestroyDeviceInfoList(classDevs);
                     return(false);
                 }
                 spDevinfoData.cbSize = (uint)Marshal.SizeOf((object)spDevinfoData);
                 USBM.SetupDiEnumDeviceInfo(classDevs, MemberIndex, ref spDevinfoData);
                 USBM.SetupDiGetDeviceRegistryProperty(classDevs, ref spDevinfoData, 1U, ref PropertyRegDataType, IntPtr.Zero, 0U, ref RequiredSize1);
                 IntPtr num2 = Marshal.AllocHGlobal((int)RequiredSize1);
                 USBM.SetupDiGetDeviceRegistryProperty(classDevs, ref spDevinfoData, 1U, ref PropertyRegDataType, num2, RequiredSize1, ref RequiredSize2);
                 string stringUni = Marshal.PtrToStringUni(num2);
                 Marshal.FreeHGlobal(num2);
                 string lowerInvariant = stringUni.ToLowerInvariant();
                 str = str.ToLowerInvariant();
                 if (lowerInvariant.Contains(str))
                 {
                     // Just... it just is. I don't get it.
                     interfaceDetailData.cbSize = 8;
                     USBM.SetupDiGetDeviceInterfaceDetail(classDevs, ref DeviceInterfaceData, IntPtr.Zero, 0U, ref RequiredSize3, IntPtr.Zero);
                     IntPtr zero3          = IntPtr.Zero;
                     IntPtr detailDataReal = Marshal.AllocHGlobal((int)RequiredSize3);
                     Marshal.StructureToPtr(interfaceDetailData, detailDataReal, false);
                     if (USBM.SetupDiGetDeviceInterfaceDetail(classDevs, ref DeviceInterfaceData, detailDataReal, RequiredSize3, IntPtr.Zero, IntPtr.Zero))
                     {
                         // Starts right after the 4 byte size.
                         this.DevicePath = Marshal.PtrToStringUni(new IntPtr(detailDataReal.ToInt64() + 4));
                         USBM.SetupDiDestroyDeviceInfoList(classDevs);
                         Marshal.FreeHGlobal(detailDataReal);
                         return(true);
                     }
                     Marshal.GetLastWin32Error();
                     USBM.SetupDiDestroyDeviceInfoList(classDevs);
                     Marshal.FreeHGlobal(detailDataReal);
                     return(false);
                 }
                 ++MemberIndex;
                 ++num1;
             }
             else
             {
                 uint lastWin32Error = (uint)Marshal.GetLastWin32Error();
                 USBM.SetupDiDestroyDeviceInfoList(classDevs);
                 return(false);
             }
         }while (num1 != 10000000U);
         return(false);
     }
     catch
     {
         return(false);
     }
 }