https://git.reactos.org/?p=reactos.git;a=commitdiff;h=969de9062c6dc95b5e3c7a66a6c48dc03e03d534

commit 969de9062c6dc95b5e3c7a66a6c48dc03e03d534
Author:     Eric Kohl <[email protected]>
AuthorDate: Sun Dec 30 14:42:12 2018 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Sun Dec 30 14:43:10 2018 +0100

    [UMPNPMGR] PNP_GetDeviceListSize: Implement the buffer size calculation for 
a list of all device instances.
---
 base/services/umpnpmgr/umpnpmgr.c | 41 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/base/services/umpnpmgr/umpnpmgr.c 
b/base/services/umpnpmgr/umpnpmgr.c
index 56faf3be3b..2583d135ef 100644
--- a/base/services/umpnpmgr/umpnpmgr.c
+++ b/base/services/umpnpmgr/umpnpmgr.c
@@ -886,6 +886,41 @@ GetEnumeratorInstanceListSize(
 }
 
 
+static
+CONFIGRET
+GetAllInstanceListSize(
+    _In_ LPCWSTR pszEnumerator,
+    _Out_ PULONG pulLength)
+{
+    WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
+    DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
+    DWORD dwError;
+    CONFIGRET ret = CR_SUCCESS;
+
+    for (dwIndex = 0; ; dwIndex++)
+    {
+        dwEnumeratorLength = MAX_DEVICE_ID_LEN;
+        dwError = RegEnumKeyExW(hEnumKey,
+                                dwIndex,
+                                szEnumeratorBuffer,
+                                &dwEnumeratorLength,
+                                NULL, NULL, NULL, NULL);
+        if (dwError != ERROR_SUCCESS)
+            break;
+
+        /* Get the size of all device instances for the enumerator */
+        ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
+                                            &dwBufferLength);
+        if (ret != CR_SUCCESS)
+            break;
+
+        *pulLength += dwBufferLength;
+    }
+
+    return ret;
+}
+
+
 /* Function 11 */
 DWORD
 WINAPI
@@ -902,7 +937,8 @@ PNP_GetDeviceListSize(
     CONFIGRET ret = CR_SUCCESS;
     NTSTATUS Status;
 
-    DPRINT("PNP_GetDeviceListSize() called\n");
+    DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
+           hBinding, pszFilter, pulLength, ulFlags);
 
     if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
         return CR_INVALID_FLAG;
@@ -980,7 +1016,8 @@ PNP_GetDeviceListSize(
     }
     else /* CM_GETIDLIST_FILTER_NONE */
     {
-        ret = CR_CALL_NOT_IMPLEMENTED;
+        ret = GetAllInstanceListSize(pszFilter,
+                                     pulLength);
     }
 
     /* Add one character for the terminating double UNICODE_NULL */

Reply via email to