mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
- use RPC for communication with lsass
- start lsass.exe on startup svn path=/trunk/; revision=20890
This commit is contained in:
parent
1fbded087b
commit
5e85dccad2
14 changed files with 233 additions and 204 deletions
|
@ -737,6 +737,7 @@ HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Tonga Standard Tim
|
|||
;HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\system32\cmd.exe"
|
||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\explorer.exe"
|
||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartServices",0x00010001,0x00000001
|
||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartLsass",0x00010001,0x00000001
|
||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartGUI",0x00010001,0x00000000
|
||||
HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Userinit",0x00020000,"%SystemRoot%\system32\userinit.exe"
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ subsys\system\explorer\explorer-cfg-template.xml 4
|
|||
subsys\system\explorer\notifyhook\notifyhook.dll 1
|
||||
subsys\system\format\format.exe 1
|
||||
subsys\system\ibrowser\ibrowser.exe 1
|
||||
subsys\system\lsass\lsass.exe 1
|
||||
subsys\system\msconfig\msconfig.exe 1
|
||||
subsys\system\msiexec\msiexec.exe 1
|
||||
subsys\system\notepad\notepad.exe 1
|
||||
|
|
|
@ -35,4 +35,16 @@
|
|||
<define name="_X86_" />
|
||||
<file switches="--oldnames">eventlogrpc.idl</file>
|
||||
</module>
|
||||
<module name="lsa_server" type="rpcserver">
|
||||
<include base="ReactOS">.</include>
|
||||
<include base="ReactOS">w32api/include</include>
|
||||
<define name="_X86_" />
|
||||
<file switches="--oldnames">lsa.idl</file>
|
||||
</module>
|
||||
<module name="lsa_client" type="rpcclient">
|
||||
<include base="ReactOS">.</include>
|
||||
<include base="ReactOS">w32api/include</include>
|
||||
<define name="_X86_" />
|
||||
<file switches="--oldnames">lsa.idl</file>
|
||||
</module>
|
||||
</group>
|
||||
|
|
42
reactos/include/idl/lsa.idl
Normal file
42
reactos/include/idl/lsa.idl
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Local Security Authority interface definition
|
||||
*/
|
||||
|
||||
#define BYTE unsigned char
|
||||
#define DWORD unsigned int
|
||||
#define BOOL unsigned long
|
||||
#define LPBYTE unsigned char*
|
||||
#define LPDWORD unsigned long*
|
||||
#define LSA_HANDLE unsigned long
|
||||
#define NTSTATUS unsigned int
|
||||
|
||||
[
|
||||
uuid(12345778-1234-abcd-ef00-0123456789ab),
|
||||
version(0.0),
|
||||
pointer_default(unique),
|
||||
explicit_handle
|
||||
]
|
||||
interface lsarpc
|
||||
{
|
||||
/*
|
||||
cpp_quote("#if 0")
|
||||
typedef [handle, unique] wchar_t *LPWSTR;
|
||||
typedef [handle, unique] char *LPSTR;
|
||||
cpp_quote("#endif")
|
||||
typedef [context_handle] void *LSA_HANDLE;
|
||||
typedef LSA_HANDLE *PLSA_HANDLE;
|
||||
typedef unsigned int NTSTATUS;
|
||||
*/
|
||||
|
||||
cpp_quote("#if 0")
|
||||
typedef struct _LSA_UNICODE_STRING {
|
||||
unsigned short Length;
|
||||
unsigned short MaximumLength;
|
||||
[size_is(MaximumLength)] wchar_t *Buffer;
|
||||
} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING;
|
||||
cpp_quote("#endif")
|
||||
|
||||
/* Function 0 */
|
||||
NTSTATUS LsarClose(handle_t BindingHandle,
|
||||
[in] LSA_HANDLE ObjectHandle);
|
||||
}
|
|
@ -24,6 +24,10 @@
|
|||
/* this has to go after the NDK when being used with the NDK */
|
||||
#include <ntsecapi.h>
|
||||
|
||||
#include <services/services.h>
|
||||
#include "svcctl_c.h"
|
||||
#include "lsa_c.h"
|
||||
|
||||
#ifndef HAS_FN_PROGRESSW
|
||||
#define FN_PROGRESSW FN_PROGRESS
|
||||
#endif
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
<importlibrary definition="advapi32.def" />
|
||||
<include base="advapi32">.</include>
|
||||
<include base="scm_client">.</include>
|
||||
<include base="lsa_client">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="WINVER">0x600</define>
|
||||
<define name="_WIN32_IE">0x0500</define>
|
||||
<define name="_WIN32_WINNT">0x0600</define>
|
||||
<library>scm_client</library>
|
||||
<library>lsa_client</library>
|
||||
<library>ntdll</library>
|
||||
<library>kernel32</library>
|
||||
<library>rpcrt4</library>
|
||||
|
|
|
@ -16,24 +16,80 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
static handle_t LSABindingHandle = NULL;
|
||||
|
||||
#ifndef SID_REVISION /* FIXME - Winnt.h */
|
||||
#define SID_REVISION (1) /* Current revision */
|
||||
#endif
|
||||
static VOID
|
||||
LSAHandleUnbind(handle_t *Handle)
|
||||
{
|
||||
RPC_STATUS status;
|
||||
|
||||
if (*Handle == NULL)
|
||||
return;
|
||||
|
||||
status = RpcBindingFree(Handle);
|
||||
if (status)
|
||||
{
|
||||
DPRINT1("RpcBindingFree returned 0x%x\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
LSAHandleBind(VOID)
|
||||
{
|
||||
LPWSTR pszStringBinding;
|
||||
RPC_STATUS status;
|
||||
handle_t Handle;
|
||||
|
||||
if (LSABindingHandle != NULL)
|
||||
return;
|
||||
|
||||
status = RpcStringBindingComposeW(NULL,
|
||||
L"ncacn_np",
|
||||
NULL,
|
||||
L"\\pipe\\lsarpc",
|
||||
NULL,
|
||||
&pszStringBinding);
|
||||
if (status)
|
||||
{
|
||||
DPRINT1("RpcStringBindingCompose returned 0x%x\n", status);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the binding handle that will be used to bind to the server. */
|
||||
status = RpcBindingFromStringBindingW(pszStringBinding,
|
||||
&Handle);
|
||||
if (status)
|
||||
{
|
||||
DPRINT1("RpcBindingFromStringBinding returned 0x%x\n", status);
|
||||
}
|
||||
|
||||
status = RpcStringFreeW(&pszStringBinding);
|
||||
if (status)
|
||||
{
|
||||
DPRINT1("RpcStringFree returned 0x%x\n", status);
|
||||
}
|
||||
|
||||
if (InterlockedCompareExchangePointer(&LSABindingHandle,
|
||||
(PVOID)Handle,
|
||||
NULL) != NULL)
|
||||
{
|
||||
LSAHandleUnbind(&Handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
LsaClose(LSA_HANDLE ObjectHandle)
|
||||
{
|
||||
static int count = 0;
|
||||
if (count++ < 20)
|
||||
{
|
||||
DPRINT1("(%p):LsaClose stub\n",ObjectHandle);
|
||||
}
|
||||
return 0xc0000000;
|
||||
DPRINT("LsaClose(0x%p) called\n", ObjectHandle);
|
||||
|
||||
LSAHandleBind();
|
||||
|
||||
return LsarClose(LSABindingHandle,
|
||||
(unsigned long)ObjectHandle);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -187,7 +243,7 @@ LsaLookupSids(
|
|||
PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
|
||||
PLSA_TRANSLATED_NAME *Names)
|
||||
{
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
return STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <advapi32.h>
|
||||
#include "svcctl_c.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <advapi32.h>
|
||||
#include <services/services.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
*/
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/ntndk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
HANDLE PortThreadHandle = NULL;
|
||||
HANDLE ConnectPortHandle = NULL;
|
||||
HANDLE MessagePortHandle = NULL;
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
InitializeLsaPort(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING PortName;
|
||||
PORT_MESSAGE Request;
|
||||
NTSTATUS Status;
|
||||
|
||||
ConnectPortHandle = NULL;
|
||||
MessagePortHandle = NULL;
|
||||
|
||||
RtlInitUnicodeString(&PortName,
|
||||
L"\\SeLsaCommandPort");
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&PortName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreatePort(&ConnectPortHandle,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
0x100,
|
||||
0x2000);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtCreatePort() failed (Status %lx)\n", Status);
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
Status = NtListenPort(ConnectPortHandle,
|
||||
&Request);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtListenPort() failed (Status %lx)\n", Status);
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
Status = NtAcceptConnectPort(&MessagePortHandle,
|
||||
ConnectPortHandle,
|
||||
NULL,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1("NtAcceptConnectPort() failed (Status %lx)\n", Status);
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
Status = NtCompleteConnectPort (MessagePortHandle);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1("NtCompleteConnectPort() failed (Status %lx)\n", Status);
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
ByeBye:
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
if (ConnectPortHandle != NULL)
|
||||
NtClose (ConnectPortHandle);
|
||||
|
||||
if (MessagePortHandle != NULL)
|
||||
NtClose (MessagePortHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
ProcessPortMessage(VOID)
|
||||
{
|
||||
PORT_MESSAGE Request;
|
||||
// LPC_MAX_MESSAGE Reply;
|
||||
NTSTATUS Status;
|
||||
|
||||
|
||||
DPRINT1("ProcessPortMessage() called\n");
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Status = NtReplyWaitReceivePort(MessagePortHandle,
|
||||
0,
|
||||
NULL,
|
||||
&Request);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtReplyWaitReceivePort() failed (Status %lx)\n", Status);
|
||||
break;
|
||||
}
|
||||
|
||||
DPRINT("Received message\n");
|
||||
|
||||
if (Request.u2.s2.Type == LPC_PORT_CLOSED)
|
||||
{
|
||||
DPRINT("Port closed\n");
|
||||
|
||||
// return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
if (Request.u2.s2.Type == LPC_REQUEST)
|
||||
{
|
||||
DPRINT("Received request\n");
|
||||
|
||||
}
|
||||
else if (Request.u2.s2.Type == LPC_DATAGRAM)
|
||||
{
|
||||
DPRINT("Received datagram\n");
|
||||
|
||||
// Message = (PIO_ERROR_LOG_MESSAGE)&Request.Data;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
PortThreadRoutine(PVOID Param)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
Status = InitializeLsaPort();
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
while (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = ProcessPortMessage();
|
||||
}
|
||||
|
||||
if (ConnectPortHandle != NULL)
|
||||
NtClose (ConnectPortHandle);
|
||||
|
||||
if (MessagePortHandle != NULL)
|
||||
NtClose (MessagePortHandle);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
StartLsaPortThread(VOID)
|
||||
{
|
||||
DWORD ThreadId;
|
||||
|
||||
PortThreadHandle = CreateThread(NULL,
|
||||
0x1000,
|
||||
(LPTHREAD_START_ROUTINE)PortThreadRoutine,
|
||||
NULL,
|
||||
0,
|
||||
&ThreadId);
|
||||
|
||||
return (PortThreadHandle != NULL);
|
||||
}
|
||||
|
||||
/* EOF */
|
67
reactos/lib/lsasrv/lsarpc.c
Normal file
67
reactos/lib/lsasrv/lsarpc.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#include <ntsecapi.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/ntndk.h>
|
||||
|
||||
#include "lsa_s.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
/* VARIABLES ***************************************************************/
|
||||
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID
|
||||
LsarStartRpcServer(VOID)
|
||||
{
|
||||
RPC_STATUS Status;
|
||||
|
||||
DPRINT("LsarStartRpcServer() called");
|
||||
|
||||
Status = RpcServerUseProtseqEpW(L"ncacn_np",
|
||||
10,
|
||||
L"\\pipe\\lsarpc",
|
||||
NULL);
|
||||
if (Status != RPC_S_OK)
|
||||
{
|
||||
DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = RpcServerRegisterIf(lsarpc_ServerIfHandle,
|
||||
NULL,
|
||||
NULL);
|
||||
if (Status != RPC_S_OK)
|
||||
{
|
||||
DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = RpcServerListen(1, 20, TRUE);
|
||||
if (Status != RPC_S_OK)
|
||||
{
|
||||
DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
DPRINT("LsarStartRpcServer() done");
|
||||
}
|
||||
|
||||
/* Function 0 */
|
||||
unsigned int
|
||||
LsarClose(IN handle_t BindingHandle,
|
||||
IN unsigned long ObjectHandle)
|
||||
{
|
||||
DPRINT1("LsarClose(0x%p) called!\n", ObjectHandle);
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -3,22 +3,42 @@
|
|||
#define NTOS_MODE_USER
|
||||
#include <ndk/ntndk.h>
|
||||
|
||||
#include <lsass/lsasrv.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
VOID StartLsaPortThread(VOID);
|
||||
VOID LsarStartRpcServer(VOID);
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
LsapInitLsa(VOID)
|
||||
{
|
||||
DPRINT1("LsapInitLsa() called\n");
|
||||
HANDLE hEvent;
|
||||
|
||||
StartLsaPortThread();
|
||||
DPRINT1("LsapInitLsa() called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
LsarStartRpcServer();
|
||||
|
||||
hEvent = OpenEventW(EVENT_MODIFY_STATE,
|
||||
FALSE,
|
||||
L"\\SECURITY_SERVICES_STARTED");
|
||||
if (hEvent != NULL)
|
||||
{
|
||||
SetEvent(hEvent);
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
|
||||
{
|
||||
return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||
}
|
||||
|
||||
|
||||
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
||||
{
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
<module name="lsasrv" type="win32dll" baseaddress="${BASEADDRESS_LSASRV}" entrypoint="0" installbase="system32" installname="lsasrv.dll">
|
||||
<importlibrary definition="lsasrv.def" />
|
||||
<include base="lsasrv">.</include>
|
||||
<include base="lsa_server">.</include>
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="__USE_W32API" />
|
||||
<define name="WINVER">0x600</define>
|
||||
<define name="_WIN32_WINNT">0x0600</define>
|
||||
<linkerflag>-nostartfiles</linkerflag>
|
||||
<linkerflag>-nostdlib</linkerflag>
|
||||
<library>lsa_server</library>
|
||||
<library>ntdll</library>
|
||||
<library>kernel32</library>
|
||||
<file>lsaport.c</file>
|
||||
<library>rpcrt4</library>
|
||||
<file>lsarpc.c</file>
|
||||
<file>lsasrv.c</file>
|
||||
<file>lsasrv.rc</file>
|
||||
</module>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
#define SUPPORT_CONSOLESTART 1
|
||||
#define START_LSASS 0
|
||||
#define START_LSASS 1
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
|
@ -161,11 +161,12 @@ StartLsass (VOID)
|
|||
BOOLEAN Result;
|
||||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
WCHAR ServiceString[] = L"lsass.exe";
|
||||
|
||||
LsassInitEvent = CreateEvent(NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
L"\\LsassInitDone");
|
||||
L"\\SECURITY_SERVICES_STARTED");
|
||||
|
||||
if (LsassInitEvent == NULL)
|
||||
{
|
||||
|
@ -183,8 +184,8 @@ StartLsass (VOID)
|
|||
StartupInfo.cbReserved2 = 0;
|
||||
StartupInfo.lpReserved2 = 0;
|
||||
|
||||
Result = CreateProcess(L"lsass.exe",
|
||||
NULL,
|
||||
Result = CreateProcess(NULL,
|
||||
ServiceString,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
|
@ -199,7 +200,6 @@ StartLsass (VOID)
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
DPRINT("WL: Waiting for lsass\n");
|
||||
WaitForSingleObject(LsassInitEvent, INFINITE);
|
||||
CloseHandle(LsassInitEvent);
|
||||
|
||||
|
|
Loading…
Reference in a new issue