2 * --------------------------------------------------------------------
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * --------------------------------------------------------------------
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS CSR Sub System
23 * FILE: subsys/csr/csrss.c
24 * PURPOSE: CSR Executable
25 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
28 /* INCLUDES ******************************************************************/
30 #define WIN32_NO_STATUS
32 #define NTOS_MODE_USER
33 #include <ndk/ntndk.h>
34 #include <csr/server.h>
39 /* PRIVATE FUNCTIONS *********************************************************/
43 CsrpSetDefaultProcessHardErrorMode (VOID
)
45 ULONG DefaultHardErrorMode
= 0;
47 /* Disable hard errors */
48 NtSetInformationProcess(NtCurrentProcess(),
49 ProcessDefaultHardErrorMode
,
50 &DefaultHardErrorMode
,
51 sizeof(DefaultHardErrorMode
));
55 * Note: Standard entrypoint for Native C Programs.
56 * The OS backend (NtProcessStartup) which calls this routine is
57 * implemented in a CRT-like static library (much like mainCRTStartup).
58 * Do NOT manually add the NtProcessStartup entrypoint or anything else.
67 KPRIORITY BasePriority
= (8 + 1) + 4;
70 UNREFERENCED_PARAMETER(envp
);
71 UNREFERENCED_PARAMETER(DebugFlag
);
74 /* Set the Priority */
75 NtSetInformationProcess(NtCurrentProcess(),
80 /* Give us IOPL so that we can access the VGA registers */
81 Status
= NtSetInformationProcess(NtCurrentProcess(),
85 if (!NT_SUCCESS(Status
))
87 /* Raise a hard error */
88 DPRINT1("CSRSS: Could not raise IOPL: %x\n", Status
);
89 Status
= NtRaiseHardError(STATUS_IO_PRIVILEGE_FAILED
,
97 /* Initialize CSR through CSRSRV */
98 Status
= CsrServerInitialization(argc
, argv
);
99 if (!NT_SUCCESS(Status
))
102 DPRINT1("CSRSS: CsrServerInitialization failed:% lx\n", Status
);
103 NtTerminateProcess (NtCurrentProcess(), Status
);
107 CsrpSetDefaultProcessHardErrorMode();
109 /* If this is Session 0, make sure killing us bugchecks the system */
110 if (!NtCurrentPeb()->SessionId
) RtlSetProcessIsCritical(TRUE
, NULL
, FALSE
);
112 /* Kill this thread. CSRSRV keeps us going */
113 NtTerminateThread (NtCurrentThread(), Status
);