How to get Device Instance Path from Windows kerne

2019-07-18 01:26发布

Take a look at this example: a USB device in Windows 7 is reported to have Device instance path(DevinstPath) USB\VID_1EAB&PID_0501\7&25C389C1&0&1 and I know exactly that it corresponds to the so-called hardware-key(hwkey) in registry.

enter image description here

enter image description here

Now my question is: When my KMDF driver code has WDFDEVICE handle for that USB device, how can I know its DevinstPath?

I know I can

  • send a BusQueryDeviceID to achieve the so-called device-id USB\VID_1EAB&PID_0501;
  • send a BusQueryInstanceID to achieve the so-called instance-id 1 .

But I don't know how to get the so-called "instance-path". Could some kernel guru kindly tell me how I can get that?

MSDN doc seems really vague on this!

BTW: I also realize that user-layer function SetupDiGetDeviceInstanceId actually returns the DevinstPath -- although it is named "InstanceId".

2条回答
一夜七次
2楼-- · 2019-07-18 01:50

Device instance path can be queried using DEVPKEY_Device_InstanceId, using either WdfDeviceAllocAndQueryPropertyEx or IoGetDevicePropertyData (passing the WDM physical device object)

查看更多
小情绪 Triste *
3楼-- · 2019-07-18 01:54

Device Instance id is autoincrement sequence. You can find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum in registry; Rules:NextPareneID.XXXXXXXX.N XXXXXX use UUID Calculation crc32 values(test ok) N is 1~9 Device Instance id format is N&PareneID&random's number&index

enter image description here

查看更多
登录 后发表回答