0258d7419eba0dde0770b2a70daac02f0f9efa44
[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 <reactos/buildno.h>
28
29 #define NDEBUG
30 #include <debug.h>
31
32 ULONG SmSsProcessId = 0;
33
34 /* Native image's entry point */
35
36 NTSTATUS __cdecl _main(int argc,
37 char *argv[],
38 char *envp[],
39 ULONG DebugFlag)
40 {
41 NTSTATUS Status = STATUS_SUCCESS;
42 PROCESS_BASIC_INFORMATION PBI = {0};
43
44 PrintString("ReactOS Session Manager (Build %s)\n",
45 KERNEL_VERSION_BUILD_STR);
46
47 /* Lookup yourself */
48 Status = NtQueryInformationProcess (NtCurrentProcess(),
49 ProcessBasicInformation,
50 & PBI,
51 sizeof PBI,
52 NULL);
53 if(NT_SUCCESS(Status))
54 {
55 SmSsProcessId = (ULONG) PBI.UniqueProcessId;
56 }
57 /* Initialize the system */
58 Status = InitSessionManager();
59 /* Watch required subsystems TODO */
60 #if 0
61 if (!NT_SUCCESS(Status))
62 {
63 int i;
64 for (i=0; i < (sizeof Children / sizeof Children[0]); i++)
65 {
66 if (Children[i])
67 {
68 NtTerminateProcess(Children[i],0);
69 }
70 }
71 DPRINT1("SM: Initialization failed!\n");
72 goto ByeBye;
73 }
74
75 Status = NtWaitForMultipleObjects(((LONG) sizeof(Children) / sizeof(HANDLE)),
76 Children,
77 WaitAny,
78 TRUE, /* alertable */
79 NULL); /* NULL for infinite */
80 if (!NT_SUCCESS(Status))
81 {
82 DPRINT1("SM: NtWaitForMultipleObjects failed! (Status=0x%08lx)\n", Status);
83 }
84 else
85 {
86 DPRINT1("SM: Process terminated!\n");
87 }
88
89 ByeBye:
90 /* Raise a hard error (crash the system/BSOD) */
91 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
92 0,0,0,0,0);
93
94 // NtTerminateProcess(NtCurrentProcess(), 0);
95 #endif
96 return NtTerminateThread(NtCurrentThread(), Status);
97 }
98
99 /* EOF */