1ffb5fc1d51e2c1bca129302595a543d2c8e01a5
[reactos.git] / reactos / ntoskrnl / lpc / create.c
1 /* $Id: create.c,v 1.2 2000/10/22 16:36:51 ekohl 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 #include <ddk/ntddk.h>
15 #include <internal/ob.h>
16 #include <internal/port.h>
17 #include <internal/dbg.h>
18
19 #define NDEBUG
20 #include <internal/debug.h>
21
22
23 NTSTATUS
24 NiCreatePort (
25 PVOID ObjectBody,
26 PVOID Parent,
27 PWSTR RemainingPath,
28 POBJECT_ATTRIBUTES ObjectAttributes
29 )
30 {
31 NTSTATUS Status;
32
33 if (RemainingPath == NULL)
34 {
35 return (STATUS_SUCCESS);
36 }
37
38 if (wcschr(RemainingPath+1, '\\') != NULL)
39 {
40 return (STATUS_UNSUCCESSFUL);
41 }
42
43 Status = ObReferenceObjectByPointer (
44 Parent,
45 STANDARD_RIGHTS_REQUIRED,
46 ObDirectoryType,
47 UserMode
48 );
49 if (!NT_SUCCESS(Status))
50 {
51 return (Status);
52 }
53
54 ObAddEntryDirectory (
55 Parent,
56 ObjectBody,
57 (RemainingPath + 1)
58 );
59 ObDereferenceObject (Parent);
60
61 return (STATUS_SUCCESS);
62 }
63
64
65 EXPORTED
66 NTSTATUS
67 STDCALL
68 NtCreatePort (
69 PHANDLE PortHandle,
70 POBJECT_ATTRIBUTES ObjectAttributes,
71 ULONG MaxConnectInfoLength,
72 ULONG MaxDataLength,
73 ULONG Reserved
74 )
75 {
76 PEPORT Port;
77 NTSTATUS Status;
78
79 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer);
80
81 Port = ObCreateObject (
82 PortHandle,
83 PORT_ALL_ACCESS,
84 ObjectAttributes,
85 ExPortType
86 );
87 if (Port == NULL)
88 {
89 return (STATUS_UNSUCCESSFUL);
90 }
91
92 Status = NiInitializePort (Port);
93 Port->MaxConnectInfoLength = 260;
94 Port->MaxDataLength = 328;
95
96 ObDereferenceObject (Port);
97
98 return (Status);
99 }
100
101
102 /* EOF */