https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eede1b9b7a258a9094cafef5615b9ed8c3877081
commit eede1b9b7a258a9094cafef5615b9ed8c3877081 Author: Bișoc George <[email protected]> AuthorDate: Wed Jun 19 17:51:11 2019 +0200 Commit: Hermès Bélusca-Maïto <[email protected]> CommitDate: Sun Jul 21 19:02:53 2019 +0200 [UMPNPMGR] Implement registry functions for SuppressUI and SuppressNewHWUI handling. (#1683) CORE-15897 Co-authored-by: Hermès Bélusca-Maïto <[email protected]> --- base/services/umpnpmgr/install.c | 11 +++++- base/services/umpnpmgr/precomp.h | 8 +++- base/services/umpnpmgr/umpnpmgr.c | 81 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 3 deletions(-) diff --git a/base/services/umpnpmgr/install.c b/base/services/umpnpmgr/install.c index 2f3bdfd1050..4c876e490ef 100644 --- a/base/services/umpnpmgr/install.c +++ b/base/services/umpnpmgr/install.c @@ -340,6 +340,15 @@ cleanup: } +FORCEINLINE +BOOL +IsUISuppressionAllowed(VOID) +{ + /* Display the newdev.dll wizard UI only if it's allowed */ + return (g_IsUISuppressed || GetSuppressNewUIValue()); +} + + /* Loop to install all queued devices installations */ DWORD WINAPI @@ -368,7 +377,7 @@ DeviceInstallThread(LPVOID lpParameter) { ResetEvent(hNoPendingInstalls); Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry); - InstallDevice(Params->DeviceIds, showWizard); + InstallDevice(Params->DeviceIds, showWizard && !IsUISuppressionAllowed()); HeapFree(GetProcessHeap(), 0, Params); } } diff --git a/base/services/umpnpmgr/precomp.h b/base/services/umpnpmgr/precomp.h index 3c51aa47b21..f7d7b4f9f72 100644 --- a/base/services/umpnpmgr/precomp.h +++ b/base/services/umpnpmgr/precomp.h @@ -39,7 +39,6 @@ typedef struct WCHAR DeviceIds[1]; } DeviceInstallParams; - /* install.c */ extern HANDLE hUserToken; @@ -52,6 +51,10 @@ extern HANDLE hDeviceInstallListNotEmpty; BOOL SetupIsActive(VOID); +FORCEINLINE +BOOL +IsUISuppressionAllowed(VOID); + DWORD WINAPI DeviceInstallThread( @@ -70,6 +73,9 @@ RpcServerThread( extern HKEY hEnumKey; extern HKEY hClassKey; +extern BOOL g_IsUISuppressed; +BOOL +GetSuppressNewUIValue(VOID); #endif /* _UMPNPMGR_PCH_ */ \ No newline at end of file diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 7aa64813c75..0195f73813c 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -43,7 +43,7 @@ static SERVICE_STATUS ServiceStatus; HKEY hEnumKey = NULL; HKEY hClassKey = NULL; - +BOOL g_IsUISuppressed = FALSE; /* FUNCTIONS *****************************************************************/ @@ -268,6 +268,77 @@ ServiceControlHandler(DWORD dwControl, } } +static DWORD +GetBooleanRegValue( + IN HKEY hKey, + IN PCWSTR lpSubKey, + IN PCWSTR lpValue, + OUT PBOOL pValue) +{ + DWORD dwError, dwType, dwData; + DWORD cbData = sizeof(dwData); + HKEY hSubKey = NULL; + + /* Default value */ + *pValue = FALSE; + + dwError = RegOpenKeyExW(hKey, + lpSubKey, + 0, + KEY_READ, + &hSubKey); + if (dwError != ERROR_SUCCESS) + { + DPRINT("GetBooleanRegValue(): RegOpenKeyExW() has failed to open '%S' key! (Error: %lu)\n", + lpSubKey, dwError); + return dwError; + } + + dwError = RegQueryValueExW(hSubKey, + lpValue, + 0, + &dwType, + (PBYTE)&dwData, + &cbData); + if (dwError != ERROR_SUCCESS) + { + DPRINT("GetBooleanRegValue(): RegQueryValueExW() has failed to query '%S' value! (Error: %lu)\n", + lpValue, dwError); + goto Cleanup; + } + if (dwType != REG_DWORD) + { + DPRINT("GetBooleanRegValue(): The value is not of REG_DWORD type!\n"); + goto Cleanup; + } + + /* Return the value */ + *pValue = (dwData == 1); + +Cleanup: + RegCloseKey(hSubKey); + + return dwError; +} + +BOOL +GetSuppressNewUIValue(VOID) +{ + BOOL bSuppressNewHWUI = FALSE; + + /* + * Query the SuppressNewHWUI policy registry value. Don't cache it + * as we want to update our behaviour in consequence. + */ + GetBooleanRegValue(HKEY_LOCAL_MACHINE, + L"Software\\Policies\\Microsoft\\Windows\\DeviceInstall\\Settings", + L"SuppressNewHWUI", + &bSuppressNewHWUI); + if (bSuppressNewHWUI) + DPRINT("GetSuppressNewUIValue(): newdev.dll's wizard UI won't be shown!\n"); + + return bSuppressNewHWUI; +} VOID WINAPI ServiceMain(DWORD argc, LPTSTR *argv) @@ -363,6 +434,14 @@ InitializePnPManager(VOID) InitializeSListHead(&DeviceInstallListHead); + /* Query the SuppressUI registry value and cache it for our whole lifetime */ + GetBooleanRegValue(HKEY_LOCAL_MACHINE, + L"System\\CurrentControlSet\\Services\\PlugPlay\\Parameters", + L"SuppressUI", + &g_IsUISuppressed); + if (g_IsUISuppressed) + DPRINT("UMPNPMGR: newdev.dll's wizard UI won't be shown!\n"); + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Enum", 0,
