- implemented process parameter block (PPB) code
[reactos.git] / reactos / subsys / smss / smss.c
1 /* $Id: smss.c,v 1.3 1999/12/06 00:25:14 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 ULONG i;
52
53 va_start(ap, fmt);
54 vsprintf(buffer, fmt, ap);
55 va_end(ap);
56
57 RtlInitAnsiString (&AnsiString, buffer);
58 RtlAnsiStringToUnicodeString (
59 &UnicodeString,
60 &AnsiString,
61 TRUE);
62 NtDisplayString(&UnicodeString);
63 RtlFreeUnicodeString (&UnicodeString);
64 }
65
66
67 /* Native image's entry point */
68
69 void
70 NtProcessStartup (PPEB Peb)
71 {
72 HANDLE Children[2]; /* csrss, winlogon */
73
74 DisplayString( L"Session Manager\n" );
75
76 PrintString ("Peb %x\n", Peb);
77
78 if (TRUE == InitSessionManager(Children))
79 {
80 LARGE_INTEGER Time = {{(DWORD)-1,(DWORD)-1}}; /* infinite? */
81 NTSTATUS wws;
82
83 DisplayString( L"SM: Waiting for process termination...\n" );
84
85 #if 0
86 wws = NtWaitForMultipleObjects (
87 ((LONG) sizeof Children / sizeof (HANDLE)),
88 Children,
89 WaitAny,
90 TRUE, /* alertable */
91 & Time
92 );
93 #endif
94 wws = NtWaitForSingleObject (
95 Children[CHILD_WINLOGON],
96 TRUE, /* alertable */
97 & Time
98 );
99
100
101 // if (!NT_SUCCESS(wws))
102 if (wws > 1)
103 {
104 DisplayString( L"SM: NtWaitForMultipleObjects failed!\n" );
105 /* FIXME: CRASH THE SYSTEM (BSOD) */
106 }
107 else
108 {
109 DisplayString( L"SM: Process terminated!\n" );
110 /* FIXME: CRASH THE SYSTEM (BSOD) */
111 }
112 }
113 else
114 {
115 DisplayString( L"SM: initialization failed!\n" );
116 /* FIXME: CRASH SYSTEM (BSOD)*/
117 }
118
119
120 /*
121 * OK: CSRSS asked to shutdown the system;
122 * We die.
123 */
124 #if 0
125 NtRaiseHardError (
126 STATUS_SYSTEM_PROCESS_TERMINATED,
127 ...);
128 #endif
129
130 NtTerminateProcess( NtCurrentProcess(), 0 );
131 }
132
133 /* EOF */