1 /* $Id: init.c 13449 2005-02-06 21:55:07Z ea $
3 * initss.c - Load the subsystems
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 * --------------------------------------------------------------------
30 #include <rosrtl/string.h>
35 /* TODO: this file should be totally rewritten
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
40 * b) make smss register with itself for IMAGE_SUBSYSTEM_NATIVE
43 * c) make smss load win32k.sys as set in Kmode key
44 * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
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
50 * e) make optional subsystems loadable (again: they must be described in the registry
51 * key Optional="Posix Os2" to be allowed to run)
54 /**********************************************************************
57 SmLoadSubsystems(VOID
)
59 SYSTEM_LOAD_AND_CALL_IMAGE ImageInfo
;
62 DPRINT("SM: loading subsystems\n");
64 /* Load kernel mode subsystem (aka win32k.sys) */
65 RtlRosInitUnicodeStringFromLiteral(&ImageInfo
.ModuleName
,
66 L
"\\SystemRoot\\system32\\win32k.sys");
68 Status
= NtSetSystemInformation(SystemLoadAndCallImage
,
70 sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
));
72 DPRINT("SMSS: Loaded win32k.sys (Status %lx)\n", Status
);
74 if (!NT_SUCCESS(Status
))
80 /* FIXME: load more subsystems (csrss!) */
89 UNICODE_STRING UnicodeString
;
90 OBJECT_ATTRIBUTES ObjectAttributes
;
91 RTL_PROCESS_INFO ProcessInfo
;
92 HANDLE CsrssInitEvent
;
93 WCHAR ImagePath
[MAX_PATH
];
95 DPRINT("SM: initializing csrss\n");
98 RtlRosInitUnicodeStringFromLiteral(&UnicodeString
,
100 InitializeObjectAttributes(&ObjectAttributes
,
105 Status
= NtCreateEvent(&CsrssInitEvent
,
110 if (!NT_SUCCESS(Status
))
112 DbgPrint("Failed to create csrss notification event\n");
116 * Start the Win32 subsystem (csrss.exe)
119 /* initialize executable path */
120 wcscpy(ImagePath
, L
"\\??\\");
121 wcscat(ImagePath
, SharedUserData
->NtSystemRoot
);
122 wcscat(ImagePath
, L
"\\system32\\csrss.exe");
124 Status
= SmCreateUserProcess(ImagePath
,
128 FALSE
, /* terminate */
131 if (!NT_SUCCESS(Status
))
133 DPRINT("SM: %s: Loading csrss.exe failed!\n", __FUNCTION__
);
137 Status
= NtWaitForSingleObject(CsrssInitEvent
,
141 Children
[CHILD_CSRSS
] = ProcessInfo
.ProcessHandle
;
149 NTSTATUS Status
= STATUS_SUCCESS
;
150 RTL_PROCESS_INFO ProcessInfo
;
151 WCHAR ImagePath
[MAX_PATH
];
154 * Start the logon process (winlogon.exe)
157 DPRINT("SM: starting winlogon\n");
159 /* initialize executable path */
160 wcscpy(ImagePath
, L
"\\??\\");
161 wcscat(ImagePath
, SharedUserData
->NtSystemRoot
);
162 wcscat(ImagePath
, L
"\\system32\\winlogon.exe");
164 Status
= SmCreateUserProcess(ImagePath
,
168 FALSE
, /* terminate */
170 if (!NT_SUCCESS(Status
))
172 DPRINT("SM: %s: Loading winlogon.exe failed!\n", __FUNCTION__
);
173 NtTerminateProcess(Children
[CHILD_CSRSS
], 0);
177 Children
[CHILD_WINLOGON
] = ProcessInfo
.ProcessHandle
;