Getting list of loaded drivers

I’m trying to write a nice app tat just gives me a list of the loaded multimedia drivers - I need the display name and the name of the actual whatever.sys file that is loaded. No problems getting a nice display name using SetupDiEnumDeviceInfo along with SetupDiGetDeviceRegistryProperty, but I’m not seeing an obvious way to take any of the available options for SPDRP_xxxxx and turn that into a driver file name.

Anyone have any idea how to go about this? Is there a way to take the GUID I get back and dig into the registry to convert that into a file name?

All help appreciated.

…ed…

Ok, I can get a list of existing drivers, but I’m not sure if I’m getting just loaded ones or not! the flags I’m using are DIGCF_ALLCLASSES | DIGCF_PRESENT | DIGCF_PROFILE to SetupDiGetClassDevs, which gives me a bazillion devices (ok, only 200-odd)… if I grab out the service name, I can see some have a service and some do not… not sure this indicates anything meaningful about whether or not it’s loaded…

Am puzzled.

…ed…

Not all drivers are pnp

EnumDeviceDrivers, http://msdn.microsoft.com/en-us/library/ms682617(VS.85).aspx

And lo and behold, a sample on how to use it :slight_smile: and get the names, http://msdn.microsoft.com/en-us/library/ms682619(VS.85).aspx

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@woolyloach.com
Sent: Thursday, July 29, 2010 3:20 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Getting list of loaded drivers

Ok, I can get a list of existing drivers, but I’m not sure if I’m getting just loaded ones or not! the flags I’m using are DIGCF_ALLCLASSES | DIGCF_PRESENT | DIGCF_PROFILE to SetupDiGetClassDevs, which gives me a bazillion devices (ok, only 200-odd)… if I grab out the service name, I can see some have a service and some do not… not sure this indicates anything meaningful about whether or not it’s loaded…

Am puzzled.

…ed…


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

Geez… how ABOUT that.

Just as I was about to suggest something semi-hideous (like querying the Object Manager’s \drivers\ and \FileSystems\ directories) or perfectly hideous (like querying the loaded module list) it turns out there’s a documented way to do this.

That’s two things I learned today. And on such a slow day on NTDEV, too…

Peter
OSR

xxxxx@woolyloach.com wrote:

I’m trying to write a nice app tat just gives me a list of the loaded multimedia drivers - I need the display name and the name of the actual whatever.sys file that is loaded.

What do you mean by “multimedia drivers”? Do you mean “media class”
drivers (GUID_DEVCLASS_MEDIA)? Remember that many web cameras install
under image class (GUID_DEVCLASS_IMAGE).

What are you going to do with this list? Which kinds of drivers do you
expect this list to contain? As an example, if you want the list of all
video capture sources in the system you are going about it the wrong
way. You should be using CLSID_SystemDeviceEnum. That returns to you
all capture sources, whether they are kernel drivers or user-mode wrappers.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Doron, wow! I had no idea those functions existed… I too learned new things today!!

The thing is, I’m an app running under WinPE… in order to proceed, I need to make sure certain base drivers are loaded, which isn’t necessarily always true on our target machines. So, I need to get a list of drivers and scan it to see if what I need is there, and if not, drvload the thing so that I can proceed. Most of the devices are “media” devices, although late yesterday I found one that isn’t, so I have to get the COMPLETE list and go through it.

I think that, with that sample code, I should be good to go! Thanks to everyone for commenting and posting! It’ll be a happy Friday now…

Ok, both methods I’ve tried work fine under WinPE… but produce different lists! Using SetupDiEnumDeviceInfo along with SetupDiGetDeviceRegistryProperty I get about 159 drivers listed, while EnumDrivers gets me 179… odd. Which is actually listing the loaded and running drivers? I believe it’s possible for drivers to be installed but unused, maybe one of these methods is ignoring or returning those?

The MSDN docs aren’t terribly clear to me.

All assistance appreciated greatly - thanks!

Setupdi lists only PnP drivers. EnumDrivers lists both PnP and legacy drivers.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@woolyloach.com
Sent: Friday, July 30, 2010 12:41 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Getting list of loaded drivers

Ok, both methods I’ve tried work fine under WinPE… but produce different lists! Using SetupDiEnumDeviceInfo along with SetupDiGetDeviceRegistryProperty I get about 159 drivers listed, while EnumDrivers gets me 179… odd. Which is actually listing the loaded and running drivers? I believe it’s possible for drivers to be installed but unused, maybe one of these methods is ignoring or returning those?

The MSDN docs aren’t terribly clear to me.

All assistance appreciated greatly - thanks!


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

Doron - ah, that makes sense! I do need to check both legacy and PnP, so EnumDrivers() is obviously the Right Thing™. And those are actually loaded drivers?

Fun times - and thanks again for the help!

What else would they be? unloaded drivers?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@woolyloach.com
Sent: Friday, July 30, 2010 1:19 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Getting list of loaded drivers

Doron - ah, that makes sense! I do need to check both legacy and PnP, so EnumDrivers() is obviously the Right Thing™. And those are actually loaded drivers?

Fun times - and thanks again for the help!


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

Sorry if I’m ignorant… I would assume that drivers could be installed but not loaded, say, in the case of someone installing a PCI card, then yanking it out… I imagine a registry entry would still exist somewhere that associated the driver with that now-missing piece of hardware… I’m not a wizard on how Windows handles that kind of thing.

Testing this is a bear… I’m trying to find a WinPE image that doesn’t have hdaudbus.sys loaded, but there doesn’t seem to be one, and I’m not sure I can use devcon to force-unload a driver (I bet not) on WinPE. Worst-case I can build a WinPE image without it…

Apologies for being a pest!

There are 100s of drivers installed on your machine, both of these APIs tell you what is running, not what is installed. You can use devcon to disable things, devcon disable <…> (see devcon help for what you need to substitute in)

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@woolyloach.com
Sent: Friday, July 30, 2010 1:55 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Getting list of loaded drivers

Sorry if I’m ignorant… I would assume that drivers could be installed but not loaded, say, in the case of someone installing a PCI card, then yanking it out… I imagine a registry entry would still exist somewhere that associated the driver with that now-missing piece of hardware… I’m not a wizard on how Windows handles that kind of thing.

Testing this is a bear… I’m trying to find a WinPE image that doesn’t have hdaudbus.sys loaded, but there doesn’t seem to be one, and I’m not sure I can use devcon to force-unload a driver (I bet not) on WinPE. Worst-case I can build a WinPE image without it…

Apologies for being a pest!


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

Thanks! That should keep me out of your hair for a while (hopefully a LONG while).

Have a good weekend!

…ed…

I barely have any hair on my head for you to be in anyways :stuck_out_tongue_winking_eye:

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@woolyloach.com
Sent: Friday, July 30, 2010 2:20 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Getting list of loaded drivers

Thanks! That should keep me out of your hair for a while (hopefully a LONG while).

Have a good weekend!

…ed…


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

>I imagine a registry entry would still exist somewhere that associated the driver with that now-missing

piece of hardware…

Correct.

Running Device Manager with a special env var will allow it to show such stale entries, so you can delete them by Uninstall menu item.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Interesting. What’s the name of the env var?

Thanks,

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Friday, July 30, 2010 7:01 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Getting list of loaded drivers

I imagine a registry entry would still exist somewhere that associated
the driver with that now-missing piece of hardware…

Correct.

Running Device Manager with a special env var will allow it to show such
stale entries, so you can delete them by Uninstall menu item.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com


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

DEVMGR_SHOW_NONPRESENT_DEVICES


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“M. M. O’Brien” wrote in message news:xxxxx@ntdev…
> Interesting. What’s the name of the env var?
>
>
> Thanks,
>
> mm
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
> Sent: Friday, July 30, 2010 7:01 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Getting list of loaded drivers
>
>>I imagine a registry entry would still exist somewhere that associated
>>the driver with that now-missing piece of hardware…
>
> Correct.
>
> Running Device Manager with a special env var will allow it to show such
> stale entries, so you can delete them by Uninstall menu item.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> 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
>
>

“M. M. O’Brien” wrote in message
news:xxxxx@ntdev…
> Interesting. What’s the name of the env var?

set DEVMGR_SHOW_NONPRESENT_DEVICES=1

Regards,
–pa

>
> Thanks,
>
> mm
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
> Sent: Friday, July 30, 2010 7:01 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Getting list of loaded drivers
>
>>I imagine a registry entry would still exist somewhere that associated
>>the driver with that now-missing piece of hardware…
>
> Correct.
>
> Running Device Manager with a special env var will allow it to show such
> stale entries, so you can delete them by Uninstall menu item.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> 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
>
>

Thanks, Pavel.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pavel A.
Sent: Saturday, July 31, 2010 10:44 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Getting list of loaded drivers

“M. M. O’Brien” wrote in message
news:xxxxx@ntdev…
> Interesting. What’s the name of the env var?

set DEVMGR_SHOW_NONPRESENT_DEVICES=1

Regards,
–pa

>
> Thanks,
>
> mm
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
> Sent: Friday, July 30, 2010 7:01 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Getting list of loaded drivers
>
>>I imagine a registry entry would still exist somewhere that associated
>>the driver with that now-missing piece of hardware…
>
> Correct.
>
> Running Device Manager with a special env var will allow it to show such
> stale entries, so you can delete them by Uninstall menu item.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> 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
>
>


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

Thanks, Max.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Saturday, July 31, 2010 10:23 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Getting list of loaded drivers

DEVMGR_SHOW_NONPRESENT_DEVICES


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“M. M. O’Brien” wrote in message
news:xxxxx@ntdev…
> Interesting. What’s the name of the env var?
>
>
> Thanks,
>
> mm
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S.
> Shatskih
> Sent: Friday, July 30, 2010 7:01 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Getting list of loaded drivers
>
>>I imagine a registry entry would still exist somewhere that associated
>>the driver with that now-missing piece of hardware…
>
> Correct.
>
> Running Device Manager with a special env var will allow it to show
> such stale entries, so you can delete them by Uninstall menu item.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> 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
>
>


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