- Start NetLogon service (lsass.exe)

- Fix lots of problems in error handling
- Some general cleanup

svn path=/trunk/; revision=24477
This commit is contained in:
Hervé Poussineau 2006-10-09 19:19:28 +00:00
parent e16a26e1f2
commit ca6e7110f5
7 changed files with 72 additions and 32 deletions

View file

@ -28,16 +28,29 @@ static BOOL
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 @@ static BOOL
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 @@ HandleLogon(
if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
{
ERR("WL: LoadUserProfileW() failed\n");
CloseHandle(Session->UserToken);
return FALSE;
}
}
@ -177,9 +189,12 @@ HandleLogon(
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 @@ HandleLogon(
/* 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 @@ HandleLogon(
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 @@ HandleLogon(
*/
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 @@ LogoffShutdownThread(LPVOID Parameter)
{
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 @@ UninitializeSAS(
UnregisterClassW(WINLOGON_SAS_CLASS, hAppInstance);
}
BOOL
NTSTATUS
HandleShutdown(
IN OUT PWLSESSION Session,
IN DWORD wlxAction)
@ -423,11 +452,11 @@ HandleShutdown(
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 @@ DispatchSAS(
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 @@ DispatchSAS(
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,

View file

@ -244,7 +244,7 @@ StartScreenSaver(
PROCESS_INFORMATION ProcessInformation;
HANDLE HandleArray[2];
LONG rc;
NTSTATUS Status;
DWORD Status;
BOOL ret = FALSE;
if (!ImpersonateLoggedOnUser(Session->UserToken))

View file

@ -70,7 +70,7 @@ GetSetupType(VOID)
}
BOOL
static BOOL
SetSetupType (DWORD dwSetupType)
{
DWORD dwError;

View file

@ -28,7 +28,6 @@
#define __SETUP_H__
DWORD GetSetupType (VOID);
BOOL SetSetupType (DWORD dwSetupType);
BOOL RunSetup (VOID);
#endif /* __SETUP_H__ */

View file

@ -102,10 +102,8 @@ StartCustomService(
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 @@ StartLsass(VOID)
return FALSE;
}
#if 0
WaitForSingleObject(LsassInitEvent, INFINITE);
#endif
CloseHandle(LsassInitEvent);
return TRUE;
@ -360,6 +356,7 @@ WinMain(
ULONG AuthenticationPackage;
NTSTATUS Status;
#endif
ULONG HardErrorResponse;
MSG Msg;
UNREFERENCED_PARAMETER(hPrevInstance);
@ -377,19 +374,19 @@ WinMain(
}
WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, sizeof(WLSESSION));
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);
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
ExitProcess(1);
}
ZeroMemory(WLSession, sizeof(WLSESSION));
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);
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
ExitProcess(1);
}
LockWorkstation(WLSession);
@ -397,7 +394,7 @@ WinMain(
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 @@ WinMain(
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 @@ WinMain(
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);
}

View file

@ -89,7 +89,7 @@ typedef struct _GINAFUNCTIONS
/* 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 @@ UpdatePerUserSystemParameters(DWORD dwUnknown,
/* sas.c */
BOOL
SetDefaultLanguage(
IN BOOLEAN UserProfile);
IN BOOL UserProfile);
BOOL
InitializeSAS(
@ -213,7 +213,7 @@ BOOL
CreateWindowStationAndDesktops(
IN OUT PWLSESSION Session);
BOOL
NTSTATUS
HandleShutdown(
IN OUT PWLSESSION Session,
IN DWORD wlxAction);

View file

@ -896,7 +896,10 @@ CreateWindowStationAndDesktops(
}
/* 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 @@ cleanup:
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);