1 /* $Id: create.c,v 1.14 2003/12/30 18:52:05 fireball 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 STATIC NTSTATUS STDCALL
23 VerifyCreateParameters (IN PHANDLE PortHandle
,
24 IN POBJECT_ATTRIBUTES ObjectAttributes
,
25 IN ULONG MaxConnectInfoLength
,
26 IN ULONG MaxDataLength
,
29 if (NULL
== PortHandle
)
31 return (STATUS_INVALID_PARAMETER_1
);
33 if (NULL
== ObjectAttributes
)
35 return (STATUS_INVALID_PARAMETER_2
);
37 if ((ObjectAttributes
->Attributes
& OBJ_OPENLINK
)
38 || (ObjectAttributes
->Attributes
& OBJ_OPENIF
)
39 || (ObjectAttributes
->Attributes
& OBJ_EXCLUSIVE
)
40 || (ObjectAttributes
->Attributes
& OBJ_PERMANENT
)
41 || (ObjectAttributes
->Attributes
& OBJ_INHERIT
))
43 return (STATUS_INVALID_PORT_ATTRIBUTES
);
45 if (MaxConnectInfoLength
> 0x104) /* FIXME: use a macro! */
47 return (STATUS_INVALID_PARAMETER_3
);
49 if (MaxDataLength
> 0x148) /* FIXME: use a macro! */
51 return (STATUS_INVALID_PARAMETER_4
);
53 /* FIXME: some checking is done also on Reserved */
54 return (STATUS_SUCCESS
);
59 NiCreatePort (PVOID ObjectBody
,
62 POBJECT_ATTRIBUTES ObjectAttributes
)
64 if (RemainingPath
== NULL
)
66 return (STATUS_SUCCESS
);
69 if (wcschr(RemainingPath
+1, '\\') != NULL
)
71 return (STATUS_UNSUCCESSFUL
);
74 return (STATUS_SUCCESS
);
78 /**********************************************************************
87 * MaxConnectInfoLength,
93 /*EXPORTED*/ NTSTATUS STDCALL
94 NtCreatePort (PHANDLE PortHandle
,
95 POBJECT_ATTRIBUTES ObjectAttributes
,
96 ULONG MaxConnectInfoLength
,
103 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes
->ObjectName
->Buffer
);
105 /* Verify parameters */
106 Status
= VerifyCreateParameters (PortHandle
,
108 MaxConnectInfoLength
,
111 if (!NT_SUCCESS(Status
))
116 /* Ask Ob to create the object */
117 Status
= ObCreateObject (ExGetPreviousMode(),
126 if (!NT_SUCCESS(Status
))
131 Status
= ObInsertObject ((PVOID
)Port
,
137 if (!NT_SUCCESS(Status
))
139 ObDereferenceObject (Port
);
143 Status
= NiInitializePort (Port
);
144 Port
->MaxConnectInfoLength
= 260; /* FIXME: use a macro! */
145 Port
->MaxDataLength
= 328; /* FIXME: use a macro! */
147 ObDereferenceObject (Port
);
152 /**********************************************************************
154 * NtCreateWaitablePort@20
157 * Waitable ports can be connected to with NtSecureConnectPort.
158 * No port interface can be used with waitable ports but
159 * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx.
160 * Present only in w2k+.
165 * MaxConnectInfoLength,
171 /*EXPORTED*/ NTSTATUS STDCALL
172 NtCreateWaitablePort (OUT PHANDLE PortHandle
,
173 IN POBJECT_ATTRIBUTES ObjectAttributes
,
174 IN ULONG MaxConnectInfoLength
,
175 IN ULONG MaxDataLength
,
180 /* Verify parameters */
181 Status
= VerifyCreateParameters (PortHandle
,
183 MaxConnectInfoLength
,
186 if (STATUS_SUCCESS
!= Status
)
191 return (STATUS_NOT_IMPLEMENTED
);