diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index bfb592601a2..4fa1095c0d1 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -891,7 +891,7 @@ PNP_GetClassName(handle_t BindingHandle, lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class"); lstrcatW(szKeyName, L"\\"); if(lstrlenW(ClassGuid) < sizeof(szKeyName)/sizeof(WCHAR)-lstrlenW(szKeyName)) - lstrcatW(szKeyName, ClassGuid); + lstrcatW(szKeyName, ClassGuid); else return CR_INVALID_DATA; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, @@ -1486,7 +1486,7 @@ PNP_RunDetection(handle_t BindingHandle, typedef BOOL (WINAPI *PDEV_INSTALL_W)(HWND, HINSTANCE, LPCWSTR, INT); static BOOL -InstallDevice(PCWSTR DeviceInstance, BOOL SetupIsActive) +InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) { PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData; HMODULE hNewDev = NULL; @@ -1520,7 +1520,7 @@ InstallDevice(PCWSTR DeviceInstance, BOOL SetupIsActive) if (!DevInstallW) goto cleanup; - if (!DevInstallW(NULL, NULL, DeviceInstance, SetupIsActive ? SW_HIDE : SW_SHOWNOACTIVATE)) + if (!DevInstallW(NULL, NULL, DeviceInstance, ShowWizard ? SW_SHOWNOACTIVATE : SW_HIDE)) goto cleanup; DeviceInstalled = TRUE; @@ -1533,6 +1533,43 @@ cleanup: } +static LONG +ReadRegSzKey( + IN HKEY hKey, + IN LPCWSTR pszKey, + OUT LPWSTR* pValue) +{ + LONG rc; + DWORD dwType; + DWORD cbData = 0; + LPWSTR Value; + + if (!pValue) + return ERROR_INVALID_PARAMETER; + + *pValue = NULL; + rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData); + if (rc != ERROR_SUCCESS) + return rc; + if (dwType != REG_SZ) + return ERROR_FILE_NOT_FOUND; + Value = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR)); + if (!Value) + return ERROR_NOT_ENOUGH_MEMORY; + rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData); + if (rc != ERROR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, Value); + return rc; + } + /* NULL-terminate the string */ + Value[cbData / sizeof(WCHAR)] = '\0'; + + *pValue = Value; + return ERROR_SUCCESS; +} + + static BOOL SetupIsActive(VOID) { @@ -1564,6 +1601,50 @@ cleanup: } +static BOOL +IsConsoleBoot(VOID) +{ + HKEY ControlKey = NULL; + LPWSTR SystemStartOptions = NULL; + LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */ + BOOL ConsoleBoot = FALSE; + LONG rc; + + rc = RegOpenKeyExW( + HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Control", + 0, + KEY_QUERY_VALUE, + &ControlKey); + + rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions); + if (rc != ERROR_SUCCESS) + goto cleanup; + + /* Check for CMDCONS in SystemStartOptions */ + CurrentOption = SystemStartOptions; + while (CurrentOption) + { + NextOption = wcschr(CurrentOption, L' '); + if (NextOption) + *NextOption = L'\0'; + if (wcsicmp(CurrentOption, L"CONSOLE") == 0) + { + DPRINT("Found %S. Switching to console boot\n", CurrentOption); + ConsoleBoot = TRUE; + goto cleanup; + } + CurrentOption = NextOption ? NextOption + 1 : NULL; + } + +cleanup: + if (ControlKey != NULL) + RegCloseKey(ControlKey); + HeapFree(GetProcessHeap(), 0, SystemStartOptions); + return ConsoleBoot; +} + + /* Loop to install all queued devices installations */ static DWORD WINAPI DeviceInstallThread(LPVOID lpParameter) @@ -1574,11 +1655,11 @@ DeviceInstallThread(LPVOID lpParameter) PLIST_ENTRY ListEntry; #endif DeviceInstallParams* Params; - BOOL setupActive; + BOOL showWizard; UNREFERENCED_PARAMETER(lpParameter); - setupActive = SetupIsActive(); + showWizard = !SetupIsActive() && !IsConsoleBoot(); SetEnvironmentVariable(L"USERPROFILE", L"."); /* FIXME: why is it needed? */ @@ -1601,7 +1682,7 @@ DeviceInstallThread(LPVOID lpParameter) { ResetEvent(hNoPendingInstalls); Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry); - InstallDevice(Params->DeviceIds, setupActive); + InstallDevice(Params->DeviceIds, showWizard); } } diff --git a/reactos/base/system/userinit/userinit.c b/reactos/base/system/userinit/userinit.c index de3305632d9..3ef7f8eca34 100644 --- a/reactos/base/system/userinit/userinit.c +++ b/reactos/base/system/userinit/userinit.c @@ -88,14 +88,14 @@ BOOL IsConsoleShell(void) if (rc != ERROR_SUCCESS) goto cleanup; - /* Check for CMDCONS in SystemStartOptions */ + /* Check for CONSOLE in SystemStartOptions */ CurrentOption = SystemStartOptions; while (CurrentOption) { NextOption = wcschr(CurrentOption, L' '); if (NextOption) *NextOption = L'\0'; - if (wcsicmp(CurrentOption, L"CMDCONS") == 0) + if (wcsicmp(CurrentOption, L"CONSOLE") == 0) { ret = TRUE; goto cleanup; diff --git a/reactos/dll/win32/msgina/msgina.c b/reactos/dll/win32/msgina/msgina.c index 11b1c857843..fa0ee3106da 100644 --- a/reactos/dll/win32/msgina/msgina.c +++ b/reactos/dll/win32/msgina/msgina.c @@ -118,7 +118,7 @@ ChooseGinaUI(VOID) NextOption = wcschr(CurrentOption, L' '); if (NextOption) *NextOption = L'\0'; - if (wcsicmp(CurrentOption, L"CMDCONS") == 0) + if (wcsicmp(CurrentOption, L"CONSOLE") == 0) { TRACE("Found %S. Switching to console boot\n", CurrentOption); ConsoleBoot = TRUE;