Avoid attempts to reinstall a driver on reboot when a previous attempt has already...
authorEric Kohl <eric.kohl@reactos.org>
Mon, 17 Apr 2017 11:34:08 +0000 (11:34 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 17 Apr 2017 11:34:08 +0000 (11:34 +0000)
[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
reactos/dll/win32/newdev/wizard.c

index 35c3911..9bc4e4b 100644 (file)
@@ -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);
     }
 
index 81f06f9..640a43e 100644 (file)
@@ -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,