mirror of
https://github.com/reactos/reactos.git
synced 2024-07-21 19:58:08 +00:00
[NTOS]: Sync up KiDispatchException with x86 code (and going back to C comment formatting).
svn path=/trunk/; revision=45509
This commit is contained in:
parent
d685272dc0
commit
bf39d09670
|
@ -176,67 +176,51 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
IN BOOLEAN FirstChance)
|
IN BOOLEAN FirstChance)
|
||||||
{
|
{
|
||||||
CONTEXT Context;
|
CONTEXT Context;
|
||||||
|
|
||||||
//
|
/* Increase number of Exception Dispatches */
|
||||||
// Increase number of Exception Dispatches
|
|
||||||
//
|
|
||||||
KeGetCurrentPrcb()->KeExceptionDispatchCount++;
|
KeGetCurrentPrcb()->KeExceptionDispatchCount++;
|
||||||
|
|
||||||
//
|
/* Set the context flags */
|
||||||
// Set the context flags
|
|
||||||
//
|
|
||||||
Context.ContextFlags = CONTEXT_FULL;
|
Context.ContextFlags = CONTEXT_FULL;
|
||||||
|
|
||||||
//
|
/* Check if User Mode or if the kernel debugger is enabled */
|
||||||
// FIXME-V6: VFP Support
|
if ((PreviousMode == UserMode) || (KeGetPcr()->KdVersionBlock))
|
||||||
//
|
{
|
||||||
|
/* FIXME-V6: VFP Support */
|
||||||
//
|
}
|
||||||
// Get a Context
|
|
||||||
//
|
/* Get a Context */
|
||||||
KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
|
KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
|
||||||
|
|
||||||
//
|
/* Look at our exception code */
|
||||||
// Look at our exception code
|
|
||||||
//
|
|
||||||
switch (ExceptionRecord->ExceptionCode)
|
switch (ExceptionRecord->ExceptionCode)
|
||||||
{
|
{
|
||||||
//
|
/* Breakpoint */
|
||||||
// Breakpoint
|
|
||||||
//
|
|
||||||
case STATUS_BREAKPOINT:
|
case STATUS_BREAKPOINT:
|
||||||
|
|
||||||
//
|
/* Decrement PC by four */
|
||||||
// We want the instruction right before the int 3
|
|
||||||
//
|
|
||||||
Context.Pc -= sizeof(ULONG);
|
Context.Pc -= sizeof(ULONG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//
|
/* Internal exception */
|
||||||
// Internal exception
|
|
||||||
//
|
|
||||||
case KI_EXCEPTION_ACCESS_VIOLATION:
|
case KI_EXCEPTION_ACCESS_VIOLATION:
|
||||||
|
|
||||||
//
|
/* Set correct code */
|
||||||
// Set correct code
|
|
||||||
//
|
|
||||||
ExceptionRecord->ExceptionCode = STATUS_ACCESS_VIOLATION;
|
ExceptionRecord->ExceptionCode = STATUS_ACCESS_VIOLATION;
|
||||||
|
if (PreviousMode == UserMode)
|
||||||
|
{
|
||||||
|
/* FIXME: Handle no execute */
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* Handle kernel-mode first, it's simpler */
|
||||||
// Handle kernel-mode first, it's simpler
|
|
||||||
//
|
|
||||||
if (PreviousMode == KernelMode)
|
if (PreviousMode == KernelMode)
|
||||||
{
|
{
|
||||||
//
|
/* Check if this is a first-chance exception */
|
||||||
// Check if this is a first-chance exception
|
|
||||||
//
|
|
||||||
if (FirstChance == TRUE)
|
if (FirstChance == TRUE)
|
||||||
{
|
{
|
||||||
//
|
/* Break into the debugger for the first time */
|
||||||
// Break into the debugger for the first time
|
|
||||||
//
|
|
||||||
if (KiDebugRoutine(TrapFrame,
|
if (KiDebugRoutine(TrapFrame,
|
||||||
ExceptionFrame,
|
ExceptionFrame,
|
||||||
ExceptionRecord,
|
ExceptionRecord,
|
||||||
|
@ -244,21 +228,15 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
FALSE))
|
FALSE))
|
||||||
{
|
{
|
||||||
//
|
/* Exception was handled */
|
||||||
// Exception was handled
|
|
||||||
//
|
|
||||||
goto Handled;
|
goto Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* If the Debugger couldn't handle it, dispatch the exception */
|
||||||
// If the Debugger couldn't handle it, dispatch the exception
|
|
||||||
//
|
|
||||||
if (RtlDispatchException(ExceptionRecord, &Context)) goto Handled;
|
if (RtlDispatchException(ExceptionRecord, &Context)) goto Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* This is a second-chance exception, only for the debugger */
|
||||||
// This is a second-chance exception, only for the debugger
|
|
||||||
//
|
|
||||||
if (KiDebugRoutine(TrapFrame,
|
if (KiDebugRoutine(TrapFrame,
|
||||||
ExceptionFrame,
|
ExceptionFrame,
|
||||||
ExceptionRecord,
|
ExceptionRecord,
|
||||||
|
@ -266,15 +244,11 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
TRUE))
|
TRUE))
|
||||||
{
|
{
|
||||||
//
|
/* Exception was handled */
|
||||||
// Exception was handled
|
|
||||||
//
|
|
||||||
goto Handled;
|
goto Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* Third strike; you're out */
|
||||||
// Third strike; you're out
|
|
||||||
//
|
|
||||||
KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
|
KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
|
||||||
ExceptionRecord->ExceptionCode,
|
ExceptionRecord->ExceptionCode,
|
||||||
(ULONG_PTR)ExceptionRecord->ExceptionAddress,
|
(ULONG_PTR)ExceptionRecord->ExceptionAddress,
|
||||||
|
@ -283,19 +257,27 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
/* FIXME: TODO */
|
||||||
// FIXME-USER: Do user-mode exception handling
|
/* 3rd strike, kill the process */
|
||||||
//
|
DPRINT1("Kill %.16s, ExceptionCode: %lx, ExceptionAddress: %lx\n",
|
||||||
ASSERT(FALSE);
|
PsGetCurrentProcess()->ImageFileName,
|
||||||
|
ExceptionRecord->ExceptionCode,
|
||||||
|
ExceptionRecord->ExceptionAddress);
|
||||||
|
|
||||||
|
ZwTerminateProcess(NtCurrentProcess(), ExceptionRecord->ExceptionCode);
|
||||||
|
KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
|
||||||
|
ExceptionRecord->ExceptionCode,
|
||||||
|
(ULONG_PTR)ExceptionRecord->ExceptionAddress,
|
||||||
|
(ULONG_PTR)TrapFrame,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handled:
|
Handled:
|
||||||
//
|
/* Convert the context back into Trap/Exception Frames */
|
||||||
// Convert the context back into Trap/Exception Frames
|
|
||||||
//
|
|
||||||
KeContextToTrapFrame(&Context,
|
KeContextToTrapFrame(&Context,
|
||||||
ExceptionFrame,
|
ExceptionFrame,
|
||||||
TrapFrame,
|
TrapFrame,
|
||||||
Context.ContextFlags,
|
Context.ContextFlags,
|
||||||
PreviousMode);
|
PreviousMode);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue