https://git.reactos.org/?p=reactos.git;a=commitdiff;h=420c4a7abfe14decc624aa9626e8871c9de267e6

commit 420c4a7abfe14decc624aa9626e8871c9de267e6
Author:     Victor Perevertkin <[email protected]>
AuthorDate: Fri Mar 19 08:59:42 2021 +0300
Commit:     Victor Perevertkin <[email protected]>
CommitDate: Fri Mar 19 08:59:42 2021 +0300

    [UMPNPMGR] Install drivers for all devices available on boot
    
    Don't wait for their events to appear, just retrieve the list and
    install drivers. This fixes the installation of manually reported device
    nodes
    
    CORE-17212 CORE-17398
---
 base/services/umpnpmgr/install.c | 55 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)

diff --git a/base/services/umpnpmgr/install.c b/base/services/umpnpmgr/install.c
index 80ef8258900..afe3c9fc0ca 100644
--- a/base/services/umpnpmgr/install.c
+++ b/base/services/umpnpmgr/install.c
@@ -358,13 +358,64 @@ DeviceInstallThread(LPVOID lpParameter)
 {
     PLIST_ENTRY ListEntry;
     DeviceInstallParams* Params;
-    BOOL showWizard;
 
     UNREFERENCED_PARAMETER(lpParameter);
 
+    // Step 1: install all drivers which were configured during the boot
+
+    DPRINT("Step 1: Installing devices configured during the boot\n");
+
+    PWSTR deviceList;
+
+    while (TRUE)
+    {
+        UINT32 devListSize;
+        DWORD status = PNP_GetDeviceListSize(NULL, NULL, &devListSize, 0);
+        if (status != CR_SUCCESS)
+        {
+            goto Step2;
+        }
+
+        deviceList = HeapAlloc(GetProcessHeap(), 0, devListSize * 
sizeof(WCHAR));
+        if (!deviceList)
+        {
+            goto Step2;
+        }
+
+        status = PNP_GetDeviceList(NULL, NULL, deviceList, &devListSize, 0);
+        if (status == CR_BUFFER_SMALL)
+        {
+            HeapFree(GetProcessHeap(), 0, deviceList);
+        }
+        else if (status != CR_SUCCESS)
+        {
+            DPRINT1("PNP_GetDeviceList failed with error %u\n", status);
+            goto Cleanup;
+        }
+        else // status == CR_SUCCESS
+        {
+            break;
+        }
+    }
+
+    for (PWSTR currentDev = deviceList;
+         currentDev[0] != UNICODE_NULL;
+         currentDev += lstrlenW(currentDev) + 1)
+    {
+        InstallDevice(currentDev, FALSE);
+    }
+
+Cleanup:
+    HeapFree(GetProcessHeap(), 0, deviceList);
+
+    // Step 2: start the wait-loop for newly added devices
+Step2:
+
+    DPRINT("Step 2: Starting the wait-loop\n");
+
     WaitForSingleObject(hInstallEvent, INFINITE);
 
-    showWizard = !SetupIsActive() && !IsConsoleBoot();
+    BOOL showWizard = !SetupIsActive() && !IsConsoleBoot();
 
     while (TRUE)
     {

Reply via email to