3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/create.c
6 * PURPOSE: Communication mechanism
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
17 /**********************************************************************
19 * LpcpVerifyCreateParameters/5
22 * Verify user parameters in NtCreatePort and in
23 * NtCreateWaitablePort.
29 STATIC NTSTATUS STDCALL
30 LpcpVerifyCreateParameters (IN PHANDLE PortHandle
,
31 IN POBJECT_ATTRIBUTES ObjectAttributes
,
32 IN ULONG MaxConnectInfoLength
,
33 IN ULONG MaxDataLength
,
34 IN ULONG MaxPoolUsage
)
36 if (NULL
== PortHandle
)
38 return (STATUS_INVALID_PARAMETER_1
);
40 if (NULL
== ObjectAttributes
)
42 return (STATUS_INVALID_PARAMETER_2
);
44 if ((ObjectAttributes
->Attributes
& OBJ_OPENLINK
)
45 || (ObjectAttributes
->Attributes
& OBJ_OPENIF
)
46 || (ObjectAttributes
->Attributes
& OBJ_EXCLUSIVE
)
47 || (ObjectAttributes
->Attributes
& OBJ_PERMANENT
)
48 || (ObjectAttributes
->Attributes
& OBJ_INHERIT
))
50 return (STATUS_INVALID_PORT_ATTRIBUTES
);
52 if (MaxConnectInfoLength
> PORT_MAX_DATA_LENGTH
)
54 return (STATUS_INVALID_PARAMETER_3
);
56 if (MaxDataLength
> PORT_MAX_MESSAGE_LENGTH
)
58 return (STATUS_INVALID_PARAMETER_4
);
60 /* TODO: some checking is done also on MaxPoolUsage
61 * to avoid choking the executive */
62 return (STATUS_SUCCESS
);
66 /**********************************************************************
77 NiCreatePort (PVOID ObjectBody
,
80 POBJECT_ATTRIBUTES ObjectAttributes
)
82 if (RemainingPath
== NULL
)
84 return (STATUS_SUCCESS
);
87 if (wcschr(RemainingPath
+1, '\\') != NULL
)
89 return (STATUS_UNSUCCESSFUL
);
92 return (STATUS_SUCCESS
);
96 /**********************************************************************
105 * MaxConnectInfoLength,
107 * MaxPoolUsage: size of NP zone the NP part of msgs is kept in
111 /*EXPORTED*/ NTSTATUS STDCALL
112 NtCreatePort (PHANDLE PortHandle
,
113 POBJECT_ATTRIBUTES ObjectAttributes
,
114 ULONG MaxConnectInfoLength
,
121 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes
->ObjectName
->Buffer
);
123 /* Verify parameters */
124 Status
= LpcpVerifyCreateParameters (PortHandle
,
126 MaxConnectInfoLength
,
129 if (STATUS_SUCCESS
!= Status
)
134 /* Ask Ob to create the object */
135 Status
= ObCreateObject (ExGetPreviousMode(),
144 if (!NT_SUCCESS(Status
))
149 Status
= ObInsertObject ((PVOID
)Port
,
155 if (!NT_SUCCESS(Status
))
157 ObDereferenceObject (Port
);
161 Status
= LpcpInitializePort (Port
, EPORT_TYPE_SERVER_RQST_PORT
, NULL
);
162 Port
->MaxConnectInfoLength
= PORT_MAX_DATA_LENGTH
;
163 Port
->MaxDataLength
= PORT_MAX_MESSAGE_LENGTH
;
164 Port
->MaxPoolUsage
= MaxPoolUsage
;
166 ObDereferenceObject (Port
);
171 /**********************************************************************
173 * NtCreateWaitablePort/5
176 * Waitable ports can be connected to with NtSecureConnectPort.
177 * No port interface can be used with waitable ports but
178 * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx.
179 * Present only in w2k+.
184 * MaxConnectInfoLength,
190 /*EXPORTED*/ NTSTATUS STDCALL
191 NtCreateWaitablePort (OUT PHANDLE PortHandle
,
192 IN POBJECT_ATTRIBUTES ObjectAttributes
,
193 IN ULONG MaxConnectInfoLength
,
194 IN ULONG MaxDataLength
,
195 IN ULONG MaxPoolUsage
)
199 /* Verify parameters */
200 Status
= LpcpVerifyCreateParameters (PortHandle
,
202 MaxConnectInfoLength
,
205 if (STATUS_SUCCESS
!= Status
)
210 return (STATUS_NOT_IMPLEMENTED
);