German language file (minor update)
[reactos.git] / reactos / subsys / smss / initss.c
1 /* $Id: init.c 13449 2005-02-06 21:55:07Z ea $
2 *
3 * initss.c - Load the subsystems
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
27
28 #include "smss.h"
29
30 #include <rosrtl/string.h>
31
32 #define NDEBUG
33 #include <debug.h>
34
35 /* TODO: this file should be totally rewritten
36 *
37 * a) look if a special option is set for smss.exe in
38 * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
39 *
40 * b) make smss register with itself for IMAGE_SUBSYSTEM_NATIVE
41 * (programmatically)
42 *
43 * c) make smss load win32k.sys as set in Kmode key
44 * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
45 *
46 * d) make smss initialize Debug (DBGSS) and Windows (CSRSS) as described
47 * in the registry key Required="Debug Windows"
48 * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
49 *
50 * e) make optional subsystems loadable (again: they must be described in the registry
51 * key Optional="Posix Os2" to be allowed to run)
52 */
53
54 /**********************************************************************
55 */
56 NTSTATUS
57 SmLoadSubsystems(VOID)
58 {
59 SYSTEM_LOAD_AND_CALL_IMAGE ImageInfo;
60 NTSTATUS Status;
61
62 DPRINT("SM: loading subsystems\n");
63
64 /* Load kernel mode subsystem (aka win32k.sys) */
65 RtlRosInitUnicodeStringFromLiteral(&ImageInfo.ModuleName,
66 L"\\SystemRoot\\system32\\win32k.sys");
67
68 Status = NtSetSystemInformation(SystemLoadAndCallImage,
69 &ImageInfo,
70 sizeof(SYSTEM_LOAD_AND_CALL_IMAGE));
71
72 DPRINT("SMSS: Loaded win32k.sys (Status %lx)\n", Status);
73 #if 0
74 if (!NT_SUCCESS(Status))
75 {
76 return(Status);
77 }
78 #endif
79
80 /* FIXME: load more subsystems (csrss!) */
81
82 return(Status);
83 }
84
85 NTSTATUS
86 SmRunCsrss(VOID)
87 {
88 NTSTATUS Status;
89 UNICODE_STRING UnicodeString;
90 OBJECT_ATTRIBUTES ObjectAttributes;
91 RTL_PROCESS_INFO ProcessInfo;
92 HANDLE CsrssInitEvent;
93 WCHAR ImagePath [MAX_PATH];
94
95 DPRINT("SM: initializing csrss\n");
96
97 /* Run csrss.exe */
98 RtlRosInitUnicodeStringFromLiteral(&UnicodeString,
99 L"\\CsrssInitDone");
100 InitializeObjectAttributes(&ObjectAttributes,
101 &UnicodeString,
102 EVENT_ALL_ACCESS,
103 0,
104 NULL);
105 Status = NtCreateEvent(&CsrssInitEvent,
106 EVENT_ALL_ACCESS,
107 &ObjectAttributes,
108 NotificationEvent,
109 FALSE);
110 if (!NT_SUCCESS(Status))
111 {
112 DbgPrint("Failed to create csrss notification event\n");
113 }
114
115 /*
116 * Start the Win32 subsystem (csrss.exe)
117 */
118
119 /* initialize executable path */
120 wcscpy(ImagePath, L"\\??\\");
121 wcscat(ImagePath, SharedUserData->NtSystemRoot);
122 wcscat(ImagePath, L"\\system32\\csrss.exe");
123
124 Status = SmCreateUserProcess(ImagePath,
125 L"",
126 FALSE, /* wait */
127 NULL,
128 FALSE, /* terminate */
129 & ProcessInfo);
130
131 if (!NT_SUCCESS(Status))
132 {
133 DPRINT("SM: %s: Loading csrss.exe failed!\n", __FUNCTION__);
134 return(Status);
135 }
136
137 Status = NtWaitForSingleObject(CsrssInitEvent,
138 FALSE,
139 NULL);
140
141 Children[CHILD_CSRSS] = ProcessInfo.ProcessHandle;
142
143 return Status;
144 }
145
146 NTSTATUS
147 SmRunWinlogon(VOID)
148 {
149 NTSTATUS Status = STATUS_SUCCESS;
150 RTL_PROCESS_INFO ProcessInfo;
151 WCHAR ImagePath [MAX_PATH];
152
153 /*
154 * Start the logon process (winlogon.exe)
155 */
156
157 DPRINT("SM: starting winlogon\n");
158
159 /* initialize executable path */
160 wcscpy(ImagePath, L"\\??\\");
161 wcscat(ImagePath, SharedUserData->NtSystemRoot);
162 wcscat(ImagePath, L"\\system32\\winlogon.exe");
163
164 Status = SmCreateUserProcess(ImagePath,
165 L"",
166 FALSE, /* wait */
167 NULL,
168 FALSE, /* terminate */
169 & ProcessInfo);
170 if (!NT_SUCCESS(Status))
171 {
172 DPRINT("SM: %s: Loading winlogon.exe failed!\n", __FUNCTION__);
173 NtTerminateProcess(Children[CHILD_CSRSS], 0);
174 return(Status);
175 }
176
177 Children[CHILD_WINLOGON] = ProcessInfo.ProcessHandle;
178
179 return Status;
180 }
181
182 /* EOF */