Fixed process parameters
[reactos.git] / reactos / subsys / smss / init.c
1 /* $Id: init.c,v 1.9 2000/01/11 17:32:13 ekohl Exp $
2 *
3 * init.c - Session Manager initialization
4 *
5 * ReactOS Operating System
6 *
7 * --------------------------------------------------------------------
8 *
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this software; see the file COPYING.LIB. If not, write
21 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
22 * MA 02139, USA.
23 *
24 * --------------------------------------------------------------------
25 *
26 * 19990530 (Emanuele Aliberti)
27 * Compiled successfully with egcs 1.1.2
28 */
29 #include <ddk/ntddk.h>
30 #include <ntdll/rtl.h>
31
32 #include "smss.h"
33
34 #define NDEBUG
35
36
37 /* GLOBAL VARIABLES *********************************************************/
38
39 HANDLE SmApiPort = INVALID_HANDLE_VALUE;
40 HANDLE DbgSsApiPort = INVALID_HANDLE_VALUE;
41 HANDLE DbgUiApiPort = INVALID_HANDLE_VALUE;
42
43 PVOID SmSystemEnvironment = NULL;
44
45
46 /* FUNCTIONS ****************************************************************/
47
48 #if 0
49 static VOID
50 SmCreatePagingFiles (VOID)
51 {
52 UNICODE_STRING FileName;
53 ULONG ulCurrentSize;
54
55 /* FIXME: Read file names from registry */
56
57 RtlInitUnicodeString (&FileName,
58 L"\\??\\C:\\reactos\\pagefile.sys");
59
60 NtCreatePagingFile (&FileName,
61 50,
62 80,
63 &ulCurrentSize);
64 }
65 #endif
66
67
68 BOOL
69 InitSessionManager (
70 HANDLE Children[]
71 )
72 {
73 NTSTATUS Status;
74 UNICODE_STRING UnicodeString;
75 OBJECT_ATTRIBUTES ObjectAttributes;
76 UNICODE_STRING CmdLineW;
77 PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
78
79
80 /* Create the "\SmApiPort" object (LPC) */
81 RtlInitUnicodeString (&UnicodeString,
82 L"\\SmApiPort");
83 InitializeObjectAttributes (&ObjectAttributes,
84 &UnicodeString,
85 0xff,
86 NULL,
87 NULL);
88
89 Status = NtCreatePort (&SmApiPort,
90 &ObjectAttributes,
91 0,
92 0,
93 0);
94
95 if (!NT_SUCCESS(Status))
96 {
97 return FALSE;
98 }
99
100 #ifndef NDEBUG
101 DisplayString (L"SM: \\SmApiPort created...\n");
102 #endif
103
104 /* Create two threads for "\SmApiPort" */
105 RtlCreateUserThread (NtCurrentProcess (),
106 NULL,
107 FALSE,
108 0,
109 NULL,
110 NULL,
111 (PTHREAD_START_ROUTINE)SmApiThread,
112 (PVOID)SmApiPort,
113 NULL,
114 NULL);
115
116 RtlCreateUserThread (NtCurrentProcess (),
117 NULL,
118 FALSE,
119 0,
120 NULL,
121 NULL,
122 (PTHREAD_START_ROUTINE)SmApiThread,
123 (PVOID)SmApiPort,
124 NULL,
125 NULL);
126
127 /* Create the system environment */
128 Status = RtlCreateEnvironment (TRUE,
129 &SmSystemEnvironment);
130 if (!NT_SUCCESS(Status))
131 return FALSE;
132 #ifndef NDEBUG
133 DisplayString (L"SM: System Environment created\n");
134 #endif
135
136 RtlSetCurrentEnvironment (SmSystemEnvironment,
137 NULL);
138 #ifndef NDEBUG
139 DisplayString (L"System Environment set\n");
140 #endif
141
142 /* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
143
144 /* FIXME: Run all programs in the boot execution list */
145
146 /* FIXME: Process the file rename list */
147
148 /* Create paging files */
149 #if 0
150 SmCreatePagingFiles ();
151 #endif
152
153 /* FIXME: Load the well known DLLs */
154
155 /* FIXME: Load missing registry hives */
156
157 /* FIXME: Set environment variables from registry */
158
159 /* Load the kernel mode driver win32k.sys */
160 #if 0
161 RtlInitUnicodeString (&CmdLineW,
162 L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
163 Status = NtLoadDriver (&CmdLineW);
164
165 if (!NT_SUCCESS(Status))
166 {
167 return FALSE;
168 }
169 #endif
170
171 #if 0
172 /* Start the Win32 subsystem (csrss.exe) */
173 DisplayString (L"SM: Executing csrss.exe\n");
174 RtlInitUnicodeString (&UnicodeString,
175 L"\\??\\C:\\reactos\\system32\\csrss.exe");
176
177 RtlCreateProcessParameters (&ProcessParameters,
178 &UnicodeString,
179 NULL,
180 NULL,
181 NULL,
182 NULL,
183 NULL,
184 NULL,
185 NULL,
186 NULL);
187
188 Status = RtlCreateUserProcess (&UnicodeString,
189 0,
190 ProcessParameters,
191 NULL,
192 NULL,
193 FALSE,
194 0,
195 NULL,
196 &Children[CHILD_CSRSS],
197 NULL);
198
199 if (!NT_SUCCESS(Status))
200 {
201 DisplayString (L"SM: Loading csrss.exe failed!\n");
202 return FALSE;
203 }
204
205 RtlDestroyProcessParameters (ProcessParameters);
206
207 #endif
208
209 /* Start the simple shell (shell.exe) */
210 DisplayString (L"SM: Executing shell\n");
211 RtlInitUnicodeString (&UnicodeString,
212 L"\\??\\C:\\reactos\\system32\\shell.exe");
213 #if 0
214 /* Start the logon process (winlogon.exe) */
215 RtlInitUnicodeString (&CmdLineW,
216 L"\\??\\C:\\reactos\\system32\\winlogon.exe");
217 #endif
218
219 RtlCreateProcessParameters (&ProcessParameters,
220 &UnicodeString,
221 NULL,
222 NULL,
223 NULL,
224 NULL,
225 NULL,
226 NULL,
227 NULL,
228 NULL);
229
230
231 Status = RtlCreateUserProcess (&UnicodeString,
232 0,
233 ProcessParameters,
234 NULL,
235 NULL,
236 FALSE,
237 0,
238 NULL,
239 &Children[CHILD_WINLOGON],
240 NULL);
241
242 RtlDestroyProcessParameters (ProcessParameters);
243
244 if (!NT_SUCCESS(Status))
245 {
246 DisplayString (L"SM: Loading shell.exe failed!\n");
247 #if 0
248 NtTerminateProcess (Children[CHILD_CSRSS],
249 0);
250 #endif
251 return FALSE;
252 }
253
254 /* Create the \DbgSsApiPort object (LPC) */
255 RtlInitUnicodeString (&UnicodeString,
256 L"\\DbgSsApiPort");
257 InitializeObjectAttributes (&ObjectAttributes,
258 &UnicodeString,
259 0xff,
260 NULL,
261 NULL);
262
263 Status = NtCreatePort (&DbgSsApiPort,
264 &ObjectAttributes,
265 0,
266 0,
267 0);
268
269 if (!NT_SUCCESS(Status))
270 {
271 return FALSE;
272 }
273 #ifndef NDEBUG
274 DisplayString (L"SM: DbgSsApiPort created...\n");
275 #endif
276
277 /* Create the \DbgUiApiPort object (LPC) */
278 RtlInitUnicodeString (&UnicodeString,
279 L"\\DbgUiApiPort");
280 InitializeObjectAttributes (&ObjectAttributes,
281 &UnicodeString,
282 0xff,
283 NULL,
284 NULL);
285
286 Status = NtCreatePort (&DbgUiApiPort,
287 &ObjectAttributes,
288 0,
289 0,
290 0);
291
292 if (!NT_SUCCESS(Status))
293 {
294 return FALSE;
295 }
296 #ifndef NDEBUG
297 DisplayString (L"SM: DbgUiApiPort created...\n");
298 #endif
299
300 return TRUE;
301 }
302
303 /* EOF */