SM - clean, simplify, make more readable
[reactos.git] / reactos / subsys / smss / smss.c
1 /* $Id$
2 *
3 * smss.c - Session Manager
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 #include "smss.h"
27 //#include <ntdll/rtl.h>
28 #include <rosrtl/string.h>
29
30 #define NDEBUG
31 #include <debug.h>
32
33 /* Native image's entry point */
34
35 VOID STDCALL
36 NtProcessStartup(PPEB Peb)
37 {
38 NTSTATUS Status;
39
40 Status = InitSessionManager(Children);
41 if (!NT_SUCCESS(Status))
42 {
43 int i;
44 for (i=0; i < (sizeof Children / sizeof Children[0]); i++)
45 {
46 if (Children[i])
47 {
48 NtTerminateProcess(Children[i],0);
49 }
50 }
51 DPRINT1("SM: Initialization failed!\n");
52 goto ByeBye;
53 }
54
55 Status = NtWaitForMultipleObjects(((LONG) sizeof(Children) / sizeof(HANDLE)),
56 Children,
57 WaitAny,
58 TRUE, /* alertable */
59 NULL); /* NULL for infinite */
60 if (!NT_SUCCESS(Status))
61 {
62 DPRINT1("SM: NtWaitForMultipleObjects failed!\n");
63 }
64 else
65 {
66 DPRINT1("SM: Process terminated!\n");
67 }
68
69 ByeBye:
70 /* Raise a hard error (crash the system/BSOD) */
71 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
72 0,0,0,0,0);
73
74 // NtTerminateProcess(NtCurrentProcess(), 0);
75 }
76
77 /* EOF */