c488521a7b72764641f4ba37fdaf5b80430ce3d9
[reactos.git] / reactos / subsys / csr / main.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS CSR Sub System
4 * FILE: subsys/csr/csrss.c
5 * PURPOSE: CSR Executable
6 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <windows.h>
12 #define NTOS_MODE_USER
13 #include <ndk/ntndk.h>
14
15 #define NDEBUG
16 #include <debug.h>
17
18 /* PRIVATE FUNCTIONS *********************************************************/
19
20 VOID
21 NTAPI
22 CsrpSetDefaultProcessHardErrorMode (VOID)
23 {
24 ULONG DefaultHardErrorMode = 0;
25
26 /* Disable hard errors */
27 NtSetInformationProcess(NtCurrentProcess(),
28 ProcessDefaultHardErrorMode,
29 &DefaultHardErrorMode,
30 sizeof(DefaultHardErrorMode);
31 }
32
33 int
34 _cdecl
35 main(int argc,
36 char *argv[],
37 char *envp[],
38 int DebugFlag)
39 {
40 KPRIORITY BasePriority = (8 + 1) + 4;
41 NTSTATUS Status;
42 ULONG Response;
43
44 /* Set the Priority */
45 NtSetInformationProcess(NtCurrentProcess(),
46 ProcessBasePriority,
47 &BasePriority,
48 sizeof(KPRIORITY));
49
50 /* Give us IOPL so that we can access the VGA registers */
51 Status = NtSetInformationProcess(NtCurrentProcess(),
52 ProcessUserModeIOPL,
53 NULL,
54 0);
55 if (NT_SUCCESS(Status))
56 {
57 /* Raise a hard error */
58 DPRINT1("CSRSS: Could not raise IOPL: %x\n", Status);
59 Status = NtRaiseHardError(STATUS_IO_PRIVILEGE_FAILED,
60 0,
61 0,
62 NULL,
63 OptionOk,
64 &Response);
65 }
66
67 /* Initialize CSR through CSRSRV */
68 Status = CsrServerInitialization(argc, argv);
69 if (!NT_SUCCESS(Status))
70 {
71 /* Kill us */
72 DPRINT1("CSRSS: CsrServerInitialization failed:% lx\n", Status);
73 NtTerminateProcess (NtCurrentProcess(), Status);
74 }
75
76 /* Disable errors */
77 CsrpSetDefaultProcessHardErrorMode();
78
79 /* If this is Session 0, make sure killing us bugchecks the system */
80 if (!NtCurrentPeb()->SessionId) RtlSetProcessIsCritical(TRUE, NULL, FALSE);
81
82 /* Kill this thread. CSRSRV keeps us going */
83 NtTerminateThread (NtCurrentThread(), Status);
84 return 0;
85 }
86
87 /* EOF */