Implement shutdown and unlocking

Remove some useless code
Implement Timeout for dialogs

svn path=/trunk/; revision=23433
This commit is contained in:
Hervé Poussineau 2006-08-03 13:50:40 +00:00
parent 21ea0d9494
commit e202c810ac
4 changed files with 113 additions and 189 deletions

View file

@ -28,35 +28,11 @@ static BOOL
StartTaskManager( StartTaskManager(
IN OUT PWLSESSION Session) IN OUT PWLSESSION Session)
{ {
STARTUPINFO StartupInfo; return Session->MsGina.Functions.WlxStartApplication(
PROCESS_INFORMATION ProcessInformation; Session->MsGina.Context,
L"Default",
if (Session->LogonStatus == WKSTA_IS_LOGGED_OFF)
return FALSE;
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
StartupInfo.lpTitle = NULL;
StartupInfo.dwFlags = 0;
StartupInfo.cbReserved2 = 0;
StartupInfo.lpReserved2 = 0;
CreateProcessW(
L"taskmgr.exe",
NULL, NULL,
NULL, L"taskmgr.exe");
NULL,
FALSE,
CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);
CloseHandle (ProcessInformation.hProcess);
CloseHandle (ProcessInformation.hThread);
return TRUE;
} }
static BOOL static BOOL
@ -107,25 +83,31 @@ HandleLogon(
return Session->MsGina.Functions.WlxActivateUserShell( return Session->MsGina.Functions.WlxActivateUserShell(
Session->MsGina.Context, Session->MsGina.Context,
L"WinSta0\\Default",//NULL, /* FIXME */ L"Default",//NULL, /* FIXME */
NULL, /* FIXME */ NULL, /* FIXME */
lpEnvironment); lpEnvironment);
} }
static BOOL static VOID
HandleLogoff( HandleLogoff(
IN OUT PWLSESSION Session) IN OUT PWLSESSION Session)
{ {
FIXME("FIXME: HandleLogoff() unimplemented\n"); FIXME("FIXME: HandleLogoff() unimplemented\n");
return FALSE;
} }
static BOOL static BOOL
HandleShutdown( HandleShutdown(
IN OUT PWLSESSION Session) IN OUT PWLSESSION Session,
IN DWORD wlxAction)
{ {
FIXME("FIXME: HandleShutdown() unimplemented\n"); FIXME("FIXME: HandleShutdown() unimplemented\n");
return FALSE; if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
NtShutdownSystem(ShutdownReboot);
else if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF)
NtShutdownSystem(ShutdownPowerOff);
else
NtShutdownSystem(ShutdownNoReboot);
return TRUE;
} }
static VOID static VOID
@ -138,8 +120,8 @@ DoGenericAction(
case WLX_SAS_ACTION_LOGON: /* 0x01 */ case WLX_SAS_ACTION_LOGON: /* 0x01 */
if (HandleLogon(Session)) if (HandleLogon(Session))
{ {
SwitchDesktop(Session->ApplicationDesktop);
Session->LogonStatus = WKSTA_IS_LOGGED_ON; Session->LogonStatus = WKSTA_IS_LOGGED_ON;
SwitchDesktop(WLSession->ApplicationDesktop);
} }
break; break;
case WLX_SAS_ACTION_NONE: /* 0x02 */ case WLX_SAS_ACTION_NONE: /* 0x02 */
@ -154,6 +136,8 @@ DoGenericAction(
break; break;
case WLX_SAS_ACTION_LOGOFF: /* 0x04 */ case WLX_SAS_ACTION_LOGOFF: /* 0x04 */
case WLX_SAS_ACTION_SHUTDOWN: /* 0x05 */ case WLX_SAS_ACTION_SHUTDOWN: /* 0x05 */
case WLX_SAS_ACTION_SHUTDOWN_POWER_OFF: /* 0x0a */
case WLX_SAS_ACTION_SHUTDOWN_REBOOT: /* 0x0b */
if (Session->LogonStatus != WKSTA_IS_LOGGED_OFF) if (Session->LogonStatus != WKSTA_IS_LOGGED_OFF)
{ {
if (!Session->MsGina.Functions.WlxIsLogoffOk(Session->MsGina.Context)) if (!Session->MsGina.Functions.WlxIsLogoffOk(Session->MsGina.Context))
@ -165,11 +149,16 @@ DoGenericAction(
Session->MsGina.Functions.WlxDisplaySASNotice(Session->MsGina.Context); Session->MsGina.Functions.WlxDisplaySASNotice(Session->MsGina.Context);
} }
if (WLX_SHUTTINGDOWN(wlxAction)) if (WLX_SHUTTINGDOWN(wlxAction))
HandleShutdown(Session); HandleShutdown(Session, wlxAction);
break; break;
case WLX_SAS_ACTION_TASKLIST: /* 0x07 */ case WLX_SAS_ACTION_TASKLIST: /* 0x07 */
SwitchDesktop(WLSession->ApplicationDesktop);
StartTaskManager(Session); StartTaskManager(Session);
break; break;
case WLX_SAS_ACTION_UNLOCK_WKSTA: /* 0x08 */
SwitchDesktop(WLSession->ApplicationDesktop);
Session->LogonStatus = WKSTA_IS_LOGGED_ON;
break;
default: default:
WARN("Unknown SAS action 0x%lx\n", wlxAction); WARN("Unknown SAS action 0x%lx\n", wlxAction);
} }

View file

@ -51,7 +51,7 @@ ShutdownComputerWindowProc(
} }
static BOOL static BOOL
StartServicesManager(void) StartServicesManager(VOID)
{ {
HANDLE ServicesInitEvent; HANDLE ServicesInitEvent;
BOOLEAN Result; BOOLEAN Result;
@ -182,6 +182,7 @@ StartLsass(VOID)
return TRUE; return TRUE;
} }
#if 0
static BOOL static BOOL
OpenRegistryKey( OpenRegistryKey(
OUT HKEY *WinLogonKey) OUT HKEY *WinLogonKey)
@ -192,6 +193,7 @@ OpenRegistryKey(
KEY_QUERY_VALUE, KEY_QUERY_VALUE,
WinLogonKey); WinLogonKey);
} }
#endif
#if 0 #if 0
static BOOL static BOOL
@ -228,7 +230,8 @@ StartProcess(
#endif #endif
/* /*
static BOOL RestartShell(void) static BOOL RestartShell(
IN OUT PWLSESSION Session)
{ {
HKEY WinLogonKey; HKEY WinLogonKey;
DWORD Type, Size, Value; DWORD Type, Size, Value;
@ -255,6 +258,7 @@ static BOOL RestartShell(void)
} }
*/ */
#if 0
static PWCHAR static PWCHAR
GetUserInit( GetUserInit(
OUT WCHAR *CommandLine, OUT WCHAR *CommandLine,
@ -300,8 +304,7 @@ GetUserInit(
return CommandLine; return CommandLine;
} }
static BOOL
BOOL
DoBrokenLogonUser( DoBrokenLogonUser(
IN PWLSESSION WLSession, IN PWLSESSION WLSession,
IN PWLX_MPR_NOTIFY_INFO pMprNotifyInfo) IN PWLX_MPR_NOTIFY_INFO pMprNotifyInfo)
@ -423,6 +426,7 @@ DoBrokenLogonUser(
return TRUE; return TRUE;
} }
#endif
static BOOL static BOOL
DisplayStatusMessage( DisplayStatusMessage(
@ -441,70 +445,6 @@ DisplayStatusMessage(
return Session->MsGina.Functions.WlxDisplayStatusMessage(Session->MsGina.Context, hDesktop, 0, NULL, StatusMsg); return Session->MsGina.Functions.WlxDisplayStatusMessage(Session->MsGina.Context, hDesktop, 0, NULL, StatusMsg);
} }
#if 0
static BOOL
InitServices(VOID)
{
/*WCHAR StatusMsg[256];
LoadString(hAppInstance, IDS_REACTOSISSTARTINGUP, StatusMsg, 256 * sizeof(WCHAR));
DisplayStatusMessage(WLSession, WLSession->ApplicationDesktop, 0, NULL, StatusMsg);*/
/* start system processes (services.exe & lsass.exe) */
if(StartProcess(L"StartServices"))
{
if(!StartServicesManager())
{
DPRINT1("WL: Failed to start Services (0x%X)\n", GetLastError());
}
}
else
{
DPRINT1("WL: StartProcess() failed!\n");
}
return TRUE;
}
#endif
#if 0
static DWORD
DoLogin(
IN OUT PWLSESSION Session)
{
DWORD WlxAction, Options;
WLX_MPR_NOTIFY_INFO MprNotifyInfo;
PWLX_PROFILE_V2_0 Profile;
PSID LogonSid = NULL;
HANDLE Token;
/* FIXME - Create a Logon Sid
if(!(LogonSid = CreateUserLogonSid(NULL)))
{
return WLX_SAS_ACTION_NONE;
}
*/
Options = 0;
WlxAction = Session->MsGina.Functions.WlxLoggedOutSAS(Session->MsGina.Context,
Session->SASAction,
&Session->LogonId,
LogonSid,
&Options,
&Token,
&MprNotifyInfo,
(PVOID*)&Profile);
if (WlxAction == WLX_SAS_ACTION_LOGON)
{
Session->UserToken = Token;
if (!DoBrokenLogonUser(Session, &MprNotifyInfo))
WlxAction = WLX_SAS_ACTION_NONE;
}
return WlxAction;
}
#endif
static VOID static VOID
SessionLoop( SessionLoop(
IN OUT PWLSESSION Session) IN OUT PWLSESSION Session)
@ -526,73 +466,20 @@ SessionLoop(
/* Don't go there! */ /* Don't go there! */
#if 0
/* FIXME - don't leave the loop when suspending the computer */
if(WLX_SUSPENDING(WlxAction))
{
Session->LogonStatus = LOGON_NONE;
WlxAction = WLX_SAS_ACTION_NONE;
/* don't leave the loop */
continue;
}
if(WLX_SHUTTINGDOWN(WlxAction))
{
Session->LogonStatus = LOGON_SHUTDOWN;
/* leave the loop here */
break;
}
#endif
/* /*
LoadString(hAppInstance, IDS_PREPARENETWORKCONNECTIONS, StatusMsg, 256 * sizeof(WCHAR)); DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_PREPARENETWORKCONNECTIONS);
MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context,
ApplicationDesktop,
0,
NULL,
StatusMsg);
Sleep(150); Sleep(150);
LoadString(hAppInstance, IDS_APPLYINGCOMPUTERSETTINGS, StatusMsg, 256 * sizeof(WCHAR)); DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGCOMPUTERSETTINGS);
MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context,
ApplicationDesktop,
0,
NULL,
StatusMsg);
Sleep(150); Sleep(150);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context);
Sleep(250);
LoadString(hAppInstance, IDS_LOADINGYOURPERSONALSETTINGS, StatusMsg, 256 * sizeof(WCHAR));
MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context,
ApplicationDesktop,
0,
NULL,
StatusMsg);
Sleep(150); Sleep(150);
LoadString(hAppInstance, IDS_APPLYINGYOURPERSONALSETTINGS, StatusMsg, 256 * sizeof(WCHAR)); DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context,
ApplicationDesktop,
0,
NULL,
StatusMsg);
Sleep(150); Sleep(150);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); RemoveStatusMessage(Session);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context);
if(!MsGinaInst->Functions->WlxActivateUserShell(MsGinaInst->Context, if(!MsGinaInst->Functions->WlxActivateUserShell(MsGinaInst->Context,
L"WinSta0\\Default", L"WinSta0\\Default",
@ -604,34 +491,19 @@ SessionLoop(
SetEvent(hShutdownEvent); SetEvent(hShutdownEvent);
} }
WaitForSingleObject(hShutdownEvent, INFINITE); WaitForSingleObject(hShutdownEvent, INFINITE);
CloseHandle(hShutdownEvent); CloseHandle(hShutdownEvent);
LoadString(hAppInstance, IDS_SAVEYOURSETTINGS, StatusMsg, 256 * sizeof(WCHAR)); DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_SAVEYOURSETTINGS);
MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context,
ApplicationDesktop,
0,
NULL,
StatusMsg);
Sleep(150); Sleep(150);
MsGinaInst->Functions->WlxShutdown(MsGinaInst->Context, WLX_SAS_ACTION_SHUTDOWN); MsGinaInst->Functions->WlxShutdown(MsGinaInst->Context, WLX_SAS_ACTION_SHUTDOWN);
DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_REACTOSISSHUTTINGDOWN);
LoadString(hAppInstance, IDS_REACTOSISSHUTTINGDOWN, StatusMsg, 256 * sizeof(WCHAR));
MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context,
ApplicationDesktop,
0,
NULL,
StatusMsg);
Sleep(250); Sleep(250);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); RemoveStatusMessage(Session);
MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context);
*/ */
} }
@ -668,6 +540,7 @@ WinMain(
ExitProcess(1); ExitProcess(1);
return 1; return 1;
} }
WLSession->DialogTimeout = 120; /* 2 minutes */
if (!CreateWindowStationAndDesktops(WLSession)) if (!CreateWindowStationAndDesktops(WLSession))
{ {
@ -675,6 +548,7 @@ WinMain(
ExitProcess(1); ExitProcess(1);
return 1; return 1;
} }
LockWorkstation(WLSession);
/* Check for pending setup */ /* Check for pending setup */
if (GetSetupType() != 0) if (GetSetupType() != 0)
@ -682,6 +556,7 @@ WinMain(
DPRINT("Winlogon: CheckForSetup() in setup mode\n"); DPRINT("Winlogon: CheckForSetup() in setup mode\n");
/* Run setup and reboot when done */ /* Run setup and reboot when done */
RemoveStatusMessage(WLSession);
SwitchDesktop(WLSession->ApplicationDesktop); SwitchDesktop(WLSession->ApplicationDesktop);
RunSetup(); RunSetup();

View file

@ -114,6 +114,9 @@ typedef struct _MSGINAINSTANCE
#define WKSTA_IS_LOGGED_ON 1 #define WKSTA_IS_LOGGED_ON 1
#define WKSTA_IS_LOCKED 2 #define WKSTA_IS_LOCKED 2
#define LockWorkstation(Session)
#define UnlockWorkstation(Session)
typedef struct _WLSESSION typedef struct _WLSESSION
{ {
MSGINAINSTANCE MsGina; MSGINAINSTANCE MsGina;
@ -130,6 +133,8 @@ typedef struct _WLSESSION
LUID LogonId; LUID LogonId;
HANDLE UserToken; HANDLE UserToken;
DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
/* Logon informations */ /* Logon informations */
DWORD Options; DWORD Options;
WLX_MPR_NOTIFY_INFO MprNotifyInfo; WLX_MPR_NOTIFY_INFO MprNotifyInfo;

View file

@ -15,9 +15,49 @@
#define YDEBUG #define YDEBUG
#include <wine/debug.h> #include <wine/debug.h>
//#define UNIMPLEMENTED DbgPrint("WL: %S() at %S:%i unimplemented!\n", __FUNCTION__, __FILE__, __LINE__) static DLGPROC PreviousWindowProc;
static UINT_PTR IdTimer;
#define WINLOGON_DESKTOP L"Winlogon" static INT_PTR CALLBACK
DefaultWlxWindowProc(
IN HWND hwndDlg,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
if (uMsg == WM_TIMER && (UINT_PTR)wParam == IdTimer)
{
CHECKPOINT1;
EndDialog(hwndDlg, -1);
KillTimer(hwndDlg, IdTimer);
CHECKPOINT1;
return TRUE;
}
else if (uMsg == WM_INITDIALOG)
{
CHECKPOINT1;
PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
IdTimer = SetTimer(hwndDlg, 0, WLSession->DialogTimeout * 1000, NULL);
CHECKPOINT1;
if (IdTimer == 0)
return FALSE;
return TRUE;
}
else if (uMsg == WM_NCDESTROY)
{
CHECKPOINT1;
PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
CHECKPOINT1;
PreviousWindowProc = NULL;
return TRUE;
}
else
{
INT_PTR ret = PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
ret = PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
return ret;
}
}
/* /*
* @implemented * @implemented
@ -52,15 +92,16 @@ WlxSasNotify(
} }
/* /*
* @unimplemented * @implemented
*/ */
BOOL WINAPI BOOL WINAPI
WlxSetTimeout( WlxSetTimeout(
HANDLE hWlx, HANDLE hWlx,
DWORD Timeout) DWORD Timeout)
{ {
UNIMPLEMENTED; PWLSESSION Session = (PWLSESSION)hWlx;
return FALSE; Session->DialogTimeout = Timeout;
return TRUE;
} }
/* /*
@ -88,6 +129,7 @@ WlxMessageBox(
LPWSTR lpszTitle, LPWSTR lpszTitle,
UINT fuStyle) UINT fuStyle)
{ {
/* FIXME: Provide a custom window proc to be able to handle timeout */
return MessageBoxW(hwndOwner, lpszText, lpszTitle, fuStyle); return MessageBoxW(hwndOwner, lpszText, lpszTitle, fuStyle);
} }
@ -102,7 +144,10 @@ WlxDialogBox(
HWND hwndOwner, HWND hwndOwner,
DLGPROC dlgprc) DLGPROC dlgprc)
{ {
return (int)DialogBox(hInst, lpszTemplate, hwndOwner, dlgprc); if (PreviousWindowProc != NULL)
return -1;
PreviousWindowProc = dlgprc;
return (int)DialogBox(hInst, lpszTemplate, hwndOwner, DefaultWlxWindowProc);
} }
/* /*
@ -117,7 +162,10 @@ WlxDialogBoxParam(
DLGPROC dlgprc, DLGPROC dlgprc,
LPARAM dwInitParam) LPARAM dwInitParam)
{ {
return (int)DialogBoxParam(hInst, lpszTemplate, hwndOwner, dlgprc, dwInitParam); if (PreviousWindowProc != NULL)
return -1;
PreviousWindowProc = dlgprc;
return (int)DialogBoxParam(hInst, lpszTemplate, hwndOwner, DefaultWlxWindowProc, dwInitParam);
} }
/* /*
@ -131,7 +179,10 @@ WlxDialogBoxIndirect(
HWND hwndOwner, HWND hwndOwner,
DLGPROC dlgprc) DLGPROC dlgprc)
{ {
return (int)DialogBoxIndirect(hInst, hDialogTemplate, hwndOwner, dlgprc); if (PreviousWindowProc != NULL)
return -1;
PreviousWindowProc = dlgprc;
return (int)DialogBoxIndirect(hInst, hDialogTemplate, hwndOwner, DefaultWlxWindowProc);
} }
/* /*
@ -146,7 +197,10 @@ WlxDialogBoxIndirectParam(
DLGPROC dlgprc, DLGPROC dlgprc,
LPARAM dwInitParam) LPARAM dwInitParam)
{ {
return (int)DialogBoxIndirectParam(hInst, hDialogTemplate, hwndOwner, dlgprc, dwInitParam); if (PreviousWindowProc != NULL)
return -1;
PreviousWindowProc = dlgprc;
return (int)DialogBoxIndirectParam(hInst, hDialogTemplate, hwndOwner, DefaultWlxWindowProc, dwInitParam);
} }
/* /*
@ -626,6 +680,7 @@ GinaInit(
Session->MsGina.Context = NULL; Session->MsGina.Context = NULL;
Session->MsGina.Version = GinaDllVersion; Session->MsGina.Version = GinaDllVersion;
Session->SuppressStatus = FALSE; Session->SuppressStatus = FALSE;
PreviousWindowProc = NULL;
return Session->MsGina.Functions.WlxInitialize( return Session->MsGina.Functions.WlxInitialize(
Session->InteractiveWindowStationName, Session->InteractiveWindowStationName,
@ -675,7 +730,7 @@ CreateWindowStationAndDesktops(
* Create the winlogon desktop * Create the winlogon desktop
*/ */
Session->WinlogonDesktop = CreateDesktop( Session->WinlogonDesktop = CreateDesktop(
WINLOGON_DESKTOP, L"Winlogon",
NULL, NULL,
NULL, NULL,
0, /* FIXME: Set some flags */ 0, /* FIXME: Set some flags */