diff --git a/reactos/bootdata/hivesft.inf b/reactos/bootdata/hivesft.inf index cbfd709e417..77dd2952341 100644 --- a/reactos/bootdata/hivesft.inf +++ b/reactos/bootdata/hivesft.inf @@ -6,6 +6,7 @@ Signature="$ReactOS$ HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\WinLogon","Shell",0x00020000,"%SystemRoot%\System32\cmd.exe" ;HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\WinLogon","Shell",0x00020000,"%SystemRoot%\bin\explorer.exe" HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\WinLogon","StartServices",0x00010001,0x00000001 +HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\WinLogon","StartGUI",0x00010001,0x00000000 HKCU, "Control Panel\Desktop", "CursorBlinkRate",0x00000000,"530" diff --git a/reactos/lib/msgina/Makefile b/reactos/lib/msgina/Makefile index faef599c0fc..622e945eb9a 100644 --- a/reactos/lib/msgina/Makefile +++ b/reactos/lib/msgina/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.4 2003/11/24 19:04:23 weiden Exp $ +# $Id: Makefile,v 1.5 2003/12/01 18:21:04 weiden Exp $ PATH_TO_TOP = ../.. @@ -18,7 +18,7 @@ TARGET_CFLAGS = \ TARGET_LFLAGS = -nostartfiles -nostdlib -TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a +TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a user32.a TARGET_GCCLIBS = gcc diff --git a/reactos/lib/msgina/msgina.c b/reactos/lib/msgina/msgina.c index 422e29b91f5..3bf2e0f1a4d 100644 --- a/reactos/lib/msgina/msgina.c +++ b/reactos/lib/msgina/msgina.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: msgina.c,v 1.4 2003/11/24 19:04:23 weiden Exp $ +/* $Id: msgina.c,v 1.5 2003/12/01 18:21:04 weiden Exp $ * * PROJECT: ReactOS msgina.dll * FILE: lib/msgina/msgina.c @@ -28,9 +28,57 @@ #include #include #include "msgina.h" +#include "resource.h" extern HINSTANCE hDllInstance; +typedef struct _DISPLAYSTATUSMSG +{ + PGINA_CONTEXT Context; + HDESK hDesktop; + DWORD dwOptions; + PWSTR pTitle; + PWSTR pMessage; + HANDLE StartupEvent; +} DISPLAYSTATUSMSG, *PDISPLAYSTATUSMSG; + +BOOL CALLBACK +LoggedOnDlgProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + switch(uMsg) + { + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDYES: + case IDNO: + { + EndDialog(hwndDlg, LOWORD(wParam)); + break; + } + } + return FALSE; + } + case WM_INITDIALOG: + { + SetFocus(GetDlgItem(hwndDlg, IDNO)); + break; + } + case WM_CLOSE: + { + EndDialog(hwndDlg, IDNO); + return TRUE; + } + } + return FALSE; +} + /* * @implemented @@ -80,6 +128,9 @@ WlxInitialize( /* save window station */ pgContext->station = lpWinsta; + /* clear status window handle */ + pgContext->hStatusWindow = 0; + /* notify winlogon that we will use the default SAS */ pgContext->pWlxFuncs->WlxUseCtrlAltDel(hWlx); @@ -128,6 +179,7 @@ WlxStartApplication( return Ret; } + /* * @implemented */ @@ -138,7 +190,7 @@ WlxActivateUserShell( PWSTR pszMprLogonScript, PVOID pEnvironment) { - PGINA_CONTEXT pgContext = (PGINA_CONTEXT) pWlxContext; + PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext; STARTUPINFO si; PROCESS_INFORMATION pi; HKEY hKey; @@ -151,6 +203,7 @@ WlxActivateUserShell( L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { + VirtualFree(pEnvironment, 0, MEM_RELEASE); return FALSE; } BufSize = MAX_PATH * sizeof(WCHAR); @@ -158,15 +211,18 @@ WlxActivateUserShell( &BufSize) != ERROR_SUCCESS) || (ValueType != REG_SZ)) { RegCloseKey(hKey); + VirtualFree(pEnvironment, 0, MEM_RELEASE); return FALSE; } RegCloseKey(hKey); - /* execute userinit */ + /* FIXME - execute logon script */ + + /* start userinit */ si.cb = sizeof(STARTUPINFO); si.lpReserved = NULL; si.lpTitle = L"userinit"; - si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L; + si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0; si.dwFlags = 0; si.wShowWindow = SW_SHOW; si.lpReserved2 = NULL; @@ -190,6 +246,204 @@ WlxActivateUserShell( } +/* + * @implemented + */ +int WINAPI +WlxLoggedOnSAS( + PVOID pWlxContext, + DWORD dwSasType, + PVOID pReserved) +{ + PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext; + int SasAction = WLX_SAS_ACTION_NONE; + + switch(dwSasType) + { + 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, + (LPTSTR)IDD_LOGOFF_DLG, + NULL, + LoggedOnDlgProc, + (LPARAM)pgContext); + if(Result == IDOK) + { + SasAction = WLX_SAS_ACTION_LOCK_WKSTA; + } + break; + } + case WLX_SAS_TYPE_SC_INSERT: + { + DbgPrint("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n"); + break; + } + case WLX_SAS_TYPE_SC_REMOVE: + { + DbgPrint("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n"); + break; + } + case WLX_SAS_TYPE_TIMEOUT: + { + DbgPrint("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_TIMEOUT not supported!\n"); + break; + } + default: + { + DbgPrint("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType); + break; + } + } + + return SasAction; +} + + +BOOL +CALLBACK +StatusMessageWindowProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + PDISPLAYSTATUSMSG msg = (PDISPLAYSTATUSMSG)lParam; + if(!msg) + return FALSE; + + msg->Context->hStatusWindow = hwndDlg; + + if(msg->pTitle) + SetWindowText(hwndDlg, msg->pTitle); + SetDlgItemText(hwndDlg, IDC_STATUSLABEL, msg->pMessage); + if(!msg->Context->SignaledStatusWindowCreated) + { + msg->Context->SignaledStatusWindowCreated = TRUE; + SetEvent(msg->StartupEvent); + } + break; + } + } + return FALSE; +} + + +DWORD WINAPI +StartupWindowThread(LPVOID lpParam) +{ + HDESK OldDesk; + PDISPLAYSTATUSMSG msg = (PDISPLAYSTATUSMSG)lpParam; + + OldDesk = GetThreadDesktop(GetCurrentThreadId()); + + if(!SetThreadDesktop(msg->hDesktop)) + { + HeapFree(GetProcessHeap(), 0, lpParam); + return FALSE; + } + DialogBoxParam(hDllInstance, + MAKEINTRESOURCE(IDD_STATUSWINDOW), + 0, + StatusMessageWindowProc, + (LPARAM)lpParam); + SetThreadDesktop(OldDesk); + + msg->Context->hStatusWindow = 0; + msg->Context->SignaledStatusWindowCreated = FALSE; + + HeapFree(GetProcessHeap(), 0, lpParam); + return TRUE; +} + + +/* + * @implemented + */ +BOOL WINAPI +WlxDisplayStatusMessage( + PVOID pWlxContext, + HDESK hDesktop, + DWORD dwOptions, + PWSTR pTitle, + PWSTR pMessage) +{ + PDISPLAYSTATUSMSG msg; + HANDLE Thread; + DWORD ThreadId; + PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext; + + if(!pgContext->hStatusWindow) + { + msg = (PDISPLAYSTATUSMSG)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DISPLAYSTATUSMSG)); + if(!msg) + return FALSE; + + msg->Context = pgContext; + msg->dwOptions = dwOptions; + msg->pTitle = pTitle; + msg->pMessage = pMessage; + msg->hDesktop = hDesktop; + + msg->StartupEvent = CreateEvent(NULL, + TRUE, + FALSE, + NULL); + + if(!msg->StartupEvent) + return FALSE; + + Thread = CreateThread(NULL, + 0, + StartupWindowThread, + (PVOID)msg, + 0, + &ThreadId); + if(Thread) + { + CloseHandle(Thread); + WaitForSingleObject(msg->StartupEvent, INFINITE); + CloseHandle(msg->StartupEvent); + return TRUE; + } + + return FALSE; + } + + if(pTitle) + SetWindowText(pgContext->hStatusWindow, pTitle); + + SetDlgItemText(pgContext->hStatusWindow, IDC_STATUSLABEL, pMessage); + + return TRUE; +} + + +/* + * @implemented + */ +BOOL WINAPI +WlxRemoveStatusMessage( + PVOID pWlxContext) +{ + PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext; + if(pgContext->hStatusWindow) + { + EndDialog(pgContext->hStatusWindow, 0); + pgContext->hStatusWindow = 0; + } + + return TRUE; +} + + BOOL STDCALL DllMain( HINSTANCE hinstDLL, diff --git a/reactos/lib/msgina/msgina.h b/reactos/lib/msgina/msgina.h index 28de22425f8..71046d8b1ef 100644 --- a/reactos/lib/msgina/msgina.h +++ b/reactos/lib/msgina/msgina.h @@ -1,9 +1,9 @@ #ifndef __MSGINA_H #define __MSGINA_H -#define GINA_VERSION (WLX_VERSION_1_0) +#define GINA_VERSION (WLX_VERSION_1_3) -#define PWLX_DISPATCH_VERSION PWLX_DISPATCH_VERSION_1_0 +#define PWLX_DISPATCH_VERSION PWLX_DISPATCH_VERSION_1_3 typedef struct { HANDLE hWlx; @@ -11,6 +11,8 @@ typedef struct { PWLX_DISPATCH_VERSION pWlxFuncs; HANDLE hDllInstance; HANDLE UserToken; + HWND hStatusWindow; + BOOL SignaledStatusWindowCreated; } GINA_CONTEXT, *PGINA_CONTEXT; HINSTANCE hDllInstance; diff --git a/reactos/lib/msgina/msgina.rc b/reactos/lib/msgina/msgina.rc index ec9787a8fc6..ef2c96bb7ed 100644 --- a/reactos/lib/msgina/msgina.rc +++ b/reactos/lib/msgina/msgina.rc @@ -1,5 +1,6 @@ #include #include +#include "resource.h" LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT @@ -36,4 +37,26 @@ BEGIN END END +IDI_LOGOFFICON ICON "resources/ico_logoff.ico" + +IDD_LOGOFF_DLG DIALOG 0, 0, 188, 60 +STYLE DS_FIXEDSYS | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Log Off ReactOS" +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +FONT 8, "MS Sans Serif" +{ + ICON IDI_LOGOFFICON, IDC_LOGOFFICON, 7, 7, 21, 21, SS_ICON | WS_CHILD | WS_VISIBLE + LTEXT "Are you sure you want to log off?", -1, 35, 16, 146, 8, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP + PUSHBUTTON "&Log Off", 1, 41, 39, 50, 14, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "&No", 2, 95, 39, 50, 14, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP +} + +IDD_STATUSWINDOW DIALOG 0, 0, 274, 26 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION +CAPTION "Please wait..." +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +FONT 8, "MS Sans Serif" +{ + LTEXT "", IDC_STATUSLABEL, 7, 8, 234, 12, SS_ENDELLIPSIS +} diff --git a/reactos/lib/msgina/resource.h b/reactos/lib/msgina/resource.h new file mode 100644 index 00000000000..7c7f0b0db8a --- /dev/null +++ b/reactos/lib/msgina/resource.h @@ -0,0 +1,14 @@ +#ifndef __MSGINA_RESOURCE_H +#define __MSGINA_RESOURCE_H + +#define IDD_LOGOFF_DLG 2250 +#define IDD_STATUSWINDOW 2450 + +#define IDC_LOGOFFICON 21 +#define IDC_STATUSLABEL 2451 + +#define IDI_LOGOFFICON 2251 + +#endif /* __MSGINA_RESOURCE_H */ + +/* EOF */ diff --git a/reactos/lib/msgina/resources/ico_logoff.ico b/reactos/lib/msgina/resources/ico_logoff.ico new file mode 100644 index 00000000000..7bb5488b4aa Binary files /dev/null and b/reactos/lib/msgina/resources/ico_logoff.ico differ diff --git a/reactos/lib/msgina/stubs.c b/reactos/lib/msgina/stubs.c index 87d5f64ece8..529a52ae893 100644 --- a/reactos/lib/msgina/stubs.c +++ b/reactos/lib/msgina/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.4 2003/11/24 19:04:23 weiden Exp $ +/* $Id: stubs.c,v 1.5 2003/12/01 18:21:04 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS msgina.dll @@ -86,20 +86,6 @@ WlxIsLogoffOk( } -/* - * @unimplemented - */ -int WINAPI -WlxLoggedOnSAS( - PVOID pWlxContext, - DWORD dwSasType, - PVOID pReserved) -{ - UNIMPLEMENTED; - return 0; -} - - /* * @unimplemented */ @@ -170,22 +156,6 @@ WlxScreenSaverNotify( } -/* - * @unimplemented - */ -BOOL WINAPI -WlxDisplayStatusMessage( - PVOID pWlxContext, - HDESK hDesktop, - DWORD dwOptions, - PWSTR pTitle, - PWSTR pMessage) -{ - UNIMPLEMENTED; - return FALSE; -} - - /* * @unimplemented */ @@ -214,18 +184,6 @@ WlxNetworkProviderLoad( } -/* - * @unimplemented - */ -BOOL WINAPI -WlxRemoveStatusMessage( - PVOID pWlxContext) -{ - UNIMPLEMENTED; - return FALSE; -} - - /* * @unimplemented */ diff --git a/reactos/subsys/system/winlogon/makefile b/reactos/subsys/system/winlogon/makefile index 7247ed2f45b..4132546008c 100644 --- a/reactos/subsys/system/winlogon/makefile +++ b/reactos/subsys/system/winlogon/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.7 2003/11/14 17:13:35 weiden Exp $ +# $Id: makefile,v 1.8 2003/12/01 18:21:04 weiden Exp $ PATH_TO_TOP = ../../.. @@ -10,11 +10,11 @@ TARGET_NAME = winlogon TARGET_INSTALLDIR = system32 -TARGET_SDKLIBS = ntdll.a kernel32.a user32.a +TARGET_SDKLIBS = ntdll.a kernel32.a user32.a secur32.a -TARGET_OBJECTS = $(TARGET_NAME).o setup.o +TARGET_OBJECTS = $(TARGET_NAME).o setup.o wlx.o -TARGET_CFLAGS = -Wall -Werror +TARGET_CFLAGS = -Wall -Werror -DUNICODE -I./ -I../../../include include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/subsys/system/winlogon/resource.h b/reactos/subsys/system/winlogon/resource.h new file mode 100644 index 00000000000..5e361f5ea6f --- /dev/null +++ b/reactos/subsys/system/winlogon/resource.h @@ -0,0 +1,31 @@ +/* Dialogs */ +#define IDD_GINALOADFAILED 400 +#define IDD_SHUTDOWNCOMPUTER 300 + +/* Icons */ +#define IDI_WINLOGON 4 + +/* Controls */ +#define IDC_GINALOADFAILED 401 +#define IDC_GINALOADFAILEDCONTACT 402 + +#define IDC_SHUTDOWNCOMPUTER 302 +#define IDC_BTNSHTDOWNCOMPUTER 305 +#define IDC_SHTDOWNICON 102 + +/* Strings */ +#define IDS_PREPARENETWORKCONNECTIONS 1675 +#define IDS_APPLYINGCOMPUTERSETTINGS 1676 +#define IDS_RUNNINGSTARTUPSCRIPTS 1677 +#define IDS_RUNNINGSHUTDOWNSCRIPTS 1678 +#define IDS_APPLYINGYOURPERSONALSETTINGS 1679 +#define IDS_RUNNINGLOGOFFSCRIPTS 1680 +#define IDS_RUNNINGLOGONSCRIPTS 1681 +#define IDS_LOADINGYOURPERSONALSETTINGS 1682 +#define IDS_CLOSINGNETWORKCONNECTIONS 1683 +#define IDS_REACTOSISSHUTTINGDOWN 1684 +#define IDS_PREPARETOSTANDBY 1685 +#define IDS_PREPARETOHIBERNATE 1686 +#define IDS_SAVEYOURSETTINGS 1687 +#define IDS_REACTOSISSTARTINGUP 1690 + diff --git a/reactos/subsys/system/winlogon/resources/winlogon.ico b/reactos/subsys/system/winlogon/resources/winlogon.ico new file mode 100644 index 00000000000..283fe4e087b Binary files /dev/null and b/reactos/subsys/system/winlogon/resources/winlogon.ico differ diff --git a/reactos/subsys/system/winlogon/setup.c b/reactos/subsys/system/winlogon/setup.c index 6a32bfbb861..3ce992f82c4 100644 --- a/reactos/subsys/system/winlogon/setup.c +++ b/reactos/subsys/system/winlogon/setup.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: setup.c,v 1.1 2003/03/25 19:26:33 ekohl Exp $ +/* $Id: setup.c,v 1.2 2003/12/01 18:21:04 weiden Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS winlogon * FILE: subsys/system/winlogon/setup.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include "setup.h" @@ -49,7 +49,7 @@ GetSetupType(VOID) DWORD dwSetupType; dwError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SYSTEM\\Setup", //TEXT("SYSTEM\\Setup"), + L"SYSTEM\\Setup", //TEXT("SYSTEM\\Setup"), 0, KEY_QUERY_VALUE, &hKey); @@ -60,7 +60,7 @@ GetSetupType(VOID) dwSize = sizeof(DWORD); dwError = RegQueryValueEx (hKey, - "SetupType", //TEXT("SetupType"), + L"SetupType", //TEXT("SetupType"), NULL, &dwType, (LPBYTE)&dwSetupType, @@ -82,7 +82,7 @@ SetSetupType (DWORD dwSetupType) HANDLE hKey; dwError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SYSTEM\\Setup", //TEXT("SYSTEM\\Setup"), + L"SYSTEM\\Setup", //TEXT("SYSTEM\\Setup"), 0, KEY_QUERY_VALUE, &hKey); @@ -92,7 +92,7 @@ SetSetupType (DWORD dwSetupType) } dwError = RegSetValueEx (hKey, - "SetupType", //TEXT("SetupType"), + L"SetupType", //TEXT("SetupType"), 0, REG_DWORD, (LPBYTE)&dwSetupType, @@ -112,7 +112,7 @@ RunSetup (VOID) { PROCESS_INFORMATION ProcessInformation; STARTUPINFO StartupInfo; - CHAR CommandLine[MAX_PATH]; + WCHAR CommandLine[MAX_PATH]; BOOLEAN Result; DWORD dwError; HANDLE hKey; @@ -123,7 +123,7 @@ RunSetup (VOID) DPRINT ("RunSetup() called\n"); dwError = RegOpenKeyEx (HKEY_LOCAL_MACHINE, - "SYSTEM\\Setup", + L"SYSTEM\\Setup", 0, KEY_QUERY_VALUE, &hKey); @@ -134,7 +134,7 @@ RunSetup (VOID) dwSize = MAX_PATH; dwError = RegQueryValueEx (hKey, - "CmdLine", + L"CmdLine", NULL, &dwType, (LPBYTE)CommandLine, diff --git a/reactos/subsys/system/winlogon/winlogon.c b/reactos/subsys/system/winlogon/winlogon.c index 403b84cc43d..1a839eaac68 100644 --- a/reactos/subsys/system/winlogon/winlogon.c +++ b/reactos/subsys/system/winlogon/winlogon.c @@ -1,4 +1,4 @@ -/* $Id: winlogon.c,v 1.20 2003/11/14 17:13:35 weiden Exp $ +/* $Id: winlogon.c,v 1.21 2003/12/01 18:21:04 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -14,48 +14,62 @@ #include #include #include -#include +#include +#include #include #include "setup.h" +#include "winlogon.h" +#include "resource.h" #define NDEBUG #include +#define SUPPORT_CONSOLESTART 1 +#define START_LSASS 0 + /* GLOBALS ******************************************************************/ +BOOL +LoadGina(PMSGINAFUNCTIONS Functions); +BOOL +MsGinaInit(); + +HINSTANCE hAppInstance; HWINSTA InteractiveWindowStation; /* WinSta0 */ HDESK ApplicationDesktop; /* WinSta0\Default */ HDESK WinlogonDesktop; /* WinSta0\Winlogon */ HDESK ScreenSaverDesktop; /* WinSta0\Screen-Saver */ +MSGINAFUNCTIONS MsGinaFunctions; + +#if SUPPORT_CONSOLESTART +BOOL StartConsole = TRUE; +#endif + /* FUNCTIONS *****************************************************************/ -static void PrintString (char* fmt,...) +static void PrintString (WCHAR* fmt,...) { - char buffer[512]; + WCHAR buffer[512]; va_list ap; va_start(ap, fmt); - vsprintf(buffer, fmt, ap); + wsprintf(buffer, fmt, ap); va_end(ap); OutputDebugString(buffer); } - static BOOLEAN StartServices(VOID) { HANDLE ServicesInitEvent; BOOLEAN Result; STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; - CHAR CommandLine[MAX_PATH]; DWORD Count; /* Start the service control manager (services.exe) */ - GetSystemDirectory(CommandLine, MAX_PATH); - strcat(CommandLine, "\\services.exe"); StartupInfo.cb = sizeof(StartupInfo); StartupInfo.lpReserved = NULL; @@ -66,10 +80,10 @@ static BOOLEAN StartServices(VOID) StartupInfo.lpReserved2 = 0; #if 0 - PrintString("WL: Creating new process - \"services.exe\".\n"); + PrintString(L"WL: Creating new process - \"services.exe\".\n"); #endif - Result = CreateProcess(CommandLine, + Result = CreateProcess(L"services.exe", NULL, NULL, NULL, @@ -81,7 +95,7 @@ static BOOLEAN StartServices(VOID) &ProcessInformation); if (!Result) { - PrintString("WL: Failed to execute services\n"); + PrintString(L"WL: Failed to execute services\n"); return FALSE; } @@ -93,7 +107,7 @@ static BOOLEAN StartServices(VOID) //DbgPrint("WL: Attempting to open event \"SvcctrlStartEvent_A3725DX\"\n"); ServicesInitEvent = OpenEvent(EVENT_ALL_ACCESS, //SYNCHRONIZE, FALSE, - "SvcctrlStartEvent_A3725DX"); + L"SvcctrlStartEvent_A3725DX"); if (ServicesInitEvent != NULL) { break; @@ -116,19 +130,18 @@ static BOOLEAN StartServices(VOID) return TRUE; } -#if 0 +#if START_LSASS static BOOLEAN StartLsass(VOID) { HANDLE LsassInitEvent; BOOLEAN Result; STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; - CHAR CommandLine[MAX_PATH]; LsassInitEvent = CreateEvent(NULL, TRUE, FALSE, - "\\LsassInitDone"); + L"\\LsassInitDone"); if (LsassInitEvent == NULL) { @@ -138,9 +151,6 @@ static BOOLEAN StartLsass(VOID) /* Start the local security authority subsystem (lsass.exe) */ - GetSystemDirectory(CommandLine, MAX_PATH); - strcat(CommandLine, "\\lsass.exe"); - StartupInfo.cb = sizeof(StartupInfo); StartupInfo.lpReserved = NULL; StartupInfo.lpDesktop = NULL; @@ -149,7 +159,7 @@ static BOOLEAN StartLsass(VOID) StartupInfo.cbReserved2 = 0; StartupInfo.lpReserved2 = 0; - Result = CreateProcess(CommandLine, + Result = CreateProcess(L"lsass.exe", NULL, NULL, NULL, @@ -175,13 +185,13 @@ static BOOLEAN StartLsass(VOID) static BOOLEAN OpenRegistryKey(HANDLE *WinLogonKey) { return ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, - _T("SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon"), + L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon", 0, KEY_QUERY_VALUE, WinLogonKey); } -static BOOLEAN StartProcess(PCHAR ValueName) +static BOOLEAN StartProcess(PWCHAR ValueName) { BOOL StartIt; HANDLE WinLogonKey; @@ -210,25 +220,51 @@ static BOOLEAN StartProcess(PCHAR ValueName) return StartIt; } +#if SUPPORT_CONSOLESTART +static BOOL StartIntoGUI(void) +{ + HANDLE WinLogonKey; + DWORD Type, Size, Value; + + if(OpenRegistryKey(&WinLogonKey)) + { + Size = sizeof(DWORD); + if(ERROR_SUCCESS == RegQueryValueEx(WinLogonKey, + L"StartGUI", + NULL, + &Type, + (LPBYTE)&Value, + &Size)) + { + if(Type == REG_DWORD) + { + RegCloseKey(WinLogonKey); + return (Value != 0); + } + } + RegCloseKey(WinLogonKey); + } + return FALSE; +} -static PCHAR GetShell(PCHAR CommandLine) +static PWCHAR GetShell(WCHAR *CommandLine) { HANDLE WinLogonKey; BOOL GotCommandLine; DWORD Type; DWORD Size; - CHAR Shell[_MAX_PATH]; + WCHAR Shell[_MAX_PATH]; GotCommandLine = FALSE; if (OpenRegistryKey(&WinLogonKey)) { Size = MAX_PATH; if (ERROR_SUCCESS == RegQueryValueEx(WinLogonKey, - _T("Shell"), + L"Shell", NULL, &Type, (LPBYTE) Shell, - &Size)) + &Size)) { if (REG_EXPAND_SZ == Type) { @@ -237,7 +273,7 @@ static PCHAR GetShell(PCHAR CommandLine) } else if (REG_SZ == Type) { - strcpy(CommandLine, Shell); + wcscpy(CommandLine, Shell); GotCommandLine = TRUE; } } @@ -247,19 +283,19 @@ static PCHAR GetShell(PCHAR CommandLine) if (! GotCommandLine) { GetSystemDirectory(CommandLine, MAX_PATH - 10); - strcat(CommandLine, "\\cmd.exe"); + wcscat(CommandLine, L"\\cmd.exe"); } return CommandLine; } -static BOOL DoLoginUser(PCHAR Name, PCHAR Password) +static BOOL DoLoginUser(PWCHAR Name, PWCHAR Password) { PROCESS_INFORMATION ProcessInformation; STARTUPINFO StartupInfo; BOOLEAN Result; - CHAR CommandLine[MAX_PATH]; - CHAR CurrentDirectory[MAX_PATH]; + WCHAR CommandLine[MAX_PATH]; + WCHAR CurrentDirectory[MAX_PATH]; GetWindowsDirectory(CurrentDirectory, MAX_PATH); @@ -292,6 +328,7 @@ static BOOL DoLoginUser(PCHAR Name, PCHAR Password) return TRUE; } +#endif int STDCALL WinMain(HINSTANCE hInstance, @@ -299,19 +336,23 @@ WinMain(HINSTANCE hInstance, LPSTR lpCmdLine, int nShowCmd) { +#if SUPPORT_CONSOLESTART + WCHAR LoginName[255]; + WCHAR Password[255]; +#endif #if 0 - LSA_STRING ProcessName; - NTSTATUS Status; + LSA_STRING ProcessName, PackageName; HANDLE LsaHandle; LSA_OPERATIONAL_MODE Mode; - CHAR LoginPrompt[] = "login:"; - CHAR PasswordPrompt[] = "password:"; + ULONG AuthenticationPackage; #endif - CHAR LoginName[255]; - CHAR Password[255]; + HANDLE hShutdownEvent; + WCHAR StatusMsg[256]; BOOL Success; NTSTATUS Status; + hAppInstance = hInstance; + /* * FIXME: Create a security descriptor with * one ACE containing the Winlogon SID @@ -321,7 +362,7 @@ WinMain(HINSTANCE hInstance, * Create the interactive window station */ InteractiveWindowStation = - CreateWindowStationW(L"WinSta0", 0, GENERIC_ALL, NULL); + CreateWindowStation(L"WinSta0", 0, GENERIC_ALL, NULL); if (InteractiveWindowStation == NULL) { DbgPrint("WL: Failed to create window station (0x%X)\n", GetLastError()); @@ -338,32 +379,32 @@ WinMain(HINSTANCE hInstance, * Create the application desktop */ ApplicationDesktop = - CreateDesktopW(L"Default", - NULL, - NULL, - 0, /* FIXME: Set some flags */ - GENERIC_ALL, - NULL); + CreateDesktop(L"Default", + NULL, + NULL, + 0, /* FIXME: Set some flags */ + GENERIC_ALL, + NULL); /* * Create the winlogon desktop */ - WinlogonDesktop = CreateDesktopW(L"Winlogon", - NULL, - NULL, - 0, /* FIXME: Set some flags */ - GENERIC_ALL, - NULL); + WinlogonDesktop = CreateDesktop(L"Winlogon", + NULL, + NULL, + 0, /* FIXME: Set some flags */ + GENERIC_ALL, + NULL); /* * Create the screen saver desktop */ - ScreenSaverDesktop = CreateDesktopW(L"Screen-Saver", - NULL, - NULL, - 0, /* FIXME: Set some flags */ - GENERIC_ALL, - NULL); + ScreenSaverDesktop = CreateDesktop(L"Screen-Saver", + NULL, + NULL, + 0, /* FIXME: Set some flags */ + GENERIC_ALL, + NULL); /* * Switch to winlogon desktop @@ -384,9 +425,6 @@ WinMain(HINSTANCE hInstance, DbgPrint("WL: Cannot switch to Winlogon desktop (0x%X)\n", GetLastError()); } - AllocConsole(); - SetConsoleTitle( "Winlogon" ); - /* Check for pending setup */ if (GetSetupType () != 0) { @@ -400,17 +438,61 @@ WinMain(HINSTANCE hInstance, ExitProcess (0); return 0; } + +#if SUPPORT_CONSOLESTART + StartConsole = !StartIntoGUI(); + if(!StartConsole) + { +#endif + if(!LoadGina(&MsGinaFunctions)) + { + NtShutdownSystem(ShutdownReboot); + ExitProcess(0); + return(0); + } + + /* FIXME - better solution needed */ + hShutdownEvent = CreateEvent(NULL, + TRUE, + FALSE, + L"WinLogonShutdown"); + + if(!hShutdownEvent) + { + DbgPrint("WL: Failed to create WinLogonShutdown event!\n"); + NtShutdownSystem(ShutdownNoReboot); + ExitProcess(0); + return(0); + } + + if(!MsGinaInit() || !MsGinaInst) + { + DbgPrint("WL: Failed to initialize winlogon!\n"); + NtShutdownSystem(ShutdownNoReboot); + ExitProcess(0); + return(0); + } + + LoadString(hAppInstance, IDS_REACTOSISSTARTINGUP, StatusMsg, 256 * sizeof(WCHAR)); + MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context, + ApplicationDesktop, + 0, + NULL, + StatusMsg); +#if SUPPORT_CONSOLESTART + } +#endif /* start system processes (services.exe & lsass.exe) */ - if (StartProcess("StartServices")) + if (StartProcess(L"StartServices")) { if (!StartServices()) { DbgPrint("WL: Failed to start Services (0x%X)\n", GetLastError()); } } -#if 0 - if (StartProcess("StartLsass")) +#if START_LSASS + if (StartProcess(L"StartLsass")) { if (!StartLsass()) { @@ -419,15 +501,37 @@ WinMain(HINSTANCE hInstance, } #endif - /* FIXME: What name does the real WinLogon use? */ #if 0 - RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"WinLogon"); + /* real winlogon uses "Winlogon" */ + RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon"); Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode); if (!NT_SUCCESS(Status)) + { + switch(Status) { - DbgPrint("WL: Failed to connect to LSASS\n"); - return(1); + case STATUS_PORT_CONNECTION_REFUSED: + /* FIXME - we don't have the 'SeTcbPrivilege' pivilege, so set it or call + LsaAddAccountRights() and try again */ + DbgPrint("WL: LsaRegisterLogonProcess() returned STATUS_PORT_CONNECTION_REFUSED\n"); + break; + case STATUS_NAME_TOO_LONG: + DbgPrint("WL: LsaRegisterLogonProcess() returned STATUS_NAME_TOO_LONG\n"); + break; + default: + DbgPrint("WL: Failed to connect to LSASS\n"); + break; } + return(1); + } + + RtlInitUnicodeString((PUNICODE_STRING)&PackageName, L"Kerberos"); + Status = LsaLookupAuthenticationPackage(LsaHandle, &PackageName, &AuthenticationPackage); + if (!NT_SUCCESS(Status)) + { + LsaDeregisterLogonProcess(LsaHandle); + DbgPrint("WL: Failed to lookup authentication package\n"); + return(1); + } #endif /* FIXME: Create a window class and associate a Winlogon @@ -475,9 +579,77 @@ WinMain(HINSTANCE hInstance, Password[i - 1] =0; #endif +#if SUPPORT_CONSOLESTART + if(StartConsole) + { if (! DoLoginUser(LoginName, Password)) { } + } + else + { +#endif + + LoadString(hAppInstance, IDS_PREPARENETWORKCONNECTIONS, StatusMsg, 256 * sizeof(WCHAR)); + MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context, + ApplicationDesktop, + 0, + NULL, + StatusMsg); + + /* FIXME */ + Sleep(250); + + LoadString(hAppInstance, IDS_APPLYINGCOMPUTERSETTINGS, StatusMsg, 256 * sizeof(WCHAR)); + MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context, + ApplicationDesktop, + 0, + NULL, + StatusMsg); + + /* FIXME */ + Sleep(250); + + MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); + MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); + MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); + + /* FIXME - call WlxLoggedOutSAS() to display the login dialog */ + Sleep(500); + + LoadString(hAppInstance, IDS_LOADINGYOURPERSONALSETTINGS, StatusMsg, 256 * sizeof(WCHAR)); + MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context, + ApplicationDesktop, + 0, + NULL, + StatusMsg); + + /* FIXME */ + Sleep(250); + + LoadString(hAppInstance, IDS_APPLYINGYOURPERSONALSETTINGS, StatusMsg, 256 * sizeof(WCHAR)); + MsGinaInst->Functions->WlxDisplayStatusMessage(MsGinaInst->Context, + ApplicationDesktop, + 0, + NULL, + StatusMsg); + + /* FIXME */ + Sleep(250); + + MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); + MsGinaInst->Functions->WlxRemoveStatusMessage(MsGinaInst->Context); + + /* FIXME - call WlxActivateUserShell() which will start userinit.exe */ + DoLoginUser(LoginName, Password); /* FIXME - remove */ + DbgPrint("shell exited! finished\n"); + MessageBox(0, L"Shell exited", L"", 0); + + WaitForSingleObject(hShutdownEvent, INFINITE); + CloseHandle(hShutdownEvent); +#if SUPPORT_CONSOLESTART + } +#endif NtShutdownSystem(ShutdownNoReboot); diff --git a/reactos/subsys/system/winlogon/winlogon.h b/reactos/subsys/system/winlogon/winlogon.h new file mode 100644 index 00000000000..174d2f7b423 --- /dev/null +++ b/reactos/subsys/system/winlogon/winlogon.h @@ -0,0 +1,102 @@ +/* + * ReactOS kernel + * Copyright (C) 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: winlogon.h,v 1.1 2003/12/01 18:21:04 weiden Exp $ + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS winlogon + * FILE: subsys/system/winlogon/winlogon.h + * PURPOSE: Winlogon + * PROGRAMMER: + */ + +#ifndef __WINLOGON_MAIN_H__ +#define __WINLOGON_MAIN_H__ + +#include + +typedef BOOL (WINAPI * PFWLXNEGOTIATE) (DWORD, DWORD *); +typedef BOOL (WINAPI * PFWLXINITIALIZE) (LPWSTR, HANDLE, PVOID, PVOID, PVOID *); +typedef VOID (WINAPI * PFWLXDISPLAYSASNOTICE) (PVOID); +typedef int (WINAPI * PFWLXLOGGEDOUTSAS) (PVOID, DWORD, PLUID, PSID, PDWORD, + PHANDLE, PWLX_MPR_NOTIFY_INFO, + PVOID *); +typedef BOOL (WINAPI * PFWLXACTIVATEUSERSHELL) (PVOID, PWSTR, PWSTR, PVOID); +typedef int (WINAPI * PFWLXLOGGEDONSAS) (PVOID, DWORD, PVOID); +typedef VOID (WINAPI * PFWLXDISPLAYLOCKEDNOTICE) (PVOID); +typedef int (WINAPI * PFWLXWKSTALOCKEDSAS) (PVOID, DWORD); +typedef BOOL (WINAPI * PFWLXISLOCKOK) (PVOID); +typedef BOOL (WINAPI * PFWLXISLOGOFFOK) (PVOID); +typedef VOID (WINAPI * PFWLXLOGOFF) (PVOID); +typedef VOID (WINAPI * PFWLXSHUTDOWN) (PVOID, DWORD); + +/* version 1.1 */ + +typedef BOOL (WINAPI * PFWLXSCREENSAVERNOTIFY) (PVOID, BOOL *); +typedef BOOL (WINAPI * PFWLXSTARTAPPLICATION) (PVOID, PWSTR, PVOID, PWSTR); + +/* version 1.3 */ + +typedef BOOL (WINAPI * PFWLXNETWORKPROVIDERLOAD) (PVOID, PWLX_MPR_NOTIFY_INFO); +typedef BOOL (WINAPI * PFWLXDISPLAYSTATUSMESSAGE) (PVOID, HDESK, DWORD, PWSTR, PWSTR); +typedef BOOL (WINAPI * PFWLXGETSTATUSMESSAGE) (PVOID, DWORD *, PWSTR, DWORD); +typedef BOOL (WINAPI * PFWLXREMOVESTATUSMESSAGE) (PVOID); + +typedef struct _MSGINAFUNCTIONS +{ + PFWLXNEGOTIATE WlxNegotiate; + PFWLXINITIALIZE WlxInitialize; + PFWLXDISPLAYSASNOTICE WlxDisplaySASNotice; + PFWLXLOGGEDOUTSAS WlxLoggedOutSAS; + PFWLXACTIVATEUSERSHELL WlxActivateUserShell; + PFWLXLOGGEDONSAS WlxLoggedOnSAS; + PFWLXDISPLAYLOCKEDNOTICE WlxDisplayLockedNotice; + PFWLXWKSTALOCKEDSAS WlxWkstaLockedSAS; + PFWLXISLOCKOK WlxIsLockOK; + PFWLXISLOGOFFOK WlxIsLogOffOK; + PFWLXLOGOFF WlxLogOff; + PFWLXSHUTDOWN WlxShutdown; + + PFWLXSCREENSAVERNOTIFY WlxScreenSaverNotify; + PFWLXSTARTAPPLICATION WlxStartApplication; + + PFWLXNETWORKPROVIDERLOAD WlxNetworkProviderLoad; + PFWLXDISPLAYSTATUSMESSAGE WlxDisplayStatusMessage; + PFWLXGETSTATUSMESSAGE WlxGetStatusMessage; + PFWLXREMOVESTATUSMESSAGE WlxRemoveStatusMessage; +} MSGINAFUNCTIONS, *PMSGINAFUNCTIONS; + +typedef struct _MSGINAINSTANCE +{ + HANDLE hDllInstance; + PMSGINAFUNCTIONS Functions; + PVOID Context; +} MSGINAINSTANCE, *PMSGINAINSTANCE; + +extern HINSTANCE hAppInstance; +extern PMSGINAINSTANCE MsGinaInst; +extern HWINSTA InteractiveWindowStation; /* WinSta0 */ +extern HDESK ApplicationDesktop; /* WinSta0\Default */ +extern HDESK WinlogonDesktop; /* WinSta0\Winlogon */ +extern HDESK ScreenSaverDesktop; /* WinSta0\Screen-Saver */ + +extern MSGINAFUNCTIONS MsGinaFunctions; + + +#endif /* __WINLOGON_MAIN_H__ */ + +/* EOF */ diff --git a/reactos/subsys/system/winlogon/winlogon.rc b/reactos/subsys/system/winlogon/winlogon.rc index 46b4f776e50..534ff4faf31 100644 --- a/reactos/subsys/system/winlogon/winlogon.rc +++ b/reactos/subsys/system/winlogon/winlogon.rc @@ -1,5 +1,6 @@ #include #include +#include "resource.h" LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -36,3 +37,44 @@ BEGIN END END +IDI_WINLOGON ICON "resources/winlogon.ico" + +IDD_SHUTDOWNCOMPUTER DIALOG 45, 22, 164, 52 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +CAPTION "Shutdown Computer" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "It is now safe to turn off your computer.", IDC_SHUTDOWNCOMPUTER, 31, 13, 132, 8 + ICON IDI_WINLOGON, IDC_SHTDOWNICON, 6, 7, 18, 20 + DEFPUSHBUTTON "&Restart", IDC_BTNSHTDOWNCOMPUTER, 62, 32, 40, 14 +END + +IDD_GINALOADFAILED DIALOG 58, 83, 231, 119 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "User Interface Failure" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "The Logon User Interface DLL %s failed to load.", IDC_GINALOADFAILED, 39, 16, 156, 24 + LTEXT "Contact your system administrator to replace the DLL, or restore the original DLL.", IDC_GINALOADFAILEDCONTACT, 39, 53, 151, 25 + DEFPUSHBUTTON "&Restart", 1, 80, 91, 68, 14 +END + +STRINGTABLE +BEGIN + IDS_PREPARENETWORKCONNECTIONS "Preparing network connections..." + IDS_APPLYINGCOMPUTERSETTINGS "Applying computer settings..." + IDS_RUNNINGSTARTUPSCRIPTS "Running startup scripts..." + IDS_RUNNINGSHUTDOWNSCRIPTS "Running shutdown scripts..." + IDS_APPLYINGYOURPERSONALSETTINGS "Applying your personal settings..." + IDS_RUNNINGLOGOFFSCRIPTS "Running logoff scripts..." + IDS_RUNNINGLOGONSCRIPTS "Running logon scripts..." + IDS_LOADINGYOURPERSONALSETTINGS "Loading your personal settings..." + IDS_CLOSINGNETWORKCONNECTIONS "Closing network connections..." + IDS_REACTOSISSHUTTINGDOWN "ReactOS is shutting down..." + IDS_PREPARETOSTANDBY "Preparing to Standby..." + IDS_PREPARETOHIBERNATE "Preparing to Hibernate..." + IDS_SAVEYOURSETTINGS "Saving your settings..." + IDS_REACTOSISSTARTINGUP "ReactOS is starting up..." +END + diff --git a/reactos/subsys/system/winlogon/wlx.c b/reactos/subsys/system/winlogon/wlx.c new file mode 100644 index 00000000000..e46e1220aeb --- /dev/null +++ b/reactos/subsys/system/winlogon/wlx.c @@ -0,0 +1,585 @@ +/* $Id: wlx.c,v 1.1 2003/12/01 18:21:04 weiden Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/winlogon/winlogon.c + * PURPOSE: Logon + * PROGRAMMER: David Welch (welch@cwcom.net) + * UPDATE HISTORY: + * Created 22/05/98 + */ + +/* INCLUDES *****************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "setup.h" +#include "winlogon.h" +#include "resource.h" + +#define NDEBUG +#include + +#define Unimplemented DbgPrint("WL: %S() at %S:%i unimplemented!\n", __FUNCTION__, __FILE__, __LINE__) + +PMSGINAINSTANCE MsGinaInst; + +/* + * @unimplemented + */ +VOID WINAPI +WlxUseCtrlAltDel( + HANDLE hWlx +) +{ + Unimplemented; +} + +/* + * @unimplemented + */ +VOID WINAPI +WlxSetContextPointer( + HANDLE hWlx, + PVOID pWlxContext +) +{ + Unimplemented; +} + +/* + * @unimplemented + */ +VOID WINAPI +WlxSasNotify( + HANDLE hWlx, + DWORD dwSasType +) +{ + Unimplemented; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxSetTimeout( + HANDLE hWlx, + DWORD Timeout +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +int WINAPI +WlxAssignShellProtection( + HANDLE hWlx, + HANDLE hToken, + HANDLE hProcess, + HANDLE hThread +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxMessageBox( + HANDLE hWlx, + HWND hwndOwner, + LPWSTR lpszText, + LPWSTR lpszTitle, + UINT fuStyle +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxDialogBox( + HANDLE hWlx, + HANDLE hInst, + LPWSTR lpszTemplate, + HWND hwndOwner, + DLGPROC dlgprc +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxDialogBoxParam( + HANDLE hWlx, + HANDLE hInst, + LPWSTR lpszTemplate, + HWND hwndOwner, + DLGPROC dlgprc, + LPARAM dwInitParam +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxDialogBoxIndirect( + HANDLE hWlx, + HANDLE hInst, + LPCDLGTEMPLATE hDialogTemplate, + HWND hwndOwner, + DLGPROC dlgprc +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxDialogBoxIndirectParam( + HANDLE hWlx, + HANDLE hInst, + LPCDLGTEMPLATE hDialogTemplate, + HWND hwndOwner, + DLGPROC dlgprc, + LPARAM dwInitParam +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxSwitchDesktopToUser( + HANDLE hWlx +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxSwitchDesktopToWinlogon( + HANDLE hWlx +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +int WINAPI +WlxChangePasswordNotify( + HANDLE hWlx, + PWLX_MPR_NOTIFY_INFO pMprInfo, + DWORD dwChangeInfo +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxGetSourceDesktop( + HANDLE hWlx, + PWLX_DESKTOP* ppDesktop +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxSetReturnDesktop( + HANDLE hWlx, + PWLX_DESKTOP pDesktop +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxCreateUserDesktop( + HANDLE hWlx, + HANDLE hToken, + DWORD Flags, + PWSTR pszDesktopName, + PWLX_DESKTOP* ppDesktop +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +int WINAPI +WlxChangePasswordNotifyEx( + HANDLE hWlx, + PWLX_MPR_NOTIFY_INFO pMprInfo, + DWORD dwChangeInfo, + PWSTR ProviderName, + PVOID Reserved +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxCloseUserDesktop( + HANDLE hWlx, + PWLX_DESKTOP pDesktop, + HANDLE hToken +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxSetOption( + HANDLE hWlx, + DWORD Option, + ULONG_PTR Value, + ULONG_PTR* OldValue +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxGetOption( + HANDLE hWlx, + DWORD Option, + ULONG_PTR* Value +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +VOID WINAPI +WlxWin31Migrate( + HANDLE hWlx +) +{ + Unimplemented; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxQueryClientCredentials( + PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxQueryInetConnectorCredentials( + PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +DWORD WINAPI +WlxQueryConsoleSwitchCredentials( + PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred +) +{ + Unimplemented; + return 0; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxQueryTsLogonCredentials( + PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred +) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL WINAPI +WlxDisconnect(void) +{ + Unimplemented; + return FALSE; +} + +/* + * @unimplemented + */ +DWORD WINAPI +WlxQueryTerminalServicesData( + HANDLE hWlx, + PWLX_TERMINAL_SERVICES_DATA pTSData, + WCHAR* UserName, + WCHAR* Domain +) +{ + Unimplemented; + return 0; +} + +const +WLX_DISPATCH_VERSION_1_4 FunctionTable = { + WlxUseCtrlAltDel, + WlxSetContextPointer, + WlxSasNotify, + WlxSetTimeout, + WlxAssignShellProtection, + WlxMessageBox, + WlxDialogBox, + WlxDialogBoxParam, + WlxDialogBoxIndirect, + WlxDialogBoxIndirectParam, + WlxSwitchDesktopToUser, + WlxSwitchDesktopToWinlogon, + WlxChangePasswordNotify, + WlxGetSourceDesktop, + WlxSetReturnDesktop, + WlxCreateUserDesktop, + WlxChangePasswordNotifyEx, + WlxCloseUserDesktop, + WlxSetOption, + WlxGetOption, + WlxWin31Migrate, + WlxQueryClientCredentials, + WlxQueryInetConnectorCredentials, + WlxDisconnect, + WlxQueryTerminalServicesData, + WlxQueryConsoleSwitchCredentials, + WlxQueryTsLogonCredentials +}; + +/******************************************************************************/ + +static void +GetMsGinaPath(WCHAR *path) +{ + DWORD Status, Type, Size; + HANDLE hKey; + + Status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", + 0, + KEY_QUERY_VALUE, + &hKey); + if(Status != ERROR_SUCCESS) + { + wcscpy(path, L"msgina.dll"); + return; + } + + Size = MAX_PATH * sizeof(WCHAR); + Status = RegQueryValueEx(hKey, + L"GinaDLL", + NULL, + &Type, + (LPBYTE)path, + &Size); + if((Status != ERROR_SUCCESS) || (Size != REG_SZ) || (Size == 0)) + { + wcscpy(path, L"msgina.dll"); + } + RegCloseKey(hKey); +} + +BOOL +CALLBACK +GinaLoadFailedProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + switch(uMsg) + { + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDOK: + EndDialog(hwndDlg, IDOK); + break; + } + break; + } + case WM_INITDIALOG: + { + int len; + WCHAR str[MAX_PATH], str2[MAX_PATH]; + + if(lParam) + { + len = GetDlgItemText(hwndDlg, IDC_GINALOADFAILED, str, MAX_PATH); + + if(len) + { + wsprintf(str2, str, (LPWSTR)lParam); + SetDlgItemText(hwndDlg, IDC_GINALOADFAILED, str2); + } + } + SetFocus(GetDlgItem(hwndDlg, IDOK)); + break; + } + case WM_CLOSE: + { + EndDialog(hwndDlg, IDCANCEL); + return TRUE; + } + } + return FALSE; +} + +BOOL +LoadGina(PMSGINAFUNCTIONS Functions) +{ + HMODULE hGina; + WCHAR GinaDll[MAX_PATH + 1]; + DWORD DllVersion = 0; + + MsGinaInst = NULL; + + GetMsGinaPath(GinaDll); + + hGina = LoadLibrary(GinaDll); + if(!hGina) + { + DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_GINALOADFAILED), 0, GinaLoadFailedProc, (LPARAM)&GinaDll); + return FALSE; + } + + Functions->WlxNegotiate = (PFWLXNEGOTIATE)GetProcAddress(hGina, "WlxNegotiate"); + Functions->WlxInitialize = (PFWLXINITIALIZE)GetProcAddress(hGina, "WlxInitialize"); + + if(Functions->WlxNegotiate) + { + if(!Functions->WlxNegotiate(WLX_VERSION_1_3, &DllVersion)) + { + return FALSE; + } + + /* FIXME - allow other versions */ + if(DllVersion != WLX_VERSION_1_3) + { + return FALSE; + } + + if(DllVersion >= WLX_VERSION_1_3) + { + Functions->WlxNetworkProviderLoad = (PFWLXNETWORKPROVIDERLOAD)GetProcAddress(hGina, "WlxNetworkProviderLoad"); + Functions->WlxDisplayStatusMessage = (PFWLXDISPLAYSTATUSMESSAGE)GetProcAddress(hGina, "WlxDisplayStatusMessage"); + Functions->WlxGetStatusMessage = (PFWLXGETSTATUSMESSAGE)GetProcAddress(hGina, "WlxGetStatusMessage"); + Functions->WlxRemoveStatusMessage = (PFWLXREMOVESTATUSMESSAGE)GetProcAddress(hGina, "WlxRemoveStatusMessage"); + } + } + + return (Functions->WlxNegotiate != NULL) && (Functions->WlxInitialize != NULL); +} + +BOOL +MsGinaInit() +{ + PMSGINAINSTANCE Instance; + + Instance = (PMSGINAINSTANCE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MSGINAINSTANCE)); + if(!Instance) + { + return 0; + } + + Instance->Functions = &MsGinaFunctions; + Instance->hDllInstance = NULL; /* FIXME */ + Instance->Context = NULL; + + MsGinaInst = Instance; + + if(!Instance->Functions->WlxInitialize(InteractiveWindowStation, + (HANDLE)Instance, + NULL, + (PVOID)&FunctionTable, + &Instance->Context)) + { + return 0; + } + return TRUE; +} +