[NTOSKRNL][LSASRV]
authorEric Kohl <eric.kohl@reactos.org>
Mon, 26 Oct 2015 21:03:40 +0000 (21:03 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 26 Oct 2015 21:03:40 +0000 (21:03 +0000)
- Move the message typedefs into a shared header file.
- Implement LsapRmCreateLogonSession and LsapRmDeleteLogonSession. Call LsapRmCreateLogonSession in LsapCreateLogonSession.

svn path=/trunk/; revision=69714

reactos/dll/win32/lsasrv/lsasrv.h
reactos/dll/win32/lsasrv/session.c
reactos/dll/win32/lsasrv/srm.c
reactos/include/reactos/srmp.h [new file with mode: 0644]
reactos/ntoskrnl/include/ntoskrnl.h
reactos/ntoskrnl/se/srm.c

index 0a1ad31..d0f1831 100644 (file)
@@ -33,6 +33,8 @@
 #include <ntlsa.h>
 #include <sddl.h>
 
 #include <ntlsa.h>
 #include <sddl.h>
 
+#include <srmp.h>
+
 #include <lsass.h>
 #include <lsa_s.h>
 
 #include <lsass.h>
 #include <lsa_s.h>
 
@@ -425,6 +427,14 @@ LsapGetLogonSessionData(IN OUT PLSA_API_MSG RequestMsg);
 NTSTATUS
 LsapRmInitializeServer(VOID);
 
 NTSTATUS
 LsapRmInitializeServer(VOID);
 
+NTSTATUS
+LsapRmCreateLogonSession(
+    PLUID LogonId);
+
+NTSTATUS
+LsapRmDeleteLogonSession(
+    PLUID LogonId);
+
 /* utils.c */
 INT
 LsapLoadString(HINSTANCE hInstance,
 /* utils.c */
 INT
 LsapLoadString(HINSTANCE hInstance,
index 67673be..90e0342 100644 (file)
@@ -68,7 +68,7 @@ LsapSetLogonSessionData(IN PLUID LogonId)
 {
     PLSAP_LOGON_SESSION Session;
 
 {
     PLSAP_LOGON_SESSION Session;
 
-    TRACE("LsapSetLogonSessionData()\n");
+    TRACE("LsapSetLogonSessionData(%p)\n", LogonId);
 
     Session = LsapGetLogonSession(LogonId);
     if (Session == NULL)
 
     Session = LsapGetLogonSession(LogonId);
     if (Session == NULL)
@@ -84,8 +84,9 @@ NTAPI
 LsapCreateLogonSession(IN PLUID LogonId)
 {
     PLSAP_LOGON_SESSION Session;
 LsapCreateLogonSession(IN PLUID LogonId)
 {
     PLSAP_LOGON_SESSION Session;
+    NTSTATUS Status;
 
 
-    TRACE("()\n");
+    TRACE("LsapCreateLogonSession(%p)\n", LogonId);
 
     /* Fail, if a session already exists */
     if (LsapGetLogonSession(LogonId) != NULL)
 
     /* Fail, if a session already exists */
     if (LsapGetLogonSession(LogonId) != NULL)
@@ -101,6 +102,16 @@ LsapCreateLogonSession(IN PLUID LogonId)
     /* Initialize the session entry */
     RtlCopyLuid(&Session->LogonId, LogonId);
 
     /* Initialize the session entry */
     RtlCopyLuid(&Session->LogonId, LogonId);
 
+    TRACE("LsapCreateLogonSession(<0x%lx,0x%lx>)\n",
+          LogonId->HighPart, LogonId->LowPart);
+
+    Status = LsapRmCreateLogonSession(LogonId);
+    if (!NT_SUCCESS(Status))
+    {
+        RtlFreeHeap(RtlGetProcessHeap(), 0, Session);
+        return Status;
+    }
+
     /* Insert the new session into the session list */
     InsertHeadList(&SessionListHead, &Session->Entry);
     SessionCount++;
     /* Insert the new session into the session list */
     InsertHeadList(&SessionListHead, &Session->Entry);
     SessionCount++;
@@ -115,7 +126,7 @@ LsapDeleteLogonSession(IN PLUID LogonId)
 {
     PLSAP_LOGON_SESSION Session;
 
 {
     PLSAP_LOGON_SESSION Session;
 
-    TRACE("()\n");
+    TRACE("LsapDeleteLogonSession(%p)\n", LogonId);
 
     /* Fail, if the session does not exist */
     Session = LsapGetLogonSession(LogonId);
 
     /* Fail, if the session does not exist */
     Session = LsapGetLogonSession(LogonId);
index 9eb9b23..68929e6 100644 (file)
 #include "lsasrv.h"
 #include <ndk/ntndk.h>
 
 #include "lsasrv.h"
 #include <ndk/ntndk.h>
 
-typedef struct _LSAP_RM_API_MESSAGE
-{
-    PORT_MESSAGE Header;
-    ULONG ApiNumber;
-    union
-    {
-        UCHAR Fill[PORT_MAXIMUM_MESSAGE_LENGTH - sizeof(PORT_MESSAGE)];
-        struct
-        {
-            ULONG Info1;
-        } WriteLog;
-
-    } u;
-} LSAP_RM_API_MESSAGE, *PLSAP_RM_API_MESSAGE;
-
-enum _LSAP_API_NUMBER
-{
-    LsapAdtWriteLogApi = 1,
-    LsapComponentTestApi,
-    LsapAsyncApi
-};
-
 /* GLOBALS *****************************************************************/
 
 HANDLE SeLsaCommandPort;
 /* GLOBALS *****************************************************************/
 
 HANDLE SeLsaCommandPort;
@@ -262,3 +240,83 @@ LsapRmInitializeServer(VOID)
 
     return STATUS_SUCCESS;
 }
 
     return STATUS_SUCCESS;
 }
+
+NTSTATUS
+LsapRmCreateLogonSession(
+    PLUID LogonId)
+{
+    SEP_RM_API_MESSAGE RequestMessage;
+    SEP_RM_API_MESSAGE ReplyMessage;
+    NTSTATUS Status;
+
+    TRACE("LsapRmCreateLogonSession(%p)\n", LogonId);
+
+    RequestMessage.Header.u2.ZeroInit = 0;
+    RequestMessage.Header.u1.s1.TotalLength =
+        (CSHORT)(sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(LUID));
+    RequestMessage.Header.u1.s1.DataLength =
+        RequestMessage.Header.u1.s1.TotalLength -
+        (CSHORT)sizeof(PORT_MESSAGE);
+
+    RequestMessage.ApiNumber = (ULONG)RmCreateLogonSession;
+    RtlCopyLuid(&RequestMessage.u.LogonLuid, LogonId);
+
+    ReplyMessage.Header.u2.ZeroInit = 0;
+    ReplyMessage.Header.u1.s1.TotalLength =
+        (CSHORT)(sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS));
+    ReplyMessage.Header.u1.s1.DataLength =
+        ReplyMessage.Header.u1.s1.TotalLength -
+        (CSHORT)sizeof(PORT_MESSAGE);
+
+    ReplyMessage.u.ResultStatus = STATUS_SUCCESS;
+
+    Status = NtRequestWaitReplyPort(SeRmCommandPort,
+                                    (PPORT_MESSAGE)&RequestMessage,
+                                    (PPORT_MESSAGE)&ReplyMessage);
+    if (NT_SUCCESS(Status))
+    {
+        Status = ReplyMessage.u.ResultStatus;
+    }
+
+    return Status;
+}
+
+NTSTATUS
+LsapRmDeleteLogonSession(
+    PLUID LogonId)
+{
+    SEP_RM_API_MESSAGE RequestMessage;
+    SEP_RM_API_MESSAGE ReplyMessage;
+    NTSTATUS Status;
+
+    TRACE("LsapRmDeleteLogonSession(%p)\n", LogonId);
+
+    RequestMessage.Header.u2.ZeroInit = 0;
+    RequestMessage.Header.u1.s1.TotalLength =
+        (CSHORT)(sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(LUID));
+    RequestMessage.Header.u1.s1.DataLength =
+        RequestMessage.Header.u1.s1.TotalLength -
+        (CSHORT)sizeof(PORT_MESSAGE);
+
+    RequestMessage.ApiNumber = (ULONG)RmDeleteLogonSession;
+    RtlCopyLuid(&RequestMessage.u.LogonLuid, LogonId);
+
+    ReplyMessage.Header.u2.ZeroInit = 0;
+    ReplyMessage.Header.u1.s1.TotalLength =
+        (CSHORT)(sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS));
+    ReplyMessage.Header.u1.s1.DataLength =
+        ReplyMessage.Header.u1.s1.TotalLength -
+        (CSHORT)sizeof(PORT_MESSAGE);
+
+    ReplyMessage.u.ResultStatus = STATUS_SUCCESS;
+
+    Status = NtRequestWaitReplyPort(SeRmCommandPort,
+                                    (PPORT_MESSAGE)&RequestMessage,
+                                    (PPORT_MESSAGE)&ReplyMessage);
+    if (NT_SUCCESS(Status))
+    {
+        Status = ReplyMessage.u.ResultStatus;
+    }
+
+    return Status;
+}
diff --git a/reactos/include/reactos/srmp.h b/reactos/include/reactos/srmp.h
new file mode 100644 (file)
index 0000000..dbc36da
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _SRMP_
+#define _SRMP_
+
+typedef enum _RM_API_NUMBER
+{
+    RmAuditSetCommand = 1,
+    RmCreateLogonSession = 2,
+    RmDeleteLogonSession = 3
+} RM_API_NUMBER;
+
+typedef struct _SEP_RM_API_MESSAGE
+{
+    PORT_MESSAGE Header;
+    ULONG ApiNumber;
+    union
+    {
+        UCHAR Fill[PORT_MAXIMUM_MESSAGE_LENGTH - sizeof(PORT_MESSAGE)];
+        NTSTATUS ResultStatus;
+        struct
+        {
+            BOOLEAN Enabled;
+            ULONG Flags[9];
+        } SetAuditEvent;
+        LUID LogonLuid;
+    } u;
+} SEP_RM_API_MESSAGE, *PSEP_RM_API_MESSAGE;
+
+
+typedef enum _LSAP_API_NUMBER
+{
+    LsapAdtWriteLogApi = 1,
+    LsapComponentTestApi,
+    LsapAsyncApi
+} LSAP_API_NUMBER;
+
+typedef struct _LSAP_RM_API_MESSAGE
+{
+    PORT_MESSAGE Header;
+    ULONG ApiNumber;
+    union
+    {
+        UCHAR Fill[PORT_MAXIMUM_MESSAGE_LENGTH - sizeof(PORT_MESSAGE)];
+        struct
+        {
+            ULONG Info1;
+        } WriteLog;
+
+    } u;
+} LSAP_RM_API_MESSAGE, *PLSAP_RM_API_MESSAGE;
+
+#endif /* _SRMP_ */
\ No newline at end of file
index 400a153..f894d9b 100644 (file)
@@ -88,6 +88,9 @@
 /* PNP GUIDs */
 #include <umpnpmgr/sysguid.h>
 
 /* PNP GUIDs */
 #include <umpnpmgr/sysguid.h>
 
+/* SRM header */
+#include <srmp.h>
+
 #define ExRaiseStatus RtlRaiseStatus
 
 //
 #define ExRaiseStatus RtlRaiseStatus
 
 //
index bd680ba..b2d5794 100644 (file)
@@ -20,30 +20,6 @@ extern LUID SeAnonymousAuthenticationId;
 
 #define SEP_LOGON_SESSION_TAG 'sLeS'
 
 
 #define SEP_LOGON_SESSION_TAG 'sLeS'
 
-enum _RM_API_NUMBER
-{
-    RmAuditSetCommand = 1,
-    RmCreateLogonSession = 2,
-    RmDeleteLogonSession = 3
-};
-
-typedef struct _SEP_RM_API_MESSAGE
-{
-    PORT_MESSAGE Header;
-    ULONG ApiNumber;
-    union
-    {
-        UCHAR Fill[PORT_MAXIMUM_MESSAGE_LENGTH - sizeof(PORT_MESSAGE)];
-        NTSTATUS ResultStatus;
-        struct
-        {
-            BOOLEAN Enabled;
-            ULONG Flags[9];
-        } SetAuditEvent;
-        LUID LogonLuid;
-    } u;
-} SEP_RM_API_MESSAGE, *PSEP_RM_API_MESSAGE;
-
 typedef struct _SEP_LOGON_SESSION_REFERENCES
 {
     struct _SEP_LOGON_SESSION_REFERENCES *Next;
 typedef struct _SEP_LOGON_SESSION_REFERENCES
 {
     struct _SEP_LOGON_SESSION_REFERENCES *Next;