1 /* $Id: init.c,v 1.9 2000/01/11 17:32:13 ekohl Exp $
3 * init.c - Session Manager initialization
5 * ReactOS Operating System
7 * --------------------------------------------------------------------
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.
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.
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,
24 * --------------------------------------------------------------------
26 * 19990530 (Emanuele Aliberti)
27 * Compiled successfully with egcs 1.1.2
29 #include <ddk/ntddk.h>
30 #include <ntdll/rtl.h>
37 /* GLOBAL VARIABLES *********************************************************/
39 HANDLE SmApiPort
= INVALID_HANDLE_VALUE
;
40 HANDLE DbgSsApiPort
= INVALID_HANDLE_VALUE
;
41 HANDLE DbgUiApiPort
= INVALID_HANDLE_VALUE
;
43 PVOID SmSystemEnvironment
= NULL
;
46 /* FUNCTIONS ****************************************************************/
50 SmCreatePagingFiles (VOID
)
52 UNICODE_STRING FileName
;
55 /* FIXME: Read file names from registry */
57 RtlInitUnicodeString (&FileName
,
58 L
"\\??\\C:\\reactos\\pagefile.sys");
60 NtCreatePagingFile (&FileName
,
74 UNICODE_STRING UnicodeString
;
75 OBJECT_ATTRIBUTES ObjectAttributes
;
76 UNICODE_STRING CmdLineW
;
77 PRTL_USER_PROCESS_PARAMETERS ProcessParameters
;
80 /* Create the "\SmApiPort" object (LPC) */
81 RtlInitUnicodeString (&UnicodeString
,
83 InitializeObjectAttributes (&ObjectAttributes
,
89 Status
= NtCreatePort (&SmApiPort
,
95 if (!NT_SUCCESS(Status
))
101 DisplayString (L
"SM: \\SmApiPort created...\n");
104 /* Create two threads for "\SmApiPort" */
105 RtlCreateUserThread (NtCurrentProcess (),
111 (PTHREAD_START_ROUTINE
)SmApiThread
,
116 RtlCreateUserThread (NtCurrentProcess (),
122 (PTHREAD_START_ROUTINE
)SmApiThread
,
127 /* Create the system environment */
128 Status
= RtlCreateEnvironment (TRUE
,
129 &SmSystemEnvironment
);
130 if (!NT_SUCCESS(Status
))
133 DisplayString (L
"SM: System Environment created\n");
136 RtlSetCurrentEnvironment (SmSystemEnvironment
,
139 DisplayString (L
"System Environment set\n");
142 /* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
144 /* FIXME: Run all programs in the boot execution list */
146 /* FIXME: Process the file rename list */
148 /* Create paging files */
150 SmCreatePagingFiles ();
153 /* FIXME: Load the well known DLLs */
155 /* FIXME: Load missing registry hives */
157 /* FIXME: Set environment variables from registry */
159 /* Load the kernel mode driver win32k.sys */
161 RtlInitUnicodeString (&CmdLineW
,
162 L
"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
163 Status
= NtLoadDriver (&CmdLineW
);
165 if (!NT_SUCCESS(Status
))
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");
177 RtlCreateProcessParameters (&ProcessParameters
,
188 Status
= RtlCreateUserProcess (&UnicodeString
,
196 &Children
[CHILD_CSRSS
],
199 if (!NT_SUCCESS(Status
))
201 DisplayString (L
"SM: Loading csrss.exe failed!\n");
205 RtlDestroyProcessParameters (ProcessParameters
);
209 /* Start the simple shell (shell.exe) */
210 DisplayString (L
"SM: Executing shell\n");
211 RtlInitUnicodeString (&UnicodeString
,
212 L
"\\??\\C:\\reactos\\system32\\shell.exe");
214 /* Start the logon process (winlogon.exe) */
215 RtlInitUnicodeString (&CmdLineW
,
216 L
"\\??\\C:\\reactos\\system32\\winlogon.exe");
219 RtlCreateProcessParameters (&ProcessParameters
,
231 Status
= RtlCreateUserProcess (&UnicodeString
,
239 &Children
[CHILD_WINLOGON
],
242 RtlDestroyProcessParameters (ProcessParameters
);
244 if (!NT_SUCCESS(Status
))
246 DisplayString (L
"SM: Loading shell.exe failed!\n");
248 NtTerminateProcess (Children
[CHILD_CSRSS
],
254 /* Create the \DbgSsApiPort object (LPC) */
255 RtlInitUnicodeString (&UnicodeString
,
257 InitializeObjectAttributes (&ObjectAttributes
,
263 Status
= NtCreatePort (&DbgSsApiPort
,
269 if (!NT_SUCCESS(Status
))
274 DisplayString (L
"SM: DbgSsApiPort created...\n");
277 /* Create the \DbgUiApiPort object (LPC) */
278 RtlInitUnicodeString (&UnicodeString
,
280 InitializeObjectAttributes (&ObjectAttributes
,
286 Status
= NtCreatePort (&DbgUiApiPort
,
292 if (!NT_SUCCESS(Status
))
297 DisplayString (L
"SM: DbgUiApiPort created...\n");