Get All Device Handles For Multiple Instances

Hi All,

I have KMDF driver for a PCI device. I had used WdfDeviceCreateDeviceInterface to create a device interface so that user applications can communicate with the device. I had defined GUID so that applications can use same GUID to retrieve device handle.

If I plugged in one or more PCI cards, then multiple instances are created with unique ID. But how can I use the GUID in the application to get all the device handles that are plugged in. Can I use the reference string along with GUID in WdfDeviceCreateDeviceInterface?

Any help is much appreciated.

Regards,
-Madhu

Check out the code in the exe folder of the usbsamp in the ddk: :\WinDDK\7600.16385.0\src\usb\usbsamp\exe

What you have to do is call a load of SetupDi functions, using the GUID as a start point, to create a device name. You’ll eventually end up calling CreateFile() on your device once the device name has been formed.

In other words, nearly all of the EXE samples show how to use setupdi to open the device interface. I think all of them stop after the first one is found and opened, but you can easily just change that logic to open them all. And, no, you cannot use the reference string in the EXE or DLL which enumerates the device interfaces, that is an opaque part of the string. The driver can use the ref string in EvtDeviceFileCreate (it is the filename) to distinguish between multiple device interface opens on the same instance. Since the multiple here is the devices themselves, not the dev interfaces on each device, I don’t think you need the ref string

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@redsoftsys.com
Sent: Wednesday, September 29, 2010 12:30 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Get All Device Handles For Multiple Instances

Check out the code in the exe folder of the usbsamp in the ddk: :\WinDDK\7600.16385.0\src\usb\usbsamp\exe

What you have to do is call a load of SetupDi functions, using the GUID as a start point, to create a device name. You’ll eventually end up calling CreateFile() on your device once the device name has been formed.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you for the replies.

I’ll try out the sample.

Regards,
Madhu