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