https://git.reactos.org/?p=reactos.git;a=commitdiff;h=16a4fc76de304184a2942…
commit 16a4fc76de304184a2942e99a90936c6abf2d4bb
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Mon Apr 13 12:33:58 2020 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Mon Apr 13 12:33:58 2020 +0200
[DEVMGR] Do not add the 'Resources' page to the device properties if the
device does not have any resources
---
dll/win32/devmgr/properties/advprop.cpp | 9 ++++-
dll/win32/devmgr/properties/hwresource.cpp | 64 +++++++++++++++++++-----------
dll/win32/devmgr/properties/properties.h | 5 +++
3 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/dll/win32/devmgr/properties/advprop.cpp
b/dll/win32/devmgr/properties/advprop.cpp
index 8df086fe4ba..27cd2faad2a 100644
--- a/dll/win32/devmgr/properties/advprop.cpp
+++ b/dll/win32/devmgr/properties/advprop.cpp
@@ -2517,6 +2517,8 @@ GetParentNode:
nDriverPages = 0;
}
+ dap->pResourceList = GetResourceList(dap->szDeviceID);
+
/* include the driver page */
if (dap->HasDriverPage)
dap->nDevPropSheets++;
@@ -2525,7 +2527,7 @@ GetParentNode:
if (dap->Extended)
dap->nDevPropSheets++;
- if (dap->HasResourcePage)
+ if (dap->HasResourcePage && dap->pResourceList != NULL)
dap->nDevPropSheets++;
/* add the device property sheets */
@@ -2627,7 +2629,7 @@ GetParentNode:
}
}
- if (dap->HasResourcePage)
+ if (dap->HasResourcePage && dap->pResourceList)
{
PROPSHEETPAGE pspDriver = {0};
pspDriver.dwSize = sizeof(PROPSHEETPAGE);
@@ -3060,6 +3062,9 @@ Cleanup:
DestroyIcon(DevAdvPropInfo->hDevIcon);
}
+ if (DevAdvPropInfo->pResourceList != NULL)
+ HeapFree(GetProcessHeap(), 0, DevAdvPropInfo->pResourceList);
+
HeapFree(GetProcessHeap(),
0,
DevAdvPropInfo);
diff --git a/dll/win32/devmgr/properties/hwresource.cpp
b/dll/win32/devmgr/properties/hwresource.cpp
index 2455544f48c..76879042415 100644
--- a/dll/win32/devmgr/properties/hwresource.cpp
+++ b/dll/win32/devmgr/properties/hwresource.cpp
@@ -244,34 +244,12 @@ AddResourceItems(
IN PDEVADVPROP_INFO dap,
IN HWND hWndDevList)
{
- HKEY hKey;
WCHAR szBuffer[100];
WCHAR szDetail[100];
- BYTE szData[512];
- DWORD dwSize;
PCM_RESOURCE_LIST ResourceList;
- LONG Result;
ULONG ItemCount = 0, Index;
- wsprintf(szBuffer, L"SYSTEM\\CurrentControlSet\\Enum\\%s\\LogConf",
dap->szDeviceID);
- Result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, KEY_READ, &hKey);
- if (Result != ERROR_SUCCESS)
- {
- /* failed to open device instance log conf dir */
- return;
- }
-
- dwSize = sizeof(szData);
- Result = RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, szData,
&dwSize);
-
- RegCloseKey(hKey);
- if (Result != ERROR_SUCCESS)
- {
- /* failed to query resources */
- return;
- }
-
- ResourceList = (PCM_RESOURCE_LIST)szData;
+ ResourceList = (PCM_RESOURCE_LIST)dap->pResourceList;
for (Index = 0; Index < ResourceList->List[0].PartialResourceList.Count;
Index++)
{
@@ -374,3 +352,43 @@ ResourcesProcDriverDlgProc(IN HWND hwndDlg,
return Ret;
}
+
+PVOID
+GetResourceList(
+ LPWSTR pszDeviceID)
+{
+ WCHAR szBuffer[100];
+ PCM_RESOURCE_LIST pResourceList = NULL;
+ HKEY hKey = NULL;
+ DWORD dwError, dwSize;
+
+ wsprintf(szBuffer, L"SYSTEM\\CurrentControlSet\\Enum\\%s\\LogConf",
pszDeviceID);
+ dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 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<PCM_RESOURCE_LIST>(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 (PVOID)pResourceList;
+}
diff --git a/dll/win32/devmgr/properties/properties.h
b/dll/win32/devmgr/properties/properties.h
index 9a7f135450b..e664ad0a513 100644
--- a/dll/win32/devmgr/properties/properties.h
+++ b/dll/win32/devmgr/properties/properties.h
@@ -53,6 +53,7 @@ typedef struct _DEVADVPROP_INFO
};
};
+ PVOID pResourceList;
WCHAR szDevName[255];
WCHAR szTemp[255];
WCHAR szDeviceID[1];
@@ -79,6 +80,10 @@ ResourcesProcDriverDlgProc(IN HWND hwndDlg,
IN WPARAM wParam,
IN LPARAM lParam);
+PVOID
+GetResourceList(
+ _In_ LPWSTR pszDeviceID);
+
/* ADVPROP.C */
INT_PTR