function list macro
[reactos.git] / reactos / ntoskrnl / lpc / create.c
1 /* $Id: create.c,v 1.14 2003/12/30 18:52:05 fireball Exp $
2 *
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)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #define NTOS_MODE_KERNEL
15 #include <ntos.h>
16 #include <internal/port.h>
17 #include <internal/dbg.h>
18
19 #define NDEBUG
20 #include <internal/debug.h>
21
22 STATIC NTSTATUS STDCALL
23 VerifyCreateParameters (IN PHANDLE PortHandle,
24 IN POBJECT_ATTRIBUTES ObjectAttributes,
25 IN ULONG MaxConnectInfoLength,
26 IN ULONG MaxDataLength,
27 IN ULONG Reserved)
28 {
29 if (NULL == PortHandle)
30 {
31 return (STATUS_INVALID_PARAMETER_1);
32 }
33 if (NULL == ObjectAttributes)
34 {
35 return (STATUS_INVALID_PARAMETER_2);
36 }
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))
42 {
43 return (STATUS_INVALID_PORT_ATTRIBUTES);
44 }
45 if (MaxConnectInfoLength > 0x104) /* FIXME: use a macro! */
46 {
47 return (STATUS_INVALID_PARAMETER_3);
48 }
49 if (MaxDataLength > 0x148) /* FIXME: use a macro! */
50 {
51 return (STATUS_INVALID_PARAMETER_4);
52 }
53 /* FIXME: some checking is done also on Reserved */
54 return (STATUS_SUCCESS);
55 }
56
57
58 NTSTATUS STDCALL
59 NiCreatePort (PVOID ObjectBody,
60 PVOID Parent,
61 PWSTR RemainingPath,
62 POBJECT_ATTRIBUTES ObjectAttributes)
63 {
64 if (RemainingPath == NULL)
65 {
66 return (STATUS_SUCCESS);
67 }
68
69 if (wcschr(RemainingPath+1, '\\') != NULL)
70 {
71 return (STATUS_UNSUCCESSFUL);
72 }
73
74 return (STATUS_SUCCESS);
75 }
76
77
78 /**********************************************************************
79 * NAME EXPORTED
80 * NtCreatePort@20
81 *
82 * DESCRIPTION
83 *
84 * ARGUMENTS
85 * PortHandle,
86 * ObjectAttributes,
87 * MaxConnectInfoLength,
88 * MaxDataLength,
89 * Reserved
90 *
91 * RETURN VALUE
92 */
93 /*EXPORTED*/ NTSTATUS STDCALL
94 NtCreatePort (PHANDLE PortHandle,
95 POBJECT_ATTRIBUTES ObjectAttributes,
96 ULONG MaxConnectInfoLength,
97 ULONG MaxDataLength,
98 ULONG Reserved)
99 {
100 PEPORT Port;
101 NTSTATUS Status;
102
103 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer);
104
105 /* Verify parameters */
106 Status = VerifyCreateParameters (PortHandle,
107 ObjectAttributes,
108 MaxConnectInfoLength,
109 MaxDataLength,
110 Reserved);
111 if (!NT_SUCCESS(Status))
112 {
113 return (Status);
114 }
115
116 /* Ask Ob to create the object */
117 Status = ObCreateObject (ExGetPreviousMode(),
118 ExPortType,
119 ObjectAttributes,
120 ExGetPreviousMode(),
121 NULL,
122 sizeof(EPORT),
123 0,
124 0,
125 (PVOID*)&Port);
126 if (!NT_SUCCESS(Status))
127 {
128 return (Status);
129 }
130
131 Status = ObInsertObject ((PVOID)Port,
132 NULL,
133 PORT_ALL_ACCESS,
134 0,
135 NULL,
136 PortHandle);
137 if (!NT_SUCCESS(Status))
138 {
139 ObDereferenceObject (Port);
140 return (Status);
141 }
142
143 Status = NiInitializePort (Port);
144 Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */
145 Port->MaxDataLength = 328; /* FIXME: use a macro! */
146
147 ObDereferenceObject (Port);
148
149 return (Status);
150 }
151
152 /**********************************************************************
153 * NAME EXPORTED
154 * NtCreateWaitablePort@20
155 *
156 * DESCRIPTION
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+.
161 *
162 * ARGUMENTS
163 * PortHandle,
164 * ObjectAttributes,
165 * MaxConnectInfoLength,
166 * MaxDataLength,
167 * Reserved
168 *
169 * RETURN VALUE
170 */
171 /*EXPORTED*/ NTSTATUS STDCALL
172 NtCreateWaitablePort (OUT PHANDLE PortHandle,
173 IN POBJECT_ATTRIBUTES ObjectAttributes,
174 IN ULONG MaxConnectInfoLength,
175 IN ULONG MaxDataLength,
176 IN ULONG Reserved)
177 {
178 NTSTATUS Status;
179
180 /* Verify parameters */
181 Status = VerifyCreateParameters (PortHandle,
182 ObjectAttributes,
183 MaxConnectInfoLength,
184 MaxDataLength,
185 Reserved);
186 if (STATUS_SUCCESS != Status)
187 {
188 return (Status);
189 }
190 /* TODO */
191 return (STATUS_NOT_IMPLEMENTED);
192 }
193
194 /* EOF */