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