- Create a window to receive the CTRL+ALT+DELETE event (not working yet)

- Remove support for console start (it is the role of msgina, not winlogon)
- Implement some simple functions

svn path=/trunk/; revision=23375
This commit is contained in:
Hervé Poussineau 2006-07-30 08:38:35 +00:00
parent 6b63d81fbd
commit 6c4f49b5cd
2 changed files with 58 additions and 104 deletions

View file

@ -1,7 +1,6 @@
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS Winlogon
* FILE: services/winlogon/winlogon.c * FILE: services/winlogon/winlogon.c
* PURPOSE: Logon * PURPOSE: Logon
* PROGRAMMER: David Welch (welch@cwcom.net) * PROGRAMMER: David Welch (welch@cwcom.net)
@ -15,9 +14,6 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#define SUPPORT_CONSOLESTART 1
#define START_LSASS 1
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
BOOL BOOL
@ -33,10 +29,7 @@ WlxCreateWindowStationAndDesktops(PWLSESSION Session);
HINSTANCE hAppInstance; HINSTANCE hAppInstance;
PWLSESSION WLSession = NULL; PWLSESSION WLSession = NULL;
HWND hwndSASWindow = NULL;
#if SUPPORT_CONSOLESTART
BOOL StartConsole = TRUE;
#endif
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -153,7 +146,6 @@ StartServices (VOID)
return TRUE; return TRUE;
} }
#if START_LSASS
static BOOLEAN static BOOLEAN
StartLsass (VOID) StartLsass (VOID)
{ {
@ -205,7 +197,6 @@ StartLsass (VOID)
return(TRUE); return(TRUE);
} }
#endif
static BOOLEAN static BOOLEAN
@ -280,7 +271,7 @@ static BOOL RestartShell(void)
VOID STDCALL VOID STDCALL
RegisterHotKeys(VOID) RegisterHotKeys(VOID)
{ {
RegisterHotKey(NULL, 0, MOD_ALT | MOD_CONTROL, VK_DELETE); RegisterHotKey(hwndSASWindow, 0, MOD_ALT | MOD_CONTROL, VK_DELETE);
} }
VOID STDCALL VOID STDCALL
@ -325,34 +316,6 @@ HandleHotKey(MSG *Msg)
} }
} }
#if SUPPORT_CONSOLESTART
static BOOL StartIntoGUI(VOID)
{
HKEY WinLogonKey;
DWORD Type, Size, Value;
if(OpenRegistryKey(&WinLogonKey))
{
Size = sizeof(DWORD);
if(ERROR_SUCCESS == RegQueryValueEx(WinLogonKey,
L"StartGUI",
NULL,
&Type,
(LPBYTE)&Value,
&Size))
{
if(Type == REG_DWORD)
{
RegCloseKey(WinLogonKey);
return (Value != 0);
}
}
RegCloseKey(WinLogonKey);
}
return FALSE;
}
static PWCHAR static PWCHAR
GetUserInit (WCHAR *CommandLine) GetUserInit (WCHAR *CommandLine)
{ {
@ -496,10 +459,8 @@ DoLogonUser (PWCHAR Name,
while (WaitForSingleObject (ProcessInformation.hProcess, 100) != WAIT_OBJECT_0) while (WaitForSingleObject (ProcessInformation.hProcess, 100) != WAIT_OBJECT_0)
{ {
if (PeekMessage(&Msg, 0, 0, 0, PM_REMOVE)) if (PeekMessage(&Msg, hwndSASWindow, 0, 0, PM_REMOVE))
{ {
if (Msg.message == WM_HOTKEY)
HandleHotKey(&Msg);
TranslateMessage(&Msg); TranslateMessage(&Msg);
DispatchMessage(&Msg); DispatchMessage(&Msg);
} }
@ -526,7 +487,32 @@ DoLogonUser (PWCHAR Name,
return TRUE; return TRUE;
} }
#endif
static LRESULT CALLBACK
SASWindowProc(
IN HWND hwndDlg,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
DbgBreakPoint();
switch (uMsg)
{
case WM_HOTKEY:
{
switch (lParam)
{
case MAKELONG(MOD_CONTROL | MOD_ALT, VK_DELETE):
{
DispatchSAS(WLSession, WLX_SAS_TYPE_CTRL_ALT_DEL);
return TRUE;
}
}
}
}
return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
}
int STDCALL int STDCALL
WinMain(HINSTANCE hInstance, WinMain(HINSTANCE hInstance,
@ -535,10 +521,7 @@ WinMain(HINSTANCE hInstance,
int nShowCmd) int nShowCmd)
{ {
BOOLEAN Old; BOOLEAN Old;
#if SUPPORT_CONSOLESTART WNDCLASS wndClass;
// WCHAR LoginName[255];
// WCHAR Password[255];
#endif
#if 0 #if 0
LSA_STRING ProcessName, PackageName; LSA_STRING ProcessName, PackageName;
HANDLE LsaHandle; HANDLE LsaHandle;
@ -559,7 +542,6 @@ WinMain(HINSTANCE hInstance,
/* Get privilege */ /* Get privilege */
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &Old); RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &Old);
#if START_LSASS
if (StartProcess(L"StartLsass")) if (StartProcess(L"StartLsass"))
{ {
if (!StartLsass()) if (!StartLsass())
@ -571,7 +553,6 @@ WinMain(HINSTANCE hInstance,
{ {
DPRINT1("WL: StartProcess() failed!\n"); DPRINT1("WL: StartProcess() failed!\n");
} }
#endif
if(!(WLSession = MsGinaInit())) if(!(WLSession = MsGinaInit()))
{ {
@ -615,9 +596,6 @@ WinMain(HINSTANCE hInstance,
return 0; return 0;
} }
#if SUPPORT_CONSOLESTART
StartConsole = !StartIntoGUI();
#endif
if(!InitializeSAS(WLSession)) if(!InitializeSAS(WLSession))
{ {
DPRINT1("WL: Failed to initialize SAS\n"); DPRINT1("WL: Failed to initialize SAS\n");
@ -663,6 +641,17 @@ WinMain(HINSTANCE hInstance,
* Register SAS with the window. * Register SAS with the window.
* Register for logoff notification * Register for logoff notification
*/ */
/* Create a window class */
ZeroMemory(&wndClass, sizeof(WNDCLASS));
wndClass.style = CS_GLOBALCLASS;
wndClass.lpfnWndProc = SASWindowProc;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = L"SAS Window class";
RegisterClass(&wndClass);
hwndSASWindow = CreateWindow(
L"SAS Window class", L"SAS window", 0,
0, 0, 0, 0,
NULL, NULL, hInstance, NULL);
/* Main loop */ /* Main loop */
#if 0 #if 0
@ -703,21 +692,6 @@ WinMain(HINSTANCE hInstance,
Password[i - 1] =0; Password[i - 1] =0;
#endif #endif
#if SUPPORT_CONSOLESTART
if(StartConsole)
{
// if (! DoLogonUser(LoginName, Password))
if (! DoLogonUser(L"Administrator", L"Secret"))
{
}
NtShutdownSystem(ShutdownNoReboot);
ExitProcess(0);
}
else
{
#endif
RegisterHotKeys(); RegisterHotKeys();
SessionLoop(WLSession); SessionLoop(WLSession);
@ -745,9 +719,6 @@ WinMain(HINSTANCE hInstance,
DPRINT1("WL: LogonStatus != LOGON_SHUTDOWN!!!\n"); DPRINT1("WL: LogonStatus != LOGON_SHUTDOWN!!!\n");
ExitProcess(0); ExitProcess(0);
} }
#if SUPPORT_CONSOLESTART
}
#endif
return 0; return 0;
} }
@ -760,17 +731,6 @@ DisplayStatusMessage(PWLSESSION Session, HDESK hDesktop, DWORD dwOptions, PWSTR
return TRUE; return TRUE;
} }
#if SUPPORT_CONSOLESTART
if(StartConsole)
{
if(pMessage)
{
DPRINT1("WL-Status: %ws\n", pMessage);
}
return TRUE;
}
#endif
return Session->MsGina.Functions.WlxDisplayStatusMessage(Session->MsGina.Context, hDesktop, dwOptions, pTitle, pMessage); return Session->MsGina.Functions.WlxDisplayStatusMessage(Session->MsGina.Context, hDesktop, dwOptions, pTitle, pMessage);
} }
@ -848,9 +808,6 @@ SessionLoop(PWLSESSION Session)
WlxSetTimeout(Session->MsGina.Context, 0); WlxSetTimeout(Session->MsGina.Context, 0);
Session->SuppressStatus = TRUE; Session->SuppressStatus = TRUE;
/* tell msgina to show a window telling the user one can logon */ /* tell msgina to show a window telling the user one can logon */
#if SUPPORT_CONSOLESTART
if(!StartConsole)
#endif
DisplaySASNotice(Session); DisplaySASNotice(Session);
Session->SuppressStatus = FALSE; Session->SuppressStatus = FALSE;
@ -863,7 +820,11 @@ SessionLoop(PWLSESSION Session)
} }
WlxAction = DoLogin(Session); WlxAction = DoLogin(Session);
if(WlxAction == WLX_SAS_ACTION_LOGOFF) if (WlxAction == WLX_SAS_ACTION_LOGON)
{
DoLogonUser(L"Administrator", L"Secret");
}
else if(WlxAction == WLX_SAS_ACTION_LOGOFF)
{ {
/* the user doesn't want to login, instead pressed cancel /* the user doesn't want to login, instead pressed cancel
we should display the window again so one can logon again */ we should display the window again so one can logon again */
@ -900,10 +861,8 @@ SessionLoop(PWLSESSION Session)
} }
/* Message loop for the SAS window */ /* Message loop for the SAS window */
while(GetMessage(&Msg, 0, 0, 0)) while(GetMessage(&Msg, hwndSASWindow, 0, 0))
{ {
if (Msg.message == WM_HOTKEY)
HandleHotKey(&Msg);
TranslateMessage(&Msg); TranslateMessage(&Msg);
DispatchMessage(&Msg); DispatchMessage(&Msg);
} }

View file

@ -84,7 +84,7 @@ WlxAssignShellProtection(
} }
/* /*
* @unimplemented * @implemented
*/ */
int WINAPI int WINAPI
WlxMessageBox( WlxMessageBox(
@ -95,12 +95,11 @@ WlxMessageBox(
UINT fuStyle UINT fuStyle
) )
{ {
Unimplemented; return MessageBoxW(hwndOwner, lpszText, lpszTitle, fuStyle);
return 0;
} }
/* /*
* @unimplemented * @implemented
*/ */
int WINAPI int WINAPI
WlxDialogBox( WlxDialogBox(
@ -111,12 +110,11 @@ WlxDialogBox(
DLGPROC dlgprc DLGPROC dlgprc
) )
{ {
Unimplemented; return (int)DialogBox(hInst, lpszTemplate, hwndOwner, dlgprc);
return 0;
} }
/* /*
* @unimplemented * @implemented
*/ */
int WINAPI int WINAPI
WlxDialogBoxParam( WlxDialogBoxParam(
@ -128,8 +126,7 @@ WlxDialogBoxParam(
LPARAM dwInitParam LPARAM dwInitParam
) )
{ {
Unimplemented; return (int)DialogBoxParam(hInst, lpszTemplate, hwndOwner, dlgprc, dwInitParam);
return 0;
} }
/* /*
@ -144,12 +141,11 @@ WlxDialogBoxIndirect(
DLGPROC dlgprc DLGPROC dlgprc
) )
{ {
Unimplemented; return (int)DialogBoxIndirect(hInst, hDialogTemplate, hwndOwner, dlgprc);
return 0;
} }
/* /*
* @unimplemented * @implemented
*/ */
int WINAPI int WINAPI
WlxDialogBoxIndirectParam( WlxDialogBoxIndirectParam(
@ -161,8 +157,7 @@ WlxDialogBoxIndirectParam(
LPARAM dwInitParam LPARAM dwInitParam
) )
{ {
Unimplemented; return (int)DialogBoxIndirectParam(hInst, hDialogTemplate, hwndOwner, dlgprc, dwInitParam);
return 0;
} }
/* /*