Minor update
[reactos.git] / reactos / subsys / smss / smss.c
1 /* $Id: smss.c,v 1.8 2000/10/09 00:18:00 ekohl 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 (
58 &UnicodeString,
59 &AnsiString,
60 TRUE);
61 NtDisplayString(&UnicodeString);
62 RtlFreeUnicodeString (&UnicodeString);
63 }
64
65
66 /* Native image's entry point */
67
68 void NtProcessStartup (PPEB Peb)
69 {
70 HANDLE Children[2]; /* csrss, winlogon */
71
72 DisplayString( L"Session Manager\n" );
73
74 if (TRUE == InitSessionManager(Children))
75 {
76 NTSTATUS wws;
77
78 DisplayString( L"SM: Waiting for process termination...\n" );
79
80 #if 0
81 wws = NtWaitForMultipleObjects (
82 ((LONG) sizeof Children / sizeof (HANDLE)),
83 Children,
84 WaitAny,
85 TRUE, /* alertable */
86 NULL /* NULL for infinite */
87 );
88 #endif
89 wws = NtWaitForSingleObject (
90 Children[CHILD_WINLOGON],
91 TRUE, /* alertable */
92 NULL
93 );
94
95 // if (!NT_SUCCESS(wws))
96 if (wws > 1)
97 {
98 DisplayString( L"SM: NtWaitForMultipleObjects failed!\n" );
99 }
100 else
101 {
102 DisplayString( L"SM: Process terminated!\n" );
103 }
104 }
105 else
106 {
107 DisplayString( L"SM: Initialization failed!\n" );
108 }
109
110 /* Raise a hard error (crash the system/BSOD) */
111 NtRaiseHardError (STATUS_SYSTEM_PROCESS_TERMINATED,
112 0,0,0,0,0);
113
114 // NtTerminateProcess(NtCurrentProcess(), 0);
115 }
116
117 /* EOF */