[NTOSKRNL][LSASRV]

- Move the message typedefs into a shared header file.
- Implement LsapRmCreateLogonSession and LsapRmDeleteLogonSession. Call LsapRmCreateLogonSession in LsapCreateLogonSession.

svn path=/trunk/; revision=69714
This commit is contained in:
Eric Kohl 2015-10-26 21:03:40 +00:00
parent 07d2565c81
commit 6b82bc960e
6 changed files with 158 additions and 49 deletions

View file

@ -33,6 +33,8 @@
#include <ntlsa.h>
#include <sddl.h>
#include <srmp.h>
#include <lsass.h>
#include <lsa_s.h>
@ -425,6 +427,14 @@ LsapGetLogonSessionData(IN OUT PLSA_API_MSG RequestMsg);
NTSTATUS
LsapRmInitializeServer(VOID);
NTSTATUS
LsapRmCreateLogonSession(
PLUID LogonId);
NTSTATUS
LsapRmDeleteLogonSession(
PLUID LogonId);
/* utils.c */
INT
LsapLoadString(HINSTANCE hInstance,

View file

@ -68,7 +68,7 @@ LsapSetLogonSessionData(IN PLUID LogonId)
{
PLSAP_LOGON_SESSION Session;
TRACE("LsapSetLogonSessionData()\n");
TRACE("LsapSetLogonSessionData(%p)\n", LogonId);
Session = LsapGetLogonSession(LogonId);
if (Session == NULL)
@ -84,8 +84,9 @@ NTAPI
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)
@ -101,6 +102,16 @@ LsapCreateLogonSession(IN PLUID 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++;
@ -115,7 +126,7 @@ LsapDeleteLogonSession(IN PLUID LogonId)
{
PLSAP_LOGON_SESSION Session;
TRACE("()\n");
TRACE("LsapDeleteLogonSession(%p)\n", LogonId);
/* Fail, if the session does not exist */
Session = LsapGetLogonSession(LogonId);

View file

@ -12,28 +12,6 @@
#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;
@ -262,3 +240,83 @@ LsapRmInitializeServer(VOID)
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;
}

View file

@ -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_ */

View file

@ -88,6 +88,9 @@
/* PNP GUIDs */
#include <umpnpmgr/sysguid.h>
/* SRM header */
#include <srmp.h>
#define ExRaiseStatus RtlRaiseStatus
//

View file

@ -20,30 +20,6 @@ extern LUID SeAnonymousAuthenticationId;
#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;