- add copyright notice
[reactos.git] / reactos / subsys / csr / main.c
1 /* $Id$
2 * --------------------------------------------------------------------
3 *
4 * This software is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; see the file COPYING.LIB. If not, write
16 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
17 * MA 02139, USA.
18 *
19 * --------------------------------------------------------------------
20 */
21 /*
22 * COPYRIGHT: See COPYING in the top level directory
23 * PROJECT: ReactOS CSR Sub System
24 * FILE: subsys/csr/csrss.c
25 * PURPOSE: CSR Executable
26 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
27 */
28
29 /* INCLUDES ******************************************************************/
30
31 #include <windows.h>
32 #define NTOS_MODE_USER
33 #include <ndk/ntndk.h>
34
35 #define NDEBUG
36 #include <debug.h>
37
38 /* PRIVATE FUNCTIONS *********************************************************/
39
40 VOID
41 NTAPI
42 CsrpSetDefaultProcessHardErrorMode (VOID)
43 {
44 ULONG DefaultHardErrorMode = 0;
45
46 /* Disable hard errors */
47 NtSetInformationProcess(NtCurrentProcess(),
48 ProcessDefaultHardErrorMode,
49 &DefaultHardErrorMode,
50 sizeof(DefaultHardErrorMode));
51 }
52
53 int
54 _cdecl
55 main(int argc,
56 char *argv[],
57 char *envp[],
58 int DebugFlag)
59 {
60 KPRIORITY BasePriority = (8 + 1) + 4;
61 NTSTATUS Status;
62 ULONG Response;
63
64 /* Set the Priority */
65 NtSetInformationProcess(NtCurrentProcess(),
66 ProcessBasePriority,
67 &BasePriority,
68 sizeof(KPRIORITY));
69
70 /* Give us IOPL so that we can access the VGA registers */
71 Status = NtSetInformationProcess(NtCurrentProcess(),
72 ProcessUserModeIOPL,
73 NULL,
74 0);
75 if (NT_SUCCESS(Status))
76 {
77 /* Raise a hard error */
78 DPRINT1("CSRSS: Could not raise IOPL: %x\n", Status);
79 Status = NtRaiseHardError(STATUS_IO_PRIVILEGE_FAILED,
80 0,
81 0,
82 NULL,
83 OptionOk,
84 &Response);
85 }
86
87 /* Initialize CSR through CSRSRV */
88 Status = CsrServerInitialization(argc, argv);
89 if (!NT_SUCCESS(Status))
90 {
91 /* Kill us */
92 DPRINT1("CSRSS: CsrServerInitialization failed:% lx\n", Status);
93 NtTerminateProcess (NtCurrentProcess(), Status);
94 }
95
96 /* Disable errors */
97 CsrpSetDefaultProcessHardErrorMode();
98
99 /* If this is Session 0, make sure killing us bugchecks the system */
100 if (!NtCurrentPeb()->SessionId) RtlSetProcessIsCritical(TRUE, NULL, FALSE);
101
102 /* Kill this thread. CSRSRV keeps us going */
103 NtTerminateThread (NtCurrentThread(), Status);
104 return 0;
105 }
106
107 /* EOF */