2005-03-12 21:26:29 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: ntoskrnl/ex/error.c
|
|
|
|
* PURPOSE: Error Functions and Status/Exception Dispatching/Raising
|
|
|
|
*
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Created File
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
|
|
|
#define NDEBUG
|
|
|
|
#include <internal/debug.h>
|
|
|
|
|
|
|
|
/* GLOBALS ****************************************************************/
|
|
|
|
|
|
|
|
BOOLEAN ExReadyForErrors = FALSE;
|
|
|
|
PEPORT ExpDefaultErrorPort = NULL;
|
|
|
|
PEPROCESS ExpDefaultErrorPortProcess = NULL;
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2005-05-09 01:38:29 +00:00
|
|
|
VOID
|
2005-03-12 21:26:29 +00:00
|
|
|
STDCALL
|
|
|
|
ExRaiseAccessViolation(VOID)
|
|
|
|
{
|
|
|
|
/* Raise the Right Status */
|
|
|
|
ExRaiseStatus (STATUS_ACCESS_VIOLATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
STDCALL
|
|
|
|
ExRaiseDatatypeMisalignment (VOID)
|
|
|
|
{
|
|
|
|
/* Raise the Right Status */
|
|
|
|
ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2005-05-09 01:38:29 +00:00
|
|
|
VOID
|
2005-03-12 21:26:29 +00:00
|
|
|
STDCALL
|
|
|
|
ExRaiseStatus(IN NTSTATUS Status)
|
|
|
|
{
|
|
|
|
EXCEPTION_RECORD ExceptionRecord;
|
|
|
|
|
|
|
|
DPRINT("ExRaiseStatus(%x)\n", Status);
|
|
|
|
|
|
|
|
/* Set up an Exception Record */
|
|
|
|
ExceptionRecord.ExceptionRecord = NULL;
|
|
|
|
ExceptionRecord.NumberParameters = 0;
|
|
|
|
ExceptionRecord.ExceptionCode = Status;
|
|
|
|
ExceptionRecord.ExceptionFlags = 0;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Call the Rtl Function */
|
|
|
|
RtlRaiseException(&ExceptionRecord);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
STDCALL
|
|
|
|
ExRaiseException (PEXCEPTION_RECORD ExceptionRecord)
|
|
|
|
{
|
|
|
|
/* Call the Rtl function */
|
|
|
|
RtlRaiseException(ExceptionRecord);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2005-05-06 22:25:30 +00:00
|
|
|
LONG
|
2005-03-12 21:26:29 +00:00
|
|
|
STDCALL
|
|
|
|
ExSystemExceptionFilter(VOID)
|
|
|
|
{
|
|
|
|
return KeGetPreviousMode() != KernelMode ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
STDCALL
|
|
|
|
ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
2005-05-09 01:38:29 +00:00
|
|
|
IN ULONG NumberOfParameters,
|
2005-09-04 18:00:59 +00:00
|
|
|
IN ULONG UnicodeStringParameterMask,
|
|
|
|
IN PULONG_PTR Parameters,
|
|
|
|
IN ULONG ValidResponseOptions,
|
|
|
|
OUT PULONG Response)
|
2005-03-12 21:26:29 +00:00
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
STDCALL
|
2005-03-12 21:26:29 +00:00
|
|
|
NtRaiseHardError(IN NTSTATUS ErrorStatus,
|
|
|
|
IN ULONG NumberOfParameters,
|
2005-09-04 18:00:59 +00:00
|
|
|
IN ULONG UnicodeStringParameterMask,
|
|
|
|
IN PULONG_PTR Parameters,
|
|
|
|
IN ULONG ValidResponseOptions,
|
|
|
|
OUT PULONG Response)
|
2005-03-12 21:26:29 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Hard error %x\n", ErrorStatus);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Call the Executive Function (WE SHOULD PUT SEH HERE/CAPTURE!) */
|
|
|
|
ExRaiseHardError(ErrorStatus,
|
|
|
|
NumberOfParameters,
|
|
|
|
UnicodeStringParameterMask,
|
|
|
|
Parameters,
|
2005-09-04 18:00:59 +00:00
|
|
|
ValidResponseOptions,
|
2005-03-12 21:26:29 +00:00
|
|
|
Response);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Return Success */
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
STDCALL
|
2005-03-12 21:26:29 +00:00
|
|
|
NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
|
|
|
|
{
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
|
|
|
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Check if we have the Privilege */
|
|
|
|
if(!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode)) {
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
DPRINT1("NtSetDefaultHardErrorPort: Caller requires the SeTcbPrivilege privilege!\n");
|
|
|
|
return STATUS_PRIVILEGE_NOT_HELD;
|
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Only called once during bootup, make sure we weren't called yet */
|
|
|
|
if(!ExReadyForErrors) {
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
Status = ObReferenceObjectByHandle(PortHandle,
|
|
|
|
0,
|
|
|
|
LpcPortObjectType,
|
|
|
|
PreviousMode,
|
|
|
|
(PVOID*)&ExpDefaultErrorPort,
|
|
|
|
NULL);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Check for Success */
|
|
|
|
if(NT_SUCCESS(Status)) {
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
/* Save the data */
|
|
|
|
ExpDefaultErrorPortProcess = PsGetCurrentProcess();
|
|
|
|
ExReadyForErrors = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 21:26:29 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|