[UMPNPMGR] PNP_GetDeviceListSize: Implement the buffer size calculation for a list...
authorEric Kohl <eric.kohl@reactos.org>
Sun, 30 Dec 2018 13:42:12 +0000 (14:42 +0100)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 30 Dec 2018 13:43:10 +0000 (14:43 +0100)
base/services/umpnpmgr/umpnpmgr.c

index 56faf3b..2583d13 100644 (file)
@@ -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 */