From 88116276ee4e4e1eae90094a7cbd6de952f83262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 20 Dec 2014 03:12:23 +0000 Subject: [PATCH] [SERVICES]: Do not use GetSystemMetrics to retrieve SafeBoot option value, but instead use directly the registry (as it is done just after...). svn path=/trunk/; revision=65753 --- reactos/base/system/services/database.c | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/reactos/base/system/services/database.c b/reactos/base/system/services/database.c index 476c627800f..cc2749a7d71 100644 --- a/reactos/base/system/services/database.c +++ b/reactos/base/system/services/database.c @@ -1774,13 +1774,15 @@ done: VOID ScmAutoStartServices(VOID) { - DWORD dwError = ERROR_SUCCESS; + DWORD dwError; PLIST_ENTRY GroupEntry; PLIST_ENTRY ServiceEntry; PSERVICE_GROUP CurrentGroup; PSERVICE CurrentService; WCHAR szSafeBootServicePath[MAX_PATH]; + DWORD SafeBootEnabled; HKEY hKey; + DWORD dwKeySize; ULONG i; /* @@ -1789,6 +1791,30 @@ ScmAutoStartServices(VOID) */ ASSERT(ScmInitialize); + /* + * Retrieve the SafeBoot parameter. + */ + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", + 0, + KEY_READ, + &hKey); + if (dwError == ERROR_SUCCESS) + { + dwKeySize = sizeof(SafeBootEnabled); + dwError = RegQueryValueExW(hKey, + L"OptionValue", + 0, + NULL, + (LPBYTE)&SafeBootEnabled, + &dwKeySize); + RegCloseKey(hKey); + } + + /* Default to Normal boot if the value doesn't exist */ + if (dwError != ERROR_SUCCESS) + SafeBootEnabled = 0; + /* Acquire the service control critical section, to synchronize starts */ EnterCriticalSection(&ControlServiceCriticalSection); @@ -1802,7 +1828,7 @@ ScmAutoStartServices(VOID) wcscpy(szSafeBootServicePath, L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot"); - switch (GetSystemMetrics(SM_CLEANBOOT)) + switch (SafeBootEnabled) { /* NOTE: Assumes MINIMAL (1) and DSREPAIR (3) load same items */ case 1: @@ -1815,7 +1841,7 @@ ScmAutoStartServices(VOID) break; } - if (GetSystemMetrics(SM_CLEANBOOT)) + if (SafeBootEnabled != 0) { /* If key does not exist then do not assume safe mode */ dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, @@ -2028,14 +2054,13 @@ ScmInitNamedPipeCriticalSection(VOID) &hKey); if (dwError == ERROR_SUCCESS) { - dwKeySize = sizeof(DWORD); + dwKeySize = sizeof(PipeTimeout); RegQueryValueExW(hKey, L"ServicesPipeTimeout", 0, NULL, (LPBYTE)&PipeTimeout, &dwKeySize); - RegCloseKey(hKey); } }