Hi everyone, you guys have been a huge help in learning driver development.
I have a minifilter which attaches only to Usbs, what I would like to do is get the VID and PID (in alphanumeric) of the device attached.
What I have done:
I use IOCTL_STORGE_QUERY_PROPERTY to check for usb and with that IOCTL i get ascii strings for VID and PID
I do FltGetDeviceObject to get the device object and then I call IoGetDeviceProperty(DevicePropertyHardwareID) on that device but it returns “STORAGE\Volume” which is not what I desire.
Yes sorry when I call IoGetDeviceProperty(DevicePropertyHardwareID) on FltGetDeviceObject it says STATUS_INVALID_DEVICE_REQUEST and when called on FltGetDiskDeviceObject it says “STORAGE\Volume”.
The problem is that one volume might span multiple disks. This results in a design that makes it difficult to get hardware ID at the file system level.
For a general USB storage the relations are as follows
usbhub.sys/usbccgp.sys PDO --(TargetDeviceRelations)–>usbstor.sys FDO–(BusRelations)–>usbstor.sys PDO–>(TargetDeviceRelations)–>disk.sys FDO–(EjectionRelations or/and RemovalRelations)–>volmgr.sys PDO–(VPB i.e. Volume Parameters Block)–>file system object
In general you can collapse TargetDeviceRelations and consider all relations as PDO-to-PDO as the Device Manager GUI does.
You have a volmgr.sys PDO through FltGetDiskDeviceObject and you need to traverse the above hierarchy up to usbhub.sys/usbccgp.sys PDO for which IoGetDeviceProperty returns something like “USB\VID_0951&PID_1642\001CC0EC2F18FC21157F23AB”.
You need to go a level below the volume manager in PnP tree to reach a disk(disk.sys) FDO. This requires retrieving EjectionRelations and RemovalRelations from all disk(disk.sys) FDOs with IRP_MN_QUERY_DEVICE_RELATIONS after the volume manager created a PDO on which a file system has been mounted. This gives you a disk FDO for a volume PDO. Volume PDOs and disk FDOs are not connected by BusRelations as this might be one volume to many disk objects relationship in case of a spanned volume so it can’t be managed by BusRelations as this is a case of multiple “buses”.
Then you need to go from the disk FDO to a USBSTOR PDO by TargetDeviceRelation or by a call to IoGetDeviceAttachmentBaseRef .
Then you need to find USBSTOR FDO through BusRealtions for USBSTOR PDO. Then retrieve USBHUB PDO from USBSTOR FDO.
I am afraid it is too complicated to be done from a driver( though I did this ). IRP_MN_QUERY_DEVICE_RELATIONS is not designed to be sent by third party drivers as it might require synchronization with the PnP Manager to remove concurrency to maintain third party drivers/filters stability ( Microsoft drivers/filters are okay with concurrent IRP_MN_QUERY_DEVICE_RELATIONS ).
The better approach would be a user mode service or application to query PnP relations. There should be a code example in MSDN or somewhere.
From: Rod Widdowsonmailto:xxxxx Sent: August 21, 2017 6:23 AM To: Windows File Systems Devs Interest Listmailto:xxxxx Subject: Re:[ntfsd] Get Alpha Numeric VID/PID
>It just seems weird that the information is not as easily available to the >drivers as compared to the user mode applications.
Welcome to the whacky world of windows drivers, there are many other cases like this
— NTFSD is sponsored by OSR
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at http:
To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></mailto:xxxxx></mailto:xxxxx></https:>