Author: hpoussin
Date: Fri Aug 4 23:44:35 2006
New Revision: 23447
URL:
http://svn.reactos.org/svn/reactos?rev=23447&view=rev
Log:
Implement /CMDCONS switch, which allows the user to start in text mode
Autologon should only be done once (when starting the computer, not after the user has
logged out)
Remove the status message dialog only in GUI
Modified:
trunk/reactos/base/system/userinit/userinit.c
trunk/reactos/boot/bootdata/hivesft.inf
trunk/reactos/dll/win32/msgina/gui.c
trunk/reactos/dll/win32/msgina/msgina.c
trunk/reactos/dll/win32/msgina/msgina.h
trunk/reactos/dll/win32/msgina/tui.c
Modified: trunk/reactos/base/system/userinit/userinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/userinit/useri…
==============================================================================
--- trunk/reactos/base/system/userinit/userinit.c (original)
+++ trunk/reactos/base/system/userinit/userinit.c Fri Aug 4 23:44:35 2006
@@ -21,6 +21,7 @@
* PROJECT: ReactOS Userinit Logon Application
* FILE: subsys/system/userinit/userinit.c
* PROGRAMMERS: Thomas Weidenmueller (w3seek(a)users.sourceforge.net)
+ * Hervé Poussineau (hpoussin(a)reactos.org)
*/
#include <windows.h>
#include <cfgmgr32.h>
@@ -32,6 +33,80 @@
/* FUNCTIONS ****************************************************************/
+static LONG
+ReadRegSzKey(
+ IN HKEY hKey,
+ IN LPCWSTR pszKey,
+ OUT LPWSTR* pValue)
+{
+ LONG rc;
+ DWORD dwType;
+ DWORD cbData = 0;
+ LPWSTR Value;
+
+ 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 IsConsoleShell(void)
+{
+ HKEY ControlKey = NULL;
+ LPWSTR SystemStartOptions = NULL;
+ LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
+ LONG rc;
+ BOOL ret = FALSE;
+
+ rc = RegOpenKeyEx(
+ 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"CMDCONS") == 0)
+ {
+ ret = TRUE;
+ goto cleanup;
+ }
+ CurrentOption = NextOption ? NextOption + 1 : NULL;
+ }
+
+cleanup:
+ if (ControlKey != NULL)
+ RegCloseKey(ControlKey);
+ HeapFree(GetProcessHeap(), 0, SystemStartOptions);
+ return ret;
+}
+
static
BOOL GetShell(WCHAR *CommandLine)
{
@@ -39,6 +114,7 @@
DWORD Type, Size;
WCHAR Shell[MAX_PATH];
BOOL Ret = FALSE;
+ BOOL ConsoleShell = IsConsoleShell();
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon",
@@ -46,7 +122,7 @@
{
Size = MAX_PATH * sizeof(WCHAR);
if(RegQueryValueEx(hKey,
- L"Shell",
+ ConsoleShell ? L"ConsoleShell" : L"Shell",
NULL,
&Type,
(LPBYTE)Shell,
@@ -63,10 +139,20 @@
if(!Ret)
{
- if(GetWindowsDirectory(CommandLine, MAX_PATH - 13))
- wcscat(CommandLine, L"\\explorer.exe");
+ if (ConsoleShell)
+ {
+ if(GetSystemDirectory(CommandLine, MAX_PATH - 8))
+ wcscat(CommandLine, L"\\cmd.exe");
+ else
+ wcscpy(CommandLine, L"cmd.exe");
+ }
else
- wcscpy(CommandLine, L"explorer.exe");
+ {
+ if(GetWindowsDirectory(CommandLine, MAX_PATH - 13))
+ wcscat(CommandLine, L"\\explorer.exe");
+ else
+ wcscpy(CommandLine, L"explorer.exe");
+ }
}
return Ret;
Modified: trunk/reactos/boot/bootdata/hivesft.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesft.inf (original)
+++ trunk/reactos/boot/bootdata/hivesft.inf Fri Aug 4 23:44:35 2006
@@ -734,11 +734,10 @@
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-;HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\system32\cmd.exe"
+HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","ConsoleShell",0x00020000,"%SystemRoot%\system32\cmd.exe"
HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\explorer.exe"
HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","StartServices",0x00010001,0x00000001
HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","StartLsass",0x00010001,0x00000001
-HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","StartGUI",0x00010001,0x00000000
HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","Userinit",0x00020000,"%SystemRoot%\system32\userinit.exe"
HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","AutoAdminLogon",0x00000000,"1"
HKLM,"SOFTWARE\ReactOS\Windows
NT\CurrentVersion\Winlogon","DefaultUserName",0x00000000,"Administrator"
Modified: trunk/reactos/dll/win32/msgina/gui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/gui.c?rev…
==============================================================================
--- trunk/reactos/dll/win32/msgina/gui.c (original)
+++ trunk/reactos/dll/win32/msgina/gui.c Fri Aug 4 23:44:35 2006
@@ -144,6 +144,19 @@
SetWindowText(pgContext->hStatusWindow, pTitle);
SetDlgItemText(pgContext->hStatusWindow, IDC_STATUSLABEL, pMessage);
+
+ return TRUE;
+}
+
+static BOOL
+GUIRemoveStatusMessage(
+ IN PGINA_CONTEXT pgContext)
+{
+ if (pgContext->hStatusWindow)
+ {
+ EndDialog(pgContext->hStatusWindow, 0);
+ pgContext->hStatusWindow = 0;
+ }
return TRUE;
}
@@ -390,6 +403,7 @@
GINA_UI GinaGraphicalUI = {
GUIInitialize,
GUIDisplayStatusMessage,
+ GUIRemoveStatusMessage,
GUIDisplaySASNotice,
GUILoggedOnSAS,
GUILoggedOutSAS,
Modified: trunk/reactos/dll/win32/msgina/msgina.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/msgina.c?…
==============================================================================
--- trunk/reactos/dll/win32/msgina/msgina.c (original)
+++ trunk/reactos/dll/win32/msgina/msgina.c Fri Aug 4 23:44:35 2006
@@ -26,13 +26,14 @@
#include "msgina.h"
+//#define YDEBUG
#include <wine/debug.h>
extern HINSTANCE hDllInstance;
extern GINA_UI GinaGraphicalUI;
extern GINA_UI GinaTextUI;
-static PGINA_UI pGinaUI = &GinaGraphicalUI; /* Default value */
+static PGINA_UI pGinaUI;
/*
* @implemented
@@ -52,41 +53,83 @@
return TRUE;
}
+static LONG
+ReadRegSzKey(
+ IN HKEY hKey,
+ IN LPCWSTR pszKey,
+ OUT LPWSTR* pValue)
+{
+ LONG rc;
+ DWORD dwType;
+ DWORD cbData = 0;
+ LPWSTR Value;
+
+ 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 VOID
ChooseGinaUI(VOID)
{
- HKEY WinLogonKey = NULL;
- DWORD Type, Size, Value;
+ HKEY ControlKey = NULL;
+ LPWSTR SystemStartOptions = NULL;
+ LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
+ BOOL ConsoleBoot = FALSE;
LONG rc;
rc = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
+ L"SYSTEM\\CurrentControlSet\\Control",
0,
KEY_QUERY_VALUE,
- &WinLogonKey);
+ &ControlKey);
+
+ rc = ReadRegSzKey(ControlKey, L"SystemStartOptions",
&SystemStartOptions);
if (rc != ERROR_SUCCESS)
goto cleanup;
- Size = sizeof(DWORD);
- rc = RegQueryValueEx(
- WinLogonKey,
- L"StartGUI",
- NULL,
- &Type,
- (LPBYTE)&Value,
- &Size);
- if (rc != ERROR_SUCCESS || Type != REG_DWORD || Size != sizeof(DWORD))
- goto cleanup;
-
- if (Value != 0)
+ /* Check for CMDCONS in SystemStartOptions */
+ CurrentOption = SystemStartOptions;
+ while (CurrentOption)
+ {
+ NextOption = wcschr(CurrentOption, L' ');
+ if (NextOption)
+ *NextOption = L'\0';
+ if (wcsicmp(CurrentOption, L"CMDCONS") == 0)
+ {
+ TRACE("Found %S. Switching to console boot\n", CurrentOption);
+ ConsoleBoot = TRUE;
+ goto cleanup;
+ }
+ CurrentOption = NextOption ? NextOption + 1 : NULL;
+ }
+
+cleanup:
+ if (ConsoleBoot)
+ pGinaUI = &GinaTextUI;
+ else
pGinaUI = &GinaGraphicalUI;
- else
- pGinaUI = &GinaTextUI;
-
-cleanup:
- if (WinLogonKey != NULL)
- RegCloseKey(WinLogonKey);
+
+ if (ControlKey != NULL)
+ RegCloseKey(ControlKey);
+ HeapFree(GetProcessHeap(), 0, SystemStartOptions);
}
/*
@@ -129,7 +172,7 @@
/* Locates the authentification package */
//LsaRegisterLogonProcess(...);
- pgContext->DoAutoLogonOnce = FALSE;
+ pgContext->AutoLogonState = AUTOLOGON_CHECK_REGISTRY;
ChooseGinaUI();
return pGinaUI->Initialize(pgContext);
@@ -290,45 +333,10 @@
IN PVOID pWlxContext)
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
- if (pgContext->hStatusWindow)
- {
- EndDialog(pgContext->hStatusWindow, 0);
- pgContext->hStatusWindow = 0;
- }
-
- return TRUE;
-}
-
-static LONG
-ReadRegSzKey(
- IN HKEY hKey,
- IN LPCWSTR pszKey,
- OUT LPWSTR* pValue)
-{
- LONG rc;
- DWORD dwType;
- DWORD cbData = 0;
- LPWSTR Value;
-
- 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;
+
+ TRACE("WlxRemoveStatusMessage()\n");
+
+ return pGinaUI->RemoveStatusMessage(pgContext);
}
static PWSTR
@@ -394,8 +402,7 @@
static BOOL
DoAutoLogon(
- IN PGINA_CONTEXT pgContext,
- IN BOOL CheckOnly)
+ IN PGINA_CONTEXT pgContext)
{
HKEY WinLogonKey = NULL;
LPWSTR AutoLogon = NULL;
@@ -407,6 +414,12 @@
BOOL result = FALSE;
LONG rc;
+ TRACE("DoAutoLogon(): AutoLogonState = %lu\n",
+ pgContext->AutoLogonState);
+
+ if (pgContext->AutoLogonState == AUTOLOGON_DISABLED)
+ return FALSE;
+
rc = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
@@ -416,47 +429,54 @@
if (rc != ERROR_SUCCESS)
goto cleanup;
- rc = ReadRegSzKey(WinLogonKey, L"AutoAdminLogon", &AutoLogon);
- if (rc != ERROR_SUCCESS)
- goto cleanup;
- if (wcscmp(AutoLogon, L"1") != 0)
- goto cleanup;
-
- rc = ReadRegSzKey(WinLogonKey, L"AutoLogonCount", &AutoCount);
- if (rc == ERROR_SUCCESS && wcscmp(AutoCount, L"0") == 0)
- goto cleanup;
- else if (rc != ERROR_FILE_NOT_FOUND)
- goto cleanup;
-
- rc = ReadRegSzKey(WinLogonKey, L"IgnoreShiftOverride", &UserName);
- if (rc == ERROR_SUCCESS)
- {
- if (wcscmp(AutoLogon, L"1") != 0 && GetKeyState(VK_SHIFT) < 0)
- goto cleanup;
- }
- else if (GetKeyState(VK_SHIFT) < 0)
- {
- /* User pressed SHIFT */
- goto cleanup;
- }
-
- if (CheckOnly)
- {
+ if (pgContext->AutoLogonState == AUTOLOGON_CHECK_REGISTRY)
+ {
+ /* Set it by default to disabled, we might reenable it again later */
+ pgContext->AutoLogonState = AUTOLOGON_DISABLED;
+
+ rc = ReadRegSzKey(WinLogonKey, L"AutoAdminLogon", &AutoLogon);
+ if (rc != ERROR_SUCCESS)
+ goto cleanup;
+ if (wcscmp(AutoLogon, L"1") != 0)
+ goto cleanup;
+
+ rc = ReadRegSzKey(WinLogonKey, L"AutoLogonCount", &AutoCount);
+ if (rc == ERROR_SUCCESS && wcscmp(AutoCount, L"0") == 0)
+ goto cleanup;
+ else if (rc != ERROR_FILE_NOT_FOUND)
+ goto cleanup;
+
+ rc = ReadRegSzKey(WinLogonKey, L"IgnoreShiftOverride", &UserName);
+ if (rc == ERROR_SUCCESS)
+ {
+ if (wcscmp(AutoLogon, L"1") != 0 && GetKeyState(VK_SHIFT) < 0)
+ goto cleanup;
+ }
+ else if (GetKeyState(VK_SHIFT) < 0)
+ {
+ /* User pressed SHIFT */
+ goto cleanup;
+ }
+
+ pgContext->AutoLogonState = AUTOLOGON_ONCE;
result = TRUE;
- goto cleanup;
- }
-
- rc = ReadRegSzKey(WinLogonKey, L"DefaultUserName", &UserName);
- if (rc != ERROR_SUCCESS)
- goto cleanup;
- rc = ReadRegSzKey(WinLogonKey, L"DefaultDomainName", &DomainName);
- if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
- goto cleanup;
- rc = ReadRegSzKey(WinLogonKey, L"DefaultPassword", &Password);
- if (rc != ERROR_SUCCESS)
- goto cleanup;
-
- result = DoLoginTasks(pgContext, UserName, DomainName, Password);
+ }
+ else /* pgContext->AutoLogonState == AUTOLOGON_ONCE */
+ {
+ pgContext->AutoLogonState = AUTOLOGON_DISABLED;
+
+ rc = ReadRegSzKey(WinLogonKey, L"DefaultUserName", &UserName);
+ if (rc != ERROR_SUCCESS)
+ goto cleanup;
+ rc = ReadRegSzKey(WinLogonKey, L"DefaultDomainName", &DomainName);
+ if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
+ goto cleanup;
+ rc = ReadRegSzKey(WinLogonKey, L"DefaultPassword", &Password);
+ if (rc != ERROR_SUCCESS)
+ goto cleanup;
+
+ result = DoLoginTasks(pgContext, UserName, DomainName, Password);
+ }
cleanup:
if (WinLogonKey != NULL)
@@ -467,6 +487,8 @@
HeapFree(GetProcessHeap(), 0, UserName);
HeapFree(GetProcessHeap(), 0, DomainName);
HeapFree(GetProcessHeap(), 0, Password);
+ TRACE("DoAutoLogon(): AutoLogonState = %lu, returning %d\n",
+ pgContext->AutoLogonState, result);
return result;
}
@@ -488,13 +510,15 @@
return;
}
- if (DoAutoLogon(NULL, TRUE))
+ if (DoAutoLogon(pgContext))
{
/* Don't display the window, we want to do an automatic logon */
- pgContext->DoAutoLogonOnce = TRUE;
+ pgContext->AutoLogonState = AUTOLOGON_ONCE;
pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx,
WLX_SAS_TYPE_CTRL_ALT_DEL);
return;
}
+ else
+ pgContext->AutoLogonState = AUTOLOGON_DISABLED;
pGinaUI->DisplaySASNotice(pgContext);
@@ -526,12 +550,10 @@
pgContext->pProfile = pProfile;
if (!GetSystemMetrics(SM_REMOTESESSION) &&
- pgContext->DoAutoLogonOnce &&
- DoAutoLogon(pgContext, FALSE))
+ DoAutoLogon(pgContext))
{
/* User is local and registry contains information
* to log on him automatically */
- pgContext->DoAutoLogonOnce = FALSE;
return WLX_SAS_ACTION_LOGON;
}
Modified: trunk/reactos/dll/win32/msgina/msgina.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/msgina.h?…
==============================================================================
--- trunk/reactos/dll/win32/msgina/msgina.h (original)
+++ trunk/reactos/dll/win32/msgina/msgina.h Fri Aug 4 23:44:35 2006
@@ -5,7 +5,13 @@
#include <winwlx.h>
#include "resource.h"
-typedef struct {
+/* Values for GINA_CONTEXT.AutoLogonState */
+#define AUTOLOGON_CHECK_REGISTRY 1
+#define AUTOLOGON_ONCE 2
+#define AUTOLOGON_DISABLED 3
+
+typedef struct
+{
HANDLE hWlx;
LPWSTR station;
PWLX_DISPATCH_VERSION_1_3 pWlxFuncs;
@@ -13,7 +19,7 @@
HANDLE UserToken;
HWND hStatusWindow;
BOOL SignaledStatusWindowCreated;
- BOOL DoAutoLogonOnce;
+ DWORD AutoLogonState;
/* Informations to be filled during logon */
PLUID pAuthenticationId;
@@ -30,6 +36,7 @@
typedef BOOL (*PFGINA_INITIALIZE)(PGINA_CONTEXT);
typedef BOOL (*PFGINA_DISPLAYSTATUSMESSAGE)(PGINA_CONTEXT, HDESK, DWORD, PWSTR, PWSTR);
+typedef BOOL (*PFGINA_REMOVESTATUSMESSAGE)(PGINA_CONTEXT);
typedef VOID (*PFGINA_DISPLAYSASNOTICE)(PGINA_CONTEXT);
typedef INT (*PFGINA_LOGGEDONSAS)(PGINA_CONTEXT, DWORD);
typedef INT (*PFGINA_LOGGEDOUTSAS)(PGINA_CONTEXT);
@@ -37,6 +44,7 @@
{
PFGINA_INITIALIZE Initialize;
PFGINA_DISPLAYSTATUSMESSAGE DisplayStatusMessage;
+ PFGINA_REMOVESTATUSMESSAGE RemoveStatusMessage;
PFGINA_DISPLAYSASNOTICE DisplaySASNotice;
PFGINA_LOGGEDONSAS LoggedOnSAS;
PFGINA_LOGGEDOUTSAS LoggedOutSAS;
Modified: trunk/reactos/dll/win32/msgina/tui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/tui.c?rev…
==============================================================================
--- trunk/reactos/dll/win32/msgina/tui.c (original)
+++ trunk/reactos/dll/win32/msgina/tui.c Fri Aug 4 23:44:35 2006
@@ -45,6 +45,14 @@
wcslen(newLine),
&result,
NULL);
+}
+
+static BOOL
+TUIRemoveStatusMessage(
+ IN PGINA_CONTEXT pgContext)
+{
+ /* Nothing to do */
+ return TRUE;
}
static VOID
@@ -145,6 +153,7 @@
GINA_UI GinaTextUI = {
TUIInitialize,
TUIDisplayStatusMessage,
+ TUIRemoveStatusMessage,
TUIDisplaySASNotice,
TUILoggedOnSAS,
TUILoggedOutSAS,