And before someone points this out- yes, I used SetupDiGetDeviceInstanceId to get that information, which is what I actually display.
Since you want hardware ID and not instance ID, you can use the SetupDiGetDeviceRegistryProperty API with SPDRP_HARDWAREID.
-----Original Message-----
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Getting list of devices a driver owns
Well, since I wrote all of the WdfVerifier tool, how about I just tell you how I did it?
I used SetupDiGetClassDevs to get all the devices in any hardware profile whether present or not (because that is what I wanted but it probably isn’t what you want). I used SetupDiEnumDeviceInfo to go through the list one device at a time. For each device I used SetupDiGetDeviceRegistryProperty to see if a particular driver was Service, an Upper Filter, or a Lower Filter (SPDRP_SERVICE, SPDRP_UPPERFILTERS, SPDRP_LOWERFILTERS). How I got a list of all the drivers I was interested in- that was complicated, and you don’t need to know that to solve your problem.
That’s it- about as direct a way to do it as I can think of. As noted in tooltips and documentation, this won’t catch drivers used as class filters- I know how to do that, but I had limited time, and it was extremely unlikely this was needed. It does pick up the devnodes created for legacy services (created when you “install” using Win32 CreateService), which would include file system filters, IIRC- not that I actually wanted to catch them, as at the time, I did not expect anybody to use KMDF to write one. But keeping them out would also have been extra work, and time was limited. I tried to write only what I needed.
But you probably don’t want to do it that way- you can probably limit the size of the tree you’re searching by setup class, for instance, and you also probably only want devices present in the current hardware profile.
-----Original Message-----
To: Windows System Software Devs Interest List
Subject: [ntdev] Getting list of devices a driver owns
Ok, I see that WdfVerifier.exe can show me a list of drivers, and what Plug and Play devices that driver owns. I need to do something very similar. Is there an API that will let me extract this information from the system? I can already use the Setup API to make sure the driver I’m interested in is actually there, would the Setup API docs be a good place to start?
Links, etc. very welcomed!
…ed…