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 *****************************************************************/
16 #include <internal/debug.h>
18 /**********************************************************************
20 * LpcpVerifyCreateParameters/5
23 * Verify user parameters in NtCreatePort and in
24 * NtCreateWaitablePort.
30 STATIC NTSTATUS STDCALL
31 LpcpVerifyCreateParameters (IN PHANDLE PortHandle
,
32 IN POBJECT_ATTRIBUTES ObjectAttributes
,
33 IN ULONG MaxConnectInfoLength
,
34 IN ULONG MaxDataLength
,
35 IN ULONG MaxPoolUsage
)
37 if (NULL
== PortHandle
)
39 return (STATUS_INVALID_PARAMETER_1
);
41 if (NULL
== ObjectAttributes
)
43 return (STATUS_INVALID_PARAMETER_2
);
45 if ((ObjectAttributes
->Attributes
& OBJ_OPENLINK
)
46 || (ObjectAttributes
->Attributes
& OBJ_OPENIF
)
47 || (ObjectAttributes
->Attributes
& OBJ_EXCLUSIVE
)
48 || (ObjectAttributes
->Attributes
& OBJ_PERMANENT
)
49 || (ObjectAttributes
->Attributes
& OBJ_INHERIT
))
51 return (STATUS_INVALID_PORT_ATTRIBUTES
);
53 if (MaxConnectInfoLength
> PORT_MAX_DATA_LENGTH
)
55 return (STATUS_INVALID_PARAMETER_3
);
57 if (MaxDataLength
> PORT_MAX_MESSAGE_LENGTH
)
59 return (STATUS_INVALID_PARAMETER_4
);
61 /* TODO: some checking is done also on MaxPoolUsage
62 * to avoid choking the executive */
63 return (STATUS_SUCCESS
);
67 /**********************************************************************
78 NiCreatePort (PVOID ObjectBody
,
81 POBJECT_ATTRIBUTES ObjectAttributes
)
83 if (RemainingPath
== NULL
)
85 return (STATUS_SUCCESS
);
88 if (wcschr(RemainingPath
+1, '\\') != NULL
)
90 return (STATUS_UNSUCCESSFUL
);
93 return (STATUS_SUCCESS
);
97 /**********************************************************************
106 * MaxConnectInfoLength,
108 * MaxPoolUsage: size of NP zone the NP part of msgs is kept in
112 /*EXPORTED*/ NTSTATUS STDCALL
113 NtCreatePort (PHANDLE PortHandle
,
114 POBJECT_ATTRIBUTES ObjectAttributes
,
115 ULONG MaxConnectInfoLength
,
122 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes
->ObjectName
->Buffer
);
124 /* Verify parameters */
125 Status
= LpcpVerifyCreateParameters (PortHandle
,
127 MaxConnectInfoLength
,
130 if (STATUS_SUCCESS
!= Status
)
135 /* Ask Ob to create the object */
136 Status
= ObCreateObject (ExGetPreviousMode(),
145 if (!NT_SUCCESS(Status
))
150 Status
= ObInsertObject ((PVOID
)Port
,
156 if (!NT_SUCCESS(Status
))
158 ObDereferenceObject (Port
);
162 Status
= NiInitializePort (Port
, EPORT_TYPE_SERVER_RQST_PORT
, NULL
);
163 Port
->MaxConnectInfoLength
= PORT_MAX_DATA_LENGTH
;
164 Port
->MaxDataLength
= PORT_MAX_MESSAGE_LENGTH
;
165 Port
->MaxPoolUsage
= MaxPoolUsage
;
167 ObDereferenceObject (Port
);
172 /**********************************************************************
174 * NtCreateWaitablePort/5
177 * Waitable ports can be connected to with NtSecureConnectPort.
178 * No port interface can be used with waitable ports but
179 * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx.
180 * Present only in w2k+.
185 * MaxConnectInfoLength,
191 /*EXPORTED*/ NTSTATUS STDCALL
192 NtCreateWaitablePort (OUT PHANDLE PortHandle
,
193 IN POBJECT_ATTRIBUTES ObjectAttributes
,
194 IN ULONG MaxConnectInfoLength
,
195 IN ULONG MaxDataLength
,
196 IN ULONG MaxPoolUsage
)
200 /* Verify parameters */
201 Status
= LpcpVerifyCreateParameters (PortHandle
,
203 MaxConnectInfoLength
,
206 if (STATUS_SUCCESS
!= Status
)
211 return (STATUS_NOT_IMPLEMENTED
);