2006-07-30 08:38:35 +00:00
|
|
|
|
/*
|
1999-06-06 16:40:10 +00:00
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2006-07-30 08:38:35 +00:00
|
|
|
|
* PROJECT: ReactOS Winlogon
|
2007-07-26 15:13:36 +00:00
|
|
|
|
* FILE: base/system/winlogon/winlogon.c
|
2005-05-08 04:07:56 +00:00
|
|
|
|
* PURPOSE: Logon
|
2006-08-02 21:01:37 +00:00
|
|
|
|
* PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
|
|
|
|
|
* Filip Navara
|
|
|
|
|
* Herv<EFBFBD> Poussineau (hpoussin@reactos.org)
|
1999-06-06 16:40:10 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
2007-07-26 15:13:36 +00:00
|
|
|
|
|
2003-12-01 18:21:04 +00:00
|
|
|
|
#include "winlogon.h"
|
2003-03-25 19:26:33 +00:00
|
|
|
|
|
2014-01-13 13:16:29 +00:00
|
|
|
|
#include <ndk/cmfuncs.h>
|
|
|
|
|
|
1999-06-08 22:45:53 +00:00
|
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
|
2003-12-01 18:21:04 +00:00
|
|
|
|
HINSTANCE hAppInstance;
|
2004-03-28 12:21:41 +00:00
|
|
|
|
PWLSESSION WLSession = NULL;
|
2003-12-01 18:21:04 +00:00
|
|
|
|
|
1999-06-06 16:40:10 +00:00
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
static
|
|
|
|
|
BOOL
|
2006-08-03 13:50:40 +00:00
|
|
|
|
StartServicesManager(VOID)
|
1999-06-06 16:40:10 +00:00
|
|
|
|
{
|
2013-03-02 20:30:36 +00:00
|
|
|
|
STARTUPINFOW StartupInfo;
|
|
|
|
|
PROCESS_INFORMATION ProcessInformation;
|
|
|
|
|
LPCWSTR ServiceString = L"services.exe";
|
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
|
|
/* Start the service control manager (services.exe) */
|
|
|
|
|
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
|
|
|
|
|
StartupInfo.cb = sizeof(StartupInfo);
|
|
|
|
|
StartupInfo.lpReserved = NULL;
|
|
|
|
|
StartupInfo.lpDesktop = NULL;
|
|
|
|
|
StartupInfo.lpTitle = NULL;
|
|
|
|
|
StartupInfo.dwFlags = 0;
|
|
|
|
|
StartupInfo.cbReserved2 = 0;
|
|
|
|
|
StartupInfo.lpReserved2 = 0;
|
|
|
|
|
|
|
|
|
|
TRACE("WL: Creating new process - %S\n", ServiceString);
|
|
|
|
|
|
|
|
|
|
res = CreateProcessW(ServiceString,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
FALSE,
|
|
|
|
|
DETACHED_PROCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&StartupInfo,
|
|
|
|
|
&ProcessInformation);
|
|
|
|
|
if (!res)
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Failed to execute services (error %lu)\n", GetLastError());
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("WL: Created new process - %S\n", ServiceString);
|
|
|
|
|
|
|
|
|
|
CloseHandle(ProcessInformation.hThread);
|
|
|
|
|
CloseHandle(ProcessInformation.hProcess);
|
|
|
|
|
|
|
|
|
|
TRACE("WL: StartServicesManager() done.\n");
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
1999-06-06 16:40:10 +00:00
|
|
|
|
}
|
1999-06-08 22:45:53 +00:00
|
|
|
|
|
2005-05-08 04:07:56 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
static
|
|
|
|
|
BOOL
|
2006-08-02 21:01:37 +00:00
|
|
|
|
StartLsass(VOID)
|
|
|
|
|
{
|
2013-03-02 20:30:36 +00:00
|
|
|
|
STARTUPINFOW StartupInfo;
|
|
|
|
|
PROCESS_INFORMATION ProcessInformation;
|
|
|
|
|
LPCWSTR ServiceString = L"lsass.exe";
|
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
|
|
/* Start the local security authority subsystem (lsass.exe) */
|
|
|
|
|
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
|
|
|
|
|
StartupInfo.cb = sizeof(StartupInfo);
|
|
|
|
|
StartupInfo.lpReserved = NULL;
|
|
|
|
|
StartupInfo.lpDesktop = NULL;
|
|
|
|
|
StartupInfo.lpTitle = NULL;
|
|
|
|
|
StartupInfo.dwFlags = 0;
|
|
|
|
|
StartupInfo.cbReserved2 = 0;
|
|
|
|
|
StartupInfo.lpReserved2 = 0;
|
|
|
|
|
|
|
|
|
|
TRACE("WL: Creating new process - %S\n", ServiceString);
|
|
|
|
|
|
|
|
|
|
res = CreateProcessW(ServiceString,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
FALSE,
|
|
|
|
|
DETACHED_PROCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&StartupInfo,
|
|
|
|
|
&ProcessInformation);
|
|
|
|
|
|
|
|
|
|
TRACE("WL: Created new process - %S\n", ServiceString);
|
|
|
|
|
|
|
|
|
|
CloseHandle(ProcessInformation.hThread);
|
|
|
|
|
CloseHandle(ProcessInformation.hProcess);
|
|
|
|
|
|
|
|
|
|
return res;
|
2006-08-02 21:01:37 +00:00
|
|
|
|
}
|
2004-03-09 15:08:12 +00:00
|
|
|
|
|
2010-09-12 16:29:43 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
static
|
|
|
|
|
VOID
|
2010-09-12 16:29:43 +00:00
|
|
|
|
WaitForLsass(VOID)
|
|
|
|
|
{
|
|
|
|
|
HANDLE hEvent;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
|
|
|
|
|
hEvent = CreateEventW(NULL,
|
|
|
|
|
TRUE,
|
|
|
|
|
FALSE,
|
|
|
|
|
L"LSA_RPC_SERVER_ACTIVE");
|
|
|
|
|
if (hEvent == NULL)
|
|
|
|
|
{
|
|
|
|
|
dwError = GetLastError();
|
2016-11-05 14:55:55 +00:00
|
|
|
|
TRACE("WL: Failed to create the notification event (Error %lu)\n", dwError);
|
2010-09-12 16:29:43 +00:00
|
|
|
|
|
|
|
|
|
if (dwError == ERROR_ALREADY_EXISTS)
|
|
|
|
|
{
|
|
|
|
|
hEvent = OpenEventW(SYNCHRONIZE,
|
|
|
|
|
FALSE,
|
|
|
|
|
L"LSA_RPC_SERVER_ACTIVE");
|
|
|
|
|
if (hEvent == NULL)
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not open the notification event (Error %lu)\n", GetLastError());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("WL: Wait for the LSA server!\n");
|
|
|
|
|
WaitForSingleObject(hEvent, INFINITE);
|
|
|
|
|
TRACE("WL: LSA server running!\n");
|
|
|
|
|
|
|
|
|
|
CloseHandle(hEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-06-22 16:23:11 +00:00
|
|
|
|
static
|
|
|
|
|
VOID
|
|
|
|
|
UpdateTcpIpInformation(VOID)
|
|
|
|
|
{
|
|
|
|
|
LONG lError;
|
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
|
DWORD dwType, dwSize;
|
|
|
|
|
PWSTR pszBuffer;
|
|
|
|
|
WCHAR szBuffer[128] = L"";
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE | KEY_SET_VALUE,
|
|
|
|
|
&hKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: RegOpenKeyExW(\"HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters\") failed (error %lu)\n", lError);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Read the "NV Hostname" value and copy it into the "Hostname" value.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
pszBuffer = szBuffer;
|
|
|
|
|
dwSize = ARRAYSIZE(szBuffer);
|
|
|
|
|
|
|
|
|
|
lError = RegQueryValueExW(hKey,
|
|
|
|
|
L"NV Hostname",
|
|
|
|
|
NULL,
|
|
|
|
|
&dwType,
|
|
|
|
|
(LPBYTE)pszBuffer,
|
|
|
|
|
&dwSize);
|
|
|
|
|
if (((lError == ERROR_INSUFFICIENT_BUFFER) || (lError == ERROR_MORE_DATA)) && (dwType == REG_SZ))
|
|
|
|
|
{
|
|
|
|
|
pszBuffer = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
|
|
|
|
if (pszBuffer)
|
|
|
|
|
{
|
|
|
|
|
lError = RegQueryValueExW(hKey,
|
|
|
|
|
L"NV Hostname",
|
|
|
|
|
NULL,
|
|
|
|
|
&dwType,
|
|
|
|
|
(LPBYTE)pszBuffer,
|
|
|
|
|
&dwSize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not reallocate memory for pszBuffer\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
|
|
|
|
|
{
|
|
|
|
|
TRACE("NV Hostname is '%S'.\n", pszBuffer);
|
|
|
|
|
|
|
|
|
|
lError = RegSetValueExW(hKey,
|
|
|
|
|
L"Hostname",
|
|
|
|
|
0,
|
|
|
|
|
REG_SZ,
|
|
|
|
|
(LPBYTE)pszBuffer,
|
|
|
|
|
dwSize);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
ERR("WL: RegSetValueExW(\"Hostname\") failed (error %lu)\n", lError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Read the "NV Domain" value and copy it into the "Domain" value.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// pszBuffer = szBuffer;
|
|
|
|
|
// dwSize = ARRAYSIZE(szBuffer);
|
|
|
|
|
|
|
|
|
|
lError = RegQueryValueExW(hKey,
|
|
|
|
|
L"NV Domain",
|
|
|
|
|
NULL,
|
|
|
|
|
&dwType,
|
|
|
|
|
(LPBYTE)pszBuffer,
|
|
|
|
|
&dwSize);
|
|
|
|
|
if (((lError == ERROR_INSUFFICIENT_BUFFER) || (lError == ERROR_MORE_DATA)) && (dwType == REG_SZ))
|
|
|
|
|
{
|
|
|
|
|
if (pszBuffer != szBuffer)
|
|
|
|
|
{
|
|
|
|
|
PWSTR pszNewBuffer;
|
|
|
|
|
pszNewBuffer = HeapReAlloc(GetProcessHeap(), 0, pszBuffer, dwSize);
|
|
|
|
|
if (pszNewBuffer)
|
|
|
|
|
{
|
|
|
|
|
pszBuffer = pszNewBuffer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszBuffer);
|
|
|
|
|
pszBuffer = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pszBuffer = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
|
|
|
|
}
|
|
|
|
|
if (pszBuffer)
|
|
|
|
|
{
|
|
|
|
|
lError = RegQueryValueExW(hKey,
|
|
|
|
|
L"NV Domain",
|
|
|
|
|
NULL,
|
|
|
|
|
&dwType,
|
|
|
|
|
(LPBYTE)pszBuffer,
|
|
|
|
|
&dwSize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not reallocate memory for pszBuffer\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
|
|
|
|
|
{
|
|
|
|
|
TRACE("NV Domain is '%S'.\n", pszBuffer);
|
|
|
|
|
|
|
|
|
|
lError = RegSetValueExW(hKey,
|
|
|
|
|
L"Domain",
|
|
|
|
|
0,
|
|
|
|
|
REG_SZ,
|
|
|
|
|
(LPBYTE)pszBuffer,
|
|
|
|
|
dwSize);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
ERR("WL: RegSetValueExW(\"Domain\") failed (error %lu)\n", lError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pszBuffer != szBuffer)
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszBuffer);
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
static
|
|
|
|
|
BOOL
|
|
|
|
|
InitKeyboardLayouts(VOID)
|
2011-10-19 20:03:50 +00:00
|
|
|
|
{
|
|
|
|
|
WCHAR wszKeyName[12], wszKLID[10];
|
2013-03-02 20:30:36 +00:00
|
|
|
|
DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
|
2011-10-19 20:03:50 +00:00
|
|
|
|
HKEY hKey;
|
|
|
|
|
UINT Flags;
|
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Open registry key with preloaded layouts */
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
|
|
|
|
{
|
2016-09-18 23:32:02 +00:00
|
|
|
|
while (TRUE)
|
2011-10-19 20:03:50 +00:00
|
|
|
|
{
|
2011-10-20 13:26:39 +00:00
|
|
|
|
/* Read values with integer names only */
|
|
|
|
|
swprintf(wszKeyName, L"%d", i++);
|
|
|
|
|
if (RegQueryValueExW(hKey, wszKeyName, NULL, &dwType, (LPBYTE)wszKLID, &dwSize) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
/* There is no more entries */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Only REG_SZ values are valid */
|
|
|
|
|
if (dwType != REG_SZ)
|
|
|
|
|
{
|
|
|
|
|
ERR("Wrong type: %ws!\n", wszKLID);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Load keyboard layout with given locale id */
|
|
|
|
|
Flags = KLF_SUBSTITUTE_OK;
|
2011-10-19 20:03:50 +00:00
|
|
|
|
if (i > 1)
|
2011-10-20 13:26:39 +00:00
|
|
|
|
Flags |= KLF_NOTELLSHELL|KLF_REPLACELANG;
|
|
|
|
|
else // First layout
|
|
|
|
|
Flags |= KLF_ACTIVATE; // |0x40000000
|
|
|
|
|
if (!LoadKeyboardLayoutW(wszKLID, Flags))
|
|
|
|
|
{
|
|
|
|
|
ERR("LoadKeyboardLayoutW(%ws) failed!\n", wszKLID);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We loaded at least one layout - success */
|
2011-10-19 20:03:50 +00:00
|
|
|
|
bRet = TRUE;
|
2011-10-20 13:26:39 +00:00
|
|
|
|
}
|
2011-10-19 20:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-20 13:26:39 +00:00
|
|
|
|
/* Close the key now */
|
|
|
|
|
RegCloseKey(hKey);
|
2013-03-02 20:30:36 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
|
2011-10-19 20:03:50 +00:00
|
|
|
|
|
2011-10-20 13:26:39 +00:00
|
|
|
|
if (!bRet)
|
|
|
|
|
{
|
|
|
|
|
/* If we failed, load US keyboard layout */
|
2019-02-24 09:37:42 +00:00
|
|
|
|
if (LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | KLF_SUBSTITUTE_OK | KLF_REPLACELANG | KLF_SETFORPROCESS))
|
2011-10-20 13:26:39 +00:00
|
|
|
|
bRet = TRUE;
|
2011-10-19 20:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-22 18:28:05 +00:00
|
|
|
|
|
2006-08-09 06:31:02 +00:00
|
|
|
|
BOOL
|
2013-12-08 14:31:40 +00:00
|
|
|
|
DisplayStatusMessage(
|
|
|
|
|
IN PWLSESSION Session,
|
|
|
|
|
IN HDESK hDesktop,
|
|
|
|
|
IN UINT ResourceId)
|
1999-06-08 22:45:53 +00:00
|
|
|
|
{
|
2013-03-02 20:30:36 +00:00
|
|
|
|
WCHAR StatusMsg[MAX_PATH];
|
2005-05-08 04:07:56 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (Session->Gina.Version < WLX_VERSION_1_3)
|
|
|
|
|
return TRUE;
|
2006-08-09 06:31:02 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (Session->SuppressStatus)
|
|
|
|
|
return TRUE;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
|
|
|
|
|
return FALSE;
|
2004-03-28 12:21:41 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
return Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, hDesktop, 0, NULL, StatusMsg);
|
2004-03-28 12:21:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
|
2006-08-09 06:31:02 +00:00
|
|
|
|
BOOL
|
2013-12-08 14:31:40 +00:00
|
|
|
|
RemoveStatusMessage(
|
|
|
|
|
IN PWLSESSION Session)
|
2004-03-28 12:21:41 +00:00
|
|
|
|
{
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (Session->Gina.Version < WLX_VERSION_1_3)
|
|
|
|
|
return TRUE;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
return Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
|
1999-06-18 22:11:21 +00:00
|
|
|
|
}
|
2004-03-28 12:21:41 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
INT_PTR
|
|
|
|
|
CALLBACK
|
2013-12-08 14:31:40 +00:00
|
|
|
|
GinaLoadFailedWindowProc(
|
|
|
|
|
IN HWND hwndDlg,
|
|
|
|
|
IN UINT uMsg,
|
|
|
|
|
IN WPARAM wParam,
|
|
|
|
|
IN LPARAM lParam)
|
2006-08-04 11:37:18 +00:00
|
|
|
|
{
|
2013-03-02 20:30:36 +00:00
|
|
|
|
switch (uMsg)
|
|
|
|
|
{
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
{
|
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
|
{
|
|
|
|
|
case IDOK:
|
|
|
|
|
EndDialog(hwndDlg, IDOK);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
WCHAR templateText[MAX_PATH], text[MAX_PATH];
|
|
|
|
|
|
|
|
|
|
len = GetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, templateText, MAX_PATH);
|
|
|
|
|
if (len)
|
|
|
|
|
{
|
|
|
|
|
wsprintfW(text, templateText, (LPWSTR)lParam);
|
|
|
|
|
SetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetFocus(GetDlgItem(hwndDlg, IDOK));
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
|
{
|
|
|
|
|
EndDialog(hwndDlg, IDCANCEL);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2006-08-04 11:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
WINAPI
|
2013-12-08 14:31:40 +00:00
|
|
|
|
WinMain(
|
|
|
|
|
IN HINSTANCE hInstance,
|
|
|
|
|
IN HINSTANCE hPrevInstance,
|
|
|
|
|
IN LPSTR lpCmdLine,
|
|
|
|
|
IN int nShowCmd)
|
2006-08-02 21:01:37 +00:00
|
|
|
|
{
|
|
|
|
|
#if 0
|
2013-03-02 20:30:36 +00:00
|
|
|
|
LSA_STRING ProcessName, PackageName;
|
|
|
|
|
HANDLE LsaHandle;
|
|
|
|
|
LSA_OPERATIONAL_MODE Mode;
|
|
|
|
|
BOOLEAN Old;
|
|
|
|
|
ULONG AuthenticationPackage;
|
|
|
|
|
NTSTATUS Status;
|
2006-08-02 21:01:37 +00:00
|
|
|
|
#endif
|
2013-03-02 20:30:36 +00:00
|
|
|
|
ULONG HardErrorResponse;
|
|
|
|
|
MSG Msg;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
|
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
|
|
|
UNREFERENCED_PARAMETER(nShowCmd);
|
|
|
|
|
|
|
|
|
|
hAppInstance = hInstance;
|
|
|
|
|
|
2014-11-25 23:34:14 +00:00
|
|
|
|
/* Make us critical */
|
|
|
|
|
RtlSetProcessIsCritical(TRUE, NULL, FALSE);
|
|
|
|
|
RtlSetThreadIsCritical(TRUE, NULL, FALSE);
|
|
|
|
|
|
2019-06-22 16:23:11 +00:00
|
|
|
|
/* Update the cached TCP/IP Information in the registry */
|
|
|
|
|
UpdateTcpIpInformation();
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (!RegisterLogonProcess(GetCurrentProcessId(), TRUE))
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not register logon process\n");
|
2014-06-30 21:08:32 +00:00
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
|
|
|
|
ExitProcess(1);
|
2013-03-02 20:30:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, sizeof(WLSESSION));
|
|
|
|
|
if (!WLSession)
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not allocate memory for winlogon instance\n");
|
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZeroMemory(WLSession, sizeof(WLSESSION));
|
|
|
|
|
WLSession->DialogTimeout = 120; /* 2 minutes */
|
|
|
|
|
|
2014-01-11 16:20:31 +00:00
|
|
|
|
/* Initialize the dialog tracking list */
|
|
|
|
|
InitDialogListHead();
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (!CreateWindowStationAndDesktops(WLSession))
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not create window station and desktops\n");
|
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LockWorkstation(WLSession);
|
2006-08-02 21:01:37 +00:00
|
|
|
|
|
2011-10-19 20:03:50 +00:00
|
|
|
|
/* Load default keyboard layouts */
|
|
|
|
|
if (!InitKeyboardLayouts())
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not preload keyboard layouts\n");
|
2013-03-02 20:30:36 +00:00
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
|
|
|
|
ExitProcess(1);
|
2011-10-19 20:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-30 17:13:16 +00:00
|
|
|
|
if (!StartRpcServer())
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not start the RPC server\n");
|
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (!StartServicesManager())
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Could not start services.exe\n");
|
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
2006-08-07 17:18:58 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
if (!StartLsass())
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Failed to start lsass.exe service (error %lu)\n", GetLastError());
|
2014-06-30 21:08:32 +00:00
|
|
|
|
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, OptionOk, &HardErrorResponse);
|
2013-03-02 20:30:36 +00:00
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
2006-08-02 21:01:37 +00:00
|
|
|
|
|
2013-05-12 13:24:37 +00:00
|
|
|
|
/* Wait for the LSA server */
|
|
|
|
|
WaitForLsass();
|
|
|
|
|
|
2015-08-16 14:39:44 +00:00
|
|
|
|
/* Init Notifications */
|
|
|
|
|
InitNotifications();
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
/* Load and initialize gina */
|
|
|
|
|
if (!GinaInit(WLSession))
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Failed to initialize Gina\n");
|
2014-06-30 21:08:32 +00:00
|
|
|
|
// FIXME: Retrieve the real name of the GINA DLL we were trying to load.
|
|
|
|
|
// It is known only inside the GinaInit function...
|
|
|
|
|
DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_GINALOADFAILED), GetDesktopWindow(), GinaLoadFailedWindowProc, (LPARAM)L"msgina.dll");
|
2013-03-02 20:30:36 +00:00
|
|
|
|
HandleShutdown(WLSession, WLX_SAS_ACTION_SHUTDOWN_REBOOT);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
2006-08-02 21:01:37 +00:00
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
DisplayStatusMessage(WLSession, WLSession->WinlogonDesktop, IDS_REACTOSISSTARTINGUP);
|
2010-09-12 16:29:43 +00:00
|
|
|
|
|
2006-08-02 21:01:37 +00:00
|
|
|
|
#if 0
|
2013-03-02 20:30:36 +00:00
|
|
|
|
/* Connect to NetLogon service (lsass.exe) */
|
|
|
|
|
/* Real winlogon uses "Winlogon" */
|
|
|
|
|
RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon");
|
|
|
|
|
Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
|
|
|
|
|
if (Status == STATUS_PORT_CONNECTION_REFUSED)
|
|
|
|
|
{
|
|
|
|
|
/* Add the 'SeTcbPrivilege' privilege and try again */
|
|
|
|
|
Status = RtlAdjustPrivilege(SE_TCB_PRIVILEGE, TRUE, TRUE, &Old);
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
ERR("RtlAdjustPrivilege() failed with error %lu\n", LsaNtStatusToWinError(Status));
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
ERR("LsaRegisterLogonProcess() failed with error %lu\n", LsaNtStatusToWinError(Status));
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString((PUNICODE_STRING)&PackageName, MICROSOFT_KERBEROS_NAME_W);
|
|
|
|
|
Status = LsaLookupAuthenticationPackage(LsaHandle, &PackageName, &AuthenticationPackage);
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
ERR("LsaLookupAuthenticationPackage() failed with error %lu\n", LsaNtStatusToWinError(Status));
|
|
|
|
|
LsaDeregisterLogonProcess(LsaHandle);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2006-08-02 21:01:37 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2015-08-23 15:48:52 +00:00
|
|
|
|
CallNotificationDlls(WLSession, StartupHandler);
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
/* Create a hidden window to get SAS notifications */
|
|
|
|
|
if (!InitializeSAS(WLSession))
|
|
|
|
|
{
|
|
|
|
|
ERR("WL: Failed to initialize SAS\n");
|
|
|
|
|
ExitProcess(2);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-14 05:27:55 +00:00
|
|
|
|
// DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_PREPARENETWORKCONNECTIONS);
|
|
|
|
|
// DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGCOMPUTERSETTINGS);
|
2013-03-02 20:30:36 +00:00
|
|
|
|
|
|
|
|
|
/* Display logged out screen */
|
2014-01-14 22:27:34 +00:00
|
|
|
|
WLSession->LogonState = STATE_INIT;
|
2013-03-02 20:30:36 +00:00
|
|
|
|
RemoveStatusMessage(WLSession);
|
|
|
|
|
|
|
|
|
|
/* Check for pending setup */
|
|
|
|
|
if (GetSetupType() != 0)
|
|
|
|
|
{
|
|
|
|
|
/* Run setup and reboot when done */
|
2018-07-16 23:49:07 +00:00
|
|
|
|
TRACE("WL: Setup mode detected\n");
|
2013-03-02 20:30:36 +00:00
|
|
|
|
RunSetup();
|
|
|
|
|
}
|
|
|
|
|
else
|
2018-07-16 23:49:07 +00:00
|
|
|
|
{
|
2014-01-14 22:27:34 +00:00
|
|
|
|
PostMessageW(WLSession->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_CTRL_ALT_DEL, 0);
|
2018-07-16 23:49:07 +00:00
|
|
|
|
}
|
2013-03-02 20:30:36 +00:00
|
|
|
|
|
2015-08-07 16:28:49 +00:00
|
|
|
|
(void)LoadLibraryW(L"sfc_os.dll");
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
/* Tell kernel that CurrentControlSet is good (needed
|
|
|
|
|
* to support Last good known configuration boot) */
|
|
|
|
|
NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED | 1);
|
|
|
|
|
|
|
|
|
|
/* Message loop for the SAS window */
|
|
|
|
|
while (GetMessageW(&Msg, WLSession->SASWindow, 0, 0))
|
|
|
|
|
{
|
|
|
|
|
TranslateMessage(&Msg);
|
|
|
|
|
DispatchMessageW(&Msg);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 14:39:44 +00:00
|
|
|
|
CleanupNotifications();
|
|
|
|
|
|
2013-03-02 20:30:36 +00:00
|
|
|
|
/* We never go there */
|
|
|
|
|
|
|
|
|
|
return 0;
|
2006-08-02 21:01:37 +00:00
|
|
|
|
}
|