[WINLOGON]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 23 Aug 2015 15:48:52 +0000 (15:48 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 23 Aug 2015 15:48:52 +0000 (15:48 +0000)
Implement calls to the notification DLLs.

svn path=/trunk/; revision=68803

reactos/base/system/winlogon/notify.c
reactos/base/system/winlogon/sas.c
reactos/base/system/winlogon/screensaver.c
reactos/base/system/winlogon/winlogon.c
reactos/base/system/winlogon/winlogon.h

index f2fd998..460eea0 100644 (file)
 // 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",
@@ -204,27 +187,96 @@ InitNotifications(VOID)
 
 
 VOID
-CleanupNotifications(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)
+{
+    PLIST_ENTRY ListEntry;
+    PNOTIFICATION_ITEM NotificationDll;
 
+    ListEntry = NotificationDllListHead.Flink;
+    while (ListEntry != &NotificationDllListHead)
+    {
+        NotificationDll = CONTAINING_RECORD(ListEntry,
+                                            NOTIFICATION_ITEM,
+                                            ListEntry);
+        if (NotificationDll != NULL)
+        {
+            FreeLibrary(NotificationDll->hInstance);
         }
 
         ListEntry = ListEntry->Flink;
 
         RemoveEntryList(&NotificationDll->ListEntry);
+
+        RtlFreeHeap(RtlGetProcessHeap(), 0, NotificationDll);
     }
 }
 
index 24cf2d2..e9945e9 100644 (file)
@@ -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);
index a46e577..402d840 100644 (file)
@@ -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)
index 65f7805..c43b16f 100644 (file)
@@ -434,6 +434,8 @@ WinMain(
     }
 #endif
 
+    CallNotificationDlls(WLSession, StartupHandler);
+
     /* Create a hidden window to get SAS notifications */
     if (!InitializeSAS(WLSession))
     {
index 4d1edf5..69526d0 100644 (file)
@@ -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);