Author Topic: WinUSB: FindDeviceFromGUID keeps returning false  (Read 9938 times)

SRTT

  • Member
  • ***
  • Posts: 3
WinUSB: FindDeviceFromGUID keeps returning false
« on: July 22, 2014, 04:58:52 pm »
Hi everyone,

I am currently experimenting with Jan Axelsons very nice VB.NET USB Examples. The HID-Code runs very smoothly and I had little trouble understanding it.

However, I have some issues with the WinUSB-Example (v22).

As far as I understand the code, a user communication with the USB Device happens after the device is found and the handle is initialized, but the FindDeviceFromGUID() keeps failing way before (returning false). In the function itself, the SetupDiGetClassDevs() returns a non-zero number and later on, the SetupDiEnumDeviceInterfaces()-function returns false as well.

What I figured/tried up until now is:

 - changing the device driver to actual WinUSB.sys because it previously was the microchip-own device driver

 - messing around with VID, PID and GUID, also simply reading them from the ManagementObjectSearcher (which works and gives me the exact same values I am trying with before and the same negative result)

 - rebooting, replugging, reinstalling the drivers several times (as well as messing around with other drivers)

I'm currently pretty much out of ideas on this; the only thing I am still unsure about is how my C-Code on the device itself maybe causes the issue but on the other hand, the device is accepted by Windows without any errors and values like PID/VID are transferred correctly.

Just for information:
 OS is Win7 Pro 64Bit SP1;
 USB Device is a PIC18F4550, successfully tested as HID with other descriptors;
 Host SourceCode is both jan Axelsons Code and a self-written variant of it;
 Device Code is an example of my IDE which I (partly heavily) changed, but again, successfully tested with HID (apart from the descriptor file);

Any suggestions/help would be much appreciated! Thx in advance ;)

Regards
Stefan

ps:
I also stumbled upon some older entries (approx. 1-2 years ago) here concerning similar (and unsolved) problems but decided to open a new thread nevertheless because of their old age.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #1 on: July 22, 2014, 05:31:18 pm »
Option 1: Do you have an INF file with the GUID? For 64-bit Windows, it will need to be signed, though you can test-sign it.

Option 2: Does your firmware support installing without an INF as described here:

http://janaxelson.com/winusb.htm

SRTT

  • Member
  • ***
  • Posts: 3
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #2 on: July 23, 2014, 04:52:49 am »
Hi Jan!

First of all, thanks for your reply.

So you're basically saying that if my INF-File isn't signed (or at least Windows tells me it isn't) and I install it nevertheless, the code will not work no matter the fact that my device manager tells me that everything is okay? Is there any other way to get around that besides option 2?

Also, to be perfectly clear: which GUID would I use? Until now I thought it was quite clear it's all about the Class-GUID but since you mentioned needing the INF-File for the GUID and me discovering the entry "DeviceInterfaceGUIDs" in my nonsigned INF-File (which is very closely named to your Source Code GUID-Variable) I'm not so sure anymore.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #3 on: July 23, 2014, 08:07:53 am »
If Device Manager shows the winusb driver assigned and no problem, you should be OK.

The GUID in the INF should match the GUID in your application.

SRTT

  • Member
  • ***
  • Posts: 3
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #4 on: July 23, 2014, 10:48:36 am »
Seems like I was using the wrong GUIDs the whole time after all.

In the INF-File, the GUID I had to use to make my device finally communicate with the WinUSB Software was NOT the ClassGUID but the DeviceInterfaceGUID which is declared under [Dev_AddReg]. I thought I already tried that, too, seems I was wrong.

The mean part of it is that Windows distracts you with several GUIDs shown in the Device Managers Properties Window but none of them is the GUID you actually need. So currently the only place I know finding the right GUID is actually the INF. And that's probably why you keep pointing towards that. ;)

By the way, I took the INF-File provided by Microchip but made some changes in it to force using Windows-intern drivers. I thought about uploading it here but I would strongly encourage anybody encountering similar problems to play around a little with the File for yourself as it comes along with the MicroChip MPLABX.

Just for documentation what I had done:
basically I looked up the coinstaller-files in my Windows-Directory (they were all located under Windows\System32), copied those into the driver folder where my Inf also is located and also downgraded the WdfCoInstaller*****.dll and the WUDFUpdate_*****.dll from 01011 (what Microchip provided) to 01009 (which I could found in my System-Directory).

I also created a catalog file for my INF through MS Inf2Cat-Tool but I don't think it is necessary for the driver to work (installation went smoothly without it as well).

It is also possible that downgrading those two files wasn't even necessary.

Anyway, glad it works now; thanks again for helping!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #5 on: July 23, 2014, 11:17:04 am »
Glad you got it working, thanks for reporting back!

TonyZ

  • Member
  • ***
  • Posts: 3
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #6 on: July 27, 2015, 01:12:48 pm »
Hello,
I also am having the same problem that the OP had a while back, and this thread has been very useful.

I just wanted to get some clarification on a couple of points:

1 - Is the INF file read *every* time that the associated USB device is plugged in? Or is it only used
once during the initial installation.

2 - What if more than one device has been installed that uses winusb.sys. Is there a separate INF file for each one? I have several on
my PC. Is there a way to tell which one is associated with a particular piece of USB hardware?

3 - In device manager, under the "Details" Tab, and if I select "Inf name", I see a file named "oem131.inf". How does this come into play?

Thanks, Jan, for being such a huge help to the USB community! Small developers like me would be lost without your help.

Regards,
Tony

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #7 on: July 27, 2015, 09:12:05 pm »
The first time Windows reads an INF, it stores the information and uses the stored information on subsequent device attachments.

The GUID identifies the device function. The INF file for a vendor-defined function identifies one or more devices (by VID and PID) that use the same GUID and function in the same way.

When Windows copies INF files to the inf directory, it renames them using oem???.inf in part to ensure no duplicates. 

With firmware support, devices can also use the system WinUSB INF file. See:

http://janaxelson.com/winusb.htm

TonyZ

  • Member
  • ***
  • Posts: 3
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #8 on: July 28, 2015, 12:40:37 pm »
Thanks, Jan.
I was able to find the correct GUID and use it in your winusb_cs demo. Now it works!  :)

Here's what I did:
Go to device manager and find the USB device that's connected. Select "Properties".
Under the Details tab, find "Inf name" in the Properties drop-down box.
This will tell you the oem??.inf file that is associated with the usb hardware.
Now, find this file on your hard drive (in Win7, it is in the C:/Windows/inf folder).
Open this file, and find the [Dev_AddReg] section. Here you will find the Interface GUID that you need to use in your windows program.

Thanks again for the help.
Tony

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: WinUSB: FindDeviceFromGUID keeps returning false
« Reply #9 on: July 28, 2015, 02:31:45 pm »
Glad you got it working. Thanks for reporting what you found.