- SMSS: Send QOS structure when creating new ports, it's not optional on NT LPC. Send maximum port length when creating new ports, it's not optional on NT LPC. Create 2 listening threads on NTLPC, instead of just one. [AUDIT: Unlock smlib, it's fully internal and specific to ROS without any relationship to NT. The author used clean-room tests and documentation].

- Fix various LPC structures in the NDK. Fix some prototypes too.
- Don't export PEPORT or PLPCP_PORT_OBJECT outside of /lpc and use PVOID isntead.
- Add a new RBUILD setting called NTLPC, which enables NTLPC when turned on.

svn path=/trunk/; revision=24664
This commit is contained in:
Alex Ionescu 2006-10-30 14:17:37 +00:00
parent 48ffe89726
commit 1a98439492
15 changed files with 123 additions and 44 deletions

View file

@ -153,7 +153,7 @@ SmInitializeDbgSs (VOID)
Status = SmpCreatePT(& DbgSsApiPort, Status = SmpCreatePT(& DbgSsApiPort,
SM_DBGSS_PORT_NAME, SM_DBGSS_PORT_NAME,
0, /* MaxDataSize */ 0, /* MaxDataSize */
0, /* MaxMessageSize */ sizeof(PORT_MESSAGE), /* MaxMessageSize */
0, /* PoolCharge */ 0, /* PoolCharge */
DbgSsApiPortThread, DbgSsApiPortThread,
& hDbgSsApiPortThread); & hDbgSsApiPortThread);
@ -166,7 +166,7 @@ SmInitializeDbgSs (VOID)
Status = SmpCreatePT(& DbgUiApiPort, Status = SmpCreatePT(& DbgUiApiPort,
SM_DBGUI_PORT_NAME, SM_DBGUI_PORT_NAME,
0, /* MaxDataSize */ 0, /* MaxDataSize */
0, /* MaxMessageSize */ sizeof(PORT_MESSAGE), /* MaxMessageSize */
0, /* PoolCharge */ 0, /* PoolCharge */
DbgUiApiPortThread, DbgUiApiPortThread,
NULL); NULL);

View file

@ -44,10 +44,8 @@ PSM_CONNECT_DATA FASTCALL SmpGetConnectData (PSM_PORT_MESSAGE Request)
return (PSM_CONNECT_DATA)(PortMessage + 1); return (PSM_CONNECT_DATA)(PortMessage + 1);
} }
#if !defined(__USE_NT_LPC__)
NTSTATUS STDCALL NTSTATUS STDCALL
SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request); SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request);
#endif
/********************************************************************** /**********************************************************************
* SmpCallbackServer/2 * SmpCallbackServer/2
@ -68,6 +66,7 @@ SmpCallbackServer (PSM_PORT_MESSAGE Request,
ULONG CallbackPortNameLength = SM_SB_NAME_MAX_LENGTH; /* TODO: compute length */ ULONG CallbackPortNameLength = SM_SB_NAME_MAX_LENGTH; /* TODO: compute length */
SB_CONNECT_DATA SbConnectData; SB_CONNECT_DATA SbConnectData;
ULONG SbConnectDataLength = sizeof SbConnectData; ULONG SbConnectDataLength = sizeof SbConnectData;
SECURITY_QUALITY_OF_SERVICE SecurityQos;
DPRINT("SM: %s called\n", __FUNCTION__); DPRINT("SM: %s called\n", __FUNCTION__);
@ -84,10 +83,15 @@ SmpCallbackServer (PSM_PORT_MESSAGE Request,
RtlInitUnicodeString (& CallbackPortName, RtlInitUnicodeString (& CallbackPortName,
ClientData->SbApiPortName); ClientData->SbApiPortName);
SecurityQos.Length = sizeof (SecurityQos);
SecurityQos.ImpersonationLevel = SecurityIdentification;
SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
SecurityQos.EffectiveOnly = TRUE;
SbConnectData.SmApiMax = (sizeof SmApi / sizeof SmApi[0]); SbConnectData.SmApiMax = (sizeof SmApi / sizeof SmApi[0]);
Status = NtConnectPort (& ClientData->SbApiPort, Status = NtConnectPort (& ClientData->SbApiPort,
& CallbackPortName, & CallbackPortName,
NULL, &SecurityQos,
NULL, NULL,
NULL, NULL,
NULL, NULL,
@ -245,7 +249,7 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
} }
} }
DPRINT("SM: %s: before NtAcceptConnectPort\n", __FUNCTION__); DPRINT("SM: %s: before NtAcceptConnectPort\n", __FUNCTION__);
#if defined(__USE_NT_LPC__) #if defined(NTLPC)
Status = NtAcceptConnectPort (ClientDataApiPort, Status = NtAcceptConnectPort (ClientDataApiPort,
Context, Context,
(PPORT_MESSAGE) Request, (PPORT_MESSAGE) Request,
@ -276,7 +280,7 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
__FUNCTION__, Status); __FUNCTION__, Status);
return Status; return Status;
} }
#if !defined(__USE_NT_LPC__) /* ReactOS LPC */ #if !defined(NTLPC) /* ReactOS LPC */
DPRINT("SM: %s: server side comm port thread (ROS LPC)\n", __FUNCTION__); DPRINT("SM: %s: server side comm port thread (ROS LPC)\n", __FUNCTION__);
Status = RtlCreateUserThread(NtCurrentProcess(), Status = RtlCreateUserThread(NtCurrentProcess(),
NULL, NULL,
@ -369,8 +373,8 @@ SmCreateApiPort(VOID)
Status = NtCreatePort(&SmApiPort, Status = NtCreatePort(&SmApiPort,
&ObjectAttributes, &ObjectAttributes,
0, sizeof(SM_CONNECT_DATA),
0, sizeof(SM_PORT_MESSAGE),
0); 0);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -386,11 +390,35 @@ SmCreateApiPort(VOID)
0, 0,
0, 0,
0, 0,
#ifdef NTLPC
(PTHREAD_START_ROUTINE)SmpApiConnectedThread,
&SmApiPort,
#else
(PTHREAD_START_ROUTINE)SmpApiThread, (PTHREAD_START_ROUTINE)SmpApiThread,
(PVOID)SmApiPort, (PVOID)SmApiPort,
#endif
NULL, NULL,
NULL); NULL);
#ifdef NTLPC
//
// On NT LPC, we need a second thread to handle incoming connections
// generated by incoming requests, otherwise the thread handling
// the request will be busy sending the LPC message, without any other
// thread being busy to receive the LPC message.
//
Status = RtlCreateUserThread(NtCurrentProcess(),
NULL,
FALSE,
0,
0,
0,
(PTHREAD_START_ROUTINE)SmpApiConnectedThread,
&SmApiPort,
NULL,
NULL);
#endif
return(Status); return(Status);
} }

View file

@ -3,6 +3,9 @@
<include base="ReactOS">include/reactos/subsys</include> <include base="ReactOS">include/reactos/subsys</include>
<define name="__USE_W32API" /> <define name="__USE_W32API" />
<define name="_DISABLE_TIDENTS" /> <define name="_DISABLE_TIDENTS" />
<if property="NTLPC" value="1">
<define name="NTLPC" />
</if>
<library>nt</library> <library>nt</library>
<library>smlib</library> <library>smlib</library>
<library>ntdll</library> <library>ntdll</library>

View file

@ -185,7 +185,9 @@ typedef enum _HARDERROR_RESPONSE
ResponseNo, ResponseNo,
ResponseOk, ResponseOk,
ResponseRetry, ResponseRetry,
ResponseYes ResponseYes,
ResponseTryAgain,
ResponseContinue
} HARDERROR_RESPONSE, *PHARDERROR_RESPONSE; } HARDERROR_RESPONSE, *PHARDERROR_RESPONSE;
// //

View file

@ -34,8 +34,15 @@ NTAPI
LpcRequestWaitReplyPort( LpcRequestWaitReplyPort(
IN PVOID Port, IN PVOID Port,
IN PPORT_MESSAGE LpcMessageRequest, IN PPORT_MESSAGE LpcMessageRequest,
OUT PPORT_MESSAGE LpcMessageReply) OUT PPORT_MESSAGE LpcMessageReply
; );
NTSTATUS
NTAPI
LpcRequestPort(
IN PVOID Port,
IN PPORT_MESSAGE LpcMessage
);
#endif #endif
// //

View file

@ -39,8 +39,22 @@ Author:
// //
// Port Object Access Masks // Port Object Access Masks
// //
#define PORT_CONNECT 0x1
#define PORT_ALL_ACCESS 0x1 #define PORT_ALL_ACCESS 0x1
//
// Port Object Flags
//
#define LPCP_CONNECTION_PORT 0x00000001
#define LPCP_UNCONNECTED_PORT 0x00000002
#define LPCP_COMMUNICATION_PORT 0x00000003
#define LPCP_CLIENT_PORT 0x00000004
#define LPCP_PORT_TYPE_MASK 0x0000000F
#define LPCP_PORT_DELETED 0x10000000
#define LPCP_WAITABLE_PORT 0x20000000
#define LPCP_NAME_DELETED 0x40000000
#define LPCP_SECURITY_DYNAMIC 0x80000000
// //
// LPC Message Types // LPC Message Types
// //
@ -170,7 +184,7 @@ typedef struct _LPCP_NONPAGED_PORT_QUEUE
typedef struct _LPCP_PORT_QUEUE typedef struct _LPCP_PORT_QUEUE
{ {
PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue; PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue;
KSEMAPHORE Semaphore; PKSEMAPHORE Semaphore;
LIST_ENTRY ReceiveHead; LIST_ENTRY ReceiveHead;
} LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE; } LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE;
@ -179,8 +193,6 @@ typedef struct _LPCP_PORT_QUEUE
// //
typedef struct _LPCP_PORT_OBJECT typedef struct _LPCP_PORT_OBJECT
{ {
ULONG Length;
ULONG Flags;
struct _LPCP_PORT_OBJECT *ConnectionPort; struct _LPCP_PORT_OBJECT *ConnectionPort;
struct _LPCP_PORT_OBJECT *ConnectedPort; struct _LPCP_PORT_OBJECT *ConnectedPort;
LPCP_PORT_QUEUE MsgQueue; LPCP_PORT_QUEUE MsgQueue;
@ -188,13 +200,17 @@ typedef struct _LPCP_PORT_OBJECT
PVOID ClientSectionBase; PVOID ClientSectionBase;
PVOID ServerSectionBase; PVOID ServerSectionBase;
PVOID PortContext; PVOID PortContext;
ULONG MaxMessageLength;
ULONG MaxConnectionInfoLength;
PETHREAD ClientThread; PETHREAD ClientThread;
SECURITY_QUALITY_OF_SERVICE SecurityQos; SECURITY_QUALITY_OF_SERVICE SecurityQos;
SECURITY_CLIENT_CONTEXT StaticSecurity; SECURITY_CLIENT_CONTEXT StaticSecurity;
LIST_ENTRY LpcReplyChainHead; LIST_ENTRY LpcReplyChainHead;
LIST_ENTRY LpcDataInfoChainHead; LIST_ENTRY LpcDataInfoChainHead;
PEPROCESS ServerProcess;
PEPROCESS MappingProcess;
ULONG MaxMessageLength;
ULONG MaxConnectionInfoLength;
ULONG Flags;
KEVENT WaitEvent;
} LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT; } LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT;
// //

View file

@ -110,6 +110,14 @@ HANDLE
NTAPI NTAPI
PsGetProcessId(PEPROCESS Process); PsGetProcessId(PEPROCESS Process);
NTSTATUS
NTAPI
PsLookupProcessThreadByCid(
IN PCLIENT_ID Cid,
OUT PEPROCESS *Process OPTIONAL,
OUT PETHREAD *Thread
);
#endif #endif
// //

View file

@ -78,7 +78,7 @@ SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL,
SecurityQos.Length = sizeof (SecurityQos); SecurityQos.Length = sizeof (SecurityQos);
SecurityQos.ImpersonationLevel = SecurityIdentification; SecurityQos.ImpersonationLevel = SecurityIdentification;
SecurityQos.ContextTrackingMode = TRUE; SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
SecurityQos.EffectiveOnly = TRUE; SecurityQos.EffectiveOnly = TRUE;
RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME); RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME);

View file

@ -17,7 +17,7 @@
/* GLOBALS ****************************************************************/ /* GLOBALS ****************************************************************/
BOOLEAN ExReadyForErrors = FALSE; BOOLEAN ExReadyForErrors = FALSE;
PEPORT ExpDefaultErrorPort = NULL; PVOID ExpDefaultErrorPort = NULL;
PEPROCESS ExpDefaultErrorPortProcess = NULL; PEPROCESS ExpDefaultErrorPortProcess = NULL;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/

View file

@ -20,7 +20,9 @@
extern POBJECT_TYPE LpcPortObjectType; extern POBJECT_TYPE LpcPortObjectType;
extern ULONG LpcpNextMessageId; extern ULONG LpcpNextMessageId;
#ifndef NTLPC
extern FAST_MUTEX LpcpLock; extern FAST_MUTEX LpcpLock;
#endif
typedef struct _EPORT_LISTENER typedef struct _EPORT_LISTENER
{ {
@ -74,13 +76,6 @@ typedef struct _QUEUEDMESSAGE
PORT_MESSAGE Message; PORT_MESSAGE Message;
} QUEUEDMESSAGE, *PQUEUEDMESSAGE; } QUEUEDMESSAGE, *PQUEUEDMESSAGE;
NTSTATUS
NTAPI
LpcRequestPort(
PEPORT Port,
PPORT_MESSAGE LpcMessage
);
NTSTATUS NTSTATUS
NTAPI NTAPI
LpcSendTerminationPort( LpcSendTerminationPort(

View file

@ -175,7 +175,7 @@ DefaultSetInfoBufferCheck(ULONG Class,
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (Class >= 0 && Class < ClassListEntries) if (Class < ClassListEntries)
{ {
if (!(ClassList[Class].Flags & ICIF_SET)) if (!(ClassList[Class].Flags & ICIF_SET))
{ {
@ -226,7 +226,7 @@ DefaultQueryInfoBufferCheck(ULONG Class,
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (Class >= 0 && Class < ClassListEntries) if (Class < ClassListEntries)
{ {
if (!(ClassList[Class].Flags & ICIF_QUERY)) if (!(ClassList[Class].Flags & ICIF_QUERY))
{ {

View file

@ -34,10 +34,11 @@
* *
* @implemented * @implemented
*/ */
NTSTATUS STDCALL LpcRequestPort (IN PEPORT Port, NTSTATUS STDCALL LpcRequestPort (IN PVOID PortObject,
IN PPORT_MESSAGE LpcMessage) IN PPORT_MESSAGE LpcMessage)
{ {
NTSTATUS Status; NTSTATUS Status;
PEPORT Port = (PEPORT)PortObject;
DPRINT("LpcRequestPort(PortHandle %08x, LpcMessage %08x)\n", Port, LpcMessage); DPRINT("LpcRequestPort(PortHandle %08x, LpcMessage %08x)\n", Port, LpcMessage);

View file

@ -9,6 +9,9 @@
<define name="__NO_CTYPE_INLINES" /> <define name="__NO_CTYPE_INLINES" />
<define name="__USE_W32API" /> <define name="__USE_W32API" />
<define name="WIN9X_COMPAT_SPINLOCK" /> <define name="WIN9X_COMPAT_SPINLOCK" />
<if property="NTLPC" value="1">
<define name="NTLPC" />
</if>
<include base="cmlib">.</include> <include base="cmlib">.</include>
<include base="ntoskrnl">include</include> <include base="ntoskrnl">include</include>
<include base="ReactOS">include/reactos/drivers</include> <include base="ReactOS">include/reactos/drivers</include>
@ -220,19 +223,35 @@
<file>loader.c</file> <file>loader.c</file>
<file>rtl.c</file> <file>rtl.c</file>
</directory> </directory>
<directory name="lpc"> <if property="NTLPC" value="0">
<file>close.c</file> <directory name="lpc">
<file>complete.c</file> <file>close.c</file>
<file>connect.c</file> <file>complete.c</file>
<file>create.c</file> <file>connect.c</file>
<file>listen.c</file> <file>create.c</file>
<file>port.c</file> <file>listen.c</file>
<file>query.c</file> <file>port.c</file>
<file>queue.c</file> <file>query.c</file>
<file>receive.c</file> <file>queue.c</file>
<file>reply.c</file> <file>receive.c</file>
<file>send.c</file> <file>reply.c</file>
</directory> <file>send.c</file>
</directory>
</if>
<if property="NTLPC" value="1">
<directory name="lpc">
<directory name="ntlpc">
<file>close.c</file>
<file>complete.c</file>
<file>connect.c</file>
<file>create.c</file>
<file>listen.c</file>
<file>port.c</file>
<file>reply.c</file>
<file>send.c</file>
</directory>
</directory>
</if>
<directory name="mm"> <directory name="mm">
<if property="ARCH" value="i386"> <if property="ARCH" value="i386">
<directory name="i386"> <directory name="i386">

View file

@ -361,7 +361,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
{ {
HANDLE hProcess; HANDLE hProcess;
PEPROCESS Process, Parent; PEPROCESS Process, Parent;
PEPORT ExceptionPortObject; PVOID ExceptionPortObject;
PDEBUG_OBJECT DebugObject; PDEBUG_OBJECT DebugObject;
PSECTION_OBJECT SectionObject; PSECTION_OBJECT SectionObject;
NTSTATUS Status, AccessStatus; NTSTATUS Status, AccessStatus;

View file

@ -486,7 +486,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
HANDLE PortHandle = NULL; HANDLE PortHandle = NULL;
HANDLE TokenHandle = NULL; HANDLE TokenHandle = NULL;
PROCESS_SESSION_INFORMATION SessionInfo = {0}; PROCESS_SESSION_INFORMATION SessionInfo = {0};
PEPORT ExceptionPort; PVOID ExceptionPort;
PAGED_CODE(); PAGED_CODE();
/* Verify Information Class validity */ /* Verify Information Class validity */