ReactOS  0.4.13-dev-100-gc8611ae
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

PWLX_NOTIFY_HANDLER GetNotificationHandler (HKEY hDllKey, HINSTANCE hInstance, PSTR pNotification)
 
static VOID LoadNotificationDll (HKEY hNotifyKey, PWSTR pKeyName)
 
BOOL InitNotifications (VOID)
 
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 17 of file notify.c.

Function Documentation

◆ CallNotificationDlls()

VOID CallNotificationDlls ( PWLSESSION  pSession,
NOTIFICATION_TYPE  Type 
)

Definition at line 249 of file notify.c.

252 {
253  PLIST_ENTRY ListEntry;
254  PNOTIFICATION_ITEM NotificationDll;
256 
257  TRACE("CallNotificationDlls()\n");
258 
259  Info.Size = sizeof(WLX_NOTIFICATION_INFO);
260 
261  switch (Type)
262  {
263  case LogoffHandler:
264  case ShutdownHandler:
265  Info.Flags = 3;
266  break;
267 
268  default:
269  Info.Flags = 0;
270  break;
271  }
272 
273  Info.UserName = NULL; //UserName;
274  Info.Domain = NULL; //Domain;
275  Info.WindowStation = pSession->InteractiveWindowStationName;
276  Info.hToken = pSession->UserToken;
277 
278  switch (Type)
279  {
280  case LogonHandler:
281  case StartShellHandler:
282  Info.hDesktop = pSession->ApplicationDesktop;
283  break;
284 
286  Info.hDesktop = pSession->ApplicationDesktop;
287  break;
288 
289  default:
290  Info.hDesktop = pSession->WinlogonDesktop;
291  break;
292  }
293 
294  Info.pStatusCallback = NULL;
295 
296  ListEntry = NotificationDllListHead.Flink;
297  while (ListEntry != &NotificationDllListHead)
298  {
299 TRACE("ListEntry %p\n", ListEntry);
300 
301  NotificationDll = CONTAINING_RECORD(ListEntry,
303  ListEntry);
304 TRACE("NotificationDll: %p\n", NotificationDll);
305  if (NotificationDll != NULL && NotificationDll->bEnabled)
306  {
307 TRACE("NotificationDll->Handler: %p\n", NotificationDll->Handler[Type]);
308  if (NotificationDll->Handler[Type] != NULL)
309  NotificationDll->Handler[Type](&Info);
310  }
311 
312  ListEntry = ListEntry->Flink;
313  }
314 }
PWLX_NOTIFY_HANDLER Handler[LastHandler]
Definition: notify.c:46
Type
Definition: Type.h:6
HDESK WinlogonDesktop
Definition: winlogon.h:224
HANDLE UserToken
Definition: winlogon.h:227
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:50
HDESK ApplicationDesktop
Definition: winlogon.h:223
struct TraceInfo Info
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR InteractiveWindowStationName
Definition: winlogon.h:222
Definition: typedefs.h:117
struct _WLX_NOTIFICATION_INFO WLX_NOTIFICATION_INFO

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

◆ CleanupNotifications()

VOID CleanupNotifications ( VOID  )

Definition at line 318 of file notify.c.

319 {
320  PLIST_ENTRY ListEntry;
321  PNOTIFICATION_ITEM NotificationDll;
322 
323  ListEntry = NotificationDllListHead.Flink;
324  while (ListEntry != &NotificationDllListHead)
325  {
326  NotificationDll = CONTAINING_RECORD(ListEntry,
328  ListEntry);
329  if (NotificationDll != NULL)
330  {
331  FreeLibrary(NotificationDll->hInstance);
332  }
333 
334  ListEntry = ListEntry->Flink;
335 
336  RemoveEntryList(&NotificationDll->ListEntry);
337 
338  RtlFreeHeap(RtlGetProcessHeap(), 0, NotificationDll);
339  }
340 }
HINSTANCE hInstance
Definition: notify.c:39
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:50
LIST_ENTRY ListEntry
Definition: notify.c:37
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define FreeLibrary(x)
Definition: compat.h:405
Definition: typedefs.h:117

Referenced by WinMain().

◆ GetNotificationHandler()

PWLX_NOTIFY_HANDLER GetNotificationHandler ( HKEY  hDllKey,
HINSTANCE  hInstance,
PSTR  pNotification 
)

Definition at line 56 of file notify.c.

60 {
61  CHAR szFuncBuffer[128];
62  DWORD dwSize;
63  DWORD dwType;
64  LONG lError;
65 
66  dwSize = 128;
67  lError = RegQueryValueExA(hDllKey,
68  pNotification,
69  NULL,
70  &dwType,
71  (PBYTE)szFuncBuffer,
72  &dwSize);
73  if (lError == ERROR_SUCCESS)
74  {
75  return (PWLX_NOTIFY_HANDLER)GetProcAddress(hInstance, szFuncBuffer);
76  }
77 
78  return NULL;
79 }
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:4041
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
HINSTANCE hInstance
Definition: charmap.c:20
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID(WINAPI * PWLX_NOTIFY_HANDLER)(PWLX_NOTIFICATION_INFO pInfo)
Definition: notify.c:17
#define GetProcAddress(x, y)
Definition: compat.h:410
BYTE * PBYTE
Definition: pedump.c:66
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by LoadNotificationDll().

◆ InitNotifications()

BOOL InitNotifications ( VOID  )

Definition at line 196 of file notify.c.

197 {
198  HKEY hNotifyKey = NULL;
199  LONG lError;
200  DWORD dwIndex;
201  WCHAR szKeyName[80];
202  DWORD dwKeyName;
203 
204  TRACE("InitNotifications()\n");
205 
207 
209  L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
210  0,
212  &hNotifyKey);
213  if (lError != ERROR_SUCCESS)
214  {
215  TRACE("RegOpenKeyExW()\n");
216  return TRUE;
217  }
218 
219  dwIndex = 0;
220  for(;;)
221  {
222  dwKeyName = 80 * sizeof(WCHAR);
223  lError = RegEnumKeyExW(hNotifyKey,
224  dwIndex,
225  szKeyName,
226  &dwKeyName,
227  NULL,
228  NULL,
229  NULL,
230  NULL);
231  if (lError != ERROR_SUCCESS)
232  break;
233 
234  TRACE("Notification DLL: %S\n", szKeyName);
235  LoadNotificationDll(hNotifyKey, szKeyName);
236 
237  dwIndex++;
238  }
239 
240  RegCloseKey(hNotifyKey);
241 
242  TRACE("InitNotifications() done\n");
243 
244  return TRUE;
245 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:50
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static VOID LoadNotificationDll(HKEY hNotifyKey, PWSTR pKeyName)
Definition: notify.c:84
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
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:2541
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by WinMain().

◆ LoadNotificationDll()

static VOID LoadNotificationDll ( HKEY  hNotifyKey,
PWSTR  pKeyName 
)
static

Definition at line 84 of file notify.c.

87 {
88  HKEY hDllKey = NULL;
89  PNOTIFICATION_ITEM NotificationDll = NULL;
90  LONG lError;
91  WCHAR szBuffer[80];
92  DWORD dwSize;
93  DWORD dwType;
96 
97  TRACE("LoadNotificationDll(%p %S)\n", hNotifyKey, pKeyName);
98 
99  lError = RegOpenKeyExW(hNotifyKey,
100  pKeyName,
101  0,
102  KEY_READ,
103  &hDllKey);
104  if (lError != ERROR_SUCCESS)
105  return;
106 
107  dwSize = 80 * sizeof(WCHAR);
108  lError = RegQueryValueExW(hDllKey,
109  L"DllName",
110  NULL,
111  &dwType,
112  (PBYTE)szBuffer,
113  &dwSize);
114  if (lError == ERROR_SUCCESS)
115  {
116  hInstance = LoadLibraryW(szBuffer);
117  if (hInstance == NULL)
118  return;
119 
120  NotificationDll = RtlAllocateHeap(RtlGetProcessHeap(),
122  sizeof(NOTIFICATION_ITEM));
123  if (NotificationDll == NULL)
124  {
126  return;
127  }
128 
129  NotificationDll->bEnabled = TRUE;
130  NotificationDll->dwMaxWait = 30; /* FIXME: ??? */
131  NotificationDll->hInstance = hInstance;
132 
133  dwSize = sizeof(BOOL);
134  RegQueryValueExW(hDllKey,
135  L"Asynchronous",
136  NULL,
137  &dwType,
138  (PBYTE)&NotificationDll->bAsynchronous,
139  &dwSize);
140 
141  dwSize = sizeof(BOOL);
142  RegQueryValueExW(hDllKey,
143  L"Enabled",
144  NULL,
145  &dwType,
146  (PBYTE)&NotificationDll->bEnabled,
147  &dwSize);
148 
149  dwSize = sizeof(BOOL);
150  RegQueryValueExW(hDllKey,
151  L"Impersonate",
152  NULL,
153  &dwType,
154  (PBYTE)&NotificationDll->bImpersonate,
155  &dwSize);
156 
157  dwSize = sizeof(BOOL);
158  RegQueryValueExW(hDllKey,
159  L"Safe",
160  NULL,
161  &dwType,
162  (PBYTE)&NotificationDll->bSafe,
163  &dwSize);
164 
165  dwSize = sizeof(BOOL);
166  RegQueryValueExW(hDllKey,
167  L"SmartCardLogonNotify",
168  NULL,
169  &dwType,
170  (PBYTE)&NotificationDll->bSmartCardLogon,
171  &dwSize);
172 
173  dwSize = sizeof(DWORD);
174  RegQueryValueExW(hDllKey,
175  L"MaxWait",
176  NULL,
177  &dwType,
178  (PBYTE)&NotificationDll->dwMaxWait,
179  &dwSize);
180 
181  for (i = LogonHandler; i < LastHandler; i++)
182  {
183  NotificationDll->Handler[i] = GetNotificationHandler(hDllKey, hInstance, FuncNames[i]);
184  TRACE("%s: %p\n", FuncNames[i], NotificationDll->Handler[i]);
185  }
186 
188  &NotificationDll->ListEntry);
189  }
190 
191  RegCloseKey(hDllKey);
192 }
enum _NOTIFICATION_TYPE NOTIFICATION_TYPE
#define TRUE
Definition: types.h:120
PWLX_NOTIFY_HANDLER Handler[LastHandler]
Definition: notify.c:46
HINSTANCE hInstance
Definition: notify.c:39
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:50
BOOL bAsynchronous
Definition: notify.c:41
#define BOOL
Definition: nt_native.h:43
LIST_ENTRY ListEntry
Definition: notify.c:37
#define DWORD
Definition: nt_native.h:44
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
HINSTANCE hInstance
Definition: charmap.c:20
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
PWLX_NOTIFY_HANDLER GetNotificationHandler(HKEY hDllKey, HINSTANCE hInstance, PSTR pNotification)
Definition: notify.c:56
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
BOOL bImpersonate
Definition: notify.c:43
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL bSmartCardLogon
Definition: notify.c:44
static const WCHAR L[]
Definition: oid.c:1250
static PSTR FuncNames[LastHandler]
Definition: notify.c:19
DWORD dwMaxWait
Definition: notify.c:45
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
BYTE * PBYTE
Definition: pedump.c:66
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by InitNotifications().

Variable Documentation

◆ FuncNames

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

Definition at line 19 of file notify.c.

Referenced by LoadNotificationDll().

◆ NotificationDllListHead

LIST_ENTRY NotificationDllListHead
static