I am rephrasing Ed Dekker’s question of a few days ago because I know
someone who is looking for a solution. Basically, they are looking for a
way to correlate the a USB_DEVICE_DESCRIPTOR to a handle to the device. so
either:
a. Given a handle to the device, get the USB_DEVICE_DESCRIPTOR, or
b. Given the information from
IOCTL_USB_GET_NODE_CONNECTION_INFORMATION get a handle to the device.
It would seem like you can do this. The people I know would prefer a user
space solution, but even a driver will be acceptable. So does anyone have a
clue?
–
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4467 (20090929) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
I’ve done something similar in the past, maybe it will help get the info you
need…
The path I took was about as indirect as you can get, but it worked for our
purposes. Using the same HANDLE you sent the
IOCTL_USB_GET_NODE_CONNECTION_INFORMATION request to, send an
IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME request.
From the driver key name, get a DEVINST handle (you can use the same
technique as DriverNameToDeviceDesc in USBView). That DEVINST represents the
USB PDO, so call CM_Get_Child to get the DEVINST of the PDO of the attached
device (e.g. the disk).
Using that DEVINST, get an HDEVINFO handle so that you can use the SetupDi
interface (I used CM_Get_Device_ID and SetupDiOpenDeviceInfo to do the
translation).
Get the name of the PDO with SetupDiSetDeviceRegistryProperty for
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME. Use ZwOpenFile to open the PDO name, and
now you have a disk HANDLE that you can send requests to.
In our case we needed to send IOCTL_STORAGE_GET_DEVICE_NUMBER to every tape
device and incorporate the results into the USBView output (simplified
explanation, but that was the basic idea). This worked out well for us, even
though it was a fair amount of annoying code to do all of the translations.
-scott
–
Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Don Burn” wrote in message news:xxxxx@ntdev…
>I am rephrasing Ed Dekker’s question of a few days ago because I know
>someone who is looking for a solution. Basically, they are looking for a
>way to correlate the a USB_DEVICE_DESCRIPTOR to a handle to the device. so
>either:
>
> a. Given a handle to the device, get the USB_DEVICE_DESCRIPTOR, or
>
> b. Given the information from
> IOCTL_USB_GET_NODE_CONNECTION_INFORMATION get a handle to the device.
>
> It would seem like you can do this. The people I know would prefer a
> user space solution, but even a driver will be acceptable. So does anyone
> have a clue?
>
>
> –
> Don Burn (MVP, Windows DKD)
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
>
>
>
> Information from ESET NOD32 Antivirus, version of virus
> signature database 4467 (20090929)
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
>
> Get the name of the PDO with SetupDiSetDeviceRegistryProperty for
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME.
I think you can also use SetupDiGetClassDevs to enumerate the disk interface names hanging off the particular devnode, like:
SetupDiGetClassDevs(DiskInterfaceGuid, result of CM_Get_Device_ID, NULL,
DIGCF_DEVICEINTERFACE);
Or you can enumerate all disk class devices, take the CM_Get_Parent of each of them, and look at whether the parent is of “USB” class.
You can also call IOCTL_STORAGE_QUERY_PROPERTY before this to really ensure that the disk is on the USB bus, instead of relying on “USB” class string.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com