Author: ekohl
Date: Thu Sep 25 12:37:19 2014
New Revision: 64266
URL:
http://svn.reactos.org/svn/reactos?rev=64266&view=rev
Log:
[SECUR32][LSASRV][LSALIB]
- Move the stubs LsaEnumerateLogonSessions, LsaGetLogonSessionData,
LsaRegisterPolicyChangeNotification and LsaUnregisterPolicyChangeNotification from lsalib
to secur32, because these functions are exported by secur32.dll only.
- Add new LPC connection code to secur32.dll for use by non-logon related functions.
- Implement LsaEnumerateLogonSessions in secur32.dll and LsapEnumLogonSessions in
lsasrv.dll.
Added:
trunk/reactos/dll/win32/secur32/lsalpc.c (with props)
Modified:
trunk/reactos/dll/win32/lsasrv/authpackage.c
trunk/reactos/dll/win32/lsasrv/authport.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
trunk/reactos/dll/win32/lsasrv/session.c
trunk/reactos/dll/win32/secur32/CMakeLists.txt
trunk/reactos/dll/win32/secur32/dllmain.c
trunk/reactos/include/psdk/ntsecapi.h
trunk/reactos/include/reactos/subsys/lsass/lsass.h
trunk/reactos/lib/lsalib/lsa.c
Modified: trunk/reactos/dll/win32/lsasrv/authpackage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/authpacka…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/authpackage.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/authpackage.c [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -8,7 +8,6 @@
#include "lsasrv.h"
-#include <ndk/mmfuncs.h>
#include <ndk/sefuncs.h>
#include <ndk/umfuncs.h>
Modified: trunk/reactos/dll/win32/lsasrv/authport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/authport.…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/authport.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/authport.c [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -9,7 +9,6 @@
#include "lsasrv.h"
#include <ndk/lpcfuncs.h>
-#include <ndk/psfuncs.h>
static LIST_ENTRY LsapLogonContextList;
@@ -92,18 +91,21 @@
HANDLE ConnectionHandle = NULL;
BOOLEAN Accept;
REMOTE_PORT_VIEW RemotePortView;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
TRACE("(%p)\n", RequestMsg);
TRACE("Logon Process Name: %s\n",
RequestMsg->ConnectInfo.LogonProcessNameBuffer);
- Status = LsapCheckLogonProcess(RequestMsg,
- &LogonContext);
-
- RequestMsg->ConnectInfo.OperationalMode = 0x43218765;
-
- RequestMsg->ConnectInfo.Status = Status;
+ if (RequestMsg->ConnectInfo.CreateContext == TRUE)
+ {
+ Status = LsapCheckLogonProcess(RequestMsg,
+ &LogonContext);
+
+ RequestMsg->ConnectInfo.OperationalMode = 0x43218765;
+
+ RequestMsg->ConnectInfo.Status = Status;
+ }
if (NT_SUCCESS(Status))
{
@@ -129,10 +131,13 @@
if (Accept == TRUE)
{
- LogonContext->ConnectionHandle = ConnectionHandle;
-
- InsertHeadList(&LsapLogonContextList,
- &LogonContext->Entry);
+ if (LogonContext != NULL)
+ {
+ LogonContext->ConnectionHandle = ConnectionHandle;
+
+ InsertHeadList(&LsapLogonContextList,
+ &LogonContext->Entry);
+ }
Status = NtCompleteConnectPort(ConnectionHandle);
if (!NT_SUCCESS(Status))
@@ -227,6 +232,11 @@
ReplyMsg = &RequestMsg;
break;
+ case LSASS_REQUEST_ENUM_LOGON_SESSIONS:
+ RequestMsg.Status = LsapEnumLogonSessions(&RequestMsg);
+ ReplyMsg = &RequestMsg;
+ break;
+
default:
RequestMsg.Status = STATUS_INVALID_SYSTEM_SERVICE;
ReplyMsg = &RequestMsg;
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -23,7 +23,9 @@
#define NTOS_MODE_USER
#include <ndk/cmfuncs.h>
#include <ndk/kefuncs.h>
+#include <ndk/mmfuncs.h>
#include <ndk/obfuncs.h>
+#include <ndk/psfuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/setypes.h>
@@ -402,6 +404,9 @@
NTSTATUS
LsapSetLogonSessionData(IN PLUID LogonId);
+NTSTATUS
+LsapEnumLogonSessions(IN OUT PLSA_API_MSG RequestMsg);
+
/* utils.c */
INT
LsapLoadString(HINSTANCE hInstance,
Modified: trunk/reactos/dll/win32/lsasrv/session.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/session.c…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/session.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/session.c [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -122,4 +122,93 @@
return STATUS_SUCCESS;
}
+
+NTSTATUS
+LsapEnumLogonSessions(IN OUT PLSA_API_MSG RequestMsg)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ HANDLE ProcessHandle = NULL;
+ PLIST_ENTRY SessionEntry;
+ PLSAP_LOGON_SESSION CurrentSession;
+ PLUID SessionList;
+ ULONG i, Length;
+ PVOID ClientBaseAddress;
+ NTSTATUS Status;
+
+ TRACE("LsapEnumLogonSessions()\n");
+
+ Length = SessionCount * sizeof(LUID);
+ SessionList = RtlAllocateHeap(RtlGetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ Length);
+ if (SessionList == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ i = 0;
+ SessionEntry = SessionListHead.Flink;
+ while (SessionEntry != &SessionListHead)
+ {
+ CurrentSession = CONTAINING_RECORD(SessionEntry,
+ LSAP_LOGON_SESSION,
+ Entry);
+
+ RtlCopyLuid(&SessionList[i],
+ &CurrentSession->LogonId);
+
+ SessionEntry = SessionEntry->Flink;
+ i++;
+ }
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+
+ Status = NtOpenProcess(&ProcessHandle,
+ PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION |
PROCESS_DUP_HANDLE,
+ &ObjectAttributes,
+ &RequestMsg->h.ClientId);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("NtOpenProcess() failed (Status %lx)\n", Status);
+ goto done;
+ }
+
+ Status = NtAllocateVirtualMemory(ProcessHandle,
+ &ClientBaseAddress,
+ 0,
+ &Length,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("NtAllocateVirtualMemory() failed (Status %lx)\n", Status);
+ goto done;
+ }
+
+ Status = NtWriteVirtualMemory(ProcessHandle,
+ ClientBaseAddress,
+ SessionList,
+ Length,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("NtWriteVirtualMemory() failed (Status %lx)\n", Status);
+ goto done;
+ }
+
+ RequestMsg->EnumLogonSessions.Reply.LogonSessionCount = SessionCount;
+ RequestMsg->EnumLogonSessions.Reply.LogonSessionBuffer = ClientBaseAddress;
+
+done:
+ if (ProcessHandle != NULL)
+ NtClose(ProcessHandle);
+
+ if (SessionList != NULL)
+ RtlFreeHeap(RtlGetProcessHeap(), 0, SessionList);
+
+ return Status;
+}
+
/* EOF */
Modified: trunk/reactos/dll/win32/secur32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/CMakeLis…
==============================================================================
--- trunk/reactos/dll/win32/secur32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/secur32/CMakeLists.txt [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -6,6 +6,7 @@
list(APPEND SOURCE
dllmain.c
+ lsalpc.c
secext.c
sspi.c
stubs.c
Modified: trunk/reactos/dll/win32/secur32/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/dllmain.…
==============================================================================
--- trunk/reactos/dll/win32/secur32/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/secur32/dllmain.c [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -8,6 +8,9 @@
*/
#include "precomp.h"
+
+VOID LsapInitLsaPort(VOID);
+VOID LsapCloseLsaPort(VOID);
/* GLOBALS *******************************************************************/
@@ -29,9 +32,11 @@
{
return FALSE;
}
+ LsapInitLsaPort();
break;
case DLL_PROCESS_DETACH:
+ LsapCloseLsaPort();
if (!RtlDestroyHeap(Secur32Heap))
{
return FALSE;
Added: trunk/reactos/dll/win32/secur32/lsalpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/lsalpc.c…
==============================================================================
--- trunk/reactos/dll/win32/secur32/lsalpc.c (added)
+++ trunk/reactos/dll/win32/secur32/lsalpc.c [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -0,0 +1,188 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: dll/win32/secur32/lsalpc.c
+ * PURPOSE: LSA LPC port functions
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "precomp.h"
+
+#include <ndk/lpctypes.h>
+#include <ndk/lpcfuncs.h>
+#include <ndk/mmfuncs.h>
+#include <ndk/rtlfuncs.h>
+#include <ndk/obfuncs.h>
+#include <psdk/ntsecapi.h>
+#include <lsass/lsass.h>
+
+#include <wine/debug.h>
+WINE_DEFAULT_DEBUG_CHANNEL(secur32);
+
+
+/* GLOBALS *******************************************************************/
+
+HANDLE LsaPortHandle;
+
+extern HANDLE Secur32Heap;
+
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+LsapInitLsaPort(VOID)
+{
+ LsaPortHandle = NULL;
+}
+
+
+VOID
+LsapCloseLsaPort(VOID)
+{
+ if (LsaPortHandle != NULL)
+ {
+ NtClose(LsaPortHandle);
+ LsaPortHandle = NULL;
+ }
+}
+
+
+NTSTATUS
+LsapOpenLsaPort(VOID)
+{
+ UNICODE_STRING PortName;
+ SECURITY_QUALITY_OF_SERVICE SecurityQos;
+ LSA_CONNECTION_INFO ConnectInfo;
+ ULONG ConnectInfoLength;
+ NTSTATUS Status;
+
+ TRACE("LsapOpenLsaPort()\n");
+
+ if (LsaPortHandle != NULL)
+ return STATUS_SUCCESS;
+
+ RtlInitUnicodeString(&PortName,
+ L"\\LsaAuthenticationPort");
+
+ SecurityQos.Length = sizeof(SecurityQos);
+ SecurityQos.ImpersonationLevel = SecurityIdentification;
+ SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
+ SecurityQos.EffectiveOnly = TRUE;
+
+ RtlZeroMemory(&ConnectInfo,
+ ConnectInfoLength);
+
+ ConnectInfo.CreateContext = FALSE;
+
+ ConnectInfoLength = sizeof(LSA_CONNECTION_INFO);
+ Status = NtConnectPort(&LsaPortHandle,
+ &PortName,
+ &SecurityQos,
+ NULL,
+ NULL,
+ NULL,
+ &ConnectInfo,
+ &ConnectInfoLength);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("NtConnectPort failed (Status 0x%08lx)\n", Status);
+ }
+
+ return Status;
+/*
+ if (!NT_SUCCESS(ConnectInfo.Status))
+ {
+ DPRINT1("ConnectInfo.Status: 0x%08lx\n", ConnectInfo.Status);
+ }
+
+ return ConnectInfo.Status;
+*/
+}
+
+
+/* PUBLIC FUNCTIONS **********************************************************/
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+LsaEnumerateLogonSessions(PULONG LogonSessionCount,
+ PLUID *LogonSessionList)
+{
+ LSA_API_MSG ApiMessage;
+ NTSTATUS Status;
+
+ TRACE("LsaEnumerateLogonSessions(%p %p)\n", LogonSessionCount,
LogonSessionList);
+
+ Status = LsapOpenLsaPort();
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ ApiMessage.ApiNumber = LSASS_REQUEST_ENUM_LOGON_SESSIONS;
+ ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.EnumLogonSessions);
+ ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
+ ApiMessage.h.u2.ZeroInit = 0;
+
+ Status = NtRequestWaitReplyPort(LsaPortHandle,
+ (PPORT_MESSAGE)&ApiMessage,
+ (PPORT_MESSAGE)&ApiMessage);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("NtRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status);
+ return Status;
+ }
+
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ ERR("NtRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n",
ApiMessage.Status);
+ return ApiMessage.Status;
+ }
+
+ *LogonSessionCount = ApiMessage.EnumLogonSessions.Reply.LogonSessionCount;
+ *LogonSessionList = ApiMessage.EnumLogonSessions.Reply.LogonSessionBuffer;
+
+ return Status;
+}
+
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+LsaGetLogonSessionData(PLUID LogonId,
+ PSECURITY_LOGON_SESSION_DATA *ppLogonSessionData)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS
InformationClass,
+ HANDLE NotificationEventHandle)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS
InformationClass,
+ HANDLE NotificationEventHandle)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+/* EOF */
Propchange: trunk/reactos/dll/win32/secur32/lsalpc.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/include/psdk/ntsecapi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntsecapi.h?re…
==============================================================================
--- trunk/reactos/include/psdk/ntsecapi.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/ntsecapi.h [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -699,6 +699,7 @@
ULONG,PULONG);
NTSTATUS NTAPI LsaEnumerateAccountsWithUserRight(LSA_HANDLE,PLSA_UNICODE_STRING,
PVOID*,PULONG);
+NTSTATUS NTAPI LsaEnumerateLogonSessions(PULONG,PLUID*);
NTSTATUS NTAPI LsaEnumeratePrivileges(LSA_HANDLE,PLSA_ENUMERATION_HANDLE,
PVOID*,ULONG,PULONG);
NTSTATUS NTAPI LsaEnumeratePrivilegesOfAccount(LSA_HANDLE,PPRIVILEGE_SET*);
Modified: trunk/reactos/include/reactos/subsys/lsass/lsass.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/lsa…
==============================================================================
--- trunk/reactos/include/reactos/subsys/lsass/lsass.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/lsass/lsass.h [iso-8859-1] Thu Sep 25 12:37:19
2014
@@ -21,6 +21,7 @@
LSASS_REQUEST_DEREGISTER_LOGON_PROCESS,
LSASS_REQUEST_LOGON_USER,
LSASS_REQUEST_LOOKUP_AUTHENTICATION_PACKAGE,
+ LSASS_REQUEST_ENUM_LOGON_SESSIONS,
LSASS_REQUEST_MAXIMUM
} LSA_API_NUMBER, *PLSA_API_NUMBER;
@@ -31,6 +32,7 @@
LSA_OPERATIONAL_MODE OperationalMode;
ULONG Length;
CHAR LogonProcessNameBuffer[LSASS_MAX_LOGON_PROCESS_NAME_LENGTH + 1];
+ BOOL CreateContext;
} LSA_CONNECTION_INFO, *PLSA_CONNECTION_INFO;
@@ -69,21 +71,12 @@
{
struct
{
-#if 0
- ULONG AuthenticationPackage;
- ULONG InBufferLength;
- UCHAR InBuffer[0];
-#endif
ULONG AuthenticationPackage;
PVOID ProtocolSubmitBuffer;
ULONG SubmitBufferLength;
} Request;
struct
{
-#if 0
- ULONG OutBufferLength;
- UCHAR OutBuffer[0];
-#endif
PVOID ProtocolReturnBuffer;
ULONG ReturnBufferLength;
NTSTATUS ProtocolStatus;
@@ -125,6 +118,24 @@
} LSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG, *PLSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG;
+typedef struct _LSA_ENUM_LOGON_SESSIONS_MSG
+{
+ union
+ {
+ struct
+ {
+ ULONG Dummy;
+ } Request;
+ struct
+ {
+ ULONG LogonSessionCount;
+ ULONG LogonSessionBufferLength;
+ PVOID LogonSessionBuffer;
+ } Reply;
+ };
+} LSA_ENUM_LOGON_SESSIONS_MSG, *PLSA_ENUM_LOGON_SESSIONS_MSG;
+
+
typedef struct _LSA_API_MSG
{
PORT_MESSAGE h;
@@ -141,6 +152,7 @@
LSA_CALL_AUTHENTICATION_PACKAGE_MSG CallAuthenticationPackage;
LSA_DEREGISTER_LOGON_PROCESS_MSG DeregisterLogonProcess;
LSA_LOOKUP_AUTHENTICATION_PACKAGE_MSG LookupAuthenticationPackage;
+ LSA_ENUM_LOGON_SESSIONS_MSG EnumLogonSessions;
};
};
};
Modified: trunk/reactos/lib/lsalib/lsa.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/lsalib/lsa.c?rev=64266…
==============================================================================
--- trunk/reactos/lib/lsalib/lsa.c [iso-8859-1] (original)
+++ trunk/reactos/lib/lsalib/lsa.c [iso-8859-1] Thu Sep 25 12:37:19 2014
@@ -91,6 +91,8 @@
RtlZeroMemory(&ConnectInfo,
ConnectInfoLength);
+
+ ConnectInfo.CreateContext = TRUE;
Status = ZwConnectPort(LsaHandle,
&PortName,
@@ -328,6 +330,7 @@
LsaLogonProcessName->Length);
ConnectInfo.Length = LsaLogonProcessName->Length;
ConnectInfo.LogonProcessNameBuffer[ConnectInfo.Length] = '\0';
+ ConnectInfo.CreateContext = TRUE;
Status = ZwConnectPort(Handle,
&PortName,
@@ -354,54 +357,3 @@
return ConnectInfo.Status;
}
-
-/*
- * @unimplemented
- */
-NTSTATUS
-WINAPI
-LsaEnumerateLogonSessions(PULONG LogonSessionCount,
- PLUID *LogonSessionList)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
-
-/*
- * @unimplemented
- */
-NTSTATUS
-WINAPI
-LsaGetLogonSessionData(PLUID LogonId,
- PSECURITY_LOGON_SESSION_DATA *ppLogonSessionData)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
-
-/*
- * @unimplemented
- */
-NTSTATUS
-WINAPI
-LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS
InformationClass,
- HANDLE NotificationEventHandle)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
-
-/*
- * @unimplemented
- */
-NTSTATUS
-WINAPI
-LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS
InformationClass,
- HANDLE NotificationEventHandle)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}