[DEVMGR] Do not add the 'Resources' page to the device properties if the device does not have any resources

This commit is contained in:
Eric Kohl 2020-04-13 12:33:58 +02:00
parent 1ca7d5d948
commit 16a4fc76de
3 changed files with 53 additions and 25 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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