ReactOS 0.4.16-dev-1946-g52006dd
notify.c File Reference
#include "winlogon.h"
Include dependency graph for notify.c:

Go to the source code of this file.

Classes

struct  _NOTIFICATION_ITEM
 

Typedefs

typedef VOID(WINAPIPWLX_NOTIFY_HANDLER) (PWLX_NOTIFICATION_INFO pInfo)
 
typedef struct _NOTIFICATION_ITEM NOTIFICATION_ITEM
 
typedef struct _NOTIFICATION_ITEMPNOTIFICATION_ITEM
 

Functions

static PWLX_NOTIFY_HANDLER GetNotificationHandler (_In_ HKEY hDllKey, _In_ HMODULE hModule, _In_ PCSTR pNotification)
 Retrieves the address of the exported notification handler, specified in the registry entry for the notification DLL.
 
static BOOL LoadNotifyDll (_Inout_ PNOTIFICATION_ITEM NotificationDll)
 Loads the notification DLL and retrieves its exported notification handlers.
 
static VOID DeleteNotification (_In_ PNOTIFICATION_ITEM Notification)
 Frees the resources associated to a notification.
 
static VOID AddSfcNotification (VOID)
 Initializes the internal SFC notifications.
 
static VOID AddNotificationDll (_In_ HKEY hNotifyKey, _In_ PCWSTR pszKeyName)
 
BOOL InitNotifications (VOID)
 
static VOID CallNotificationDll (_In_ PNOTIFICATION_ITEM NotificationDll, _In_ NOTIFICATION_TYPE Type, _In_ PWLX_NOTIFICATION_INFO pInfo)
 
VOID CallNotificationDlls (PWLSESSION pSession, NOTIFICATION_TYPE Type)
 
VOID CleanupNotifications (VOID)
 

Variables

static PSTR FuncNames [LastHandler]
 
static LIST_ENTRY NotificationDllListHead
 

Typedef Documentation

◆ NOTIFICATION_ITEM

◆ PNOTIFICATION_ITEM

◆ PWLX_NOTIFY_HANDLER

typedef VOID(WINAPI * PWLX_NOTIFY_HANDLER) (PWLX_NOTIFICATION_INFO pInfo)

Definition at line 15 of file notify.c.

Function Documentation

◆ AddNotificationDll()

static VOID AddNotificationDll ( _In_ HKEY  hNotifyKey,
_In_ PCWSTR  pszKeyName 
)
static

Definition at line 235 of file notify.c.

238{
239 HKEY hDllKey = NULL;
240 PNOTIFICATION_ITEM NotificationDll;
242 DWORD dwValue, dwSize, dwType;
243 LONG lError;
244
245 TRACE("AddNotificationDll(0x%p, %S)\n", hNotifyKey, pszKeyName);
246
247 lError = RegOpenKeyExW(hNotifyKey,
248 pszKeyName,
249 0,
250 KEY_READ,
251 &hDllKey);
252 if (lError != ERROR_SUCCESS)
253 return;
254
255 /* In safe-boot mode, load the notification DLL only if it is enabled there */
256 if (GetSystemMetrics(SM_CLEANBOOT) != 0) // TODO: Cache when Winlogon starts
257 {
258 BOOL bSafeMode = FALSE; // Default to NOT loading the DLL in SafeMode.
259
260 dwSize = sizeof(dwValue);
261 lError = RegQueryValueExW(hDllKey,
262 L"SafeMode",
263 NULL,
264 &dwType,
265 (PBYTE)&dwValue,
266 &dwSize);
267 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
268 bSafeMode = !!dwValue;
269
270 /* Bail out if the DLL should not be loaded in safe-boot mode.
271 * NOTE: On Win2000 and later, the value is always overridden
272 * to TRUE, and the DLL is loaded unconditionally. This defeats
273 * the whole purpose of this feature... In ReactOS we restore it! */
274 if (!bSafeMode)
275 {
276 RegCloseKey(hDllKey);
277 return;
278 }
279 }
280
281 NotificationDll = RtlAllocateHeap(RtlGetProcessHeap(),
283 sizeof(*NotificationDll));
284 if (!NotificationDll)
285 {
286 lError = ERROR_OUTOFMEMORY;
287 goto done;
288 }
289
290 NotificationDll->pszKeyName = WlStrDup(pszKeyName);
291 if (NotificationDll->pszKeyName == NULL)
292 {
293 lError = ERROR_OUTOFMEMORY;
294 goto done;
295 }
296
297 dwSize = 0;
298 lError = RegQueryValueExW(hDllKey,
299 L"DllName",
300 NULL,
301 &dwType,
302 NULL,
303 &dwSize);
304 if ((lError != ERROR_SUCCESS) ||
305 (dwType != REG_SZ && dwType != REG_EXPAND_SZ) ||
306 (dwSize == 0) || (dwSize % sizeof(WCHAR)))
307 {
308 lError = ERROR_FILE_NOT_FOUND;
309 goto done;
310 }
311 /* Ensure the string can be NUL-terminated */
312 dwSize += sizeof(WCHAR);
313
314 pszDllName = RtlAllocateHeap(RtlGetProcessHeap(), 0, dwSize);
315 if (!pszDllName)
316 {
317 lError = ERROR_OUTOFMEMORY;
318 goto done;
319 }
320
321 lError = RegQueryValueExW(hDllKey,
322 L"DllName",
323 NULL,
324 &dwType,
326 &dwSize);
327 if (lError != ERROR_SUCCESS)
328 {
329 RtlFreeHeap(RtlGetProcessHeap(), 0, pszDllName);
330 goto done;
331 }
332 /* NUL-terminate */
333 pszDllName[dwSize / sizeof(WCHAR) - 1] = UNICODE_NULL;
334
335 /* Expand the path if applicable. Note that Windows always does the
336 * expansion, independently of the REG_SZ or REG_EXPAND_SZ type. */
337 if (wcschr(pszDllName, L'%') != NULL)
338 {
340 if (dwSize)
341 {
342 PWSTR pszDllPath = RtlAllocateHeap(RtlGetProcessHeap(), 0,
343 dwSize * sizeof(WCHAR));
344 if (!pszDllPath)
345 {
346 RtlFreeHeap(RtlGetProcessHeap(), 0, pszDllName);
347 lError = ERROR_OUTOFMEMORY;
348 goto done;
349 }
351
352 /* Free the old buffer and replace it with the expanded path */
353 RtlFreeHeap(RtlGetProcessHeap(), 0, pszDllName);
354 pszDllName = pszDllPath;
355 }
356 }
357
358 NotificationDll->pszDllName = pszDllName;
359
360 NotificationDll->bEnabled = TRUE;
361 NotificationDll->dwMaxWait = 30; /* FIXME: ??? */
362
363 dwSize = sizeof(dwValue);
364 lError = RegQueryValueExW(hDllKey,
365 L"Asynchronous",
366 NULL,
367 &dwType,
368 (PBYTE)&dwValue,
369 &dwSize);
370 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
371 NotificationDll->bAsynchronous = !!dwValue;
372
373 dwSize = sizeof(dwValue);
374 lError = RegQueryValueExW(hDllKey,
375 L"Impersonate",
376 NULL,
377 &dwType,
378 (PBYTE)&dwValue,
379 &dwSize);
380 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
381 NotificationDll->bImpersonate = !!dwValue;
382
383 dwSize = sizeof(dwValue);
384 lError = RegQueryValueExW(hDllKey,
385 L"SmartCardLogonNotify",
386 NULL,
387 &dwType,
388 (PBYTE)&dwValue,
389 &dwSize);
390 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
391 NotificationDll->bSmartCardLogon = !!dwValue;
392
393 dwSize = sizeof(dwValue);
394 lError = RegQueryValueExW(hDllKey,
395 L"MaxWait",
396 NULL,
397 &dwType,
398 (PBYTE)&dwValue,
399 &dwSize);
400 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
401 NotificationDll->dwMaxWait = dwValue;
402
404 &NotificationDll->ListEntry);
405
406 lError = ERROR_SUCCESS;
407
408done:
409 if (lError != ERROR_SUCCESS)
410 {
411 if (NotificationDll)
412 DeleteNotification(NotificationDll);
413 }
414
415 RegCloseKey(hDllKey);
416}
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:49
static VOID DeleteNotification(_In_ PNOTIFICATION_ITEM Notification)
Frees the resources associated to a notification.
Definition: notify.c:155
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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 wcschr
Definition: compat.h:17
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define L(x)
Definition: resources.c:13
#define InsertHeadList(ListHead, Entry)
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1026
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define UNICODE_NULL
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:615
#define TRACE(s)
Definition: solgame.cpp:4
char * pszDllName
Definition: spec2def.c:74
DWORD dwMaxWait
Definition: notify.c:43
LIST_ENTRY ListEntry
Definition: notify.c:35
PWSTR pszKeyName
Definition: notify.c:37
PWSTR pszDllName
Definition: notify.c:38
BOOL bAsynchronous
Definition: notify.c:40
BOOL bImpersonate
Definition: notify.c:41
BOOL bSmartCardLogon
Definition: notify.c:42
uint16_t * PWSTR
Definition: typedefs.h:56
PWSTR WlStrDup(_In_opt_ PCWSTR String)
Duplicates the given string, allocating a buffer on the heap.
Definition: winlogon.c:29
#define SM_CLEANBOOT
Definition: winuser.h:1038
int WINAPI GetSystemMetrics(_In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by InitNotifications().

◆ AddSfcNotification()

static VOID AddSfcNotification ( VOID  )
static

Initializes the internal SFC notifications.

Definition at line 176 of file notify.c.

177{
178 PNOTIFICATION_ITEM NotificationDll;
180 DWORD dwError;
181 WCHAR szSfcPath[MAX_PATH];
182
183 ExpandEnvironmentStringsW(L"%SystemRoot%\\system32\\sfc.dll",
184 szSfcPath,
185 ARRAYSIZE(szSfcPath));
186
187 NotificationDll = RtlAllocateHeap(RtlGetProcessHeap(),
189 sizeof(*NotificationDll));
190 if (!NotificationDll)
191 return; // If needed: dwError = ERROR_OUTOFMEMORY;
192
193 NotificationDll->pszDllName = WlStrDup(szSfcPath);
194 if (NotificationDll->pszDllName == NULL)
195 {
196 dwError = ERROR_OUTOFMEMORY;
197 goto done;
198 }
199
200 NotificationDll->bEnabled = TRUE;
201 NotificationDll->dwMaxWait = 30; /* FIXME: ??? */
202 NotificationDll->bSfcNotification = TRUE;
203
204 /* Load sfc.dll, and also sfc_os.dll on systems where it forwards to */
205 hModule = LoadLibraryW(szSfcPath);
206 if (!hModule)
207 {
208 dwError = GetLastError();
209 ERR("LoadLibraryW(%S) failed, Error %lu\n", szSfcPath, dwError);
210 goto done;
211 }
212 NotificationDll->hModule = hModule;
213
214 NotificationDll->Handler[LogonHandler] = (PWLX_NOTIFY_HANDLER)GetProcAddress(hModule, "SfcWLEventLogon");
215 NotificationDll->Handler[LogoffHandler] = (PWLX_NOTIFY_HANDLER)GetProcAddress(hModule, "SfcWLEventLogoff");
216 if (!NotificationDll->Handler[LogonHandler] || !NotificationDll->Handler[LogoffHandler])
217 {
218 dwError = ERROR_PROC_NOT_FOUND;
219 ERR("Couldn't snap SfcWLEventLogon/SfcWLEventLogoff\n");
220 goto done;
221 }
222
224 &NotificationDll->ListEntry);
225
226 dwError = ERROR_SUCCESS;
227
228done:
229 if (dwError != ERROR_SUCCESS)
230 DeleteNotification(NotificationDll);
231}
#define ERR(fmt,...)
Definition: precomp.h:57
VOID(WINAPI * PWLX_NOTIFY_HANDLER)(PWLX_NOTIFICATION_INFO pInfo)
Definition: notify.c:15
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
HMODULE hModule
Definition: netsh.c:17
PWLX_NOTIFY_HANDLER Handler[LastHandler]
Definition: notify.c:45
HMODULE hModule
Definition: notify.c:36
BOOL bSfcNotification
Definition: notify.c:44
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:321
@ LogonHandler
Definition: winlogon.h:264
@ LogoffHandler
Definition: winlogon.h:265

Referenced by InitNotifications().

◆ CallNotificationDll()

static VOID CallNotificationDll ( _In_ PNOTIFICATION_ITEM  NotificationDll,
_In_ NOTIFICATION_TYPE  Type,
_In_ PWLX_NOTIFICATION_INFO  pInfo 
)
static

Definition at line 473 of file notify.c.

477{
478 PWLX_NOTIFY_HANDLER pNotifyHandler;
480 HANDLE UserToken;
481
482 /* Delay-load the DLL if needed */
483 if (!NotificationDll->hModule)
484 {
485 if (!LoadNotifyDll(NotificationDll))
486 {
487 /* We failed, disable it */
488 NotificationDll->bEnabled = FALSE;
489 return;
490 }
491 ASSERT(NotificationDll->hModule);
492 }
493
494 /* Retrieve the notification handler; bail out if none is specified */
495 pNotifyHandler = NotificationDll->Handler[Type];
496 if (!pNotifyHandler)
497 return;
498
499 /* Capture the notification info structure, since
500 * the notification handler might mess with it */
501 Info = *pInfo;
502
503 /* Impersonate the logged-on user if necessary */
504 UserToken = (NotificationDll->bImpersonate ? Info.hToken : NULL);
505 if (UserToken && !ImpersonateLoggedOnUser(UserToken))
506 {
507 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
508 return;
509 }
510
511 /* Call the notification handler in SEH to prevent any Winlogon crashes */
513 {
514 pNotifyHandler(&Info);
515 }
517 {
518 ERR("WL: Exception 0x%08lx hit by notification DLL %ws while executing %s notify function\n",
519 _SEH2_GetExceptionCode(), NotificationDll->pszDllName, FuncNames[Type]);
520 }
521 _SEH2_END;
522
523 /* Revert impersonation */
524 if (UserToken)
525 RevertToSelf();
526}
Type
Definition: Type.h:7
static PSTR FuncNames[LastHandler]
Definition: notify.c:17
static BOOL LoadNotifyDll(_Inout_ PNOTIFICATION_ITEM NotificationDll)
Loads the notification DLL and retrieves its exported notification handlers.
Definition: notify.c:95
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
BOOL WINAPI RevertToSelf(void)
Definition: security.c:855
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define ASSERT(a)
Definition: mode.c:44
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by CallNotificationDlls().

◆ CallNotificationDlls()

VOID CallNotificationDlls ( PWLSESSION  pSession,
NOTIFICATION_TYPE  Type 
)

Definition at line 530 of file notify.c.

533{
534 PLIST_ENTRY ListEntry;
536
537 /* Check for invalid notification type */
539
540 TRACE("CallNotificationDlls(%s)\n", FuncNames[Type]);
541
542 /* Set up the notification info structure template */
543 Info.Size = sizeof(Info);
544
545 switch (Type)
546 {
547 case LogoffHandler:
548 case ShutdownHandler:
549 Info.Flags = 3;
550 break;
551
552 default:
553 Info.Flags = 0;
554 break;
555 }
556
557 Info.UserName = pSession->UserName;
558 Info.Domain = pSession->Domain;
559 Info.WindowStation = pSession->InteractiveWindowStationName;
560 Info.hToken = pSession->UserToken;
561
562 switch (Type)
563 {
564 case LogonHandler:
566 Info.hDesktop = pSession->ApplicationDesktop;
567 break;
568
570 Info.hDesktop = pSession->ApplicationDesktop;
571 break;
572
573 default:
574 Info.hDesktop = pSession->WinlogonDesktop;
575 break;
576 }
577
578 Info.pStatusCallback = NULL;
579
580 for (ListEntry = NotificationDllListHead.Flink;
581 ListEntry != &NotificationDllListHead;
582 ListEntry = ListEntry->Flink)
583 {
585 CONTAINING_RECORD(ListEntry, NOTIFICATION_ITEM, ListEntry);
586 if (Notification->bEnabled)
588 }
589}
static VOID CallNotificationDll(_In_ PNOTIFICATION_ITEM NotificationDll, _In_ NOTIFICATION_TYPE Type, _In_ PWLX_NOTIFICATION_INFO pInfo)
Definition: notify.c:473
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
HANDLE UserToken
Definition: winlogon.h:237
HDESK WinlogonDesktop
Definition: winlogon.h:234
PWSTR UserName
Definition: winlogon.h:231
PWSTR Domain
Definition: winlogon.h:232
PWSTR InteractiveWindowStationName
Definition: winlogon.h:230
HDESK ApplicationDesktop
Definition: winlogon.h:233
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
@ LastHandler
Definition: winlogon.h:276
@ StartShellHandler
Definition: winlogon.h:274
@ StartScreenSaverHandler
Definition: winlogon.h:270
@ ShutdownHandler
Definition: winlogon.h:269

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

◆ CleanupNotifications()

VOID CleanupNotifications ( VOID  )

Definition at line 593 of file notify.c.

594{
596 {
599 CONTAINING_RECORD(ListEntry, NOTIFICATION_ITEM, ListEntry);
601 }
602}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964

Referenced by WinMain().

◆ DeleteNotification()

static VOID DeleteNotification ( _In_ PNOTIFICATION_ITEM  Notification)
static

Frees the resources associated to a notification.

Definition at line 155 of file notify.c.

157{
158 if (Notification->hModule)
159 FreeLibrary(Notification->hModule);
160
161 if (Notification->pszKeyName)
162 RtlFreeHeap(RtlGetProcessHeap(), 0, Notification->pszKeyName);
163
164 if (Notification->pszDllName)
165 RtlFreeHeap(RtlGetProcessHeap(), 0, Notification->pszDllName);
166
167 RtlFreeHeap(RtlGetProcessHeap(), 0, Notification);
168}
#define FreeLibrary(x)
Definition: compat.h:748

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

◆ GetNotificationHandler()

static PWLX_NOTIFY_HANDLER GetNotificationHandler ( _In_ HKEY  hDllKey,
_In_ HMODULE  hModule,
_In_ PCSTR  pNotification 
)
static

Retrieves the address of the exported notification handler, specified in the registry entry for the notification DLL.

Definition at line 61 of file notify.c.

65{
66 LONG lError;
67 DWORD dwType, dwSize;
68 CHAR szFuncBuffer[128];
69
70 dwSize = sizeof(szFuncBuffer);
71 lError = RegQueryValueExA(hDllKey,
72 pNotification,
73 NULL,
74 &dwType,
75 (PBYTE)szFuncBuffer,
76 &dwSize);
77 if ((lError != ERROR_SUCCESS) ||
78 (dwType != REG_SZ && dwType != REG_EXPAND_SZ) || (dwSize == 0))
79 {
80 return NULL;
81 }
82
83 /* NUL-terminate */
84 szFuncBuffer[dwSize / sizeof(CHAR) - 1] = ANSI_NULL;
85
86 return (PWLX_NOTIFY_HANDLER)GetProcAddress(hModule, szFuncBuffer);
87}
#define CHAR(Char)
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
#define ANSI_NULL
char CHAR
Definition: xmlstorage.h:175

Referenced by LoadNotifyDll().

◆ InitNotifications()

BOOL InitNotifications ( VOID  )

Definition at line 420 of file notify.c.

421{
422 HKEY hNotifyKey = NULL;
423 LONG lError;
424 DWORD dwIndex;
425 DWORD dwKeyName;
426 WCHAR szKeyName[80];
427
428 TRACE("InitNotifications()\n");
429
431
433
435 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
436 0,
437 KEY_READ,
438 &hNotifyKey);
439 if (lError != ERROR_SUCCESS)
440 {
441 TRACE("RegOpenKeyExW()\n");
442 return TRUE;
443 }
444
445 for (dwIndex = 0; ; ++dwIndex)
446 {
447 dwKeyName = ARRAYSIZE(szKeyName);
448 lError = RegEnumKeyExW(hNotifyKey,
449 dwIndex,
450 szKeyName,
451 &dwKeyName,
452 NULL,
453 NULL,
454 NULL,
455 NULL);
456 if (lError != ERROR_SUCCESS)
457 break;
458
459 TRACE("Notification DLL: %S\n", szKeyName);
460 AddNotificationDll(hNotifyKey, szKeyName);
461 }
462
463 RegCloseKey(hNotifyKey);
464
465 TRACE("InitNotifications() done\n");
466
467 return TRUE;
468}
static VOID AddNotificationDll(_In_ HKEY hNotifyKey, _In_ PCWSTR pszKeyName)
Definition: notify.c:235
static VOID AddSfcNotification(VOID)
Initializes the internal SFC notifications.
Definition: notify.c:176
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by WinMain().

◆ LoadNotifyDll()

static BOOL LoadNotifyDll ( _Inout_ PNOTIFICATION_ITEM  NotificationDll)
static

Loads the notification DLL and retrieves its exported notification handlers.

Definition at line 95 of file notify.c.

97{
98 HKEY hNotifyKey, hDllKey;
100 LONG lError;
102
103 if (NotificationDll->bSfcNotification)
104 return TRUE; // Already loaded.
105
107 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
108 0,
109 KEY_READ,
110 &hNotifyKey);
111 if (lError != ERROR_SUCCESS)
112 {
113 ERR("RegOpenKeyExW(Winlogon\\Notify) failed, Error %lu\n", lError);
114 return FALSE;
115 }
116
117 lError = RegOpenKeyExW(hNotifyKey,
118 NotificationDll->pszKeyName,
119 0,
120 KEY_READ,
121 &hDllKey);
122 RegCloseKey(hNotifyKey);
123
124 if (lError != ERROR_SUCCESS)
125 {
126 ERR("RegOpenKeyExW(%S) failed, Error %lu\n", NotificationDll->pszKeyName, lError);
127 return FALSE;
128 }
129
130 hModule = LoadLibraryW(NotificationDll->pszDllName);
131 if (!hModule)
132 {
133 ERR("LoadLibraryW(%S) failed, Error %lu\n", NotificationDll->pszDllName, GetLastError());
134 RegCloseKey(hDllKey);
135 return FALSE;
136 }
137 NotificationDll->hModule = hModule;
138
140 {
141 NotificationDll->Handler[Type] = GetNotificationHandler(hDllKey, hModule, FuncNames[Type]);
142 TRACE("%s: %p\n", FuncNames[Type], NotificationDll->Handler[Type]);
143 }
144
145 RegCloseKey(hDllKey);
146 return TRUE;
147}
NOTIFICATION_TYPE
Definition: precomp.h:47
static PWLX_NOTIFY_HANDLER GetNotificationHandler(_In_ HKEY hDllKey, _In_ HMODULE hModule, _In_ PCSTR pNotification)
Retrieves the address of the exported notification handler, specified in the registry entry for the n...
Definition: notify.c:61

Referenced by CallNotificationDll().

Variable Documentation

◆ FuncNames

PSTR FuncNames[LastHandler]
static
Initial value:
=
{
"Logon",
"Logoff",
"Lock",
"Unlock",
"Startup",
"Shutdown",
"StartScreenSaver",
"StopScreenSaver",
"Disconnect",
"Reconnect",
"StartShell",
"PostShell"
}

Definition at line 17 of file notify.c.

Referenced by CallNotificationDll(), CallNotificationDlls(), and LoadNotifyDll().

◆ NotificationDllListHead

LIST_ENTRY NotificationDllListHead
static