Enumerating device paths for CreateFile/WinUsb_Initialize()

Pardon the userland intrusion. W7Ux64 FWIW.

My Blackfin firmware now advertises itself as a composite device -
interface 2 sporting a single control endpoint only. Interface 1 is mass
storage and class compliant, Interface 2 is for really simple control
functions (mainly during device test). I thought WinUSB would be a great
solution here - inbox drivers, simple usermode interface, etc. etc.

Question: How to legitimately query the host for device paths in the
format required by CreateFile?

The current search starts off with the usual:

  1. SetupDiGetClassDevs with GUID_DEVINTERFACE_USB_DEVICE
  2. SetupDiEnumDeviceInterfaces
  3. SetupDiGetDeviceInterfaceDetail -> i.e. extract
    pDetailDataBuffer->DevicePath

but since this is a composite device the enumerator only gets to the
parent. So the next steps are:

  1. SetupDiEnumDeviceInfo
  2. CM_Get_Device_ID
  3. CM_Get_DevNode_Status -> check it is a node in
    the tree
  4. CM_Get_Child and CM_Get_Sibling -> for each
    child call CM_Get_Device_ID()

Now this all works. The next steps are:

  1. SetupDiOpenDeviceInfo using the path returned in 7.
  2. SetupDiOpenDevRegKey(hDevInfo,&da, DICS_FLAG_GLOBAL, 0, DIREG_DEV,
    KEY_READ);
  3. Finally RegQueryValueEx with the key obtained in 9 and a value of
    ‘DeviceInterfaceGUIDs’.

Step 10 always fails with a ERROR_FILE_NOT_FOUND. GetlastError() reports
‘operation completed successfully’

Step 3 returns the parent device path:
\?\usb#vid_XXXX&pid_a00a#123456789012#{a5dcbf10-6530-11d2-901f-00c04fb951ed}

Step 5 returns the parent device ID:
USB\VID_XXXX&PID_A00A\123456789012

Step 7 returns the correct child IDs:
USB\VID_XXXX&PID_A00A&MI_00\8&15CD2222&0&0000
USB\VID_XXXX&PID_A00A&MI_01\8&15CD2222&0&0001

What am I missing here? I can see the correct key/values in the
registry. I could cheat and build up the key myself but this seems
unsatisfactory.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_XXXX&PID_A00A&MI_01\8&15cd2222&0&0001\Device
Parameters

Thx++

Jerry

Scratch that. Turns out that RegQueryValueEx was actually returning
ERROR_MORE_DATA in the right cases.

Amazing how posting to a list seems to reverse that nice Mr Heisenberg’s
Uncertainty Principle …

Jerry Evans wrote:

Pardon the userland intrusion. W7Ux64 FWIW.

My Blackfin firmware now advertises itself as a composite device -
interface 2 sporting a single control endpoint only. Interface 1 is mass
storage and class compliant, Interface 2 is for really simple control
functions (mainly during device test).

There is very little point in having a control endpoint other than 0.
You don’t gain anything.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.