From dd0e23b69135a64ef8bd9504d635c76082befc6c Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 17 Apr 2017 11:34:08 +0000 Subject: [PATCH] Avoid attempts to reinstall a driver on reboot when a previous attempt has already failed. [NEWDEV] Set the CONFIGFLAG_FAILEDINSTALL flag in the new hardware wizards welcome page and remove it only when the driver was successfully installed. [UMPNPMGR] Do not invoke the device installer if the devices CONFIGFLAG_FAILEDINSTALL flag is set. svn path=/trunk/; revision=74348 --- reactos/base/services/umpnpmgr/umpnpmgr.c | 18 ++++++++- reactos/dll/win32/newdev/wizard.c | 49 ++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index 35c3911a474..9bc4e4b3f15 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -21,7 +21,7 @@ * PROJECT: ReactOS kernel * FILE: base/services/umpnpmgr/umpnpmgr.c * PURPOSE: User-mode Plug and Play manager - * PROGRAMMER: Eric Kohl + * PROGRAMMER: Eric Kohl (eric.kohl@reactos.org) * Hervé Poussineau (hpoussin@reactos.org) * Colin Finck (colin@reactos.org) */ @@ -3230,6 +3230,22 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) return TRUE; } + BytesWritten = sizeof(DWORD); + if (RegQueryValueExW(DeviceKey, + L"ConfigFlags", + NULL, + NULL, + (PBYTE)&Value, + &BytesWritten) == ERROR_SUCCESS) + { + if (Value & CONFIGFLAG_FAILEDINSTALL) + { + DPRINT("No need to install: %S\n", DeviceInstance); + RegCloseKey(DeviceKey); + return TRUE; + } + } + RegCloseKey(DeviceKey); } diff --git a/reactos/dll/win32/newdev/wizard.c b/reactos/dll/win32/newdev/wizard.c index 81f06f9e6e9..640a43e1b63 100644 --- a/reactos/dll/win32/newdev/wizard.c +++ b/reactos/dll/win32/newdev/wizard.c @@ -51,6 +51,44 @@ CenterWindow( SWP_NOSIZE); } +static BOOL +SetFailedInstall( + IN HDEVINFO DeviceInfoSet, + IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, + IN BOOLEAN Set) +{ + DWORD dwType, dwSize, dwFlags = 0; + + dwSize = sizeof(dwFlags); + if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet, + DevInfoData, + SPDRP_CONFIGFLAGS, + &dwType, + (PBYTE)&dwFlags, + dwSize, + &dwSize)) + { + return FALSE; + } + + if (Set) + dwFlags |= CONFIGFLAG_FAILEDINSTALL; + else + dwFlags &= ~CONFIGFLAG_FAILEDINSTALL; + + if (!SetupDiSetDeviceRegistryProperty(DeviceInfoSet, + DevInfoData, + SPDRP_CONFIGFLAGS, + (PBYTE)&dwFlags, + dwSize)) + { + + return FALSE; + } + + return TRUE; +} + static BOOL CanDisableDevice( IN DEVINST DevInst, @@ -462,6 +500,10 @@ WelcomeDlgProc( BM_SETCHECK, (WPARAM)TRUE, (LPARAM)0); + + SetFailedInstall(DevInstData->hDevInfo, + &DevInstData->devInfoData, + TRUE); break; } @@ -807,8 +849,13 @@ InstallDrvDlgProc( hThread = 0; if (wParam == 0) { - /* Should we reboot? */ SP_DEVINSTALL_PARAMS installParams; + + SetFailedInstall(DevInstData->hDevInfo, + &DevInstData->devInfoData, + FALSE); + + /* Should we reboot? */ installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); if (SetupDiGetDeviceInstallParams( DevInstData->hDevInfo,