Author Topic: Doubts with GUIDs in INF files and using them in the program functions  (Read 14472 times)

gikubik

  • Member
  • ***
  • Posts: 8
Hi everybody,

I'm following Jan Axelson book trying to understand USB interface to develop my own program. Here are some doubts. First of all, in the example of INF files we can find these lines (p.233):

Class = USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}

This GUID and name are auto-generated (invented) or there are a list of classes and I have to fit into one of them? (I must say at this point that I'm developing a vendor-specific device and I'm planing to use WinUsb driver). Looking for information about WinUsb I found these other couple of lines:

Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}


First question is: can I write what I want into parameter "Class" and then generate a valid ClassGUID and that's all? Or I should use exactly the same data proposed by Jan in his book? Why Microsoft is proposing another Class name and ClassGUID for using exactly the same driver?

Second question is about function SetupDiGetClassDevs which we have to use at the begining of the process of getting a device path. One of its parameter is ClassGuid (p.254):

ByRef ClassGuid As System.Guid

Maybe question will seem you stupid but following the instructions in the book is not clear for me which GUID we have to pass to this function through this paramenter: Class Guid or Interface Guid? In the book, when we use this function we are passing myGuid:

deviceInfoSet = SetupDiGetClassDevs _
(myGuid, _
IntPtr.Zero, _
IntPtr.Zero, _
DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)


And previously, Jan defined this variable as Device Interface GUID:

Public Const WINUSB_DEMO_GUID_STRING As String = _
"{42CA71EC-CE1C-44c2-82DE-87D8D8FF6C1E}"

Dim myGuid As New System.Guid(WINUSB_DEMO_GUID_STRING)


This GUID inside the INF file is the Device Interface GUID:

HKR,,DeviceInterfaceGUIDs,0x10000,"{42CA71EC-CE1C-44c2-82DE-87D8D8FF6C1E}"

So, my second question: which GUID has to be passed to the function? The one which appear as ClassGUID into the INF file or the one called Device Interface GUID?

Thanks in advanced to all. I'm from Spain and I hope my English will be clear enough! I think questions are a little dense...

Thanks!
Xavi

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Doubts with GUIDs in INF files and using them in the program functions
« Reply #1 on: October 13, 2013, 01:53:42 pm »
Not too long ago, Microsoft defined a way for WinUSB devices to use the system WinUSB INF file instead of requiring vendors to provide an INF file for each device. Details are here:

http://blogs.msdn.com/b/usbcoreblog/archive/2012/09/26/how-to-install-winusb-sys-without-a-custom-inf.aspx

gikubik

  • Member
  • ***
  • Posts: 8
Re: Doubts with GUIDs in INF files and using them in the program functions
« Reply #2 on: October 14, 2013, 06:55:43 am »
Thanks Jan for your quick answer,

I understand now why appeared that "USBDevice" in Microsoft information. Unfortunately my skills programming are not good enough and following your instructions (even with this new system working) is really helpful. I think the old way you proposed in your book is still working and I'm going to use it. Furthermore, I would like to be able to install my device in all versions of Windows XP and knowing that maybe computers don't have internet connection or have windows update blocked (I think new system is only working with SP3 installed and you need to have internet connection and windows update activated).

So my questions are still in the air (a bit modified now with Jan's answer because question about the existence of Class=USBDevice has no sense) and I will be grateful to receive any help knowing that I want to follow "the old way". My questions again:

***************
I'm following Jan Axelson book trying to understand USB interface to develop my own program. Here are some doubts. First of all, in the example of INF files we can find these lines (p.233):

Class = USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}

First question is: can I write what I want into parameter Class and then generate a valid ClassGUID and that's all? Or I should use exactly the same data proposed by Jan in his book?

Second question is about function SetupDiGetClassDevs which we have to use at the begining of the process of getting a device path. One of its parameter is ClassGuid (p.254):

ByRef ClassGuid As System.Guid

Maybe question will seem you stupid but following the instructions in the book is not clear for me which GUID we have to pass to this function through this parameter: Class Guid or Device Interface Guid? In the book, when we use this function we are passing myGuid:

deviceInfoSet = SetupDiGetClassDevs _
(myGuid, _
IntPtr.Zero, _
IntPtr.Zero, _
DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)

And previously, Jan defined this variable as Device Interface GUID:

Public Const WINUSB_DEMO_GUID_STRING As String = _
"{42CA71EC-CE1C-44c2-82DE-87D8D8FF6C1E}"


Dim myGuid As New System.Guid(WINUSB_DEMO_GUID_STRING)

This GUID inside the INF file is the Device Interface GUID:

HKR,,DeviceInterfaceGUIDs,0x10000,"{42CA71EC-CE1C-44c2-82DE-87D8D8FF6C1E}"

So, my second question: which GUID has to be passed to the function? The one which appear as ClassGUID into the INF file or the one called Device Interface GUID? Which of these?:

{42CA71EC-CE1C-44c2-82DE-87D8D8FF6C1E}
{36FC9E60-C465-11CF-8056-444553540000}

***************

Thanks again.
Xavi


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Doubts with GUIDs in INF files and using them in the program functions
« Reply #3 on: October 14, 2013, 10:10:28 am »
If you're using your own INF file, the GUID you pass to SetupDiGetClassDevs should match the GUID in the INF file. The GUID should be unique to your device.

If you're using Microsoft's winusb.inf, the GUID you pass to SetupDiGetClassDevs should match the GUID in the device's (Microsoft-defined) extended properties OS feature descriptor. 

You can generate a GUID with:

http://www.guidgen.com/

64-bit Windows editions require digitally signed INF files. Using Microsoft's winusb.inf eliminates the need to sign your own INF file.

The Class should be USB Device:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff553426%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/hardware/ff540189%28v=vs.85%29.aspx

I have example code here:

http://www.lvr.com/winusb.htm


gikubik

  • Member
  • ***
  • Posts: 8
Re: Doubts with GUIDs in INF files and using them in the program functions
« Reply #4 on: October 15, 2013, 06:42:40 am »
Thanks again Jan,

Ok, If I understood correctly, I have to use USBDevice class in my own INF file:

Class = USBDevice
ClassGuid = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}


And then generate a unique GUID for my device (which will be the "Interface Device GUID") using the link you gave me and also add it to my INF file here:

HKR,,DeviceInterfaceGUIDs,0x10000,"{My_Generated_GUID}"

Finally this last GUID (My_Generated_GUID) is the one I have to use with function SetupDiGetClassDevs

As long as I'm using 32bits system, I don't need .CAT file

Maybe I'm a bit silly but in my opinion it's not easy! So thank you very much for your book and your help here Jan because in my case, without it, it would be impossible!!

Xavi


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Doubts with GUIDs in INF files and using them in the program functions
« Reply #5 on: October 15, 2013, 10:12:30 am »
If you're not using the system WinUSB INF file, the GUID in your application should match the GUID in your INF file, and the GUID should be unique to your device.