如何从Windows内核驱动程序获取设备实例路径? [英] How to get Device Instance Path from Windows kernel driver?

查看:901
本文介绍了如何从Windows内核驱动程序获取设备实例路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看看这个例子:据报道Windows 7中的USB设备具有设备实例路径(DevinstPath) USB \ VID_1EAB& PID_0501 \ 7& 25C389C1& 0& 1 ,我确切地知道它对应于注册表中的所谓的硬件密钥(hwkey).

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.

现在我的问题是:当我的KMDF驱动程序代码具有该USB设备的WDFDEVICE句柄时,如何知道其DevinstPath?

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

我知道我可以

  • 发送 BusQueryDeviceID 以获得所谓的设备ID USB \ VID_1EAB& PID_0501
  • 发送 BusQueryInstanceID 以获得所谓的实例ID 1 .
  • 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文档似乎真的含糊不清!

MSDN doc seems really vague on this!

顺便说一句:我还意识到用户层函数 SetupDiGetDeviceInstanceId 实际上会返回DevinstPath,尽管它被命名为"InstanceId".

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

推荐答案

可以使用 DEVPKEY_Device_InstanceId 通过WdfDeviceAllocAndQueryPropertyExIoGetDevicePropertyData(传递WDM物理设备对象)查询设备实例路径.

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

这篇关于如何从Windows内核驱动程序获取设备实例路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆