1 /* 2 * LICENSE: BSD - See COPYING.ARM in root directory 3 * PROJECT: ReactOS Client/Server Runtime SubSystem 4 * FILE: subsystems/win32/csrss/csrss.c 5 * PURPOSE: CSRSS Process Main Executable Code 6 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) 7 * ReactOS Portable Systems Group 8 */ 9 10 /* INCLUDES *******************************************************************/ 11 12 #define NTOS_MODE_USER 13 #include <ndk/exfuncs.h> 14 #include <ndk/psfuncs.h> 15 #include <ndk/rtlfuncs.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 = PROCESS_PRIORITY_NORMAL_FOREGROUND + 4; 45 NTSTATUS Status; 46 #if defined (_X86_) 47 ULONG Response; 48 #endif 49 UNREFERENCED_PARAMETER(envp); 50 UNREFERENCED_PARAMETER(DebugFlag); 51 52 /* Set the base priority */ 53 NtSetInformationProcess(NtCurrentProcess(), 54 ProcessBasePriority, 55 &BasePriority, 56 sizeof(BasePriority)); 57 58 #if defined (_X86_) 59 /* Give us IOPL so that we can access the VGA registers */ 60 Status = NtSetInformationProcess(NtCurrentProcess(), 61 ProcessUserModeIOPL, 62 NULL, 63 0); 64 if (!NT_SUCCESS(Status)) 65 { 66 /* Raise a hard error */ 67 DPRINT1("CSRSS: Could not raise IOPL, Status: 0x%08lx\n", Status); 68 Status = NtRaiseHardError(STATUS_IO_PRIVILEGE_FAILED, 69 0, 70 0, 71 NULL, 72 OptionOk, 73 &Response); 74 } 75 #endif 76 77 /* Initialize CSR through CSRSRV */ 78 Status = CsrServerInitialization(argc, argv); 79 if (!NT_SUCCESS(Status)) 80 { 81 /* Kill us */ 82 DPRINT1("CSRSS: Unable to initialize server, Status: 0x%08lx\n", Status); 83 NtTerminateProcess(NtCurrentProcess(), Status); 84 } 85 86 /* Disable errors */ 87 CsrpSetDefaultProcessHardErrorMode(); 88 89 /* If this is Session 0, make sure killing us bugchecks the system */ 90 if (NtCurrentPeb()->SessionId == 0) RtlSetProcessIsCritical(TRUE, NULL, FALSE); 91 92 /* Kill this thread. CSRSRV keeps us going */ 93 NtTerminateThread(NtCurrentThread(), Status); 94 return 0; 95 } 96 97 /* EOF */ 98