diff --git a/reactos/base/system/winlogon/notify.c b/reactos/base/system/winlogon/notify.c index f2fd99839ad..460eea039dd 100644 --- a/reactos/base/system/winlogon/notify.c +++ b/reactos/base/system/winlogon/notify.c @@ -16,23 +16,6 @@ // 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", @@ -203,6 +186,75 @@ InitNotifications(VOID) } +VOID +CallNotificationDlls( + PWLSESSION pSession, + NOTIFICATION_TYPE Type) +{ + PLIST_ENTRY ListEntry; + PNOTIFICATION_ITEM NotificationDll; + WLX_NOTIFICATION_INFO Info; + + TRACE("CallNotificationDlls()\n"); + + Info.Size = sizeof(WLX_NOTIFICATION_INFO); + + switch (Type) + { + case LogoffHandler: + case ShutdownHandler: + Info.Flags = 3; + break; + + default: + Info.Flags = 0; + break; + } + + Info.UserName = NULL; //UserName; + Info.Domain = NULL; //Domain; + Info.WindowStation = pSession->InteractiveWindowStationName; + Info.hToken = pSession->UserToken; + + switch (Type) + { + case LogonHandler: + case StartShellHandler: + Info.hDesktop = pSession->ApplicationDesktop; + break; + + case StartScreenSaverHandler: + Info.hDesktop = pSession->ApplicationDesktop; + break; + + default: + Info.hDesktop = pSession->WinlogonDesktop; + break; + } + + Info.pStatusCallback = NULL; + + ListEntry = NotificationDllListHead.Flink; + while (ListEntry != &NotificationDllListHead) + { +TRACE("ListEntry %p\n", ListEntry); + + NotificationDll = CONTAINING_RECORD(ListEntry, + NOTIFICATION_ITEM, + ListEntry); +TRACE("NotificationDll: %p\n", NotificationDll); + if (NotificationDll != NULL) + { +TRACE("NotificationDll->Handler: %p\n", NotificationDll->Handler[Type]); + if (NotificationDll->Handler[Type] != NULL) + NotificationDll->Handler[Type](&Info); + } + + ListEntry = ListEntry->Flink; + } +} + + VOID CleanupNotifications(VOID) { @@ -217,14 +269,14 @@ CleanupNotifications(VOID) ListEntry); if (NotificationDll != NULL) { - - - + FreeLibrary(NotificationDll->hInstance); } ListEntry = ListEntry->Flink; RemoveEntryList(&NotificationDll->ListEntry); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NotificationDll); } } diff --git a/reactos/base/system/winlogon/sas.c b/reactos/base/system/winlogon/sas.c index 24cf2d25722..e9945e9b48d 100644 --- a/reactos/base/system/winlogon/sas.c +++ b/reactos/base/system/winlogon/sas.c @@ -446,6 +446,8 @@ HandleLogon( goto cleanup; } + CallNotificationDlls(Session, LogonHandler); + DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS); UpdatePerUserSystemParameters(0, TRUE); @@ -465,6 +467,8 @@ HandleLogon( goto cleanup; } + CallNotificationDlls(Session, StartShellHandler); + if (!InitializeScreenSaver(Session)) WARN("WL: Failed to initialize screen saver\n"); @@ -783,10 +787,14 @@ HandleLogoff( DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_SAVEYOURSETTINGS); UnloadUserProfile(Session->UserToken, Session->hProfileInfo); + + CallNotificationDlls(Session, LogoffHandler); + CloseHandle(Session->UserToken); UpdatePerUserSystemParameters(0, FALSE); Session->LogonState = STATE_LOGGED_OFF; Session->UserToken = NULL; + return STATUS_SUCCESS; } @@ -894,6 +902,8 @@ HandleShutdown( return STATUS_UNSUCCESSFUL; } + CallNotificationDlls(Session, ShutdownHandler); + /* Destroy SAS window */ UninitializeSAS(Session); @@ -932,6 +942,7 @@ DoGenericAction( if (!HandleLogon(Session)) { Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context); + CallNotificationDlls(Session, LogonHandler); } } break; @@ -957,6 +968,7 @@ DoGenericAction( SwitchDesktop(Session->WinlogonDesktop); Session->LogonState = STATE_LOCKED; Session->Gina.Functions.WlxDisplayLockedNotice(Session->Gina.Context); + CallNotificationDlls(Session, LockHandler); } break; case WLX_SAS_ACTION_LOGOFF: /* 0x04 */ @@ -999,6 +1011,7 @@ DoGenericAction( case WLX_SAS_ACTION_UNLOCK_WKSTA: /* 0x08 */ SwitchDesktop(Session->ApplicationDesktop); Session->LogonState = STATE_LOGGED_ON; + CallNotificationDlls(Session, UnlockHandler); break; default: WARN("Unknown SAS action 0x%lx\n", wlxAction); diff --git a/reactos/base/system/winlogon/screensaver.c b/reactos/base/system/winlogon/screensaver.c index a46e577ccb0..402d84053d5 100644 --- a/reactos/base/system/winlogon/screensaver.c +++ b/reactos/base/system/winlogon/screensaver.c @@ -348,6 +348,8 @@ StartScreenSaver( SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0); + CallNotificationDlls(Session, StartScreenSaverHandler); + /* Wait the end of the process or some other activity */ ResetEvent(Session->hUserActivity); HandleArray[0] = ProcessInformation.hProcess; @@ -363,6 +365,8 @@ StartScreenSaver( CloseHandle(ProcessInformation.hProcess); + CallNotificationDlls(Session, StopScreenSaverHandler); + cleanup: RevertToSelf(); if (hKey) diff --git a/reactos/base/system/winlogon/winlogon.c b/reactos/base/system/winlogon/winlogon.c index 65f78055005..c43b16f5325 100644 --- a/reactos/base/system/winlogon/winlogon.c +++ b/reactos/base/system/winlogon/winlogon.c @@ -434,6 +434,8 @@ WinMain( } #endif + CallNotificationDlls(WLSession, StartupHandler); + /* Create a hidden window to get SAS notifications */ if (!InitializeSAS(WLSession)) { diff --git a/reactos/base/system/winlogon/winlogon.h b/reactos/base/system/winlogon/winlogon.h index 4d1edf5b0ac..69526d0ff74 100644 --- a/reactos/base/system/winlogon/winlogon.h +++ b/reactos/base/system/winlogon/winlogon.h @@ -240,6 +240,23 @@ typedef struct _WLSESSION WLX_PROFILE_V2_0 *Profile; } WLSESSION, *PWLSESSION; +typedef enum _NOTIFICATION_TYPE +{ + LogonHandler, + LogoffHandler, + LockHandler, + UnlockHandler, + StartupHandler, + ShutdownHandler, + StartScreenSaverHandler, + StopScreenSaverHandler, + DisconnectHandler, + ReconnectHandler, + StartShellHandler, + PostShellHandler, + LastHandler +} NOTIFICATION_TYPE, *PNOTIFICATION_TYPE; + extern HINSTANCE hAppInstance; extern PWLSESSION WLSession; @@ -266,6 +283,11 @@ InitNotifications(VOID); VOID CleanupNotifications(VOID); +VOID +CallNotificationDlls( + PWLSESSION pSession, + NOTIFICATION_TYPE Type); + /* rpcserver.c */ BOOL StartRpcServer(VOID);