https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d25869e0e7853179c13e…
commit 4d25869e0e7853179c13e4e28e5178289c3e3f06
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Wed Apr 7 19:26:06 2021 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Wed Apr 7 19:35:50 2021 +0200
[SYSSETUP] Manually start PlugPlay service, and wait for it before continuing
That way, class installers are already registered before installing devices.
CORE-17538
---
boot/bootdata/hivesys.inf | 2 +-
dll/win32/syssetup/install.c | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/boot/bootdata/hivesys.inf b/boot/bootdata/hivesys.inf
index 7dc2c1141fd..fc218fed6a6 100644
--- a/boot/bootdata/hivesys.inf
+++ b/boot/bootdata/hivesys.inf
@@ -1995,7 +1995,7 @@
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ErrorControl",0x00010001,0x00
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Group",0x00000000,"PlugPlay"
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe
-k DcomLaunch"
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ObjectName",0x00000000,"LocalSystem"
-HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Start",0x00010001,0x00000002
+HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Start",0x00010001,0x00000003
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Type",0x00010001,0x00000020
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\umpnpmgr.dll"
diff --git a/dll/win32/syssetup/install.c b/dll/win32/syssetup/install.c
index f0ce192f498..ba8fd226b64 100644
--- a/dll/win32/syssetup/install.c
+++ b/dll/win32/syssetup/install.c
@@ -486,7 +486,9 @@ EnableUserModePnpManager(VOID)
{
SC_HANDLE hSCManager = NULL;
SC_HANDLE hService = NULL;
+ SERVICE_STATUS_PROCESS ServiceStatus;
BOOL bRet = FALSE;
+ DWORD BytesNeeded, WaitTime;
hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);
if (hSCManager == NULL)
@@ -498,7 +500,7 @@ EnableUserModePnpManager(VOID)
hService = OpenServiceW(hSCManager,
L"PlugPlay",
- SERVICE_CHANGE_CONFIG | SERVICE_START);
+ SERVICE_CHANGE_CONFIG | SERVICE_START |
SERVICE_QUERY_STATUS);
if (hService == NULL)
{
DPRINT1("Unable to open PlugPlay service\n");
@@ -524,6 +526,35 @@ EnableUserModePnpManager(VOID)
goto cleanup;
}
+ while (TRUE)
+ {
+ bRet = QueryServiceStatusEx(hService,
+ SC_STATUS_PROCESS_INFO,
+ (LPBYTE)&ServiceStatus,
+ sizeof(ServiceStatus),
+ &BytesNeeded);
+ if (!bRet)
+ {
+ DPRINT1("QueryServiceStatusEx() failed for PlugPlay service (error
0x%x)\n", GetLastError());
+ goto cleanup;
+ }
+
+ if (ServiceStatus.dwCurrentState != SERVICE_START_PENDING)
+ break;
+
+ WaitTime = ServiceStatus.dwWaitHint / 10;
+ if (WaitTime < 1000) WaitTime = 1000;
+ else if (WaitTime > 10000) WaitTime = 10000;
+ Sleep(WaitTime);
+ };
+
+ if (ServiceStatus.dwCurrentState != SERVICE_RUNNING)
+ {
+ bRet = FALSE;
+ DPRINT1("Failed to start PlugPlay service\n");
+ goto cleanup;
+ }
+
bRet = TRUE;
cleanup: