Determining the parent of a USB device

I am developing a disk filter driver and need to be able to check the USB VID/PID of the parent device (and potentially grandparent devices) that the disk is connected to.

Initially, I tried using IoGetDevicePropertyData with the DEVPKEY_Device_Parent as the key, but was unsuccessful. After some research, it looks like this is unsupported on Windows 7 in kernel mode.

Is there another way of finding out the USB VID/PID of the parents and grandparents?

xxxxx@cru-inc.com wrote:

I am developing a disk filter driver and need to be able to check the USB VID/PID of the parent device (and potentially grandparent devices) that the disk is connected to.

Initially, I tried using IoGetDevicePropertyData with the DEVPKEY_Device_Parent as the key, but was unsuccessful. After some research, it looks like this is unsupported on Windows 7 in kernel mode.

Is there another way of finding out the USB VID/PID of the parents and grandparents?

You are assuming that the parents and grandparents are USB devices.
That’s not necessarily true.

As a kernel driver, you can follow the chain of device objects directly,
and make your queries that way.


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

When you say “follow the chain of device objects directly,” what do you mean exactly?

When I use IoGetDeviceAttachmentBaseRef(), I get the PDO of the mass storage device, but then I’ve hit the bottom of the stack. Somehow I need to be able to hook into the stack of the USB hub. I see that the PDO of the hub can be accessed if I loop through the NextDevice list, but that doesn’t tell me that the hub is a parent of the mass storage device, right?