f49085afaa040eef1543644b2fb890e4befb9eaf
[reactos.git] / reactos / subsys / smss / smss.c
1 /* $Id: smss.c,v 1.14 2002/10/25 22:08:20 chorns Exp $
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 * 19990529 (Emanuele Aliberti)
27 * Compiled successfully with egcs 1.1.2
28 */
29 #include <ddk/ntddk.h>
30
31 #include "smss.h"
32
33
34 void
35 DisplayString(LPCWSTR lpwString)
36 {
37 UNICODE_STRING us;
38
39 RtlInitUnicodeString(&us, lpwString);
40 NtDisplayString(&us);
41 }
42
43
44 void
45 PrintString(char* fmt,...)
46 {
47 char buffer[512];
48 va_list ap;
49 UNICODE_STRING UnicodeString;
50 ANSI_STRING AnsiString;
51
52 va_start(ap, fmt);
53 vsprintf(buffer, fmt, ap);
54 va_end(ap);
55
56 RtlInitAnsiString(&AnsiString, buffer);
57 RtlAnsiStringToUnicodeString(&UnicodeString,
58 &AnsiString,
59 TRUE);
60 NtDisplayString(&UnicodeString);
61 RtlFreeUnicodeString(&UnicodeString);
62 }
63
64
65 /* Native image's entry point */
66
67 VOID STDCALL
68 NtProcessStartup(PPEB Peb)
69 {
70 HANDLE Children[2]; /* csrss, winlogon */
71 NTSTATUS Status;
72
73 Status = InitSessionManager(Children);
74 if (!NT_SUCCESS(Status))
75 {
76 PrintString("SM: Initialization failed!\n");
77 goto ByeBye;
78 }
79
80 Status = NtWaitForMultipleObjects(((LONG) sizeof(Children) / sizeof(HANDLE)),
81 Children,
82 WaitAny,
83 TRUE, /* alertable */
84 NULL); /* NULL for infinite */
85 if (!NT_SUCCESS(Status))
86 {
87 PrintString("SM: NtWaitForMultipleObjects failed!\n");
88 }
89 else
90 {
91 PrintString("SM: Process terminated!\n");
92 }
93
94 ByeBye:
95 /* Raise a hard error (crash the system/BSOD) */
96 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
97 0,0,0,0,0);
98
99 // NtTerminateProcess(NtCurrentProcess(), 0);
100 }
101
102 /* EOF */