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