1 /* $Id: create.c,v 1.16 2004/02/02 23:48:42 ea Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/create.c
6 * PURPOSE: Communication mechanism
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 /* INCLUDES *****************************************************************/
14 #define NTOS_MODE_KERNEL
16 #include <internal/port.h>
17 #include <internal/dbg.h>
20 #include <internal/debug.h>
22 /**********************************************************************
24 * LpcpVerifyCreateParameters/5
27 * Verify user parameters in NtCreatePort and in
28 * NtCreateWaitablePort.
34 STATIC NTSTATUS STDCALL
35 LpcpVerifyCreateParameters (IN PHANDLE PortHandle
,
36 IN POBJECT_ATTRIBUTES ObjectAttributes
,
37 IN ULONG MaxConnectInfoLength
,
38 IN ULONG MaxDataLength
,
41 if (NULL
== PortHandle
)
43 return (STATUS_INVALID_PARAMETER_1
);
45 if (NULL
== ObjectAttributes
)
47 return (STATUS_INVALID_PARAMETER_2
);
49 if ((ObjectAttributes
->Attributes
& OBJ_OPENLINK
)
50 || (ObjectAttributes
->Attributes
& OBJ_OPENIF
)
51 || (ObjectAttributes
->Attributes
& OBJ_EXCLUSIVE
)
52 || (ObjectAttributes
->Attributes
& OBJ_PERMANENT
)
53 || (ObjectAttributes
->Attributes
& OBJ_INHERIT
))
55 return (STATUS_INVALID_PORT_ATTRIBUTES
);
57 if (MaxConnectInfoLength
> PORT_MAX_DATA_LENGTH
)
59 return (STATUS_INVALID_PARAMETER_3
);
61 if (MaxDataLength
> PORT_MAX_MESSAGE_LENGTH
)
63 return (STATUS_INVALID_PARAMETER_4
);
65 /* FIXME: some checking is done also on Reserved, but
66 * not in public (free/checked) versions. */
67 return (STATUS_SUCCESS
);
71 /**********************************************************************
82 NiCreatePort (PVOID ObjectBody
,
85 POBJECT_ATTRIBUTES ObjectAttributes
)
87 if (RemainingPath
== NULL
)
89 return (STATUS_SUCCESS
);
92 if (wcschr(RemainingPath
+1, '\\') != NULL
)
94 return (STATUS_UNSUCCESSFUL
);
97 return (STATUS_SUCCESS
);
101 /**********************************************************************
110 * MaxConnectInfoLength,
116 /*EXPORTED*/ NTSTATUS STDCALL
117 NtCreatePort (PHANDLE PortHandle
,
118 POBJECT_ATTRIBUTES ObjectAttributes
,
119 ULONG MaxConnectInfoLength
,
126 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes
->ObjectName
->Buffer
);
128 /* Verify parameters */
129 Status
= LpcpVerifyCreateParameters (PortHandle
,
131 MaxConnectInfoLength
,
134 if (STATUS_SUCCESS
!= Status
)
139 /* Ask Ob to create the object */
140 Status
= ObCreateObject (ExGetPreviousMode(),
149 if (!NT_SUCCESS(Status
))
154 Status
= ObInsertObject ((PVOID
)Port
,
160 if (!NT_SUCCESS(Status
))
162 ObDereferenceObject (Port
);
166 Status
= NiInitializePort (Port
, EPORT_TYPE_SERVER_RQST_PORT
, NULL
);
167 Port
->MaxConnectInfoLength
= PORT_MAX_DATA_LENGTH
;
168 Port
->MaxDataLength
= PORT_MAX_MESSAGE_LENGTH
;
170 ObDereferenceObject (Port
);
175 /**********************************************************************
177 * NtCreateWaitablePort/5
180 * Waitable ports can be connected to with NtSecureConnectPort.
181 * No port interface can be used with waitable ports but
182 * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx.
183 * Present only in w2k+.
188 * MaxConnectInfoLength,
194 /*EXPORTED*/ NTSTATUS STDCALL
195 NtCreateWaitablePort (OUT PHANDLE PortHandle
,
196 IN POBJECT_ATTRIBUTES ObjectAttributes
,
197 IN ULONG MaxConnectInfoLength
,
198 IN ULONG MaxDataLength
,
203 /* Verify parameters */
204 Status
= LpcpVerifyCreateParameters (PortHandle
,
206 MaxConnectInfoLength
,
209 if (STATUS_SUCCESS
!= Status
)
214 return (STATUS_NOT_IMPLEMENTED
);