https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e044df87366d52fa5dfce…
commit e044df87366d52fa5dfce50e994e3d8e2a2965c7
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sun Apr 11 15:10:47 2021 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sun Apr 11 15:12:02 2021 +0200
[SETUPAPI] Correctly enumerate non-installed devices in SetupDiGetClassDevsExW
Always try to read the correct device GUID from registry, even if GUID filter is
disabled.
CORE-17527
---
dll/win32/setupapi/devclass.c | 51 ++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/dll/win32/setupapi/devclass.c b/dll/win32/setupapi/devclass.c
index 56398262437..61aa7eb8329 100644
--- a/dll/win32/setupapi/devclass.c
+++ b/dll/win32/setupapi/devclass.c
@@ -179,38 +179,35 @@ SETUP_CreateDevicesList(
}
/* Retrieve GUID of this device */
- if (Class)
+ ClassGuidBufferSize = sizeof(ClassGuidBuffer);
+ cr = CM_Get_DevNode_Registry_Property_ExW(dnDevInst,
+ CM_DRP_CLASSGUID,
+ NULL,
+ ClassGuidBuffer,
+ &ClassGuidBufferSize,
+ 0,
+ list->hMachine);
+ if (cr == CR_SUCCESS)
{
- ClassGuidBufferSize = sizeof(ClassGuidBuffer);
- cr = CM_Get_DevNode_Registry_Property_ExW(dnDevInst,
- CM_DRP_CLASSGUID,
- NULL,
- ClassGuidBuffer,
- &ClassGuidBufferSize,
- 0,
- list->hMachine);
- if (cr == CR_SUCCESS)
+ ClassGuidBuffer[MAX_GUID_STRING_LEN - 2] = '\0'; /* Replace the } by
a NULL character */
+ if (UuidFromStringW(&ClassGuidBuffer[1], &ClassGuid) != RPC_S_OK)
{
- ClassGuidBuffer[MAX_GUID_STRING_LEN - 2] = '\0'; /* Replace the }
by a NULL character */
- if (UuidFromStringW(&ClassGuidBuffer[1], &ClassGuid) !=
RPC_S_OK)
- {
- /* Bad GUID, skip the entry */
- ERR("Invalid ClassGUID '%S' for device %S\n",
ClassGuidBuffer, InstancePath);
- continue;
- }
- }
- else
- {
- TRACE("Using default class GUID_NULL for device %S\n",
InstancePath);
- memcpy(&ClassGuid, &GUID_NULL, sizeof(GUID));
- }
-
- if (!IsEqualIID(&ClassGuid, Class))
- {
- TRACE("Skipping %S due to wrong class GUID\n", InstancePath);
+ /* Bad GUID, skip the entry */
+ ERR("Invalid ClassGUID '%S' for device %S\n",
ClassGuidBuffer, InstancePath);
continue;
}
}
+ else
+ {
+ TRACE("Using default class GUID_NULL for device %S\n",
InstancePath);
+ memcpy(&ClassGuid, &GUID_NULL, sizeof(GUID));
+ }
+
+ if (Class && !IsEqualIID(&ClassGuid, Class))
+ {
+ TRACE("Skipping %S due to wrong class GUID\n", InstancePath);
+ continue;
+ }
/* Good! Create a device info element */
if (!CreateDeviceInfo(list, InstancePath, &ClassGuid, &deviceInfo))