Simplify management of loggedout window

Implement locking/unlocking of the workstation (only by code, not the associated dialogs)

svn path=/trunk/; revision=23434
This commit is contained in:
Hervé Poussineau 2006-08-03 13:54:44 +00:00
parent e202c810ac
commit 603ac11c9a
8 changed files with 157 additions and 162 deletions

View file

@ -28,17 +28,21 @@ BEGIN
LTEXT "Password:",IDC_STATIC,36,93,42,8
EDITTEXT IDC_USERNAME,84,72,119,14,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,84,91,119,14,ES_AUTOHSCROLL | ES_PASSWORD
CONTROL "",IDC_ROSLOGO,"Static",SS_BLACKFRAME,7,7,261,51
END
IDD_LOGGEDON_DLG DIALOGEX 0,0,186,52
IDD_LOGGEDON_DLG DIALOGEX 0,0,247,116
STYLE NOT WS_VISIBLE | DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SETFONT | DS_FIXEDSYS | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
CAPTION "Security"
FONT 8,"MS Shell Dlg 2",400,0,1
BEGIN
PUSHBUTTON "Cancel",IDCANCEL,125,31,50,14
PUSHBUTTON "Log off",IDC_LOGOFF,11,31,50,14
PUSHBUTTON "Shutdown",IDC_SHUTDOWN,69,31,50,14
LTEXT "What do you want to do?",IDC_STATIC,50,18,87,8
PUSHBUTTON "Cancel",IDCANCEL,170,95,70,14
PUSHBUTTON "Log off",IDC_LOGOFF,90,76,70,14
PUSHBUTTON "Shutdown",IDC_SHUTDOWN,170,76,70,14
LTEXT "What do you want to do?",IDC_STATIC,86,53,87,8
PUSHBUTTON "Lock computer",IDC_LOCK,10,76,70,14
PUSHBUTTON "Task manager",IDC_TASKMGR,90,95,70,14
CONTROL "",IDC_ROSLOGO,"Static",SS_BLACKFRAME,7,7,230,38
END
STRINGTABLE
@ -47,4 +51,3 @@ BEGIN
IDS_ASKFORUSER "User name: "
IDS_ASKFORPASSWORD "Password: "
END

View file

@ -7,15 +7,8 @@
#include "msgina.h"
#include <debug.h>
#define TRACE DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define FIXME DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define WARN DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#undef DPRINT
#undef DPRINT1
static HBITMAP hBitmap = NULL;
static int cxSource, cySource;
#define YDEBUG
#include <wine/debug.h>
typedef struct _DISPLAYSTATUSMSG
{
@ -155,21 +148,30 @@ GUIDisplayStatusMessage(
return TRUE;
}
static INT_PTR CALLBACK
DisplaySASNoticeWindowProc(
IN HWND hwndDlg,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
}
static VOID
GUIDisplaySASNotice(
IN OUT PGINA_CONTEXT pgContext)
{
int result;
INT result;
TRACE("GUIDisplaySASNotice()\n");
/* Display the notice window */
result = pgContext->pWlxFuncs->WlxDialogBoxParam(
pgContext->hWlx,
result = DialogBoxParam(
pgContext->hDllInstance,
MAKEINTRESOURCE(IDD_NOTICE_DLG),
NULL,
(DLGPROC)DefWindowProc,
DisplaySASNoticeWindowProc,
(LPARAM)NULL);
if (result == -1)
{
@ -210,40 +212,37 @@ LoggedOutWindowProc(
IN WPARAM wParam,
IN LPARAM lParam)
{
BITMAP bitmap;
PGINA_CONTEXT pgContext;
pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwndDlg, GWL_USERDATA);
switch (uMsg)
{
case WM_INITDIALOG:
{
/* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)lParam);
pgContext = (PGINA_CONTEXT)lParam;
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDC_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
if (hBitmap != NULL)
{
GetObject(hBitmap, sizeof(BITMAP), &bitmap);
cxSource = bitmap.bmWidth;
cySource = bitmap.bmHeight;
}
pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
break;
}
case WM_PAINT:
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc, hdcMem;
hdc = BeginPaint(hwndDlg, &ps);
hdcMem = CreateCompatibleDC(hdc);
SelectObject(hdcMem, hBitmap);
BitBlt(hdc, 0, 0, cxSource, cySource, hdcMem, 0, 0, SRCCOPY);
DeleteDC(hdcMem);
EndPaint(hwndDlg, &ps);
HDC hdc;
if (pgContext->hBitmap)
{
hdc = BeginPaint(hwndDlg, &ps);
DrawState(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
EndPaint(hwndDlg, &ps);
}
break;
}
case WM_DESTROY:
{
DeleteObject(hBitmap);
DeleteObject(pgContext->hBitmap);
break;
}
case WM_COMMAND:
@ -252,10 +251,8 @@ LoggedOutWindowProc(
{
case IDOK:
{
PGINA_CONTEXT pgContext;
LPWSTR UserName = NULL, Password = NULL;
INT result = WLX_SAS_ACTION_NONE;
pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwndDlg, GWL_USERDATA);
if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) && *UserName == '\0')
break;
@ -300,14 +297,23 @@ LoggedOnWindowProc(
{
switch (LOWORD(wParam))
{
case IDYES:
case IDNO:
{
EndDialog(hwndDlg, LOWORD(wParam));
break;
}
case IDC_LOCK:
EndDialog(hwndDlg, WLX_SAS_ACTION_LOCK_WKSTA);
return TRUE;
case IDC_LOGOFF:
EndDialog(hwndDlg, WLX_SAS_ACTION_LOGOFF);
return TRUE;
case IDC_SHUTDOWN:
EndDialog(hwndDlg, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF);
return TRUE;
case IDC_TASKMGR:
EndDialog(hwndDlg, WLX_SAS_ACTION_TASKLIST);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, WLX_SAS_ACTION_NONE);
return TRUE;
}
return TRUE;
break;
}
case WM_INITDIALOG:
{
@ -329,50 +335,30 @@ GUILoggedOnSAS(
IN OUT PGINA_CONTEXT pgContext,
IN DWORD dwSasType)
{
INT SasAction = WLX_SAS_ACTION_NONE;
INT result;
TRACE("GUILoggedOnSAS()\n");
switch (dwSasType)
if (dwSasType != WLX_SAS_TYPE_CTRL_ALT_DEL)
{
case WLX_SAS_TYPE_CTRL_ALT_DEL:
{
INT result;
/* Display "Are you sure you want to log off?" dialog */
result = pgContext->pWlxFuncs->WlxDialogBoxParam(
pgContext->hWlx,
pgContext->hDllInstance,
MAKEINTRESOURCE(IDD_LOGGEDON_DLG),
NULL,
LoggedOnWindowProc,
(LPARAM)pgContext);
if (result == IDOK)
SasAction = WLX_SAS_ACTION_LOCK_WKSTA;
break;
}
case WLX_SAS_TYPE_SC_INSERT:
{
FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
break;
}
case WLX_SAS_TYPE_SC_REMOVE:
{
FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
break;
}
case WLX_SAS_TYPE_TIMEOUT:
{
FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_TIMEOUT not supported!\n");
break;
}
default:
{
WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType);
break;
}
/* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
* close itself thanks to the use of WlxDialogBoxParam */
return WLX_SAS_ACTION_NONE;
}
return SasAction;
result = pgContext->pWlxFuncs->WlxDialogBoxParam(
pgContext->hWlx,
pgContext->hDllInstance,
MAKEINTRESOURCE(IDD_LOGGEDON_DLG),
NULL,
LoggedOnWindowProc,
(LPARAM)pgContext);
if (result >= WLX_SAS_ACTION_LOGON &&
result <= WLX_SAS_ACTION_SWITCH_CONSOLE)
{
return result;
}
return WLX_SAS_ACTION_NONE;
}
static INT

View file

@ -42,7 +42,7 @@ WlxNegotiate(
IN DWORD dwWinlogonVersion,
OUT PDWORD pdwDllVersion)
{
DPRINT1("WlxNegotiate(%lx, %p)\n", dwWinlogonVersion, pdwDllVersion);
TRACE("WlxNegotiate(%lx, %p)\n", dwWinlogonVersion, pdwDllVersion);
if(!pdwDllVersion || (dwWinlogonVersion < WLX_VERSION_1_3))
return FALSE;
@ -147,20 +147,22 @@ WlxStartApplication(
PWSTR pszCmdLine)
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
STARTUPINFO si;
PROCESS_INFORMATION pi;
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
WCHAR CurrentDirectory[MAX_PATH];
BOOL Ret;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = pszCmdLine;
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.dwFlags = 0;
si.wShowWindow = SW_SHOW;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
si.lpDesktop = pszDesktopName;
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.lpReserved = NULL;
StartupInfo.lpTitle = pszCmdLine;
StartupInfo.dwX = StartupInfo.dwY = StartupInfo.dwXSize = StartupInfo.dwYSize = 0L;
StartupInfo.dwFlags = 0;
StartupInfo.wShowWindow = SW_SHOW;
StartupInfo.lpReserved2 = NULL;
StartupInfo.cbReserved2 = 0;
StartupInfo.lpDesktop = pszDesktopName;
GetWindowsDirectoryW (CurrentDirectory, MAX_PATH);
Ret = CreateProcessAsUser(pgContext->UserToken,
NULL,
pszCmdLine,
@ -169,11 +171,11 @@ WlxStartApplication(
FALSE,
CREATE_UNICODE_ENVIRONMENT,
pEnvironment,
NULL,
&si,
&pi);
CurrentDirectory,
&StartupInfo,
&ProcessInformation);
VirtualFree(pEnvironment, 0, MEM_RELEASE);
//VirtualFree(pEnvironment, 0, MEM_RELEASE);
return Ret;
}
@ -188,15 +190,10 @@ WlxActivateUserShell(
PWSTR pszMprLogonScript,
PVOID pEnvironment)
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
HKEY hKey;
DWORD BufSize, ValueType;
WCHAR pszUserInitApp[MAX_PATH];
WCHAR pszExpUserInitApp[MAX_PATH];
BOOL Ret;
WCHAR CurrentDirectory[MAX_PATH];
/* get the path of userinit */
if(RegOpenKeyExW(HKEY_LOCAL_MACHINE,
@ -216,38 +213,12 @@ WlxActivateUserShell(
return FALSE;
}
RegCloseKey(hKey);
/* start userinit */
/* FIXME - allow to start more applications that are comma-separated */
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = pszDesktopName;
StartupInfo.lpTitle = NULL;
StartupInfo.dwFlags = 0;
StartupInfo.lpReserved2 = NULL;
StartupInfo.cbReserved2 = 0;
StartupInfo.dwX = StartupInfo.dwY = StartupInfo.dwXSize = StartupInfo.dwYSize = 0;
StartupInfo.wShowWindow = SW_SHOW;
ExpandEnvironmentStrings(pszUserInitApp, pszExpUserInitApp, MAX_PATH);
GetWindowsDirectoryW (CurrentDirectory, MAX_PATH);
Ret = CreateProcessAsUser(pgContext->UserToken,
NULL,
pszExpUserInitApp,
NULL,
NULL,
FALSE,
CREATE_UNICODE_ENVIRONMENT,
pEnvironment,
CurrentDirectory,
&StartupInfo,
&ProcessInformation);
if(!Ret) ERR("GINA: Failed: 3, error %lu\n", GetLastError());
VirtualFree(pEnvironment, 0, MEM_RELEASE);
Ret = pgContext->pWlxFuncs->WlxSwitchDesktopToUser(pgContext->hWlx);
if(!Ret) ERR("GINA: Failed: 4, error %lu\n", GetLastError());
return Ret;
/* Start userinit */
/* FIXME - allow to start more applications that are comma-separated */
/* FIXME: Call VirtualFree(pEnvironment, 0, MEM_RELEASE); ? */
return WlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszExpUserInitApp);
}
@ -261,10 +232,36 @@ WlxLoggedOnSAS(
PVOID pReserved)
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
INT SasAction = WLX_SAS_ACTION_NONE;
DPRINT1("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
return pGinaUI->LoggedOnSAS(pgContext, dwSasType);
switch (dwSasType)
{
case WLX_SAS_TYPE_CTRL_ALT_DEL:
case WLX_SAS_TYPE_TIMEOUT:
{
SasAction = pGinaUI->LoggedOnSAS(pgContext, dwSasType);
break;
}
case WLX_SAS_TYPE_SC_INSERT:
{
FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
break;
}
case WLX_SAS_TYPE_SC_REMOVE:
{
FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
break;
}
default:
{
WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType);
break;
}
}
return SasAction;
}
/*
@ -280,7 +277,7 @@ WlxDisplayStatusMessage(
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
DPRINT1("WlxDisplayStatusMessage(\"%S\")\n", pMessage);
TRACE("WlxDisplayStatusMessage(\"%S\")\n", pMessage);
return pGinaUI->DisplayStatusMessage(pgContext, hDesktop, dwOptions, pTitle, pMessage);
}
@ -363,13 +360,13 @@ DoLoginTasks(
LOGON32_PROVIDER_DEFAULT,
pgContext->phToken))
{
WARN("GINA: Logonuser() failed\n");
WARN("LogonUserW() failed\n");
return FALSE;
}
if(!(*pgContext->phToken))
if(!*pgContext->phToken)
{
WARN("GINA: *phToken == NULL!\n");
WARN("*phToken == NULL!\n");
return FALSE;
}
@ -384,7 +381,7 @@ DoLoginTasks(
sizeof(TOKEN_STATISTICS),
&cbStats))
{
WARN("GINA: Couldn't get Authentication id from user token!\n");
WARN("Couldn't get Authentication id from user token!\n");
return FALSE;
}
*pgContext->pAuthenticationId = Stats.AuthenticationId;
@ -482,7 +479,7 @@ WlxDisplaySASNotice(
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
DPRINT1("WlxDisplaySASNotice(%p)\n", pWlxContext);
TRACE("WlxDisplaySASNotice(%p)\n", pWlxContext);
if (GetSystemMetrics(SM_REMOTESESSION))
{
@ -501,7 +498,7 @@ WlxDisplaySASNotice(
pGinaUI->DisplaySASNotice(pgContext);
DPRINT1("WlxDisplaySASNotice() done\n");
TRACE("WlxDisplaySASNotice() done\n");
}
/*
@ -520,7 +517,7 @@ WlxLoggedOutSAS(
{
PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
DPRINT1("WlxLoggedOutSAS()\n");
TRACE("WlxLoggedOutSAS()\n");
pgContext->pAuthenticationId = pAuthenticationId;
pgContext->pdwOptions = pdwOptions;

View file

@ -21,6 +21,9 @@ typedef struct {
PHANDLE phToken;
PWLX_MPR_NOTIFY_INFO pNprNotifyInfo;
PVOID *pProfile;
/* Current logo to display */
HBITMAP hBitmap;
} GINA_CONTEXT, *PGINA_CONTEXT;
HINSTANCE hDllInstance;

View file

@ -7,8 +7,7 @@
#define REACTOS_STR_ORIGINAL_FILENAME "msgina.dll\0"
#include <reactos/version.rc>
IDC_ROSLOGO BITMAP "resources/reactos.bmp"
IDI_ROSLOGO BITMAP "resources/reactos.bmp"
#include "En.rc"

View file

@ -11,11 +11,15 @@
#define IDC_PASSWORD 1003
#define IDC_SHUTDOWN 1004
#define IDC_STATUSLABEL 1005
#define IDC_ROSLOGO 1006
#define IDC_LOCK 1006
#define IDC_ROSLOGO 1007
#define IDI_ROSLOGO 1008
#define IDS_ASKFORUSER 40000
#define IDS_PRESSCTRLALTDELETE 40001
#define IDC_TASKMGR 40002
#define IDS_ASKFORPASSWORD 40002
#endif /* __MSGINA_RESOURCE_H */
/* EOF */

View file

@ -56,7 +56,7 @@ WlxIsLockOk(
PVOID pWlxContext)
{
UNIMPLEMENTED;
return FALSE;
return TRUE;
}
@ -68,7 +68,7 @@ WlxIsLogoffOk(
PVOID pWlxContext)
{
UNIMPLEMENTED;
return FALSE;
return TRUE;
}
@ -106,7 +106,7 @@ WlxWkstaLockedSAS(
DWORD dwSasType)
{
UNIMPLEMENTED;
return 0;
return WLX_SAS_ACTION_UNLOCK_WKSTA;
}

View file

@ -7,12 +7,8 @@
#include "msgina.h"
#include <debug.h>
#define TRACE DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define FIXME DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define WARN DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#undef DPRINT
#undef DPRINT1
#define YDEBUG
#include <wine/debug.h>
static BOOL
TUIInitialize(
@ -77,8 +73,15 @@ TUILoggedOnSAS(
IN DWORD dwSasType)
{
TRACE("TUILoggedOnSAS()\n");
for (;;) FIXME("FIXME!\n");
return 0;
if (dwSasType != WLX_SAS_TYPE_CTRL_ALT_DEL)
{
/* Nothing to do for WLX_SAS_TYPE_TIMEOUT */
return WLX_SAS_ACTION_NONE;
}
FIXME("FIXME: TUILoggedOnSAS(): Let's suppose the user wants to log off...\n");
return WLX_SAS_ACTION_LOGOFF;
}
static BOOL
@ -122,18 +125,18 @@ static INT
TUILoggedOutSAS(
IN OUT PGINA_CONTEXT pgContext)
{
WCHAR User[256];
WCHAR UserName[256];
WCHAR Password[256];
TRACE("TUILoggedOutSAS()\n");
/* Ask the user for credentials */
if (!ReadString(pgContext, IDS_ASKFORUSER, User, 256, TRUE))
if (!ReadString(pgContext, IDS_ASKFORUSER, UserName, 256, TRUE))
return WLX_SAS_ACTION_NONE;
if (!ReadString(pgContext, IDS_ASKFORPASSWORD, Password, 256, FALSE))
return WLX_SAS_ACTION_NONE;
if (DoLoginTasks(pgContext, User, NULL, Password))
if (DoLoginTasks(pgContext, UserName, NULL, Password))
return WLX_SAS_ACTION_LOGON;
else
return WLX_SAS_ACTION_NONE;