-/* $Id: smss.c,v 1.5 2000/01/26 10:07:30 dwelch Exp $
+/* $Id: smss.c,v 1.15 2003/08/11 18:50:12 chorns Exp $
*
* smss.c - Session Manager
*
#include "smss.h"
+#define NDEBUG
+#include <debug.h>
+
void
-DisplayString( LPCWSTR lpwString )
+DisplayString(LPCWSTR lpwString)
{
- UNICODE_STRING us;
+ UNICODE_STRING us;
- RtlInitUnicodeString (&us, lpwString);
- NtDisplayString (&us);
+ RtlInitUnicodeString(&us, lpwString);
+ NtDisplayString(&us);
}
void
-PrintString (char* fmt,...)
+PrintString(char* fmt,...)
{
- char buffer[512];
- va_list ap;
- UNICODE_STRING UnicodeString;
- ANSI_STRING AnsiString;
- ULONG i;
-
- va_start(ap, fmt);
- vsprintf(buffer, fmt, ap);
- va_end(ap);
-
- RtlInitAnsiString (&AnsiString, buffer);
- RtlAnsiStringToUnicodeString (
- &UnicodeString,
- &AnsiString,
- TRUE);
- NtDisplayString(&UnicodeString);
- RtlFreeUnicodeString (&UnicodeString);
+ char buffer[512];
+ va_list ap;
+ UNICODE_STRING UnicodeString;
+ ANSI_STRING AnsiString;
+
+ va_start(ap, fmt);
+ vsprintf(buffer, fmt, ap);
+ va_end(ap);
+
+ RtlInitAnsiString(&AnsiString, buffer);
+ RtlAnsiStringToUnicodeString(&UnicodeString,
+ &AnsiString,
+ TRUE);
+ NtDisplayString(&UnicodeString);
+ RtlFreeUnicodeString(&UnicodeString);
}
/* Native image's entry point */
-void NtProcessStartup (PPEB Peb)
+VOID STDCALL
+NtProcessStartup(PPEB Peb)
{
- HANDLE Children[2]; /* csrss, winlogon */
-
- DisplayString( L"Session Manager\n" );
-
- PrintString ("Peb %x\n", Peb);
-
- if (TRUE == InitSessionManager(Children))
- {
- NTSTATUS wws;
-
- DisplayString( L"SM: Waiting for process termination...\n" );
-
-#if 0
- wws = NtWaitForMultipleObjects (
- ((LONG) sizeof Children / sizeof (HANDLE)),
- Children,
- WaitAny,
- TRUE, /* alertable */
- NULL /* NULL for infinite */
- );
-#endif
- wws = NtWaitForSingleObject (
- Children[CHILD_WINLOGON],
- TRUE, /* alertable */
- NULL
- );
-
-
- // if (!NT_SUCCESS(wws))
- if (wws > 1)
- {
- DisplayString( L"SM: NtWaitForMultipleObjects failed!\n" );
- /* FIXME: CRASH THE SYSTEM (BSOD) */
- }
- else
- {
- DisplayString( L"SM: Process terminated!\n" );
- /* FIXME: CRASH THE SYSTEM (BSOD) */
- }
- }
- else
- {
- DisplayString( L"SM: initialization failed!\n" );
- /* FIXME: CRASH SYSTEM (BSOD)*/
- }
-
-
- /*
- * OK: CSRSS asked to shutdown the system;
- * We die.
- */
-#if 0
- NtRaiseHardError (
- STATUS_SYSTEM_PROCESS_TERMINATED,
- ...);
-#endif
-
- NtTerminateProcess( NtCurrentProcess(), 0 );
+ HANDLE Children[2]; /* csrss, winlogon */
+ NTSTATUS Status;
+
+ Status = InitSessionManager(Children);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("SM: Initialization failed!\n");
+ goto ByeBye;
+ }
+
+ Status = NtWaitForMultipleObjects(((LONG) sizeof(Children) / sizeof(HANDLE)),
+ Children,
+ WaitAny,
+ TRUE, /* alertable */
+ NULL); /* NULL for infinite */
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("SM: NtWaitForMultipleObjects failed!\n");
+ }
+ else
+ {
+ DPRINT1("SM: Process terminated!\n");
+ }
+
+ByeBye:
+ /* Raise a hard error (crash the system/BSOD) */
+ NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
+ 0,0,0,0,0);
+
+// NtTerminateProcess(NtCurrentProcess(), 0);
}
/* EOF */