Corrected additional object manager issues pointed by Philip Susi
[reactos.git] / reactos / subsys / csrss / init.c
1 /* $Id: init.c,v 1.3 1999/12/22 14:48:29 dwelch Exp $
2 *
3 * reactos/subsys/csrss/init.c
4 *
5 * Initialize the CSRSS subsystem server process.
6 *
7 * ReactOS Operating System
8 *
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 #include <ddk/ntddk.h>
14 #include <ntdll/rtl.h>
15 #include <csrss/csrss.h>
16
17 #include "api.h"
18
19 /* GLOBALS ******************************************************************/
20
21 /*
22 * Server's named ports.
23 */
24 static HANDLE ApiPortHandle;
25
26 #if 0
27 static HANDLE SbApiPortHandle;
28 #endif
29
30
31 #if 0
32 /**********************************************************************
33 * NAME
34 * Thread_SbApi
35 *
36 * DESCRIPTION
37 * Handle connection requests from clients to the port
38 * "\Windows\SbApiPort".
39 */
40 static
41 void
42 Thread_SbApi(void * pPort)
43 {
44 NTSTATUS Status;
45 HANDLE Port;
46 HANDLE ConnectedPort;
47
48 Port = * (HANDLE*) pPort;
49
50 Status = NtListenPort(
51 Port,
52 CSRSS_SBAPI_PORT_QUEUE_SIZE
53 );
54 if (!NT_SUCCESS(Status))
55 {
56 return;
57 }
58 /*
59 * Wait for a client to connect
60 */
61 while (TRUE)
62 {
63 Status = NtAcceptConnectPort(
64 Port,
65 & ConnectedPort
66 );
67 if (NT_SUCCESS(Status))
68 {
69 if (NT_SUCCESS(NtCompleteConnectPort(ConnectedPort)))
70 {
71 /* dispatch call */
72 continue;
73 }
74 /* error: Port.CompleteConnect failed */
75 continue;
76 }
77 /* error: Port.AcceptConnect failed */
78 }
79 }
80 #endif
81
82
83 /**********************************************************************
84 * NAME
85 * InitializeServer
86 *
87 * DESCRIPTION
88 * Create a directory object (\windows) and two named LPC ports:
89 *
90 * 1. \windows\ApiPort
91 * 2. \windows\SbApiPort
92 *
93 * RETURN VALUE
94 * TRUE: Initialization OK; otherwise FALSE.
95 */
96 BOOL InitializeServer(void)
97 {
98 NTSTATUS Status;
99 OBJECT_ATTRIBUTES ObAttributes;
100 UNICODE_STRING PortName;
101
102 /* NEW NAMED PORT: \ApiPort */
103 RtlInitUnicodeString(&PortName, L"\\ApiPort");
104 InitializeObjectAttributes(&ObAttributes,
105 &PortName,
106 0,
107 NULL,
108 NULL);
109 Status = NtCreatePort(&ApiPortHandle,
110 &ObAttributes,
111 260,
112 328,
113 0);
114 if (!NT_SUCCESS(Status))
115 {
116 DisplayString(L"Unable to create \\ApiPort (Status %x)\n");
117 return(FALSE);
118 }
119
120 Status = RtlCreateUserThread(NtCurrentProcess(),
121 NULL,
122 FALSE,
123 0,
124 NULL,
125 NULL,
126 (PTHREAD_START_ROUTINE)Thread_Api,
127 ApiPortHandle,
128 NULL,
129 NULL);
130 if (!NT_SUCCESS(Status))
131 {
132 DisplayString(L"Unable to create server thread\n");
133 NtClose(ApiPortHandle);
134 return FALSE;
135 }
136
137 #if 0
138 /* NEW NAMED PORT: \SbApiPort */
139 Status = NtCreatePort(
140 &Server.SbApi.Port,
141 & ObAttributes,
142 ...
143 );
144 if (!NT_SUCCESS(Status))
145 {
146 NtClose(Server.Api.Port);
147 return FALSE;
148 }
149 Status = NtCreateThread(
150 & Server.SbApi.Thread,
151 Thread_SbApi,
152 (void*) & Server.SbApi.Port
153 );
154 if (!NT_SUCCESS(Status))
155 {
156 NtClose(Server.Api.Port);
157 NtClose(Server.SbApi.Port);
158 return FALSE;
159 }
160 #endif
161
162 return TRUE;
163 }
164
165
166 /* EOF */