CSR Reloaded... well, split.
[reactos.git] / reactos / subsys / csr / main.c
1 /* $Id$
2 *
3 * main.c - Client/Server Runtime - entry point
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 * Library 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 * 19990417 (Emanuele Aliberti)
27 * Do nothing native application skeleton
28 * 19990528 (Emanuele Aliberti)
29 * Compiled successfully with egcs 1.1.2
30 * 19990605 (Emanuele Aliberti)
31 * First standalone run under ReactOS (it
32 * actually does nothing but running).
33 * 20050329 (Emanuele Aliberti)
34 * C/S run-time moved to CSRSRV.DLL
35 * Win32 emulation moved to server DLLs basesrv+winsrv
36 * (previously code was already in win32csr.dll)
37 */
38 #include "csr.h"
39
40 #define NDEBUG
41 #include <debug.h>
42
43 COMMAND_LINE_ARGUMENT Argument;
44
45 /* never fail or so */
46
47 VOID STDCALL CsrpSetDefaultProcessHardErrorMode (VOID)
48 {
49 DWORD DefaultHardErrorMode = 0;
50 NtSetInformationProcess (NtCurrentProcess(),
51 ProcessDefaultHardErrorMode,
52 & DefaultHardErrorMode,
53 sizeof DefaultHardErrorMode);
54 }
55
56 /* Native process' entry point */
57
58 VOID STDCALL NtProcessStartup (PPEB Peb)
59 {
60 NTSTATUS Status = STATUS_SUCCESS;
61
62 /*
63 * Parse the command line.
64 */
65 Status = CsrParseCommandLine (Peb, & Argument);
66 if (STATUS_SUCCESS != Status)
67 {
68 DPRINT1("CSR: %s: CsrParseCommandLine failed (Status=0x%08lx)\n",
69 __FUNCTION__, Status);
70 }
71 /*
72 * Initialize the environment subsystem server.
73 */
74 Status = CsrServerInitialization (Argument.Count, Argument.Vector);
75 if (!NT_SUCCESS(Status))
76 {
77 /* FATAL! */
78 DPRINT1("CSR: %s: CSRSRV!CsrServerInitialization failed (Status=0x%08lx)\n",
79 __FUNCTION__, Status);
80
81 CsrFreeCommandLine (Peb, & Argument);
82 /*
83 * Tell the SM we failed. If we are a required
84 * subsystem, SM will halt the system.
85 */
86 NtTerminateProcess (NtCurrentProcess(), Status);
87 }
88 /*
89 * The server booted OK: never stop on error!
90 */
91 CsrpSetDefaultProcessHardErrorMode ();
92 /*
93 * Cleanup command line
94 */
95 CsrFreeCommandLine (Peb, & Argument);
96 /*
97 * Terminate the current thread only (server's
98 * threads that serve the LPC port continue
99 * running and keep the process alive).
100 */
101 NtTerminateThread (NtCurrentThread(), Status);
102 }
103
104 /* EOF */