mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 04:20:46 +00:00
Clean up catch.c
svn path=/trunk/; revision=14387
This commit is contained in:
parent
8df3d41437
commit
fd13cf7e83
1 changed files with 27 additions and 13 deletions
|
@ -4,7 +4,8 @@
|
||||||
* FILE: ntoskrnl/ke/catch.c
|
* FILE: ntoskrnl/ke/catch.c
|
||||||
* PURPOSE: Exception handling
|
* PURPOSE: Exception handling
|
||||||
*
|
*
|
||||||
* PROGRAMMERS: David Welch (welch@mcmail.com)
|
* PROGRAMMERS: Anich Gregor
|
||||||
|
* David Welch (welch@mcmail.com)
|
||||||
* Casper S. Hornstrup (chorns@users.sourceforge.net)
|
* Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
IN PCONTEXT Context);
|
IN PCONTEXT Context);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
|
@ -56,13 +57,15 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
/* Increase number of Exception Dispatches */
|
/* Increase number of Exception Dispatches */
|
||||||
KeGetCurrentPrcb()->KeExceptionDispatchCount++;
|
KeGetCurrentPrcb()->KeExceptionDispatchCount++;
|
||||||
|
|
||||||
if (!Context) {
|
if (!Context)
|
||||||
|
{
|
||||||
|
|
||||||
/* Assume Full context */
|
/* Assume Full context */
|
||||||
TContext.ContextFlags = CONTEXT_FULL;
|
TContext.ContextFlags = CONTEXT_FULL;
|
||||||
|
|
||||||
/* Check the mode */
|
/* Check the mode */
|
||||||
if (PreviousMode == UserMode) {
|
if (PreviousMode == UserMode)
|
||||||
|
{
|
||||||
|
|
||||||
/* Add Debugger Registers if this is User Mode */
|
/* Add Debugger Registers if this is User Mode */
|
||||||
TContext.ContextFlags = TContext.ContextFlags | CONTEXT_DEBUGGER;
|
TContext.ContextFlags = TContext.ContextFlags | CONTEXT_DEBUGGER;
|
||||||
|
@ -76,13 +79,15 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* FIXME: Isn't this right? With a break after? */
|
#if 0 /* FIXME: Isn't this right? With a break after? */
|
||||||
if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) {
|
if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT)
|
||||||
|
{
|
||||||
Context->Eip--;
|
Context->Eip--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check if a Debugger is enabled */
|
/* Check if a Debugger is enabled */
|
||||||
if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_GDB) {
|
if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_GDB)
|
||||||
|
{
|
||||||
|
|
||||||
/* Break into it */
|
/* Break into it */
|
||||||
Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
|
Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
|
||||||
|
@ -92,13 +97,16 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
if (Action == kdContinue) return;
|
if (Action == kdContinue) return;
|
||||||
|
|
||||||
/* If the Debugger couldn't handle it... */
|
/* If the Debugger couldn't handle it... */
|
||||||
if (Action != kdDoNotHandleException) {
|
if (Action != kdDoNotHandleException)
|
||||||
|
{
|
||||||
|
|
||||||
/* See what kind of Exception this is */
|
/* See what kind of Exception this is */
|
||||||
if (PreviousMode == UserMode) {
|
if (PreviousMode == UserMode)
|
||||||
|
{
|
||||||
|
|
||||||
/* User mode exception, search the frames if we have to */
|
/* User mode exception, search the frames if we have to */
|
||||||
if (SearchFrames) {
|
if (SearchFrames)
|
||||||
|
{
|
||||||
|
|
||||||
PULONG Stack;
|
PULONG Stack;
|
||||||
ULONG CDest;
|
ULONG CDest;
|
||||||
|
@ -140,12 +148,15 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
(12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT)));
|
(12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT)));
|
||||||
|
|
||||||
/* Check for success */
|
/* Check for success */
|
||||||
if (NT_SUCCESS(StatusOfCopy)) {
|
if (NT_SUCCESS(StatusOfCopy))
|
||||||
|
{
|
||||||
|
|
||||||
/* Set new Stack Pointer */
|
/* Set new Stack Pointer */
|
||||||
Tf->Esp = (ULONG)pNewUserStack;
|
Tf->Esp = (ULONG)pNewUserStack;
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now it really hit the ventilation device. Sorry,
|
* Now it really hit the ventilation device. Sorry,
|
||||||
|
@ -180,7 +191,9 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
DPRINT1("Unhandled UserMode exception, terminating thread\n");
|
DPRINT1("Unhandled UserMode exception, terminating thread\n");
|
||||||
ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
|
ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
/* This is Kernel Mode */
|
/* This is Kernel Mode */
|
||||||
#ifdef KDBG
|
#ifdef KDBG
|
||||||
|
@ -201,7 +214,8 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
|
|
||||||
/* If RtlpDispatchException() did not handle the exception then bugcheck */
|
/* If RtlpDispatchException() did not handle the exception then bugcheck */
|
||||||
if (Value != ExceptionContinueExecution ||
|
if (Value != ExceptionContinueExecution ||
|
||||||
0 != (ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)) {
|
0 != (ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE))
|
||||||
|
{
|
||||||
|
|
||||||
DPRINT("ExceptionRecord->ExceptionAddress = 0x%x\n", ExceptionRecord->ExceptionAddress);
|
DPRINT("ExceptionRecord->ExceptionAddress = 0x%x\n", ExceptionRecord->ExceptionAddress);
|
||||||
#ifdef KDBG
|
#ifdef KDBG
|
||||||
|
|
Loading…
Reference in a new issue