-/* $Id: create.c,v 1.7 2002/02/19 00:09:23 ekohl Exp $
- *
+/* $Id$
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/lpc/create.c
* PURPOSE: Communication mechanism
- * PROGRAMMER: David Welch (welch@cwcom.net)
- * UPDATE HISTORY:
- * Created 22/05/98
+ *
+ * PROGRAMMERS: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
-#include <ddk/ntddk.h>
-#include <internal/port.h>
-#include <internal/dbg.h>
-
+#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
-STATIC NTSTATUS STDCALL
-VerifyCreateParameters (IN PHANDLE PortHandle,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN ULONG MaxConnectInfoLength,
- IN ULONG MaxDataLength,
- IN ULONG Reserved)
+/**********************************************************************
+ * NAME
+ * LpcpVerifyCreateParameters/5
+ *
+ * DESCRIPTION
+ * Verify user parameters in NtCreatePort and in
+ * NtCreateWaitablePort.
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ */
+STATIC NTSTATUS STDCALL
+LpcpVerifyCreateParameters (IN PHANDLE PortHandle,
+ IN POBJECT_ATTRIBUTES ObjectAttributes,
+ IN ULONG MaxConnectInfoLength,
+ IN ULONG MaxDataLength,
+ IN ULONG MaxPoolUsage)
{
if (NULL == PortHandle)
{
{
return (STATUS_INVALID_PORT_ATTRIBUTES);
}
- if (MaxConnectInfoLength > 0x104) /* FIXME: use a macro! */
+ if (MaxConnectInfoLength > LPC_MAX_DATA_LENGTH)
{
return (STATUS_INVALID_PARAMETER_3);
}
- if (MaxDataLength > 0x148) /* FIXME: use a macro! */
+ if (MaxDataLength > LPC_MAX_MESSAGE_LENGTH)
{
return (STATUS_INVALID_PARAMETER_4);
}
- /* FIXME: some checking is done also on Reserved */
+ /* TODO: some checking is done also on MaxPoolUsage
+ * to avoid choking the executive */
return (STATUS_SUCCESS);
}
-
-NTSTATUS STDCALL
-NiCreatePort (PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- POBJECT_ATTRIBUTES ObjectAttributes)
-{
- if (RemainingPath == NULL)
- {
- return (STATUS_SUCCESS);
- }
-
- if (wcschr(RemainingPath+1, '\\') != NULL)
- {
- return (STATUS_UNSUCCESSFUL);
- }
-
- return (STATUS_SUCCESS);
-}
-
-
/**********************************************************************
* NAME EXPORTED
- * NtCreatePort@20
- *
+ * NtCreatePort/5
+ *
* DESCRIPTION
*
* ARGUMENTS
* ObjectAttributes,
* MaxConnectInfoLength,
* MaxDataLength,
- * Reserved
- *
+ * MaxPoolUsage: size of NP zone the NP part of msgs is kept in
+ *
* RETURN VALUE
- *
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtCreatePort (PHANDLE PortHandle,
POBJECT_ATTRIBUTES ObjectAttributes,
ULONG MaxConnectInfoLength,
ULONG MaxDataLength,
- ULONG Reserved)
+ ULONG MaxPoolUsage)
{
PEPORT Port;
NTSTATUS Status;
-
+
DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer);
-
+
/* Verify parameters */
- Status = VerifyCreateParameters (PortHandle,
- ObjectAttributes,
- MaxConnectInfoLength,
- MaxDataLength,
- Reserved);
- if (!NT_SUCCESS(Status))
+ Status = LpcpVerifyCreateParameters (PortHandle,
+ ObjectAttributes,
+ MaxConnectInfoLength,
+ MaxDataLength,
+ MaxPoolUsage);
+ if (STATUS_SUCCESS != Status)
{
return (Status);
}
+
/* Ask Ob to create the object */
- Status = ObCreateObject (PortHandle,
- PORT_ALL_ACCESS,
+ Status = ObCreateObject (ExGetPreviousMode(),
+ LpcPortObjectType,
ObjectAttributes,
- ExPortType,
+ ExGetPreviousMode(),
+ NULL,
+ sizeof(EPORT),
+ 0,
+ 0,
(PVOID*)&Port);
if (!NT_SUCCESS(Status))
{
return (Status);
}
-
- Status = NiInitializePort (Port);
- Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */
- Port->MaxDataLength = 328; /* FIXME: use a macro! */
-
+
+ Status = ObInsertObject ((PVOID)Port,
+ NULL,
+ PORT_ALL_ACCESS,
+ 0,
+ NULL,
+ PortHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject (Port);
+ return (Status);
+ }
+
+ Status = LpcpInitializePort (Port, EPORT_TYPE_SERVER_RQST_PORT, NULL);
+ Port->MaxConnectInfoLength = LPC_MAX_DATA_LENGTH;
+ Port->MaxDataLength = LPC_MAX_MESSAGE_LENGTH;
+ Port->MaxPoolUsage = MaxPoolUsage;
+
ObDereferenceObject (Port);
-
+
return (Status);
}
/**********************************************************************
* NAME EXPORTED
- * NtCreateWaitablePort@20
- *
+ * NtCreateWaitablePort/5
+ *
* DESCRIPTION
* Waitable ports can be connected to with NtSecureConnectPort.
* No port interface can be used with waitable ports but
* ObjectAttributes,
* MaxConnectInfoLength,
* MaxDataLength,
- * Reserved
- *
+ * MaxPoolUsage
+ *
* RETURN VALUE
- *
*/
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
NtCreateWaitablePort (OUT PHANDLE PortHandle,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN ULONG MaxConnectInfoLength,
IN ULONG MaxDataLength,
- IN ULONG Reserved)
+ IN ULONG MaxPoolUsage)
{
NTSTATUS Status;
-
+
/* Verify parameters */
- Status = VerifyCreateParameters (PortHandle,
- ObjectAttributes,
- MaxConnectInfoLength,
- MaxDataLength,
- Reserved);
+ Status = LpcpVerifyCreateParameters (PortHandle,
+ ObjectAttributes,
+ MaxConnectInfoLength,
+ MaxDataLength,
+ MaxPoolUsage);
if (STATUS_SUCCESS != Status)
{
return (Status);