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