/* $Id$
- *
- * main.c - Client/Server Runtime - entry point
- *
- * ReactOS Operating System
- *
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* MA 02139, USA.
*
* --------------------------------------------------------------------
- *
- * 19990417 (Emanuele Aliberti)
- * Do nothing native application skeleton
- * 19990528 (Emanuele Aliberti)
- * Compiled successfully with egcs 1.1.2
- * 19990605 (Emanuele Aliberti)
- * First standalone run under ReactOS (it
- * actually does nothing but running).
- * 20050329 (Emanuele Aliberti)
- * C/S run-time moved to CSRSRV.DLL
- * Win32 emulation moved to server DLLs basesrv+winsrv
- * (previously code was already in win32csr.dll)
*/
-#include "csr.h"
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS CSR Sub System
+ * FILE: subsys/csr/csrss.c
+ * PURPOSE: CSR Executable
+ * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <windows.h>
+#define NTOS_MODE_USER
+#include <ndk/ntndk.h>
#define NDEBUG
#include <debug.h>
-COMMAND_LINE_ARGUMENT Argument;
-
-/* never fail or so */
+/* PRIVATE FUNCTIONS *********************************************************/
-VOID STDCALL CsrpSetDefaultProcessHardErrorMode (VOID)
+VOID
+NTAPI
+CsrpSetDefaultProcessHardErrorMode (VOID)
{
- DWORD DefaultHardErrorMode = 0;
- NtSetInformationProcess (NtCurrentProcess(),
- ProcessDefaultHardErrorMode,
- & DefaultHardErrorMode,
- sizeof DefaultHardErrorMode);
-}
+ ULONG DefaultHardErrorMode = 0;
-/* Native process' entry point */
+ /* Disable hard errors */
+ NtSetInformationProcess(NtCurrentProcess(),
+ ProcessDefaultHardErrorMode,
+ &DefaultHardErrorMode,
+ sizeof(DefaultHardErrorMode));
+}
-VOID STDCALL NtProcessStartup (PPEB Peb)
+int
+_cdecl
+main(int argc,
+ char *argv[],
+ char *envp[],
+ int DebugFlag)
{
- NTSTATUS Status = STATUS_SUCCESS;
+ KPRIORITY BasePriority = (8 + 1) + 4;
+ NTSTATUS Status;
+ ULONG Response;
+
+ /* Set the Priority */
+ NtSetInformationProcess(NtCurrentProcess(),
+ ProcessBasePriority,
+ &BasePriority,
+ sizeof(KPRIORITY));
+
+ /* Give us IOPL so that we can access the VGA registers */
+ Status = NtSetInformationProcess(NtCurrentProcess(),
+ ProcessUserModeIOPL,
+ NULL,
+ 0);
+ if (NT_SUCCESS(Status))
+ {
+ /* Raise a hard error */
+ DPRINT1("CSRSS: Could not raise IOPL: %x\n", Status);
+ Status = NtRaiseHardError(STATUS_IO_PRIVILEGE_FAILED,
+ 0,
+ 0,
+ NULL,
+ OptionOk,
+ &Response);
+ }
+
+ /* Initialize CSR through CSRSRV */
+ Status = CsrServerInitialization(argc, argv);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Kill us */
+ DPRINT1("CSRSS: CsrServerInitialization failed:% lx\n", Status);
+ NtTerminateProcess (NtCurrentProcess(), Status);
+ }
+
+ /* Disable errors */
+ CsrpSetDefaultProcessHardErrorMode();
- /*
- * Parse the command line.
- */
- Status = CsrParseCommandLine (Peb, & Argument);
- if (STATUS_SUCCESS != Status)
- {
- DPRINT1("CSR: %s: CsrParseCommandLine failed (Status=0x%08lx)\n",
- __FUNCTION__, Status);
- }
- /*
- * Initialize the environment subsystem server.
- */
- Status = CsrServerInitialization (Argument.Count, Argument.Vector);
- if (!NT_SUCCESS(Status))
- {
- /* FATAL! */
- DPRINT1("CSR: %s: CSRSRV!CsrServerInitialization failed (Status=0x%08lx)\n",
- __FUNCTION__, Status);
+ /* If this is Session 0, make sure killing us bugchecks the system */
+ if (!NtCurrentPeb()->SessionId) RtlSetProcessIsCritical(TRUE, NULL, FALSE);
- CsrFreeCommandLine (Peb, & Argument);
- /*
- * Tell the SM we failed. If we are a required
- * subsystem, SM will halt the system.
- */
- NtTerminateProcess (NtCurrentProcess(), Status);
- }
- /*
- * The server booted OK: never stop on error!
- */
- CsrpSetDefaultProcessHardErrorMode ();
- /*
- * Cleanup command line
- */
- CsrFreeCommandLine (Peb, & Argument);
- /*
- * Terminate the current thread only (server's
- * threads that serve the LPC port continue
- * running and keep the process alive).
- */
- NtTerminateThread (NtCurrentThread(), Status);
+ /* Kill this thread. CSRSRV keeps us going */
+ NtTerminateThread (NtCurrentThread(), Status);
+ return 0;
}
/* EOF */