Reactos

[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.

Eric Kohl d8bfa93f 8aab5a9b

+59 -3
+59 -3
dll/win32/devmgr/properties/hwresource.cpp
··· 209 209 return Ret; 210 210 } 211 211 212 - 213 - PVOID 214 - GetResourceList( 212 + static 213 + PCM_RESOURCE_LIST 214 + GetAllocatedResourceList( 215 215 LPWSTR pszDeviceID) 216 216 { 217 217 PCM_RESOURCE_LIST pResourceList = NULL; ··· 248 248 done: 249 249 if (hKey != NULL) 250 250 RegCloseKey(hKey); 251 + 252 + return pResourceList; 253 + } 254 + 255 + static 256 + PCM_RESOURCE_LIST 257 + GetBootResourceList( 258 + LPWSTR pszDeviceID) 259 + { 260 + PCM_RESOURCE_LIST pResourceList = NULL; 261 + HKEY hKey = NULL; 262 + DWORD dwError, dwSize; 263 + 264 + CStringW keyName = L"SYSTEM\\CurrentControlSet\\Enum\\"; 265 + keyName += pszDeviceID; 266 + keyName += L"\\LogConf"; 267 + 268 + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &hKey); 269 + if (dwError != ERROR_SUCCESS) 270 + { 271 + /* failed to open device instance log conf dir */ 272 + return NULL; 273 + } 274 + 275 + dwSize = 0; 276 + RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, NULL, &dwSize); 277 + if (dwSize == 0) 278 + goto done; 279 + 280 + pResourceList = static_cast<PCM_RESOURCE_LIST>(HeapAlloc(GetProcessHeap(), 0, dwSize)); 281 + if (pResourceList == NULL) 282 + goto done; 283 + 284 + dwError = RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, (LPBYTE)pResourceList, &dwSize); 285 + if (dwError != ERROR_SUCCESS) 286 + { 287 + HeapFree(GetProcessHeap(), 0, pResourceList); 288 + pResourceList = NULL; 289 + } 290 + 291 + done: 292 + if (hKey != NULL) 293 + RegCloseKey(hKey); 294 + 295 + return pResourceList; 296 + } 297 + 298 + PVOID 299 + GetResourceList( 300 + LPWSTR pszDeviceID) 301 + { 302 + PCM_RESOURCE_LIST pResourceList = NULL; 303 + 304 + pResourceList = GetAllocatedResourceList(pszDeviceID); 305 + if (pResourceList == NULL) 306 + pResourceList = GetBootResourceList(pszDeviceID); 251 307 252 308 return (PVOID)pResourceList; 253 309 }