ReactOS 0.4.16-dev-2104-gb84fa49
winlogon.c File Reference
#include "winlogon.h"
#include <ndk/cmfuncs.h>
Include dependency graph for winlogon.c:

Go to the source code of this file.

Functions

PWSTR WlStrDup (_In_opt_ PCWSTR String)
 Duplicates the given string, allocating a buffer on the heap.
 
static BOOL StartServicesManager (VOID)
 
static BOOL StartLsass (VOID)
 
static VOID WaitForLsass (VOID)
 
static VOID UpdateTcpIpInformation (VOID)
 
static BOOL InitKeyboardLayouts (VOID)
 
BOOL DisplayStatusMessage (IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
 
BOOL RemoveStatusMessage (IN PWLSESSION Session)
 
static INT_PTR CALLBACK GinaLoadFailedWindowProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
int WINAPI WinMain (IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd)
 

Variables

HINSTANCE hAppInstance
 
PWLSESSION WLSession = NULL
 

Function Documentation

◆ DisplayStatusMessage()

BOOL DisplayStatusMessage ( IN PWLSESSION  Session,
IN HDESK  hDesktop,
IN UINT  ResourceId 
)

Definition at line 373 of file winlogon.c.

377{
378 WCHAR StatusMsg[MAX_PATH];
379
380 if (Session->Gina.Version < WLX_VERSION_1_3)
381 return TRUE;
382
383 if (Session->SuppressStatus)
384 return TRUE;
385
386 if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
387 return FALSE;
388
389 return Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, hDesktop, 0, NULL, StatusMsg);
390}
INT ResourceId
Definition: LoadImageGCC.c:72
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
HINSTANCE hAppInstance
Definition: winlogon.c:19
#define WLX_VERSION_1_3
Definition: winwlx.h:31
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by HandleLogoff(), HandleLogon(), HandleShutdown(), and WinMain().

◆ GinaLoadFailedWindowProc()

static INT_PTR CALLBACK GinaLoadFailedWindowProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 407 of file winlogon.c.

412{
413 switch (uMsg)
414 {
415 case WM_COMMAND:
416 {
417 switch (LOWORD(wParam))
418 {
419 case IDOK:
420 EndDialog(hwndDlg, IDOK);
421 return TRUE;
422 }
423 break;
424 }
425
426 case WM_INITDIALOG:
427 {
428 int len;
429 WCHAR templateText[MAX_PATH], text[MAX_PATH];
430
431 len = GetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, templateText, MAX_PATH);
432 if (len)
433 {
434 wsprintfW(text, templateText, (LPWSTR)lParam);
436 }
437 return TRUE;
438 }
439
440 case WM_CLOSE:
441 {
442 EndDialog(hwndDlg, IDCANCEL);
443 return TRUE;
444 }
445 }
446
447 return FALSE;
448}
#define IDC_GINALOADFAILED
Definition: resource.h:15
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
const WCHAR * text
Definition: package.c:1794
GLenum GLsizei len
Definition: glext.h:6722
#define LOWORD(l)
Definition: pedump.c:82
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define WM_CLOSE
Definition: winuser.h:1649
#define IDCANCEL
Definition: winuser.h:842
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define WM_COMMAND
Definition: winuser.h:1768
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1767
#define IDOK
Definition: winuser.h:841
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WinMain().

◆ InitKeyboardLayouts()

static BOOL InitKeyboardLayouts ( VOID  )
static

Definition at line 309 of file winlogon.c.

310{
311 WCHAR wszKeyName[12], wszKLID[10];
312 DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
313 HKEY hKey;
314 UINT Flags;
315 BOOL bRet = FALSE;
316
317 /* Open registry key with preloaded layouts */
318 if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
319 {
320 while (TRUE)
321 {
322 /* Read values with integer names only */
323 swprintf(wszKeyName, L"%d", i++);
324 if (RegQueryValueExW(hKey, wszKeyName, NULL, &dwType, (LPBYTE)wszKLID, &dwSize) != ERROR_SUCCESS)
325 {
326 /* There is no more entries */
327 break;
328 }
329
330 /* Only REG_SZ values are valid */
331 if (dwType != REG_SZ)
332 {
333 ERR("Wrong type: %ws!\n", wszKLID);
334 continue;
335 }
336
337 /* Load keyboard layout with given locale id */
339 if (i > 1)
341 else // First layout
342 Flags |= KLF_ACTIVATE; // |0x40000000
343 if (!LoadKeyboardLayoutW(wszKLID, Flags))
344 {
345 ERR("LoadKeyboardLayoutW(%ws) failed!\n", wszKLID);
346 continue;
347 }
348 else
349 {
350 /* We loaded at least one layout - success */
351 bRet = TRUE;
352 }
353 }
354
355 /* Close the key now */
357 }
358 else
359 WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
360
361 if (!bRet)
362 {
363 /* If we failed, load US keyboard layout */
365 bRet = TRUE;
366 }
367
368 return bRet;
369}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1026
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define KLF_SETFORPROCESS
Definition: winuser.h:117
#define KLF_REPLACELANG
Definition: winuser.h:115
#define KLF_ACTIVATE
Definition: winuser.h:111
HKL WINAPI LoadKeyboardLayoutW(_In_ LPCWSTR, _In_ UINT)
#define KLF_SUBSTITUTE_OK
Definition: winuser.h:112
#define KLF_NOTELLSHELL
Definition: winuser.h:116
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by WinMain().

◆ RemoveStatusMessage()

BOOL RemoveStatusMessage ( IN PWLSESSION  Session)

Definition at line 394 of file winlogon.c.

396{
397 if (Session->Gina.Version < WLX_VERSION_1_3)
398 return TRUE;
399
400 return Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
401}

Referenced by DoGenericAction(), HandleLogoff(), HandleLogon(), and WinMain().

◆ StartLsass()

static BOOL StartLsass ( VOID  )
static

Definition at line 95 of file winlogon.c.

96{
97 STARTUPINFOW StartupInfo;
98 PROCESS_INFORMATION ProcessInformation;
99 LPCWSTR ServiceString = L"lsass.exe";
100 BOOL res;
101
102 /* Start the local security authority subsystem (lsass.exe) */
103 ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
104 StartupInfo.cb = sizeof(StartupInfo);
105 StartupInfo.lpReserved = NULL;
106 StartupInfo.lpDesktop = NULL;
107 StartupInfo.lpTitle = NULL;
108 StartupInfo.dwFlags = 0;
109 StartupInfo.cbReserved2 = 0;
110 StartupInfo.lpReserved2 = 0;
111
112 TRACE("WL: Creating new process - %S\n", ServiceString);
113
114 res = CreateProcessW(ServiceString,
115 NULL,
116 NULL,
117 NULL,
118 FALSE,
120 NULL,
121 NULL,
122 &StartupInfo,
123 &ProcessInformation);
124
125 TRACE("WL: Created new process - %S\n", ServiceString);
126
127 CloseHandle(ProcessInformation.hThread);
128 CloseHandle(ProcessInformation.hProcess);
129
130 return res;
131}
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4600
GLuint res
Definition: glext.h:9613
#define ZeroMemory
Definition: minwinbase.h:31
#define TRACE(s)
Definition: solgame.cpp:4
#define DETACHED_PROCESS
Definition: winbase.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by WinMain().

◆ StartServicesManager()

static BOOL StartServicesManager ( VOID  )
static

Definition at line 47 of file winlogon.c.

48{
49 STARTUPINFOW StartupInfo;
50 PROCESS_INFORMATION ProcessInformation;
51 LPCWSTR ServiceString = L"services.exe";
52 BOOL res;
53
54 /* Start the service control manager (services.exe) */
55 ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
56 StartupInfo.cb = sizeof(StartupInfo);
57 StartupInfo.lpReserved = NULL;
58 StartupInfo.lpDesktop = NULL;
59 StartupInfo.lpTitle = NULL;
60 StartupInfo.dwFlags = 0;
61 StartupInfo.cbReserved2 = 0;
62 StartupInfo.lpReserved2 = 0;
63
64 TRACE("WL: Creating new process - %S\n", ServiceString);
65
66 res = CreateProcessW(ServiceString,
67 NULL,
68 NULL,
69 NULL,
70 FALSE,
72 NULL,
73 NULL,
74 &StartupInfo,
75 &ProcessInformation);
76 if (!res)
77 {
78 ERR("WL: Failed to execute services (error %lu)\n", GetLastError());
79 return FALSE;
80 }
81
82 TRACE("WL: Created new process - %S\n", ServiceString);
83
84 CloseHandle(ProcessInformation.hThread);
85 CloseHandle(ProcessInformation.hProcess);
86
87 TRACE("WL: StartServicesManager() done.\n");
88
89 return TRUE;
90}
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by WinMain().

◆ UpdateTcpIpInformation()

static VOID UpdateTcpIpInformation ( VOID  )
static

Definition at line 173 of file winlogon.c.

174{
175 LONG lError;
176 HKEY hKey = NULL;
177 DWORD dwType, dwSize;
178 PWSTR pszBuffer;
179 WCHAR szBuffer[128] = L"";
180
182 L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
183 0,
185 &hKey);
186 if (lError != ERROR_SUCCESS)
187 {
188 ERR("WL: RegOpenKeyExW(\"HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters\") failed (error %lu)\n", lError);
189 return;
190 }
191
192 /*
193 * Read the "NV Hostname" value and copy it into the "Hostname" value.
194 */
195
196 pszBuffer = szBuffer;
197 dwSize = ARRAYSIZE(szBuffer);
198
199 lError = RegQueryValueExW(hKey,
200 L"NV Hostname",
201 NULL,
202 &dwType,
203 (LPBYTE)pszBuffer,
204 &dwSize);
205 if (((lError == ERROR_INSUFFICIENT_BUFFER) || (lError == ERROR_MORE_DATA)) && (dwType == REG_SZ))
206 {
207 pszBuffer = HeapAlloc(GetProcessHeap(), 0, dwSize);
208 if (pszBuffer)
209 {
210 lError = RegQueryValueExW(hKey,
211 L"NV Hostname",
212 NULL,
213 &dwType,
214 (LPBYTE)pszBuffer,
215 &dwSize);
216 }
217 else
218 {
219 ERR("WL: Could not reallocate memory for pszBuffer\n");
220 goto Quit;
221 }
222 }
223 if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
224 {
225 TRACE("NV Hostname is '%S'.\n", pszBuffer);
226
227 lError = RegSetValueExW(hKey,
228 L"Hostname",
229 0,
230 REG_SZ,
231 (LPBYTE)pszBuffer,
232 dwSize);
233 if (lError != ERROR_SUCCESS)
234 ERR("WL: RegSetValueExW(\"Hostname\") failed (error %lu)\n", lError);
235 }
236
237 /*
238 * Read the "NV Domain" value and copy it into the "Domain" value.
239 */
240
241 // pszBuffer = szBuffer;
242 // dwSize = ARRAYSIZE(szBuffer);
243
244 lError = RegQueryValueExW(hKey,
245 L"NV Domain",
246 NULL,
247 &dwType,
248 (LPBYTE)pszBuffer,
249 &dwSize);
250 if (((lError == ERROR_INSUFFICIENT_BUFFER) || (lError == ERROR_MORE_DATA)) && (dwType == REG_SZ))
251 {
252 if (pszBuffer != szBuffer)
253 {
254 PWSTR pszNewBuffer;
255 pszNewBuffer = HeapReAlloc(GetProcessHeap(), 0, pszBuffer, dwSize);
256 if (pszNewBuffer)
257 {
258 pszBuffer = pszNewBuffer;
259 }
260 else
261 {
262 HeapFree(GetProcessHeap(), 0, pszBuffer);
263 pszBuffer = NULL;
264 }
265 }
266 else
267 {
268 pszBuffer = HeapAlloc(GetProcessHeap(), 0, dwSize);
269 }
270 if (pszBuffer)
271 {
272 lError = RegQueryValueExW(hKey,
273 L"NV Domain",
274 NULL,
275 &dwType,
276 (LPBYTE)pszBuffer,
277 &dwSize);
278 }
279 else
280 {
281 ERR("WL: Could not reallocate memory for pszBuffer\n");
282 goto Quit;
283 }
284 }
285 if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
286 {
287 TRACE("NV Domain is '%S'.\n", pszBuffer);
288
289 lError = RegSetValueExW(hKey,
290 L"Domain",
291 0,
292 REG_SZ,
293 (LPBYTE)pszBuffer,
294 dwSize);
295 if (lError != ERROR_SUCCESS)
296 ERR("WL: RegSetValueExW(\"Domain\") failed (error %lu)\n", lError);
297 }
298
299 if (pszBuffer != szBuffer)
300 HeapFree(GetProcessHeap(), 0, pszBuffer);
301
302Quit:
304}
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_SET_VALUE
Definition: nt_native.h:1020
long LONG
Definition: pedump.c:60
uint16_t * PWSTR
Definition: typedefs.h:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by WinMain().

◆ WaitForLsass()

static VOID WaitForLsass ( VOID  )
static

Definition at line 136 of file winlogon.c.

137{
139 DWORD dwError;
140
142 TRUE,
143 FALSE,
144 L"LSA_RPC_SERVER_ACTIVE");
145 if (hEvent == NULL)
146 {
147 dwError = GetLastError();
148 TRACE("WL: Failed to create the notification event (Error %lu)\n", dwError);
149
150 if (dwError == ERROR_ALREADY_EXISTS)
151 {
153 FALSE,
154 L"LSA_RPC_SERVER_ACTIVE");
155 if (hEvent == NULL)
156 {
157 ERR("WL: Could not open the notification event (Error %lu)\n", GetLastError());
158 return;
159 }
160 }
161 }
162
163 TRACE("WL: Wait for the LSA server!\n");
165 TRACE("WL: LSA server running!\n");
166
168}
#define INFINITE
Definition: serial.h:102
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
static HANDLE hEvent
Definition: comm.c:54
#define SYNCHRONIZE
Definition: nt_native.h:61
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( IN HINSTANCE  hInstance,
IN HINSTANCE  hPrevInstance,
IN LPSTR  lpCmdLine,
IN int  nShowCmd 
)

Definition at line 453 of file winlogon.c.

458{
459#if 0
460 LSA_STRING ProcessName, PackageName;
463 BOOLEAN Old;
466#endif
467 ULONG HardErrorResponse;
468 MSG Msg;
469
470 UNREFERENCED_PARAMETER(hPrevInstance);
471 UNREFERENCED_PARAMETER(lpCmdLine);
472 UNREFERENCED_PARAMETER(nShowCmd);
473
475
476 /* Make us critical */
479
480 /* Update the cached TCP/IP Information in the registry */
482
484 {
485 ERR("WL: Could not register logon process\n");
487 ExitProcess(1);
488 }
489
491 if (!WLSession)
492 {
493 ERR("WL: Could not allocate memory for winlogon instance\n");
495 ExitProcess(1);
496 }
497
499 WLSession->DialogTimeout = 120; /* 2 minutes */
500
501 /* Initialize the dialog tracking list */
503
505 {
506 ERR("WL: Could not create window station and desktops\n");
508 ExitProcess(1);
509 }
510
512
513 /* Load default keyboard layouts */
514 if (!InitKeyboardLayouts())
515 {
516 ERR("WL: Could not preload keyboard layouts\n");
518 ExitProcess(1);
519 }
520
521 if (!StartRpcServer())
522 {
523 ERR("WL: Could not start the RPC server\n");
525 ExitProcess(1);
526 }
527
529 {
530 ERR("WL: Could not start services.exe\n");
532 ExitProcess(1);
533 }
534
535 if (!StartLsass())
536 {
537 ERR("WL: Failed to start lsass.exe service (error %lu)\n", GetLastError());
539 ExitProcess(1);
540 }
541
542 /* Wait for the LSA server */
543 WaitForLsass();
544
545 /* Init Notifications */
547
548 /* Load and initialize gina */
549 if (!GinaInit(WLSession))
550 {
551 ERR("WL: Failed to initialize Gina\n");
552 // FIXME: Retrieve the real name of the GINA DLL we were trying to load.
553 // It is known only inside the GinaInit function...
556 ExitProcess(1);
557 }
558
560
561#if 0
562 /* Connect to NetLogon service (lsass.exe) */
563 /* Real winlogon uses "Winlogon" */
564 RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon");
565 Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
567 {
568 /* Add the 'SeTcbPrivilege' privilege and try again */
570 if (!NT_SUCCESS(Status))
571 {
572 ERR("RtlAdjustPrivilege() failed with error %lu\n", LsaNtStatusToWinError(Status));
573 return 1;
574 }
575
576 Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
577 }
578
579 if (!NT_SUCCESS(Status))
580 {
581 ERR("LsaRegisterLogonProcess() failed with error %lu\n", LsaNtStatusToWinError(Status));
582 return 1;
583 }
584
587 if (!NT_SUCCESS(Status))
588 {
589 ERR("LsaLookupAuthenticationPackage() failed with error %lu\n", LsaNtStatusToWinError(Status));
591 return 1;
592 }
593#endif
594
596
597 /* Create a hidden window to get SAS notifications */
599 {
600 ERR("WL: Failed to initialize SAS\n");
601 ExitProcess(2);
602 }
603
604 // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_PREPARENETWORKCONNECTIONS);
605 // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGCOMPUTERSETTINGS);
606
607 /* Display logged out screen */
610
611 /* Check for pending setup */
612 if (GetSetupType() != 0)
613 {
614 /* Run setup and reboot when done */
615 TRACE("WL: Setup mode detected\n");
616 RunSetup();
617 }
618 else
619 {
621 }
622
623 /* Tell kernel that CurrentControlSet is good (needed
624 * to support Last good known configuration boot) */
626
627 /* Message loop for the SAS window */
628 while (GetMessageW(&Msg, WLSession->SASWindow, 0, 0))
629 {
632 }
633
635
636 /* We never go there */
637 // TODO: Shutdown if we are in session 0, otherwise let the process terminate.
639 return 0;
640}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
DWORD StartRpcServer(VOID)
Definition: rpcserver.c:32
HANDLE LsaHandle
Definition: wkssvc.c:41
BOOL InitNotifications(VOID)
Definition: notify.c:420
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:530
VOID CleanupNotifications(VOID)
Definition: notify.c:593
#define IDD_GINALOADFAILED
Definition: resource.h:14
#define IDS_REACTOSISSTARTINGUP
Definition: resource.h:37
DWORD GetSetupType(VOID)
Definition: setup.c:16
BOOL RunSetup(VOID)
Definition: setup.c:153
HINSTANCE hInstance
Definition: charmap.c:19
struct @1779 Msg[]
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG AuthenticationPackage
Definition: logon.c:18
ULONG WINAPI LsaNtStatusToWinError(IN NTSTATUS Status)
Definition: lsa.c:1131
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1489
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:551
_In_ ULONG Mode
Definition: hubbusif.h:303
LONG_PTR LPARAM
Definition: minwindef.h:175
#define SE_TCB_PRIVILEGE
Definition: security.c:661
#define CM_BOOT_FLAG_ACCEPTED
Definition: cmtypes.h:160
@ OptionOk
Definition: extypes.h:187
NTSYSAPI NTSTATUS __cdecl RtlSetThreadIsCritical(_In_ BOOLEAN NewValue, _Out_opt_ PBOOLEAN OldValue, _In_ BOOLEAN NeedBreaks)
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSYSAPI NTSTATUS __cdecl RtlSetProcessIsCritical(_In_ BOOLEAN NewValue, _Out_opt_ PBOOLEAN OldValue, _In_ BOOLEAN NeedBreaks)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtInitializeRegistry(IN USHORT Flag)
Definition: ntapi.c:1318
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define MICROSOFT_KERBEROS_NAME_W
Definition: ntsecapi.h:25
NTSTATUS NTAPI LsaLookupAuthenticationPackage(HANDLE, PLSA_STRING, PULONG)
ULONG LSA_OPERATIONAL_MODE
Definition: ntsecapi.h:367
NTSTATUS NTAPI LsaDeregisterLogonProcess(HANDLE)
NTSTATUS NTAPI LsaRegisterLogonProcess(PLSA_STRING, PHANDLE, PLSA_OPERATIONAL_MODE)
#define STATUS_PORT_CONNECTION_REFUSED
Definition: ntstatus.h:395
#define STATUS_SYSTEM_PROCESS_TERMINATED
Definition: ntstatus.h:792
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
NTSTATUS HandleShutdown(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1149
BOOL InitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:1740
DWORD DialogTimeout
Definition: winlogon.h:240
HDESK WinlogonDesktop
Definition: winlogon.h:234
LOGON_STATE LogonState
Definition: winlogon.h:239
HWND SASWindow
Definition: winlogon.h:228
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:373
static BOOL InitKeyboardLayouts(VOID)
Definition: winlogon.c:309
static BOOL StartLsass(VOID)
Definition: winlogon.c:95
static INT_PTR CALLBACK GinaLoadFailedWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: winlogon.c:407
static BOOL StartServicesManager(VOID)
Definition: winlogon.c:47
PWLSESSION WLSession
Definition: winlogon.c:20
static VOID UpdateTcpIpInformation(VOID)
Definition: winlogon.c:173
BOOL RemoveStatusMessage(IN PWLSESSION Session)
Definition: winlogon.c:394
static VOID WaitForLsass(VOID)
Definition: winlogon.c:136
#define LockWorkstation(Session)
Definition: winlogon.h:217
BOOL GinaInit(IN OUT PWLSESSION Session)
Definition: wlx.c:930
struct _WLSESSION * PWLSESSION
VOID InitDialogListHead(VOID)
Definition: wlx.c:31
struct _WLSESSION WLSESSION
@ STATE_INIT
Definition: winlogon.h:204
BOOL CreateWindowStationAndDesktops(_Inout_ PWLSESSION Session)
Definition: wlx.c:953
@ StartupHandler
Definition: winlogon.h:268
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DialogBoxParam
Definition: winuser.h:5875
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
BOOL WINAPI RegisterLogonProcess(DWORD, BOOL)
Definition: logon.c:43
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
#define WLX_WM_SAS
Definition: winwlx.h:71
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63

◆ WlStrDup()

PWSTR WlStrDup ( _In_opt_ PCWSTR  String)

Duplicates the given string, allocating a buffer on the heap.

Definition at line 29 of file winlogon.c.

31{
32 PWSTR ptr;
33
34 if (!String)
35 return NULL;
36
37 ptr = RtlAllocateHeap(RtlGetProcessHeap(), 0,
38 (wcslen(String) + 1) * sizeof(WCHAR));
39 if (ptr)
41 return ptr;
42}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
static PVOID ptr
Definition: dispmode.c:27
wcscpy
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439

Referenced by AddNotificationDll(), AddSfcNotification(), and HandleLogon().

Variable Documentation

◆ hAppInstance

HINSTANCE hAppInstance

Definition at line 19 of file winlogon.c.

Referenced by DisplayStatusMessage(), and WinMain().

◆ WLSession

PWLSESSION WLSession = NULL

Definition at line 20 of file winlogon.c.

Referenced by DefaultWlxScreenSaverNotify(), RunSetupThreadProc(), and WinMain().