mirror of
https://github.com/reactos/reactos.git
synced 2025-05-23 11:04:52 +00:00
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 svn path=/trunk/; revision=23447
This commit is contained in:
parent
41fb06f69a
commit
56a847b2ca
6 changed files with 247 additions and 109 deletions
|
@ -21,6 +21,7 @@
|
||||||
* PROJECT: ReactOS Userinit Logon Application
|
* PROJECT: ReactOS Userinit Logon Application
|
||||||
* FILE: subsys/system/userinit/userinit.c
|
* FILE: subsys/system/userinit/userinit.c
|
||||||
* PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
|
* PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
|
||||||
|
* Hervé Poussineau (hpoussin@reactos.org)
|
||||||
*/
|
*/
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <cfgmgr32.h>
|
#include <cfgmgr32.h>
|
||||||
|
@ -32,6 +33,80 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* 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
|
static
|
||||||
BOOL GetShell(WCHAR *CommandLine)
|
BOOL GetShell(WCHAR *CommandLine)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +114,7 @@ BOOL GetShell(WCHAR *CommandLine)
|
||||||
DWORD Type, Size;
|
DWORD Type, Size;
|
||||||
WCHAR Shell[MAX_PATH];
|
WCHAR Shell[MAX_PATH];
|
||||||
BOOL Ret = FALSE;
|
BOOL Ret = FALSE;
|
||||||
|
BOOL ConsoleShell = IsConsoleShell();
|
||||||
|
|
||||||
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon",
|
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon",
|
||||||
|
@ -46,7 +122,7 @@ BOOL GetShell(WCHAR *CommandLine)
|
||||||
{
|
{
|
||||||
Size = MAX_PATH * sizeof(WCHAR);
|
Size = MAX_PATH * sizeof(WCHAR);
|
||||||
if(RegQueryValueEx(hKey,
|
if(RegQueryValueEx(hKey,
|
||||||
L"Shell",
|
ConsoleShell ? L"ConsoleShell" : L"Shell",
|
||||||
NULL,
|
NULL,
|
||||||
&Type,
|
&Type,
|
||||||
(LPBYTE)Shell,
|
(LPBYTE)Shell,
|
||||||
|
@ -63,10 +139,20 @@ BOOL GetShell(WCHAR *CommandLine)
|
||||||
|
|
||||||
if(!Ret)
|
if(!Ret)
|
||||||
{
|
{
|
||||||
if(GetWindowsDirectory(CommandLine, MAX_PATH - 13))
|
if (ConsoleShell)
|
||||||
wcscat(CommandLine, L"\\explorer.exe");
|
{
|
||||||
|
if(GetSystemDirectory(CommandLine, MAX_PATH - 8))
|
||||||
|
wcscat(CommandLine, L"\\cmd.exe");
|
||||||
|
else
|
||||||
|
wcscpy(CommandLine, L"cmd.exe");
|
||||||
|
}
|
||||||
else
|
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;
|
return Ret;
|
||||||
|
|
|
@ -734,11 +734,10 @@ HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Tonga Standard Tim
|
||||||
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,\
|
||||||
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","Shell",0x00020000,"%SystemRoot%\explorer.exe"
|
||||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartServices",0x00010001,0x00000001
|
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","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","Userinit",0x00020000,"%SystemRoot%\system32\userinit.exe"
|
||||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon",0x00000000,"1"
|
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon",0x00000000,"1"
|
||||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","DefaultUserName",0x00000000,"Administrator"
|
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","DefaultUserName",0x00000000,"Administrator"
|
||||||
|
|
|
@ -148,6 +148,19 @@ GUIDisplayStatusMessage(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
GUIRemoveStatusMessage(
|
||||||
|
IN PGINA_CONTEXT pgContext)
|
||||||
|
{
|
||||||
|
if (pgContext->hStatusWindow)
|
||||||
|
{
|
||||||
|
EndDialog(pgContext->hStatusWindow, 0);
|
||||||
|
pgContext->hStatusWindow = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK
|
static INT_PTR CALLBACK
|
||||||
DisplaySASNoticeWindowProc(
|
DisplaySASNoticeWindowProc(
|
||||||
IN HWND hwndDlg,
|
IN HWND hwndDlg,
|
||||||
|
@ -390,6 +403,7 @@ GUILoggedOutSAS(
|
||||||
GINA_UI GinaGraphicalUI = {
|
GINA_UI GinaGraphicalUI = {
|
||||||
GUIInitialize,
|
GUIInitialize,
|
||||||
GUIDisplayStatusMessage,
|
GUIDisplayStatusMessage,
|
||||||
|
GUIRemoveStatusMessage,
|
||||||
GUIDisplaySASNotice,
|
GUIDisplaySASNotice,
|
||||||
GUILoggedOnSAS,
|
GUILoggedOnSAS,
|
||||||
GUILoggedOutSAS,
|
GUILoggedOutSAS,
|
||||||
|
|
|
@ -26,13 +26,14 @@
|
||||||
|
|
||||||
#include "msgina.h"
|
#include "msgina.h"
|
||||||
|
|
||||||
|
//#define YDEBUG
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
|
||||||
extern HINSTANCE hDllInstance;
|
extern HINSTANCE hDllInstance;
|
||||||
|
|
||||||
extern GINA_UI GinaGraphicalUI;
|
extern GINA_UI GinaGraphicalUI;
|
||||||
extern GINA_UI GinaTextUI;
|
extern GINA_UI GinaTextUI;
|
||||||
static PGINA_UI pGinaUI = &GinaGraphicalUI; /* Default value */
|
static PGINA_UI pGinaUI;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -52,41 +53,83 @@ WlxNegotiate(
|
||||||
return TRUE;
|
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
|
static VOID
|
||||||
ChooseGinaUI(VOID)
|
ChooseGinaUI(VOID)
|
||||||
{
|
{
|
||||||
HKEY WinLogonKey = NULL;
|
HKEY ControlKey = NULL;
|
||||||
DWORD Type, Size, Value;
|
LPWSTR SystemStartOptions = NULL;
|
||||||
|
LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
|
||||||
|
BOOL ConsoleBoot = FALSE;
|
||||||
LONG rc;
|
LONG rc;
|
||||||
|
|
||||||
rc = RegOpenKeyEx(
|
rc = RegOpenKeyEx(
|
||||||
HKEY_LOCAL_MACHINE,
|
HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
|
L"SYSTEM\\CurrentControlSet\\Control",
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE,
|
||||||
&WinLogonKey);
|
&ControlKey);
|
||||||
|
|
||||||
|
rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
Size = sizeof(DWORD);
|
/* Check for CMDCONS in SystemStartOptions */
|
||||||
rc = RegQueryValueEx(
|
CurrentOption = SystemStartOptions;
|
||||||
WinLogonKey,
|
while (CurrentOption)
|
||||||
L"StartGUI",
|
{
|
||||||
NULL,
|
NextOption = wcschr(CurrentOption, L' ');
|
||||||
&Type,
|
if (NextOption)
|
||||||
(LPBYTE)&Value,
|
*NextOption = L'\0';
|
||||||
&Size);
|
if (wcsicmp(CurrentOption, L"CMDCONS") == 0)
|
||||||
if (rc != ERROR_SUCCESS || Type != REG_DWORD || Size != sizeof(DWORD))
|
{
|
||||||
goto cleanup;
|
TRACE("Found %S. Switching to console boot\n", CurrentOption);
|
||||||
|
ConsoleBoot = TRUE;
|
||||||
if (Value != 0)
|
goto cleanup;
|
||||||
pGinaUI = &GinaGraphicalUI;
|
}
|
||||||
else
|
CurrentOption = NextOption ? NextOption + 1 : NULL;
|
||||||
pGinaUI = &GinaTextUI;
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (WinLogonKey != NULL)
|
if (ConsoleBoot)
|
||||||
RegCloseKey(WinLogonKey);
|
pGinaUI = &GinaTextUI;
|
||||||
|
else
|
||||||
|
pGinaUI = &GinaGraphicalUI;
|
||||||
|
|
||||||
|
if (ControlKey != NULL)
|
||||||
|
RegCloseKey(ControlKey);
|
||||||
|
HeapFree(GetProcessHeap(), 0, SystemStartOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -129,7 +172,7 @@ WlxInitialize(
|
||||||
/* Locates the authentification package */
|
/* Locates the authentification package */
|
||||||
//LsaRegisterLogonProcess(...);
|
//LsaRegisterLogonProcess(...);
|
||||||
|
|
||||||
pgContext->DoAutoLogonOnce = FALSE;
|
pgContext->AutoLogonState = AUTOLOGON_CHECK_REGISTRY;
|
||||||
|
|
||||||
ChooseGinaUI();
|
ChooseGinaUI();
|
||||||
return pGinaUI->Initialize(pgContext);
|
return pGinaUI->Initialize(pgContext);
|
||||||
|
@ -290,45 +333,10 @@ WlxRemoveStatusMessage(
|
||||||
IN PVOID pWlxContext)
|
IN PVOID pWlxContext)
|
||||||
{
|
{
|
||||||
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
|
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
|
||||||
if (pgContext->hStatusWindow)
|
|
||||||
{
|
|
||||||
EndDialog(pgContext->hStatusWindow, 0);
|
|
||||||
pgContext->hStatusWindow = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
TRACE("WlxRemoveStatusMessage()\n");
|
||||||
}
|
|
||||||
|
|
||||||
static LONG
|
return pGinaUI->RemoveStatusMessage(pgContext);
|
||||||
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 PWSTR
|
static PWSTR
|
||||||
|
@ -394,8 +402,7 @@ DoLoginTasks(
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
DoAutoLogon(
|
DoAutoLogon(
|
||||||
IN PGINA_CONTEXT pgContext,
|
IN PGINA_CONTEXT pgContext)
|
||||||
IN BOOL CheckOnly)
|
|
||||||
{
|
{
|
||||||
HKEY WinLogonKey = NULL;
|
HKEY WinLogonKey = NULL;
|
||||||
LPWSTR AutoLogon = NULL;
|
LPWSTR AutoLogon = NULL;
|
||||||
|
@ -407,6 +414,12 @@ DoAutoLogon(
|
||||||
BOOL result = FALSE;
|
BOOL result = FALSE;
|
||||||
LONG rc;
|
LONG rc;
|
||||||
|
|
||||||
|
TRACE("DoAutoLogon(): AutoLogonState = %lu\n",
|
||||||
|
pgContext->AutoLogonState);
|
||||||
|
|
||||||
|
if (pgContext->AutoLogonState == AUTOLOGON_DISABLED)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
rc = RegOpenKeyEx(
|
rc = RegOpenKeyEx(
|
||||||
HKEY_LOCAL_MACHINE,
|
HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
|
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
|
||||||
|
@ -416,47 +429,54 @@ DoAutoLogon(
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
rc = ReadRegSzKey(WinLogonKey, L"AutoAdminLogon", &AutoLogon);
|
if (pgContext->AutoLogonState == AUTOLOGON_CHECK_REGISTRY)
|
||||||
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)
|
/* 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;
|
goto cleanup;
|
||||||
}
|
|
||||||
else if (GetKeyState(VK_SHIFT) < 0)
|
|
||||||
{
|
|
||||||
/* User pressed SHIFT */
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CheckOnly)
|
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;
|
result = TRUE;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
else /* pgContext->AutoLogonState == AUTOLOGON_ONCE */
|
||||||
|
{
|
||||||
|
pgContext->AutoLogonState = AUTOLOGON_DISABLED;
|
||||||
|
|
||||||
rc = ReadRegSzKey(WinLogonKey, L"DefaultUserName", &UserName);
|
rc = ReadRegSzKey(WinLogonKey, L"DefaultUserName", &UserName);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
rc = ReadRegSzKey(WinLogonKey, L"DefaultDomainName", &DomainName);
|
rc = ReadRegSzKey(WinLogonKey, L"DefaultDomainName", &DomainName);
|
||||||
if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
|
if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
rc = ReadRegSzKey(WinLogonKey, L"DefaultPassword", &Password);
|
rc = ReadRegSzKey(WinLogonKey, L"DefaultPassword", &Password);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
result = DoLoginTasks(pgContext, UserName, DomainName, Password);
|
result = DoLoginTasks(pgContext, UserName, DomainName, Password);
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (WinLogonKey != NULL)
|
if (WinLogonKey != NULL)
|
||||||
|
@ -467,6 +487,8 @@ cleanup:
|
||||||
HeapFree(GetProcessHeap(), 0, UserName);
|
HeapFree(GetProcessHeap(), 0, UserName);
|
||||||
HeapFree(GetProcessHeap(), 0, DomainName);
|
HeapFree(GetProcessHeap(), 0, DomainName);
|
||||||
HeapFree(GetProcessHeap(), 0, Password);
|
HeapFree(GetProcessHeap(), 0, Password);
|
||||||
|
TRACE("DoAutoLogon(): AutoLogonState = %lu, returning %d\n",
|
||||||
|
pgContext->AutoLogonState, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,13 +510,15 @@ WlxDisplaySASNotice(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DoAutoLogon(NULL, TRUE))
|
if (DoAutoLogon(pgContext))
|
||||||
{
|
{
|
||||||
/* Don't display the window, we want to do an automatic logon */
|
/* 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);
|
pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
pgContext->AutoLogonState = AUTOLOGON_DISABLED;
|
||||||
|
|
||||||
pGinaUI->DisplaySASNotice(pgContext);
|
pGinaUI->DisplaySASNotice(pgContext);
|
||||||
|
|
||||||
|
@ -526,12 +550,10 @@ WlxLoggedOutSAS(
|
||||||
pgContext->pProfile = pProfile;
|
pgContext->pProfile = pProfile;
|
||||||
|
|
||||||
if (!GetSystemMetrics(SM_REMOTESESSION) &&
|
if (!GetSystemMetrics(SM_REMOTESESSION) &&
|
||||||
pgContext->DoAutoLogonOnce &&
|
DoAutoLogon(pgContext))
|
||||||
DoAutoLogon(pgContext, FALSE))
|
|
||||||
{
|
{
|
||||||
/* User is local and registry contains information
|
/* User is local and registry contains information
|
||||||
* to log on him automatically */
|
* to log on him automatically */
|
||||||
pgContext->DoAutoLogonOnce = FALSE;
|
|
||||||
return WLX_SAS_ACTION_LOGON;
|
return WLX_SAS_ACTION_LOGON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,13 @@
|
||||||
#include <winwlx.h>
|
#include <winwlx.h>
|
||||||
#include "resource.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;
|
HANDLE hWlx;
|
||||||
LPWSTR station;
|
LPWSTR station;
|
||||||
PWLX_DISPATCH_VERSION_1_3 pWlxFuncs;
|
PWLX_DISPATCH_VERSION_1_3 pWlxFuncs;
|
||||||
|
@ -13,7 +19,7 @@ typedef struct {
|
||||||
HANDLE UserToken;
|
HANDLE UserToken;
|
||||||
HWND hStatusWindow;
|
HWND hStatusWindow;
|
||||||
BOOL SignaledStatusWindowCreated;
|
BOOL SignaledStatusWindowCreated;
|
||||||
BOOL DoAutoLogonOnce;
|
DWORD AutoLogonState;
|
||||||
|
|
||||||
/* Informations to be filled during logon */
|
/* Informations to be filled during logon */
|
||||||
PLUID pAuthenticationId;
|
PLUID pAuthenticationId;
|
||||||
|
@ -30,6 +36,7 @@ HINSTANCE hDllInstance;
|
||||||
|
|
||||||
typedef BOOL (*PFGINA_INITIALIZE)(PGINA_CONTEXT);
|
typedef BOOL (*PFGINA_INITIALIZE)(PGINA_CONTEXT);
|
||||||
typedef BOOL (*PFGINA_DISPLAYSTATUSMESSAGE)(PGINA_CONTEXT, HDESK, DWORD, PWSTR, PWSTR);
|
typedef BOOL (*PFGINA_DISPLAYSTATUSMESSAGE)(PGINA_CONTEXT, HDESK, DWORD, PWSTR, PWSTR);
|
||||||
|
typedef BOOL (*PFGINA_REMOVESTATUSMESSAGE)(PGINA_CONTEXT);
|
||||||
typedef VOID (*PFGINA_DISPLAYSASNOTICE)(PGINA_CONTEXT);
|
typedef VOID (*PFGINA_DISPLAYSASNOTICE)(PGINA_CONTEXT);
|
||||||
typedef INT (*PFGINA_LOGGEDONSAS)(PGINA_CONTEXT, DWORD);
|
typedef INT (*PFGINA_LOGGEDONSAS)(PGINA_CONTEXT, DWORD);
|
||||||
typedef INT (*PFGINA_LOGGEDOUTSAS)(PGINA_CONTEXT);
|
typedef INT (*PFGINA_LOGGEDOUTSAS)(PGINA_CONTEXT);
|
||||||
|
@ -37,6 +44,7 @@ typedef struct _GINA_UI
|
||||||
{
|
{
|
||||||
PFGINA_INITIALIZE Initialize;
|
PFGINA_INITIALIZE Initialize;
|
||||||
PFGINA_DISPLAYSTATUSMESSAGE DisplayStatusMessage;
|
PFGINA_DISPLAYSTATUSMESSAGE DisplayStatusMessage;
|
||||||
|
PFGINA_REMOVESTATUSMESSAGE RemoveStatusMessage;
|
||||||
PFGINA_DISPLAYSASNOTICE DisplaySASNotice;
|
PFGINA_DISPLAYSASNOTICE DisplaySASNotice;
|
||||||
PFGINA_LOGGEDONSAS LoggedOnSAS;
|
PFGINA_LOGGEDONSAS LoggedOnSAS;
|
||||||
PFGINA_LOGGEDOUTSAS LoggedOutSAS;
|
PFGINA_LOGGEDOUTSAS LoggedOutSAS;
|
||||||
|
|
|
@ -47,6 +47,14 @@ TUIDisplayStatusMessage(
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
TUIRemoveStatusMessage(
|
||||||
|
IN PGINA_CONTEXT pgContext)
|
||||||
|
{
|
||||||
|
/* Nothing to do */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
TUIDisplaySASNotice(
|
TUIDisplaySASNotice(
|
||||||
IN OUT PGINA_CONTEXT pgContext)
|
IN OUT PGINA_CONTEXT pgContext)
|
||||||
|
@ -145,6 +153,7 @@ TUILoggedOutSAS(
|
||||||
GINA_UI GinaTextUI = {
|
GINA_UI GinaTextUI = {
|
||||||
TUIInitialize,
|
TUIInitialize,
|
||||||
TUIDisplayStatusMessage,
|
TUIDisplayStatusMessage,
|
||||||
|
TUIRemoveStatusMessage,
|
||||||
TUIDisplaySASNotice,
|
TUIDisplaySASNotice,
|
||||||
TUILoggedOnSAS,
|
TUILoggedOnSAS,
|
||||||
TUILoggedOutSAS,
|
TUILoggedOutSAS,
|
||||||
|
|
Loading…
Reference in a new issue