From d8bfa93f2167bd7f58d72e567ce704ff494e5ce7 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 20 Jun 2025 20:50:18 +0200 Subject: [PATCH] [DEVMGR] Fix reading the device resource lists For each device we must first try to read its AllocConfig resource list. If its AllocConfig resource list is not available, try to read its BootConfig resource list. --- dll/win32/devmgr/properties/hwresource.cpp | 62 ++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/dll/win32/devmgr/properties/hwresource.cpp b/dll/win32/devmgr/properties/hwresource.cpp index 980315da511..4a15a737644 100644 --- a/dll/win32/devmgr/properties/hwresource.cpp +++ b/dll/win32/devmgr/properties/hwresource.cpp @@ -209,9 +209,9 @@ ResourcesProcDriverDlgProc(IN HWND hwndDlg, return Ret; } - -PVOID -GetResourceList( +static +PCM_RESOURCE_LIST +GetAllocatedResourceList( LPWSTR pszDeviceID) { PCM_RESOURCE_LIST pResourceList = NULL; @@ -249,5 +249,61 @@ done: if (hKey != NULL) RegCloseKey(hKey); + return pResourceList; +} + +static +PCM_RESOURCE_LIST +GetBootResourceList( + LPWSTR pszDeviceID) +{ + PCM_RESOURCE_LIST pResourceList = NULL; + HKEY hKey = NULL; + DWORD dwError, dwSize; + + CStringW keyName = L"SYSTEM\\CurrentControlSet\\Enum\\"; + keyName += pszDeviceID; + keyName += L"\\LogConf"; + + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &hKey); + if (dwError != ERROR_SUCCESS) + { + /* failed to open device instance log conf dir */ + return NULL; + } + + dwSize = 0; + RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, NULL, &dwSize); + if (dwSize == 0) + goto done; + + pResourceList = static_cast(HeapAlloc(GetProcessHeap(), 0, dwSize)); + if (pResourceList == NULL) + goto done; + + dwError = RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, (LPBYTE)pResourceList, &dwSize); + if (dwError != ERROR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, pResourceList); + pResourceList = NULL; + } + +done: + if (hKey != NULL) + RegCloseKey(hKey); + + return pResourceList; +} + +PVOID +GetResourceList( + LPWSTR pszDeviceID) +{ + PCM_RESOURCE_LIST pResourceList = NULL; + + pResourceList = GetAllocatedResourceList(pszDeviceID); + if (pResourceList == NULL) + pResourceList = GetBootResourceList(pszDeviceID); + return (PVOID)pResourceList; }