[WINLOGON]

Add logon notification package registration.

svn path=/trunk/; revision=68717
This commit is contained in:
Eric Kohl 2015-08-16 14:39:44 +00:00
parent c8cb8d539e
commit 5baa8bc772
4 changed files with 244 additions and 0 deletions

View file

@ -7,6 +7,7 @@ add_rpc_files(server ${REACTOS_SOURCE_DIR}/include/reactos/idl/winreg.idl)
list(APPEND SOURCE
environment.c
notify.c
rpcserver.c
sas.c
screensaver.c

View file

@ -0,0 +1,231 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Winlogon
* FILE: base/system/winlogon/notify.c
* PURPOSE: Logon notifications
* PROGRAMMERS: Eric Kohl
*/
/* INCLUDES *****************************************************************/
#include "winlogon.h"
/* GLOBALS ******************************************************************/
// void Event_Handler_Function_Name(PWLX_NOTIFICATION_INFO pInfo);
typedef VOID (WINAPI *PWLX_NOTIFY_HANDLER)(PWLX_NOTIFICATION_INFO pInfo);
typedef enum _NOTIFICATION_TYPE
{
LogonHandler,
LogoffHandler,
LockHandler,
UnlockHandler,
StartupHandler,
ShutdownHandler,
StartScreenSaverHandler,
StopScreenSaverHandler,
DisconnectHandler,
ReconnectHandler,
StartShellHandler,
PostShellHandler,
LastHandler
} NOTIFICATION_TYPE, *PNOTIFICATION_TYPE;
static PSTR FuncNames[LastHandler] =
{
"Logon",
"Logoff",
"Lock",
"Unlock",
"Startup",
"Shutdown",
"StartScreenSaver",
"StopScreenSaver",
"Disconnect",
"Reconnect",
"StartShell",
"PostShell"
};
typedef struct _NOTIFICATION_ITEM
{
LIST_ENTRY ListEntry;
HINSTANCE hInstance;
PWLX_NOTIFY_HANDLER Handler[LastHandler];
} NOTIFICATION_ITEM, *PNOTIFICATION_ITEM;
static LIST_ENTRY NotificationDllListHead;
/* FUNCTIONS *****************************************************************/
PWLX_NOTIFY_HANDLER
GetNotificationHandler(
HKEY hDllKey,
HINSTANCE hInstance,
PSTR pNotification)
{
CHAR szFuncBuffer[128];
DWORD dwSize;
DWORD dwType;
LONG lError;
dwSize = 128;
lError = RegQueryValueExA(hDllKey,
pNotification,
NULL,
&dwType,
(PBYTE)szFuncBuffer,
&dwSize);
if (lError == ERROR_SUCCESS)
{
return (PWLX_NOTIFY_HANDLER)GetProcAddress(hInstance, szFuncBuffer);
}
return NULL;
}
static
VOID
LoadNotificationDll(
HKEY hNotifyKey,
PWSTR pKeyName)
{
HKEY hDllKey = NULL;
PNOTIFICATION_ITEM NotificationDll = NULL;
LONG lError;
WCHAR szBuffer[80];
DWORD dwSize;
DWORD dwType;
HINSTANCE hInstance;
NOTIFICATION_TYPE i;
TRACE("LoadNotificationDll(%p %S)\n", hNotifyKey, pKeyName);
lError = RegOpenKeyExW(hNotifyKey,
pKeyName,
0,
KEY_READ,
&hDllKey);
if (lError != ERROR_SUCCESS)
return;
dwSize = 80 * sizeof(WCHAR);
lError = RegQueryValueExW(hDllKey,
L"DllName",
NULL,
&dwType,
(PBYTE)szBuffer,
&dwSize);
if (lError == ERROR_SUCCESS)
{
hInstance = LoadLibraryW(szBuffer);
if (hInstance == NULL)
return;
NotificationDll = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(NOTIFICATION_ITEM));
if (NotificationDll == NULL)
return;
NotificationDll->hInstance = hInstance;
for (i = LogonHandler; i < LastHandler; i++)
{
NotificationDll->Handler[i] = GetNotificationHandler(hDllKey, hInstance, FuncNames[i]);
TRACE("%s: %p\n", FuncNames[i], NotificationDll->Handler[i]);
}
InsertHeadList(&NotificationDllListHead,
&NotificationDll->ListEntry);
}
RegCloseKey(hDllKey);
}
BOOL
InitNotifications(VOID)
{
HKEY hNotifyKey = NULL;
LONG lError;
DWORD dwIndex;
WCHAR szKeyName[80];
DWORD dwKeyName;
TRACE("InitNotifications()\n");
InitializeListHead(&NotificationDllListHead);
lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
0,
KEY_READ | KEY_ENUMERATE_SUB_KEYS,
&hNotifyKey);
if (lError != ERROR_SUCCESS)
{
TRACE("RegOpenKeyExW()\n");
return TRUE;
}
dwIndex = 0;
for(;;)
{
dwKeyName = 80 * sizeof(WCHAR);
lError = RegEnumKeyExW(hNotifyKey,
dwIndex,
szKeyName,
&dwKeyName,
NULL,
NULL,
NULL,
NULL);
if (lError != ERROR_SUCCESS)
break;
TRACE("Notification DLL: %S\n", szKeyName);
LoadNotificationDll(hNotifyKey, szKeyName);
dwIndex++;
}
RegCloseKey(hNotifyKey);
TRACE("InitNotifications() done\n");
return TRUE;
}
VOID
CleanupNotifications(VOID)
{
PLIST_ENTRY ListEntry;
PNOTIFICATION_ITEM NotificationDll;
ListEntry = NotificationDllListHead.Flink;
while (ListEntry != &NotificationDllListHead)
{
NotificationDll = CONTAINING_RECORD(ListEntry,
NOTIFICATION_ITEM,
ListEntry);
if (NotificationDll != NULL)
{
}
ListEntry = ListEntry->Flink;
RemoveEntryList(&NotificationDll->ListEntry);
}
}
/* EOF */

View file

@ -384,6 +384,9 @@ WinMain(
/* Wait for the LSA server */
WaitForLsass();
/* Init Notifications */
InitNotifications();
/* Load and initialize gina */
if (!GinaInit(WLSession))
{
@ -470,6 +473,8 @@ WinMain(
DispatchMessageW(&Msg);
}
CleanupNotifications();
/* We never go there */
return 0;

View file

@ -259,6 +259,13 @@ extern PWLSESSION WLSession;
BOOL
CreateUserEnvironment(IN PWLSESSION Session);
/* notifiy.c */
BOOL
InitNotifications(VOID);
VOID
CleanupNotifications(VOID);
/* rpcserver.c */
BOOL
StartRpcServer(VOID);