ReactOS 0.4.17-dev-251-gcbc75d1
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 353 of file winlogon.c.

357{
358 WCHAR StatusMsg[MAX_PATH];
359
360 if (Session->Gina.Version < WLX_VERSION_1_3)
361 return TRUE;
362
363 if (Session->SuppressStatus)
364 return TRUE;
365
366 if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
367 return FALSE;
368
369 return Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, hDesktop, 0, NULL, StatusMsg);
370}
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
short WCHAR
Definition: pedump.c:58
#define LoadStringW
Definition: utils.h:64
HINSTANCE hAppInstance
Definition: winlogon.c:19
#define WLX_VERSION_1_3
Definition: winwlx.h:31

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 387 of file winlogon.c.

392{
393 switch (uMsg)
394 {
395 case WM_COMMAND:
396 {
397 switch (LOWORD(wParam))
398 {
399 case IDOK:
400 EndDialog(hwndDlg, IDOK);
401 return TRUE;
402 }
403 break;
404 }
405
406 case WM_INITDIALOG:
407 {
408 int len;
409 WCHAR templateText[MAX_PATH], text[MAX_PATH];
410
411 len = GetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, templateText, MAX_PATH);
412 if (len)
413 {
414 wsprintfW(text, templateText, (LPWSTR)lParam);
416 }
417 return TRUE;
418 }
419
420 case WM_CLOSE:
421 {
422 EndDialog(hwndDlg, IDCANCEL);
423 return TRUE;
424 }
425 }
426
427 return FALSE;
428}
#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
uint16_t * LPWSTR
Definition: typedefs.h:56
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)

Referenced by WinMain().

◆ InitKeyboardLayouts()

static BOOL InitKeyboardLayouts ( VOID  )
static

Definition at line 289 of file winlogon.c.

290{
291 WCHAR wszKeyName[12], wszKLID[10];
292 DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
293 HKEY hKey;
294 UINT Flags;
295 BOOL bRet = FALSE;
296
297 /* Open registry key with preloaded layouts */
298 if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
299 {
300 while (TRUE)
301 {
302 /* Read values with integer names only */
303 _swprintf(wszKeyName, L"%d", i++);
304 if (RegQueryValueExW(hKey, wszKeyName, NULL, &dwType, (LPBYTE)wszKLID, &dwSize) != ERROR_SUCCESS)
305 {
306 /* There is no more entries */
307 break;
308 }
309
310 /* Only REG_SZ values are valid */
311 if (dwType != REG_SZ)
312 {
313 ERR("Wrong type: %ws!\n", wszKLID);
314 continue;
315 }
316
317 /* Load keyboard layout with given locale id */
319 if (i > 1)
321 else // First layout
322 Flags |= KLF_ACTIVATE; // |0x40000000
323 if (!LoadKeyboardLayoutW(wszKLID, Flags))
324 {
325 ERR("LoadKeyboardLayoutW(%ws) failed!\n", wszKLID);
326 continue;
327 }
328 else
329 {
330 /* We loaded at least one layout - success */
331 bRet = TRUE;
332 }
333 }
334
335 /* Close the key now */
337 }
338 else
339 WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
340
341 if (!bRet)
342 {
343 /* If we failed, load US keyboard layout */
345 bRet = TRUE;
346 }
347
348 return bRet;
349}
#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 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
#define _swprintf(buf, format,...)
Definition: sprintf.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 374 of file winlogon.c.

376{
377 if (Session->Gina.Version < WLX_VERSION_1_3)
378 return TRUE;
379
380 return Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
381}

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

◆ StartLsass()

static BOOL StartLsass ( VOID  )
static

Definition at line 85 of file winlogon.c.

86{
87 STARTUPINFOW StartupInfo = { sizeof(StartupInfo) };
88 PROCESS_INFORMATION ProcessInformation;
89 LPCWSTR ServiceString = L"lsass.exe";
90 BOOL res;
91
92 /* Start the local security authority subsystem (lsass.exe) */
93 TRACE("WL: Creating new process - %S\n", ServiceString);
94 res = CreateProcessW(ServiceString,
95 NULL,
96 NULL,
97 NULL,
98 FALSE,
100 NULL,
101 NULL,
102 &StartupInfo,
103 &ProcessInformation);
104
105 TRACE("WL: Created new process - %S\n", ServiceString);
106
107 CloseHandle(ProcessInformation.hThread);
108 CloseHandle(ProcessInformation.hProcess);
109
110 return res;
111}
#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:4441
GLuint res
Definition: glext.h:9613
#define TRACE(s)
Definition: solgame.cpp:4
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define DETACHED_PROCESS
Definition: winbase.h:183

Referenced by WinMain().

◆ StartServicesManager()

static BOOL StartServicesManager ( VOID  )
static

Definition at line 47 of file winlogon.c.

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

Referenced by WinMain().

◆ UpdateTcpIpInformation()

static VOID UpdateTcpIpInformation ( VOID  )
static

Definition at line 153 of file winlogon.c.

154{
155 LONG lError;
156 HKEY hKey = NULL;
157 DWORD dwType, dwSize;
158 PWSTR pszBuffer;
159 WCHAR szBuffer[128] = L"";
160
162 L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
163 0,
165 &hKey);
166 if (lError != ERROR_SUCCESS)
167 {
168 ERR("WL: RegOpenKeyExW(\"HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters\") failed (error %lu)\n", lError);
169 return;
170 }
171
172 /*
173 * Read the "NV Hostname" value and copy it into the "Hostname" value.
174 */
175
176 pszBuffer = szBuffer;
177 dwSize = ARRAYSIZE(szBuffer);
178
179 lError = RegQueryValueExW(hKey,
180 L"NV Hostname",
181 NULL,
182 &dwType,
183 (LPBYTE)pszBuffer,
184 &dwSize);
185 if (((lError == ERROR_INSUFFICIENT_BUFFER) || (lError == ERROR_MORE_DATA)) && (dwType == REG_SZ))
186 {
187 pszBuffer = HeapAlloc(GetProcessHeap(), 0, dwSize);
188 if (pszBuffer)
189 {
190 lError = RegQueryValueExW(hKey,
191 L"NV Hostname",
192 NULL,
193 &dwType,
194 (LPBYTE)pszBuffer,
195 &dwSize);
196 }
197 else
198 {
199 ERR("WL: Could not reallocate memory for pszBuffer\n");
200 goto Quit;
201 }
202 }
203 if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
204 {
205 TRACE("NV Hostname is '%S'.\n", pszBuffer);
206
207 lError = RegSetValueExW(hKey,
208 L"Hostname",
209 0,
210 REG_SZ,
211 (LPBYTE)pszBuffer,
212 dwSize);
213 if (lError != ERROR_SUCCESS)
214 ERR("WL: RegSetValueExW(\"Hostname\") failed (error %lu)\n", lError);
215 }
216
217 /*
218 * Read the "NV Domain" value and copy it into the "Domain" value.
219 */
220
221 // pszBuffer = szBuffer;
222 // dwSize = ARRAYSIZE(szBuffer);
223
224 lError = RegQueryValueExW(hKey,
225 L"NV Domain",
226 NULL,
227 &dwType,
228 (LPBYTE)pszBuffer,
229 &dwSize);
230 if (((lError == ERROR_INSUFFICIENT_BUFFER) || (lError == ERROR_MORE_DATA)) && (dwType == REG_SZ))
231 {
232 if (pszBuffer != szBuffer)
233 {
234 PWSTR pszNewBuffer;
235 pszNewBuffer = HeapReAlloc(GetProcessHeap(), 0, pszBuffer, dwSize);
236 if (pszNewBuffer)
237 {
238 pszBuffer = pszNewBuffer;
239 }
240 else
241 {
242 HeapFree(GetProcessHeap(), 0, pszBuffer);
243 pszBuffer = NULL;
244 }
245 }
246 else
247 {
248 pszBuffer = HeapAlloc(GetProcessHeap(), 0, dwSize);
249 }
250 if (pszBuffer)
251 {
252 lError = RegQueryValueExW(hKey,
253 L"NV Domain",
254 NULL,
255 &dwType,
256 (LPBYTE)pszBuffer,
257 &dwSize);
258 }
259 else
260 {
261 ERR("WL: Could not reallocate memory for pszBuffer\n");
262 goto Quit;
263 }
264 }
265 if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
266 {
267 TRACE("NV Domain is '%S'.\n", pszBuffer);
268
269 lError = RegSetValueExW(hKey,
270 L"Domain",
271 0,
272 REG_SZ,
273 (LPBYTE)pszBuffer,
274 dwSize);
275 if (lError != ERROR_SUCCESS)
276 ERR("WL: RegSetValueExW(\"Domain\") failed (error %lu)\n", lError);
277 }
278
279 if (pszBuffer != szBuffer)
280 HeapFree(GetProcessHeap(), 0, pszBuffer);
281
282Quit:
284}
#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 116 of file winlogon.c.

117{
119 DWORD dwError;
120
122 TRUE,
123 FALSE,
124 L"LSA_RPC_SERVER_ACTIVE");
125 if (hEvent == NULL)
126 {
127 dwError = GetLastError();
128 TRACE("WL: Failed to create the notification event (Error %lu)\n", dwError);
129
130 if (dwError == ERROR_ALREADY_EXISTS)
131 {
133 FALSE,
134 L"LSA_RPC_SERVER_ACTIVE");
135 if (hEvent == NULL)
136 {
137 ERR("WL: Could not open the notification event (Error %lu)\n", GetLastError());
138 return;
139 }
140 }
141 }
142
143 TRACE("WL: Wait for the LSA server!\n");
145 TRACE("WL: LSA server running!\n");
146
148}
#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:618
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:587

Referenced by WinMain().

◆ WinMain()

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

Definition at line 433 of file winlogon.c.

438{
439#if 0
440 LSA_STRING ProcessName, PackageName;
443 BOOLEAN Old;
446#endif
447 ULONG HardErrorResponse;
448 MSG Msg;
449
450 UNREFERENCED_PARAMETER(hPrevInstance);
451 UNREFERENCED_PARAMETER(lpCmdLine);
452 UNREFERENCED_PARAMETER(nShowCmd);
453
455
456 /* Make us critical */
459
460 /* Update the cached TCP/IP Information in the registry */
462
464 {
465 ERR("WL: Could not register logon process\n");
467 ExitProcess(1);
468 }
469
471 if (!WLSession)
472 {
473 ERR("WL: Could not allocate memory for winlogon instance\n");
475 ExitProcess(1);
476 }
477
479 WLSession->DialogTimeout = 120; /* 2 minutes */
480
481 /* Initialize the dialog tracking list */
483
485 {
486 ERR("WL: Could not create window station and desktops\n");
488 ExitProcess(1);
489 }
490
492
493 /* Load default keyboard layouts */
494 if (!InitKeyboardLayouts())
495 {
496 ERR("WL: Could not preload keyboard layouts\n");
498 ExitProcess(1);
499 }
500
501 if (!StartRpcServer())
502 {
503 ERR("WL: Could not start the RPC server\n");
505 ExitProcess(1);
506 }
507
509 {
510 ERR("WL: Could not start services.exe\n");
512 ExitProcess(1);
513 }
514
515 if (!StartLsass())
516 {
517 ERR("WL: Failed to start lsass.exe service (error %lu)\n", GetLastError());
519 ExitProcess(1);
520 }
521
522 /* Wait for the LSA server */
523 WaitForLsass();
524
525 /* Init Notifications */
527
528 /* Load and initialize gina */
529 if (!GinaInit(WLSession))
530 {
531 ERR("WL: Failed to initialize Gina\n");
532 // FIXME: Retrieve the real name of the GINA DLL we were trying to load.
533 // It is known only inside the GinaInit function...
536 ExitProcess(1);
537 }
538
540
541#if 0
542 /* Connect to NetLogon service (lsass.exe) */
543 /* Real winlogon uses "Winlogon" */
544 RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon");
545 Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
547 {
548 /* Add the 'SeTcbPrivilege' privilege and try again */
550 if (!NT_SUCCESS(Status))
551 {
552 ERR("RtlAdjustPrivilege() failed with error %lu\n", LsaNtStatusToWinError(Status));
553 return 1;
554 }
555
556 Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
557 }
558
559 if (!NT_SUCCESS(Status))
560 {
561 ERR("LsaRegisterLogonProcess() failed with error %lu\n", LsaNtStatusToWinError(Status));
562 return 1;
563 }
564
567 if (!NT_SUCCESS(Status))
568 {
569 ERR("LsaLookupAuthenticationPackage() failed with error %lu\n", LsaNtStatusToWinError(Status));
571 return 1;
572 }
573#endif
574
576
577 /* Create a hidden window to get SAS notifications */
579 {
580 ERR("WL: Failed to initialize SAS\n");
581 ExitProcess(2);
582 }
583
584 // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_PREPARENETWORKCONNECTIONS);
585 // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGCOMPUTERSETTINGS);
586
587 /* Display logged out screen */
590
591 /* Check for pending setup */
592 if (GetSetupType() != 0)
593 {
594 /* Run setup and reboot when done */
595 TRACE("WL: Setup mode detected\n");
596 RunSetup();
597 }
598 else
599 {
601 }
602
603 /* Tell kernel that CurrentControlSet is good (needed
604 * to support Last good known configuration boot) */
606
607 /* Message loop for the SAS window */
608 while (GetMessageW(&Msg, WLSession->SASWindow, 0, 0))
609 {
612 }
613
615
616 /* We never go there */
617 // TODO: Shutdown if we are in session 0, otherwise let the process terminate.
619 return 0;
620}
unsigned char BOOLEAN
Definition: actypes.h:127
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:417
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:573
VOID CleanupNotifications(VOID)
Definition: notify.c:635
#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 @1772 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:1330
Status
Definition: gdiplustypes.h:24
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
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
#define SE_TCB_PRIVILEGE
Definition: security.c:561
#define CM_BOOT_FLAG_ACCEPTED
Definition: cmtypes.h:174
@ 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 STATUS_PORT_CONNECTION_REFUSED
Definition: ntstatus.h:395
#define STATUS_SYSTEM_PROCESS_TERMINATED
Definition: ntstatus.h:792
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#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)
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:738
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:1155
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:353
static BOOL InitKeyboardLayouts(VOID)
Definition: winlogon.c:289
static BOOL StartLsass(VOID)
Definition: winlogon.c:85
static INT_PTR CALLBACK GinaLoadFailedWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: winlogon.c:387
static BOOL StartServicesManager(VOID)
Definition: winlogon.c:47
PWLSESSION WLSession
Definition: winlogon.c:20
static VOID UpdateTcpIpInformation(VOID)
Definition: winlogon.c:153
BOOL RemoveStatusMessage(IN PWLSESSION Session)
Definition: winlogon.c:374
static VOID WaitForLsass(VOID)
Definition: winlogon.c:116
#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:5930
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().