Read all installed devices with DIGCF_ALLCLASSES

Hi Kernel Heroes and Heroines,

Hope everyone is doing well today.

Just got quick question, I have been trying to list all installed devices in the system yet not managing to,

when I call

hDevInfo = SetupDiGetClassDevs(NULL, 0, 0, DIGCF_ALLCLASSES);

and then I enumerate with loop through both

SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData)

&&

SetupDiEnumDeviceInterfaces(hDevInfo, &DeviceInfoData, &ClassGUID, i, &deviceInterfaceData);

to get deviceinfodata and deviceInterfaceData for devicepath, and deviceinstanceid and other fields from Device registry property codes.

I don’t get all of the devices installed in system, rather it returns very few, especially I noticed it doesn’t return devices from class Storage devices

so I wondered if there is any way I could list the whole of devices from all classes mentioned here

https://msdn.microsoft.com/en-us/library/windows/hardware/ff541389(v=vs.85).aspx

with one call ? is it possible ? because I managed reading all devices I needed but in two calls to the routine SetupDiGetClassDevs as following,

hDevInfo = SetupDiGetClassDevs(GUID_DEVINTERFACE_DISK, 0, 0, DIGCF_DEVICEINTERFACE);

hDevInfo = SetupDiGetClassDevs(GUID_DEVINTERFACE_STORAGEPORT, 0, 0, DIGCF_DEVICEINTERFACE);

As you notice both storageport and disk classes are part of Storage devices class,

so at the very worst scenario is it possible to list at least list all devices associated with Storage devices class .

Looking forward & thanks in advance.

Zakaria .

You can’t generically find all device interfaces and their paths. You need to know each guid. You can iterate over the entire device tree and find all the generic properties (hw id, instance id, etc). The CM_Xxxx APIs might be better suited for that.

d

Bent from my phone


From: xxxxx@micron.commailto:xxxxx
Sent: ?5/?6/?2015 5:46 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] Read all installed devices with DIGCF_ALLCLASSES

Hi Kernel Heroes and Heroines,

Hope everyone is doing well today.

Just got quick question, I have been trying to list all installed devices in the system yet not managing to,

when I call

hDevInfo = SetupDiGetClassDevs(NULL, 0, 0, DIGCF_ALLCLASSES);

and then I enumerate with loop through both

SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData)

&&

SetupDiEnumDeviceInterfaces(hDevInfo, &DeviceInfoData, &ClassGUID, i, &deviceInterfaceData);

to get deviceinfodata and deviceInterfaceData for devicepath, and deviceinstanceid and other fields from Device registry property codes.

I don’t get all of the devices installed in system, rather it returns very few, especially I noticed it doesn’t return devices from class Storage devices

so I wondered if there is any way I could list the whole of devices from all classes mentioned here

https://msdn.microsoft.com/en-us/library/windows/hardware/ff541389(v=vs.85).aspx

with one call ? is it possible ? because I managed reading all devices I needed but in two calls to the routine SetupDiGetClassDevs as following,

hDevInfo = SetupDiGetClassDevs(GUID_DEVINTERFACE_DISK, 0, 0, DIGCF_DEVICEINTERFACE);

hDevInfo = SetupDiGetClassDevs(GUID_DEVINTERFACE_STORAGEPORT, 0, 0, DIGCF_DEVICEINTERFACE);

As you notice both storageport and disk classes are part of Storage devices class,

so at the very worst scenario is it possible to list at least list all devices associated with Storage devices class .

Looking forward & thanks in advance.

Zakaria .


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Thanks

xxxxx@micron.com wrote:

Hi Kernel Heroes and Heroines,

Hope everyone is doing well today.

Just got quick question, I have been trying to list all installed devices in the system yet not managing to,

when I call

hDevInfo = SetupDiGetClassDevs(NULL, 0, 0, DIGCF_ALLCLASSES);

Remember that DIGCF_ALLCLASSES is different than
DIGCF_ALLCLASSES|DIGCF_DEVICEINTERFACE. You would think that “ALL”
would have a universal meaning, but it’s not necessarily so. They
enumerate different lists.


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