[DEVMGR] Get rid of the unknown device class hack

Treat the unknown device class like any other device class.

CORE-17527
This commit is contained in:
Eric Kohl 2021-04-16 23:45:08 +02:00
parent 7d77ec28f7
commit 9e947e2b2b

View file

@ -351,23 +351,11 @@ CDeviceView::GetNextClass(
if (cr != CR_SUCCESS) if (cr != CR_SUCCESS)
return false; return false;
// Check if this is the unknown class // We only want the devices for this class
if (IsEqualGUID(*ClassGuid, GUID_DEVCLASS_UNKNOWN)) *hDevInfo = SetupDiGetClassDevsW(ClassGuid,
{ NULL,
// Get device info for all devices NULL,
*hDevInfo = SetupDiGetClassDevsW(NULL, DIGCF_PRESENT);
NULL,
NULL,
DIGCF_ALLCLASSES);
}
else
{
// We only want the devices for this class
*hDevInfo = SetupDiGetClassDevsW(ClassGuid,
NULL,
NULL,
DIGCF_PRESENT);
}
return (hDevInfo != INVALID_HANDLE_VALUE); return (hDevInfo != INVALID_HANDLE_VALUE);
} }
@ -449,7 +437,6 @@ CDeviceView::ListDevicesByType()
bClassSuccess = GetNextClass(ClassIndex, &ClassGuid, &hDevInfo); bClassSuccess = GetNextClass(ClassIndex, &ClassGuid, &hDevInfo);
if (bClassSuccess) if (bClassSuccess)
{ {
bool bClassUnknown = false;
bool AddedParent = false; bool AddedParent = false;
INT DeviceIndex = 0; INT DeviceIndex = 0;
bool MoreItems = false; bool MoreItems = false;
@ -462,10 +449,6 @@ CDeviceView::ListDevicesByType()
continue; continue;
} }
// Set a flag is this is the (special case) unknown class
if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_UNKNOWN))
bClassUnknown = true;
// Check if this is a hidden class // Check if this is a hidden class
if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_LEGACYDRIVER) || if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_LEGACYDRIVER) ||
IsEqualGUID(ClassGuid, GUID_DEVCLASS_VOLUME)) IsEqualGUID(ClassGuid, GUID_DEVCLASS_VOLUME))
@ -494,18 +477,6 @@ CDeviceView::ListDevicesByType()
{ {
MoreItems = true; MoreItems = true;
// The unknown class handle contains all devices on the system,
// and we're just looking for the ones with a null GUID
if (bClassUnknown)
{
if (IsEqualGUID(DeviceInfoData.ClassGuid, GUID_NULL) == FALSE)
{
// This is a known device, we aren't interested in it
DeviceIndex++;
continue;
}
}
// Get the cached device node // Get the cached device node
DeviceNode = GetDeviceNode(DeviceInfoData.DevInst); DeviceNode = GetDeviceNode(DeviceInfoData.DevInst);
if (DeviceNode == nullptr) if (DeviceNode == nullptr)