Author: hpoussin Date: Mon Oct 9 23:19:28 2006 New Revision: 24477
URL: http://svn.reactos.org/svn/reactos?rev=24477&view=rev Log: - Start NetLogon service (lsass.exe) - Fix lots of problems in error handling - Some general cleanup
Modified: trunk/reactos/base/system/winlogon/sas.c trunk/reactos/base/system/winlogon/screensaver.c trunk/reactos/base/system/winlogon/setup.c trunk/reactos/base/system/winlogon/setup.h trunk/reactos/base/system/winlogon/winlogon.c trunk/reactos/base/system/winlogon/winlogon.h trunk/reactos/base/system/winlogon/wlx.c
Modified: trunk/reactos/base/system/winlogon/sas.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/sas.c?... ============================================================================== --- trunk/reactos/base/system/winlogon/sas.c (original) +++ trunk/reactos/base/system/winlogon/sas.c Mon Oct 9 23:19:28 2006 @@ -28,16 +28,29 @@ StartTaskManager( IN OUT PWLSESSION Session) { + LPVOID lpEnvironment; + + if (!Session->Gina.Functions.WlxStartApplication) + return FALSE; + + if (!CreateEnvironmentBlock( + &lpEnvironment, + Session->UserToken, + TRUE)) + { + return FALSE; + } + return Session->Gina.Functions.WlxStartApplication( Session->Gina.Context, L"Default", - NULL, + lpEnvironment, L"taskmgr.exe"); }
BOOL SetDefaultLanguage( - IN BOOLEAN UserProfile) + IN BOOL UserProfile) { HKEY BaseKey; LPCWSTR SubKey; @@ -146,11 +159,11 @@ HandleLogon( IN OUT PWLSESSION Session) { - PROFILEINFOW ProfileInfo = { 0 }; + PROFILEINFOW ProfileInfo = { 0, }; LPVOID lpEnvironment = NULL; BOOLEAN Old;
- if (!(Session->Options & WLX_LOGON_OPT_NO_PROFILE)) + if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE)) { /* Load the user profile */ ProfileInfo.dwSize = sizeof(PROFILEINFOW); @@ -165,7 +178,6 @@ if (!LoadUserProfileW(Session->UserToken, &ProfileInfo)) { ERR("WL: LoadUserProfileW() failed\n"); - CloseHandle(Session->UserToken); return FALSE; } } @@ -177,9 +189,12 @@ TRUE)) { ERR("WL: CreateEnvironmentBlock() failed\n"); - if (!(Session->Options & WLX_LOGON_OPT_NO_PROFILE)) + if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE)) + { UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile); - CloseHandle(Session->UserToken); + CloseHandle(Session->UserToken); + Session->UserToken = NULL; + } return FALSE; } /* FIXME: use Session->Profile.pszEnvironment */ @@ -195,7 +210,15 @@
/* Set default language */ if (!SetDefaultLanguage(TRUE)) + { + if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE)) + { + UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile); + CloseHandle(Session->UserToken); + Session->UserToken = NULL; + } return FALSE; + }
if (!Session->Gina.Functions.WlxActivateUserShell( Session->Gina.Context, @@ -203,6 +226,12 @@ NULL, /* FIXME */ lpEnvironment)) { + if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE)) + { + UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile); + CloseHandle(Session->UserToken); + Session->UserToken = NULL; + } return FALSE; } /*if(!GinaInst->Functions->WlxActivateUserShell(GinaInst->Context, @@ -222,7 +251,7 @@ */
if (!InitializeScreenSaver(Session)) - ERR("WL: Failed to initialize screen saver\n"); + WARN("WL: Failed to initialize screen saver\n");
return TRUE; } @@ -241,7 +270,7 @@ { PLOGOFF_SHUTDOWN_DATA LSData = (PLOGOFF_SHUTDOWN_DATA)Parameter;
- if (LSData->Session->UserToken && !ImpersonateLoggedOnUser(LSData->Session->UserToken)) + if (LSData->Session->UserToken != NULL && !ImpersonateLoggedOnUser(LSData->Session->UserToken)) { ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError()); return 0; @@ -363,7 +392,7 @@ UnregisterClassW(WINLOGON_SAS_CLASS, hAppInstance); }
-BOOL +NTSTATUS HandleShutdown( IN OUT PWLSESSION Session, IN DWORD wlxAction) @@ -423,11 +452,11 @@ if (FALSE) { /* FIXME - only show this dialog if it's a shutdown and the computer doesn't support APM */ - DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_SHUTDOWNCOMPUTER), 0, ShutdownComputerWindowProc); + DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_SHUTDOWNCOMPUTER), GetDesktopWindow(), ShutdownComputerWindowProc); } NtShutdownSystem(ShutdownNoReboot); } - return TRUE; + return STATUS_SUCCESS; }
static VOID @@ -508,9 +537,9 @@ DWORD wlxAction = WLX_SAS_ACTION_NONE;
if (Session->LogonStatus == WKSTA_IS_LOGGED_ON) - wlxAction = Session->Gina.Functions.WlxLoggedOnSAS(Session->Gina.Context, dwSasType, NULL); + wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOnSAS(Session->Gina.Context, dwSasType, NULL); else if (Session->LogonStatus == WKSTA_IS_LOCKED) - wlxAction = Session->Gina.Functions.WlxWkstaLockedSAS(Session->Gina.Context, dwSasType); + wlxAction = (DWORD)Session->Gina.Functions.WlxWkstaLockedSAS(Session->Gina.Context, dwSasType); else { /* Display a new dialog (if necessary) */ @@ -528,7 +557,7 @@ ZeroMemory(&Session->Profile, sizeof(Session->Profile)); Session->Options = 0;
- wlxAction = Session->Gina.Functions.WlxLoggedOutSAS( + wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS( Session->Gina.Context, Session->SASAction, &Session->LogonId,
Modified: trunk/reactos/base/system/winlogon/screensaver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/screen... ============================================================================== --- trunk/reactos/base/system/winlogon/screensaver.c (original) +++ trunk/reactos/base/system/winlogon/screensaver.c Mon Oct 9 23:19:28 2006 @@ -244,7 +244,7 @@ PROCESS_INFORMATION ProcessInformation; HANDLE HandleArray[2]; LONG rc; - NTSTATUS Status; + DWORD Status; BOOL ret = FALSE;
if (!ImpersonateLoggedOnUser(Session->UserToken))
Modified: trunk/reactos/base/system/winlogon/setup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/setup.... ============================================================================== --- trunk/reactos/base/system/winlogon/setup.c (original) +++ trunk/reactos/base/system/winlogon/setup.c Mon Oct 9 23:19:28 2006 @@ -70,7 +70,7 @@ }
-BOOL +static BOOL SetSetupType (DWORD dwSetupType) { DWORD dwError;
Modified: trunk/reactos/base/system/winlogon/setup.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/setup.... ============================================================================== --- trunk/reactos/base/system/winlogon/setup.h (original) +++ trunk/reactos/base/system/winlogon/setup.h Mon Oct 9 23:19:28 2006 @@ -28,7 +28,6 @@ #define __SETUP_H__
DWORD GetSetupType (VOID); -BOOL SetSetupType (DWORD dwSetupType); BOOL RunSetup (VOID);
#endif /* __SETUP_H__ */
Modified: trunk/reactos/base/system/winlogon/winlogon.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlog... ============================================================================== --- trunk/reactos/base/system/winlogon/winlogon.c (original) +++ trunk/reactos/base/system/winlogon/winlogon.c Mon Oct 9 23:19:28 2006 @@ -102,10 +102,8 @@ hService = OpenServiceW(hSCManager, ServiceName, SERVICE_START); if (!hService) goto cleanup; -#if 0 if (!StartServiceW(hService, 0, NULL)) goto cleanup; -#endif
ret = TRUE;
@@ -140,9 +138,7 @@ return FALSE; }
-#if 0 WaitForSingleObject(LsassInitEvent, INFINITE); -#endif CloseHandle(LsassInitEvent);
return TRUE; @@ -360,6 +356,7 @@ ULONG AuthenticationPackage; NTSTATUS Status; #endif + ULONG HardErrorResponse; MSG Msg;
UNREFERENCED_PARAMETER(hPrevInstance); @@ -377,27 +374,27 @@ }
WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, sizeof(WLSESSION)); + if (!WLSession) + { + ERR("WL: Could not allocate memory for winlogon instance\n"); + NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse); + ExitProcess(1); + } ZeroMemory(WLSession, sizeof(WLSESSION)); - if (!WLSession) - { - ERR("WL: Could not allocate memory for winlogon instance\n"); - NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, 0, 0); + WLSession->DialogTimeout = 120; /* 2 minutes */ + + if (!CreateWindowStationAndDesktops(WLSession)) + { + ERR("WL: Could not create window station and desktops\n"); + NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse); ExitProcess(1); } - WLSession->DialogTimeout = 120; /* 2 minutes */ - - if (!CreateWindowStationAndDesktops(WLSession)) - { - ERR("WL: Could not create window station and desktops\n"); - NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, 0, 0); - ExitProcess(1); - } LockWorkstation(WLSession);
if (!StartServicesManager()) { ERR("WL: Could not start services.exe\n"); - NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, 0, 0); + NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse); ExitProcess(1); }
@@ -420,7 +417,7 @@ if (!StartLsass()) { DPRINT1("WL: Failed to start lsass.exe service (error %lu)\n", GetLastError()); - NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, 0, 0); + NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, OptionOk, &HardErrorResponse); ExitProcess(1); }
@@ -428,7 +425,7 @@ if (!GinaInit(WLSession)) { ERR("WL: Failed to initialize Gina\n"); - DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_GINALOADFAILED), 0, GinaLoadFailedWindowProc, (LPARAM)L""); + DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_GINALOADFAILED), GetDesktopWindow(), GinaLoadFailedWindowProc, (LPARAM)L""); HandleShutdown(WLSession, WLX_SAS_ACTION_SHUTDOWN_REBOOT); ExitProcess(1); }
Modified: trunk/reactos/base/system/winlogon/winlogon.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlog... ============================================================================== --- trunk/reactos/base/system/winlogon/winlogon.h (original) +++ trunk/reactos/base/system/winlogon/winlogon.h Mon Oct 9 23:19:28 2006 @@ -89,7 +89,7 @@
/* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 3.5.1) */ PFWLXSCREENSAVERNOTIFY WlxScreenSaverNotify; /* optional */ - PFWLXSTARTAPPLICATION WlxStartApplication; /* optional, not called ATM */ + PFWLXSTARTAPPLICATION WlxStartApplication; /* optional */
/* Functions available if WlxVersion >= WLX_VERSION_1_2 (MS Windows NT 4.0) */
@@ -179,7 +179,7 @@ /* sas.c */ BOOL SetDefaultLanguage( - IN BOOLEAN UserProfile); + IN BOOL UserProfile);
BOOL InitializeSAS( @@ -213,7 +213,7 @@ CreateWindowStationAndDesktops( IN OUT PWLSESSION Session);
-BOOL +NTSTATUS HandleShutdown( IN OUT PWLSESSION Session, IN DWORD wlxAction);
Modified: trunk/reactos/base/system/winlogon/wlx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/wlx.c?... ============================================================================== --- trunk/reactos/base/system/winlogon/wlx.c (original) +++ trunk/reactos/base/system/winlogon/wlx.c Mon Oct 9 23:19:28 2006 @@ -896,7 +896,10 @@ }
/* FIXME: big HACK */ - Session->WinlogonDesktop = Session->ApplicationDesktop; + CloseDesktop(Session->WinlogonDesktop); + CloseDesktop(Session->ScreenSaverDesktop); + Session->WinlogonDesktop = OpenDesktopW(L"Default", 0, FALSE, GENERIC_ALL); + Session->ScreenSaverDesktop = OpenDesktopW(L"Default", 0, FALSE, GENERIC_ALL);
/* * Switch to winlogon desktop @@ -914,13 +917,25 @@ if (!ret) { if (Session->ApplicationDesktop) + { CloseDesktop(Session->ApplicationDesktop); + Session->ApplicationDesktop = NULL; + } if (Session->WinlogonDesktop) + { CloseDesktop(Session->WinlogonDesktop); + Session->WinlogonDesktop = NULL; + } if (Session->ScreenSaverDesktop) + { CloseDesktop(Session->ScreenSaverDesktop); + Session->ScreenSaverDesktop = NULL; + } if (Session->InteractiveWindowStation) + { CloseWindowStation(Session->InteractiveWindowStation); + Session->InteractiveWindowStation = NULL; + } } HeapFree(GetProcessHeap(), 0, pDefaultAcl); HeapFree(GetProcessHeap(), 0, pUserDesktopAcl);