ULONG SectionSize; /* CallbackID */
} LPC_MESSAGE, *PLPC_MESSAGE;
+typedef LPC_MESSAGE PORT_MESSAGE, *PPORT_MESSAGE;
+
#define MAX_MESSAGE_DATA (0x130)
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
{
KSPIN_LOCK Lock;
KSEMAPHORE Semaphore;
-
- ULONG State;
-
+
+ USHORT Type;
+ USHORT State;
+
+ struct _EPORT * RequestPort;
struct _EPORT * OtherPort;
ULONG QueueLength;
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 */
/* 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);
-/* $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
/***********************************************************************
* 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;
-
- DPRINT("NtCompleteConnectPort(PortHandle %x)\n", PortHandle);
+ PEPORT ReplyPort;
- 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);
}
-/* $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
{
return (Status);
}
- NiInitializePort(OurPort);
+ NiInitializePort(OurPort, EPORT_TYPE_CLIENT_COMM_PORT, NamedPort);
/*
* Allocate a request message.
return(Status);
}
- NiInitializePort(OurPort);
+ NiInitializePort(OurPort, EPORT_TYPE_SERVER_COMM_PORT, NamedPort);
}
/*
-/* $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
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;
-/* $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
* 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);
}