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
> LPC_MAX_DATA_LENGTH
)
54 return (STATUS_INVALID_PARAMETER_3
);
56 if (MaxDataLength
> LPC_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
);
65 /**********************************************************************
74 * MaxConnectInfoLength,
76 * MaxPoolUsage: size of NP zone the NP part of msgs is kept in
80 /*EXPORTED*/ NTSTATUS STDCALL
81 NtCreatePort (PHANDLE PortHandle
,
82 POBJECT_ATTRIBUTES ObjectAttributes
,
83 ULONG MaxConnectInfoLength
,
90 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes
->ObjectName
->Buffer
);
92 /* Verify parameters */
93 Status
= LpcpVerifyCreateParameters (PortHandle
,
98 if (STATUS_SUCCESS
!= Status
)
103 /* Ask Ob to create the object */
104 Status
= ObCreateObject (ExGetPreviousMode(),
113 if (!NT_SUCCESS(Status
))
118 Status
= ObInsertObject ((PVOID
)Port
,
124 if (!NT_SUCCESS(Status
))
126 ObDereferenceObject (Port
);
130 Status
= LpcpInitializePort (Port
, EPORT_TYPE_SERVER_RQST_PORT
, NULL
);
131 Port
->MaxConnectInfoLength
= LPC_MAX_DATA_LENGTH
;
132 Port
->MaxDataLength
= LPC_MAX_MESSAGE_LENGTH
;
133 Port
->MaxPoolUsage
= MaxPoolUsage
;
135 ObDereferenceObject (Port
);
140 /**********************************************************************
142 * NtCreateWaitablePort/5
145 * Waitable ports can be connected to with NtSecureConnectPort.
146 * No port interface can be used with waitable ports but
147 * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx.
148 * Present only in w2k+.
153 * MaxConnectInfoLength,
159 /*EXPORTED*/ NTSTATUS STDCALL
160 NtCreateWaitablePort (OUT PHANDLE PortHandle
,
161 IN POBJECT_ATTRIBUTES ObjectAttributes
,
162 IN ULONG MaxConnectInfoLength
,
163 IN ULONG MaxDataLength
,
164 IN ULONG MaxPoolUsage
)
168 /* Verify parameters */
169 Status
= LpcpVerifyCreateParameters (PortHandle
,
171 MaxConnectInfoLength
,
174 if (STATUS_SUCCESS
!= Status
)
179 return (STATUS_NOT_IMPLEMENTED
);