From 420c4a7abfe14decc624aa9626e8871c9de267e6 Mon Sep 17 00:00:00 2001 From: Victor Perevertkin Date: Fri, 19 Mar 2021 08:59:42 +0300 Subject: [PATCH] [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) {