- added environment functions
[reactos.git] / reactos / subsys / smss / init.c
1 /* $Id: init.c,v 1.4 1999/12/01 15:18:54 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
78 /* Create the "\SmApiPort" object (LPC) */
79 RtlInitUnicodeString (&UnicodeString,
80 L"\\SmApiPort");
81 InitializeObjectAttributes (&ObjectAttributes,
82 &UnicodeString,
83 0xff,
84 NULL,
85 NULL);
86
87 Status = NtCreatePort (&SmApiPort,
88 0,
89 &ObjectAttributes,
90 0,
91 0);
92
93 if (!NT_SUCCESS(Status))
94 {
95 return FALSE;
96 }
97
98 #ifndef NDEBUG
99 DisplayString (L"SmApiPort created...\n");
100 #endif
101
102 /* Create two threads for "\SmApiPort" */
103 RtlCreateUserThread (NtCurrentProcess (),
104 NULL,
105 FALSE,
106 0,
107 NULL,
108 NULL,
109 (PTHREAD_START_ROUTINE)SmApiThread,
110 (PVOID)SmApiPort,
111 NULL,
112 NULL);
113
114 RtlCreateUserThread (NtCurrentProcess (),
115 NULL,
116 FALSE,
117 0,
118 NULL,
119 NULL,
120 (PTHREAD_START_ROUTINE)SmApiThread,
121 (PVOID)SmApiPort,
122 NULL,
123 NULL);
124
125 /* Create the system environment */
126 Status = RtlCreateEnvironment (TRUE,
127 &SmSystemEnvironment);
128 if (!NT_SUCCESS(Status))
129 return FALSE;
130 #ifndef NDEBUG
131 DisplayString (L"System Environment created\n");
132 #endif
133
134 /* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
135
136 /* FIXME: Run all programs in the boot execution list */
137
138 /* FIXME: Process the file rename list */
139
140 /* Create paging files */
141 #if 0
142 SmCreatePagingFiles ();
143 #endif
144
145 /* FIXME: Load the well known DLLs */
146
147 /* FIXME: Load missing registry hives */
148
149 /* FIXME: Set environment variables from registry */
150
151 /* Load the kernel mode driver win32k.sys */
152 RtlInitUnicodeString (&CmdLineW,
153 L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
154 Status = NtLoadDriver (&CmdLineW);
155
156 if (!NT_SUCCESS(Status))
157 {
158 return FALSE;
159 }
160
161 /* Start the Win32 subsystem (csrss.exe) */
162 #if 0
163 DisplayString (L"Executing csrss.exe\n");
164 RtlInitUnicodeString (&UnicodeString,
165 L"\\??\\C:\\reactos\\system32\\csrss.exe");
166
167 Status = RtlCreateUserProcess (&UnicodeString,
168 NULL,
169 NULL,
170 FALSE,
171 0,
172 NULL,
173 &Children[CHILD_CSRSS],
174 NULL);
175
176 if (!NT_SUCCESS(Status))
177 {
178 DisplayString (L"Loading csrss.exe failed!\n");
179 return FALSE;
180 }
181 #endif
182
183 /* Start the simple shell (shell.exe) */
184 DisplayString (L"Executing shell\n");
185 RtlInitUnicodeString (&UnicodeString,
186 L"\\??\\C:\\reactos\\system32\\shell.exe");
187
188 #if 0
189 /* Start the logon process (winlogon.exe) */
190 RtlInitUnicodeString (&CmdLineW,
191 L"\\??\\C:\\reactos\\system32\\winlogon.exe");
192 #endif
193 Status = RtlCreateUserProcess (&UnicodeString,
194 NULL,
195 NULL,
196 FALSE,
197 0,
198 NULL,
199 &Children[CHILD_WINLOGON],
200 NULL);
201
202 if (!NT_SUCCESS(Status))
203 {
204 DisplayString (L"Loading shell.exe failed!\n");
205 #if 0
206 NtTerminateProcess (Children[CHILD_CSRSS],
207 0);
208 #endif
209 return FALSE;
210 }
211
212 /* Create the \DbgSsApiPort object (LPC) */
213 RtlInitUnicodeString (&UnicodeString,
214 L"\\DbgSsApiPort");
215 InitializeObjectAttributes (&ObjectAttributes,
216 &UnicodeString,
217 0xff,
218 NULL,
219 NULL);
220
221 Status = NtCreatePort (&DbgSsApiPort,
222 0,
223 &ObjectAttributes,
224 0,
225 0);
226
227 if (!NT_SUCCESS(Status))
228 {
229 return FALSE;
230 }
231 #ifndef NDEBUG
232 DisplayString (L"DbgSsApiPort created...\n");
233 #endif
234
235 /* Create the \DbgUiApiPort object (LPC) */
236 RtlInitUnicodeString (&UnicodeString,
237 L"\\DbgUiApiPort");
238 InitializeObjectAttributes (&ObjectAttributes,
239 &UnicodeString,
240 0xff,
241 NULL,
242 NULL);
243
244 Status = NtCreatePort (&DbgUiApiPort,
245 0,
246 &ObjectAttributes,
247 0,
248 0);
249
250 if (!NT_SUCCESS(Status))
251 {
252 return FALSE;
253 }
254 #ifndef NDEBUG
255 DisplayString (L"DbgUiApiPort created...\n");
256 #endif
257
258 return TRUE;
259 }
260
261 /* EOF */