mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-01 19:26:16 +00:00
LPC: initial work on NT/ROS compatibility.
svn path=/trunk/; revision=8007
This commit is contained in:
@@ -1704,6 +1704,8 @@ typedef struct _LPC_MESSAGE
|
||||
ULONG SectionSize; /* CallbackID */
|
||||
} LPC_MESSAGE, *PLPC_MESSAGE;
|
||||
|
||||
typedef LPC_MESSAGE PORT_MESSAGE, *PPORT_MESSAGE;
|
||||
|
||||
#define MAX_MESSAGE_DATA (0x130)
|
||||
|
||||
typedef struct _LPC_MAX_MESSAGE
|
||||
@@ -1712,6 +1714,8 @@ typedef struct _LPC_MAX_MESSAGE
|
||||
BYTE Data[MAX_MESSAGE_DATA];
|
||||
} LPC_MAX_MESSAGE, *PLPC_MAX_MESSAGE;
|
||||
|
||||
typedef LPC_MAX_MESSAGE PORT_MAX_MESSAGE, *PPORT_MAX_MESSAGE;
|
||||
|
||||
#define PORT_MESSAGE_TYPE(m) (LPC_TYPE)((m).Header.MessageType)
|
||||
|
||||
#define PORT_MAX_DATA_LENGTH 0x104
|
||||
|
||||
@@ -11,9 +11,11 @@ typedef struct _EPORT
|
||||
{
|
||||
KSPIN_LOCK Lock;
|
||||
KSEMAPHORE Semaphore;
|
||||
|
||||
ULONG State;
|
||||
|
||||
|
||||
USHORT Type;
|
||||
USHORT State;
|
||||
|
||||
struct _EPORT * RequestPort;
|
||||
struct _EPORT * OtherPort;
|
||||
|
||||
ULONG QueueLength;
|
||||
@@ -69,6 +71,11 @@ STDCALL
|
||||
LpcSendTerminationPort (PEPORT Port,
|
||||
TIME CreationTime);
|
||||
|
||||
/* EPORT.Type */
|
||||
|
||||
#define EPORT_TYPE_SERVER_RQST_PORT (0)
|
||||
#define EPORT_TYPE_SERVER_COMM_PORT (1)
|
||||
#define EPORT_TYPE_CLIENT_COMM_PORT (2)
|
||||
|
||||
/* EPORT.State */
|
||||
|
||||
@@ -125,7 +132,9 @@ NiCreatePort (PVOID ObjectBody,
|
||||
/* Code in ntoskrnl/lpc/port.c */
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NiInitializePort (IN OUT PEPORT Port);
|
||||
NiInitializePort (IN OUT PEPORT Port,
|
||||
IN USHORT Type,
|
||||
IN PEPORT Parent OPTIONAL);
|
||||
NTSTATUS
|
||||
NiInitPort (VOID);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: complete.c,v 1.10 2003/12/30 18:52:05 fireball Exp $
|
||||
/* $Id: complete.c,v 1.11 2004/02/02 23:48:42 ea Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
@@ -23,34 +23,62 @@
|
||||
|
||||
/***********************************************************************
|
||||
* NAME EXPORTED
|
||||
* NtCompleteConnectPort@4
|
||||
* NtCompleteConnectPort/1
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Wake up the client thread that issued the NtConnectPort call
|
||||
* this server-side port was created for communicating with.
|
||||
* To be used in LPC servers processes on reply ports only.
|
||||
*
|
||||
* ARGUMENTS
|
||||
* hServerSideCommPort: a reply port handle returned by
|
||||
* NtAcceptConnectPort.
|
||||
*
|
||||
* RETURN VALUE
|
||||
* STATUS_SUCCESS or an error code from Ob.
|
||||
*/
|
||||
/*EXPORTED*/ NTSTATUS STDCALL
|
||||
NtCompleteConnectPort (HANDLE PortHandle)
|
||||
NTSTATUS STDCALL
|
||||
NtCompleteConnectPort (HANDLE hServerSideCommPort)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPORT OurPort;
|
||||
PEPORT ReplyPort;
|
||||
|
||||
DPRINT("NtCompleteConnectPort(PortHandle %x)\n", PortHandle);
|
||||
|
||||
Status = ObReferenceObjectByHandle (PortHandle,
|
||||
DPRINT("NtCompleteConnectPort(hServerSideCommPort %x)\n", hServerSideCommPort);
|
||||
|
||||
/*
|
||||
* Ask Ob to translate the port handle to EPORT
|
||||
*/
|
||||
Status = ObReferenceObjectByHandle (hServerSideCommPort,
|
||||
PORT_ALL_ACCESS,
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&OurPort,
|
||||
(PVOID*)&ReplyPort,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
/*
|
||||
* Verify EPORT type is a server-side reply port;
|
||||
* otherwise tell the caller the port handle is not
|
||||
* valid.
|
||||
*/
|
||||
if (ReplyPort->Type != EPORT_TYPE_SERVER_COMM_PORT)
|
||||
{
|
||||
ObDereferenceObject (ReplyPort);
|
||||
return STATUS_INVALID_PORT_HANDLE;
|
||||
}
|
||||
|
||||
OurPort->State = EPORT_CONNECTED_SERVER;
|
||||
|
||||
KeReleaseSemaphore(&OurPort->OtherPort->Semaphore, IO_NO_INCREMENT, 1,
|
||||
ReplyPort->State = EPORT_CONNECTED_SERVER;
|
||||
/*
|
||||
* Wake up the client thread that issued NtConnectPort.
|
||||
*/
|
||||
KeReleaseSemaphore(&ReplyPort->OtherPort->Semaphore, IO_NO_INCREMENT, 1,
|
||||
FALSE);
|
||||
|
||||
ObDereferenceObject (OurPort);
|
||||
/*
|
||||
* Tell Ob we are no more interested in ReplyPort
|
||||
*/
|
||||
ObDereferenceObject (ReplyPort);
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: connect.c,v 1.24 2004/02/01 18:19:28 ea Exp $
|
||||
/* $Id: connect.c,v 1.25 2004/02/02 23:48:42 ea Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
@@ -86,7 +86,7 @@ EiConnectPort(IN PEPORT* ConnectedPort,
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
NiInitializePort(OurPort);
|
||||
NiInitializePort(OurPort, EPORT_TYPE_CLIENT_COMM_PORT, NamedPort);
|
||||
|
||||
/*
|
||||
* Allocate a request message.
|
||||
@@ -600,7 +600,7 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NiInitializePort(OurPort);
|
||||
NiInitializePort(OurPort, EPORT_TYPE_SERVER_COMM_PORT, NamedPort);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: create.c,v 1.15 2004/02/01 18:19:28 ea Exp $
|
||||
/* $Id: create.c,v 1.16 2004/02/02 23:48:42 ea Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
@@ -163,7 +163,7 @@ NtCreatePort (PHANDLE PortHandle,
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = NiInitializePort (Port);
|
||||
Status = NiInitializePort (Port, EPORT_TYPE_SERVER_RQST_PORT, NULL);
|
||||
Port->MaxConnectInfoLength = PORT_MAX_DATA_LENGTH;
|
||||
Port->MaxDataLength = PORT_MAX_MESSAGE_LENGTH;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: port.c,v 1.16 2003/12/14 17:44:02 hbirr Exp $
|
||||
/* $Id: port.c,v 1.17 2004/02/02 23:48:42 ea Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
@@ -89,18 +89,28 @@ NiInitPort (VOID)
|
||||
* otherwise.
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
NiInitializePort (IN OUT PEPORT Port)
|
||||
NiInitializePort (IN OUT PEPORT Port,
|
||||
IN USHORT Type,
|
||||
IN PEPORT Parent OPTIONAL)
|
||||
{
|
||||
if ((Type != EPORT_TYPE_SERVER_RQST_PORT) &&
|
||||
(Type != EPORT_TYPE_SERVER_COMM_PORT) &&
|
||||
(Type != EPORT_TYPE_CLIENT_COMM_PORT))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER_2;
|
||||
}
|
||||
memset (Port, 0, sizeof(EPORT));
|
||||
KeInitializeSpinLock (& Port->Lock);
|
||||
KeInitializeSemaphore( &Port->Semaphore, 0, LONG_MAX );
|
||||
Port->RequestPort = Parent;
|
||||
Port->OtherPort = NULL;
|
||||
Port->QueueLength = 0;
|
||||
Port->ConnectQueueLength = 0;
|
||||
Port->Type = Type;
|
||||
Port->State = EPORT_INACTIVE;
|
||||
InitializeListHead (& Port->QueueListHead);
|
||||
InitializeListHead (& Port->ConnectQueueListHead);
|
||||
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user