mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
- 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:
parent
e16a26e1f2
commit
ca6e7110f5
7 changed files with 72 additions and 32 deletions
|
@ -28,16 +28,29 @@ static BOOL
|
||||||
StartTaskManager(
|
StartTaskManager(
|
||||||
IN OUT PWLSESSION Session)
|
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(
|
return Session->Gina.Functions.WlxStartApplication(
|
||||||
Session->Gina.Context,
|
Session->Gina.Context,
|
||||||
L"Default",
|
L"Default",
|
||||||
NULL,
|
lpEnvironment,
|
||||||
L"taskmgr.exe");
|
L"taskmgr.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
SetDefaultLanguage(
|
SetDefaultLanguage(
|
||||||
IN BOOLEAN UserProfile)
|
IN BOOL UserProfile)
|
||||||
{
|
{
|
||||||
HKEY BaseKey;
|
HKEY BaseKey;
|
||||||
LPCWSTR SubKey;
|
LPCWSTR SubKey;
|
||||||
|
@ -146,11 +159,11 @@ static BOOL
|
||||||
HandleLogon(
|
HandleLogon(
|
||||||
IN OUT PWLSESSION Session)
|
IN OUT PWLSESSION Session)
|
||||||
{
|
{
|
||||||
PROFILEINFOW ProfileInfo = { 0 };
|
PROFILEINFOW ProfileInfo = { 0, };
|
||||||
LPVOID lpEnvironment = NULL;
|
LPVOID lpEnvironment = NULL;
|
||||||
BOOLEAN Old;
|
BOOLEAN Old;
|
||||||
|
|
||||||
if (!(Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
||||||
{
|
{
|
||||||
/* Load the user profile */
|
/* Load the user profile */
|
||||||
ProfileInfo.dwSize = sizeof(PROFILEINFOW);
|
ProfileInfo.dwSize = sizeof(PROFILEINFOW);
|
||||||
|
@ -165,7 +178,6 @@ HandleLogon(
|
||||||
if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
|
if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
|
||||||
{
|
{
|
||||||
ERR("WL: LoadUserProfileW() failed\n");
|
ERR("WL: LoadUserProfileW() failed\n");
|
||||||
CloseHandle(Session->UserToken);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,9 +189,12 @@ HandleLogon(
|
||||||
TRUE))
|
TRUE))
|
||||||
{
|
{
|
||||||
ERR("WL: CreateEnvironmentBlock() failed\n");
|
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);
|
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
|
||||||
CloseHandle(Session->UserToken);
|
CloseHandle(Session->UserToken);
|
||||||
|
Session->UserToken = NULL;
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* FIXME: use Session->Profile.pszEnvironment */
|
/* FIXME: use Session->Profile.pszEnvironment */
|
||||||
|
@ -195,7 +210,15 @@ HandleLogon(
|
||||||
|
|
||||||
/* Set default language */
|
/* Set default language */
|
||||||
if (!SetDefaultLanguage(TRUE))
|
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;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Session->Gina.Functions.WlxActivateUserShell(
|
if (!Session->Gina.Functions.WlxActivateUserShell(
|
||||||
Session->Gina.Context,
|
Session->Gina.Context,
|
||||||
|
@ -203,6 +226,12 @@ HandleLogon(
|
||||||
NULL, /* FIXME */
|
NULL, /* FIXME */
|
||||||
lpEnvironment))
|
lpEnvironment))
|
||||||
{
|
{
|
||||||
|
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
||||||
|
{
|
||||||
|
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
|
||||||
|
CloseHandle(Session->UserToken);
|
||||||
|
Session->UserToken = NULL;
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/*if(!GinaInst->Functions->WlxActivateUserShell(GinaInst->Context,
|
/*if(!GinaInst->Functions->WlxActivateUserShell(GinaInst->Context,
|
||||||
|
@ -222,7 +251,7 @@ HandleLogon(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!InitializeScreenSaver(Session))
|
if (!InitializeScreenSaver(Session))
|
||||||
ERR("WL: Failed to initialize screen saver\n");
|
WARN("WL: Failed to initialize screen saver\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +270,7 @@ LogoffShutdownThread(LPVOID Parameter)
|
||||||
{
|
{
|
||||||
PLOGOFF_SHUTDOWN_DATA LSData = (PLOGOFF_SHUTDOWN_DATA)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());
|
ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -363,7 +392,7 @@ UninitializeSAS(
|
||||||
UnregisterClassW(WINLOGON_SAS_CLASS, hAppInstance);
|
UnregisterClassW(WINLOGON_SAS_CLASS, hAppInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
NTSTATUS
|
||||||
HandleShutdown(
|
HandleShutdown(
|
||||||
IN OUT PWLSESSION Session,
|
IN OUT PWLSESSION Session,
|
||||||
IN DWORD wlxAction)
|
IN DWORD wlxAction)
|
||||||
|
@ -423,11 +452,11 @@ HandleShutdown(
|
||||||
if (FALSE)
|
if (FALSE)
|
||||||
{
|
{
|
||||||
/* FIXME - only show this dialog if it's a shutdown and the computer doesn't support APM */
|
/* 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);
|
NtShutdownSystem(ShutdownNoReboot);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
@ -508,9 +537,9 @@ DispatchSAS(
|
||||||
DWORD wlxAction = WLX_SAS_ACTION_NONE;
|
DWORD wlxAction = WLX_SAS_ACTION_NONE;
|
||||||
|
|
||||||
if (Session->LogonStatus == WKSTA_IS_LOGGED_ON)
|
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)
|
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
|
else
|
||||||
{
|
{
|
||||||
/* Display a new dialog (if necessary) */
|
/* Display a new dialog (if necessary) */
|
||||||
|
@ -528,7 +557,7 @@ DispatchSAS(
|
||||||
ZeroMemory(&Session->Profile, sizeof(Session->Profile));
|
ZeroMemory(&Session->Profile, sizeof(Session->Profile));
|
||||||
Session->Options = 0;
|
Session->Options = 0;
|
||||||
|
|
||||||
wlxAction = Session->Gina.Functions.WlxLoggedOutSAS(
|
wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS(
|
||||||
Session->Gina.Context,
|
Session->Gina.Context,
|
||||||
Session->SASAction,
|
Session->SASAction,
|
||||||
&Session->LogonId,
|
&Session->LogonId,
|
||||||
|
|
|
@ -244,7 +244,7 @@ StartScreenSaver(
|
||||||
PROCESS_INFORMATION ProcessInformation;
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
HANDLE HandleArray[2];
|
HANDLE HandleArray[2];
|
||||||
LONG rc;
|
LONG rc;
|
||||||
NTSTATUS Status;
|
DWORD Status;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
if (!ImpersonateLoggedOnUser(Session->UserToken))
|
if (!ImpersonateLoggedOnUser(Session->UserToken))
|
||||||
|
|
|
@ -70,7 +70,7 @@ GetSetupType(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
static BOOL
|
||||||
SetSetupType (DWORD dwSetupType)
|
SetSetupType (DWORD dwSetupType)
|
||||||
{
|
{
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#define __SETUP_H__
|
#define __SETUP_H__
|
||||||
|
|
||||||
DWORD GetSetupType (VOID);
|
DWORD GetSetupType (VOID);
|
||||||
BOOL SetSetupType (DWORD dwSetupType);
|
|
||||||
BOOL RunSetup (VOID);
|
BOOL RunSetup (VOID);
|
||||||
|
|
||||||
#endif /* __SETUP_H__ */
|
#endif /* __SETUP_H__ */
|
||||||
|
|
|
@ -102,10 +102,8 @@ StartCustomService(
|
||||||
hService = OpenServiceW(hSCManager, ServiceName, SERVICE_START);
|
hService = OpenServiceW(hSCManager, ServiceName, SERVICE_START);
|
||||||
if (!hService)
|
if (!hService)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
#if 0
|
|
||||||
if (!StartServiceW(hService, 0, NULL))
|
if (!StartServiceW(hService, 0, NULL))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
|
@ -140,9 +138,7 @@ StartLsass(VOID)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
WaitForSingleObject(LsassInitEvent, INFINITE);
|
WaitForSingleObject(LsassInitEvent, INFINITE);
|
||||||
#endif
|
|
||||||
CloseHandle(LsassInitEvent);
|
CloseHandle(LsassInitEvent);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -360,6 +356,7 @@ WinMain(
|
||||||
ULONG AuthenticationPackage;
|
ULONG AuthenticationPackage;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
#endif
|
#endif
|
||||||
|
ULONG HardErrorResponse;
|
||||||
MSG Msg;
|
MSG Msg;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
|
@ -377,19 +374,19 @@ WinMain(
|
||||||
}
|
}
|
||||||
|
|
||||||
WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, sizeof(WLSESSION));
|
WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, sizeof(WLSESSION));
|
||||||
ZeroMemory(WLSession, sizeof(WLSESSION));
|
|
||||||
if (!WLSession)
|
if (!WLSession)
|
||||||
{
|
{
|
||||||
ERR("WL: Could not allocate memory for winlogon instance\n");
|
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);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
|
ZeroMemory(WLSession, sizeof(WLSESSION));
|
||||||
WLSession->DialogTimeout = 120; /* 2 minutes */
|
WLSession->DialogTimeout = 120; /* 2 minutes */
|
||||||
|
|
||||||
if (!CreateWindowStationAndDesktops(WLSession))
|
if (!CreateWindowStationAndDesktops(WLSession))
|
||||||
{
|
{
|
||||||
ERR("WL: Could not create window station and desktops\n");
|
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);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
LockWorkstation(WLSession);
|
LockWorkstation(WLSession);
|
||||||
|
@ -397,7 +394,7 @@ WinMain(
|
||||||
if (!StartServicesManager())
|
if (!StartServicesManager())
|
||||||
{
|
{
|
||||||
ERR("WL: Could not start services.exe\n");
|
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);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +417,7 @@ WinMain(
|
||||||
if (!StartLsass())
|
if (!StartLsass())
|
||||||
{
|
{
|
||||||
DPRINT1("WL: Failed to start lsass.exe service (error %lu)\n", GetLastError());
|
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);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +425,7 @@ WinMain(
|
||||||
if (!GinaInit(WLSession))
|
if (!GinaInit(WLSession))
|
||||||
{
|
{
|
||||||
ERR("WL: Failed to initialize Gina\n");
|
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);
|
HandleShutdown(WLSession, WLX_SAS_ACTION_SHUTDOWN_REBOOT);
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ typedef struct _GINAFUNCTIONS
|
||||||
|
|
||||||
/* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 3.5.1) */
|
/* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 3.5.1) */
|
||||||
PFWLXSCREENSAVERNOTIFY WlxScreenSaverNotify; /* optional */
|
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) */
|
/* Functions available if WlxVersion >= WLX_VERSION_1_2 (MS Windows NT 4.0) */
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ UpdatePerUserSystemParameters(DWORD dwUnknown,
|
||||||
/* sas.c */
|
/* sas.c */
|
||||||
BOOL
|
BOOL
|
||||||
SetDefaultLanguage(
|
SetDefaultLanguage(
|
||||||
IN BOOLEAN UserProfile);
|
IN BOOL UserProfile);
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
InitializeSAS(
|
InitializeSAS(
|
||||||
|
@ -213,7 +213,7 @@ BOOL
|
||||||
CreateWindowStationAndDesktops(
|
CreateWindowStationAndDesktops(
|
||||||
IN OUT PWLSESSION Session);
|
IN OUT PWLSESSION Session);
|
||||||
|
|
||||||
BOOL
|
NTSTATUS
|
||||||
HandleShutdown(
|
HandleShutdown(
|
||||||
IN OUT PWLSESSION Session,
|
IN OUT PWLSESSION Session,
|
||||||
IN DWORD wlxAction);
|
IN DWORD wlxAction);
|
||||||
|
|
|
@ -896,7 +896,10 @@ CreateWindowStationAndDesktops(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: big HACK */
|
/* 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
|
* Switch to winlogon desktop
|
||||||
|
@ -914,13 +917,25 @@ cleanup:
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
if (Session->ApplicationDesktop)
|
if (Session->ApplicationDesktop)
|
||||||
|
{
|
||||||
CloseDesktop(Session->ApplicationDesktop);
|
CloseDesktop(Session->ApplicationDesktop);
|
||||||
|
Session->ApplicationDesktop = NULL;
|
||||||
|
}
|
||||||
if (Session->WinlogonDesktop)
|
if (Session->WinlogonDesktop)
|
||||||
|
{
|
||||||
CloseDesktop(Session->WinlogonDesktop);
|
CloseDesktop(Session->WinlogonDesktop);
|
||||||
|
Session->WinlogonDesktop = NULL;
|
||||||
|
}
|
||||||
if (Session->ScreenSaverDesktop)
|
if (Session->ScreenSaverDesktop)
|
||||||
|
{
|
||||||
CloseDesktop(Session->ScreenSaverDesktop);
|
CloseDesktop(Session->ScreenSaverDesktop);
|
||||||
|
Session->ScreenSaverDesktop = NULL;
|
||||||
|
}
|
||||||
if (Session->InteractiveWindowStation)
|
if (Session->InteractiveWindowStation)
|
||||||
|
{
|
||||||
CloseWindowStation(Session->InteractiveWindowStation);
|
CloseWindowStation(Session->InteractiveWindowStation);
|
||||||
|
Session->InteractiveWindowStation = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, pDefaultAcl);
|
HeapFree(GetProcessHeap(), 0, pDefaultAcl);
|
||||||
HeapFree(GetProcessHeap(), 0, pUserDesktopAcl);
|
HeapFree(GetProcessHeap(), 0, pUserDesktopAcl);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue