- implemented process parameter block (PPB) code
[reactos.git] / reactos / subsys / smss / init.c
1 /* $Id: init.c,v 1.6 1999/12/06 00:25:14 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 PPPB Ppb;
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 0,
91 &ObjectAttributes,
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 RtlInitUnicodeString (&CmdLineW,
161 L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
162 Status = NtLoadDriver (&CmdLineW);
163
164 if (!NT_SUCCESS(Status))
165 {
166 return FALSE;
167 }
168
169 /* Start the Win32 subsystem (csrss.exe) */
170 #if 0
171 DisplayString (L"SM: Executing csrss.exe\n");
172 RtlInitUnicodeString (&UnicodeString,
173 L"\\??\\C:\\reactos\\system32\\csrss.exe");
174
175 Status = RtlCreateUserProcess (&UnicodeString,
176 NULL,
177 NULL,
178 FALSE,
179 0,
180 NULL,
181 &Children[CHILD_CSRSS],
182 NULL);
183
184 if (!NT_SUCCESS(Status))
185 {
186 DisplayString (L"SM: Loading csrss.exe failed!\n");
187 return FALSE;
188 }
189 #endif
190
191 /* Start the simple shell (shell.exe) */
192 DisplayString (L"SM: Executing shell\n");
193 RtlInitUnicodeString (&UnicodeString,
194 L"\\??\\C:\\reactos\\system32\\shell.exe");
195 #if 0
196 /* Start the logon process (winlogon.exe) */
197 RtlInitUnicodeString (&CmdLineW,
198 L"\\??\\C:\\reactos\\system32\\winlogon.exe");
199 #endif
200
201 RtlCreateProcessParameters (&Ppb,
202 &UnicodeString,
203 NULL,
204 NULL,
205 NULL,
206 NULL,
207 NULL,
208 NULL,
209 NULL,
210 NULL);
211
212
213 Status = RtlCreateUserProcess (&UnicodeString,
214 0,
215 Ppb,
216 NULL,
217 NULL,
218 FALSE,
219 0,
220 NULL,
221 &Children[CHILD_WINLOGON],
222 NULL);
223
224 RtlDestroyProcessParameters (Ppb);
225
226 if (!NT_SUCCESS(Status))
227 {
228 DisplayString (L"SM: Loading shell.exe failed!\n");
229 #if 0
230 NtTerminateProcess (Children[CHILD_CSRSS],
231 0);
232 #endif
233 return FALSE;
234 }
235
236 /* Create the \DbgSsApiPort object (LPC) */
237 RtlInitUnicodeString (&UnicodeString,
238 L"\\DbgSsApiPort");
239 InitializeObjectAttributes (&ObjectAttributes,
240 &UnicodeString,
241 0xff,
242 NULL,
243 NULL);
244
245 Status = NtCreatePort (&DbgSsApiPort,
246 0,
247 &ObjectAttributes,
248 0,
249 0);
250
251 if (!NT_SUCCESS(Status))
252 {
253 return FALSE;
254 }
255 #ifndef NDEBUG
256 DisplayString (L"SM: DbgSsApiPort created...\n");
257 #endif
258
259 /* Create the \DbgUiApiPort object (LPC) */
260 RtlInitUnicodeString (&UnicodeString,
261 L"\\DbgUiApiPort");
262 InitializeObjectAttributes (&ObjectAttributes,
263 &UnicodeString,
264 0xff,
265 NULL,
266 NULL);
267
268 Status = NtCreatePort (&DbgUiApiPort,
269 0,
270 &ObjectAttributes,
271 0,
272 0);
273
274 if (!NT_SUCCESS(Status))
275 {
276 return FALSE;
277 }
278 #ifndef NDEBUG
279 DisplayString (L"SM: DbgUiApiPort created...\n");
280 #endif
281
282 return TRUE;
283 }
284
285 /* EOF */