1 /* $Id: init.c,v 1.6 1999/12/06 00:25:14 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
;
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 */
160 RtlInitUnicodeString (&CmdLineW
,
161 L
"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
162 Status
= NtLoadDriver (&CmdLineW
);
164 if (!NT_SUCCESS(Status
))
169 /* Start the Win32 subsystem (csrss.exe) */
171 DisplayString (L
"SM: Executing csrss.exe\n");
172 RtlInitUnicodeString (&UnicodeString
,
173 L
"\\??\\C:\\reactos\\system32\\csrss.exe");
175 Status
= RtlCreateUserProcess (&UnicodeString
,
181 &Children
[CHILD_CSRSS
],
184 if (!NT_SUCCESS(Status
))
186 DisplayString (L
"SM: Loading csrss.exe failed!\n");
191 /* Start the simple shell (shell.exe) */
192 DisplayString (L
"SM: Executing shell\n");
193 RtlInitUnicodeString (&UnicodeString
,
194 L
"\\??\\C:\\reactos\\system32\\shell.exe");
196 /* Start the logon process (winlogon.exe) */
197 RtlInitUnicodeString (&CmdLineW
,
198 L
"\\??\\C:\\reactos\\system32\\winlogon.exe");
201 RtlCreateProcessParameters (&Ppb
,
213 Status
= RtlCreateUserProcess (&UnicodeString
,
221 &Children
[CHILD_WINLOGON
],
224 RtlDestroyProcessParameters (Ppb
);
226 if (!NT_SUCCESS(Status
))
228 DisplayString (L
"SM: Loading shell.exe failed!\n");
230 NtTerminateProcess (Children
[CHILD_CSRSS
],
236 /* Create the \DbgSsApiPort object (LPC) */
237 RtlInitUnicodeString (&UnicodeString
,
239 InitializeObjectAttributes (&ObjectAttributes
,
245 Status
= NtCreatePort (&DbgSsApiPort
,
251 if (!NT_SUCCESS(Status
))
256 DisplayString (L
"SM: DbgSsApiPort created...\n");
259 /* Create the \DbgUiApiPort object (LPC) */
260 RtlInitUnicodeString (&UnicodeString
,
262 InitializeObjectAttributes (&ObjectAttributes
,
268 Status
= NtCreatePort (&DbgUiApiPort
,
274 if (!NT_SUCCESS(Status
))
279 DisplayString (L
"SM: DbgUiApiPort created...\n");