#ifndef LIBCAPTIVE
CONTEXT TContext;
#endif /* LIBCAPTIVE */
+ KD_CONTINUE_TYPE Action = kdContinue;
DPRINT("KiDispatchException() called\n");
Context->Eip--;
}
#endif
- if (PreviousMode == UserMode)
+
+#ifndef LIBCAPTIVE
+ if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_GDB)
+ {
+ Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
+ }
+#ifdef KDBG
+ else if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_KDB)
{
+ Action = KdbEnterDebuggerException (ExceptionRecord, Context, Tf);
+ }
+#endif /* KDBG */
+#endif /* LIBCAPTIVE */
+ if (Action != kdHandleException)
+ {
+ if (PreviousMode == UserMode)
+ {
#ifdef LIBCAPTIVE
- KeBugCheck(0);
+ KeBugCheck (0);
#else /* !LIBCAPTIVE */
- if (SearchFrames)
- {
- PULONG Stack;
- ULONG CDest;
-
- /* FIXME: Give the kernel debugger a chance */
-
- /* FIXME: Forward exception to user mode debugger */
+ if (SearchFrames)
+ {
+ PULONG Stack;
+ ULONG CDest;
- /* FIXME: Check user mode stack for enough space */
+ /* FIXME: Forward exception to user mode debugger */
+ /* FIXME: Check user mode stack for enough space */
- /*
- * Let usermode try and handle the exception
- */
- Tf->Esp = Tf->Esp -
- (12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT));
- Stack = (PULONG)Tf->Esp;
- CDest = 3 + (ROUND_UP(sizeof(EXCEPTION_RECORD), 4) / 4);
- /* Return address */
- Stack[0] = 0;
- /* Pointer to EXCEPTION_RECORD structure */
- Stack[1] = (ULONG)&Stack[3];
- /* Pointer to CONTEXT structure */
- Stack[2] = (ULONG)&Stack[CDest];
- memcpy(&Stack[3], ExceptionRecord, sizeof(EXCEPTION_RECORD));
- memcpy(&Stack[CDest], Context, sizeof(CONTEXT));
-
- Tf->Eip = (ULONG)LdrpGetSystemDllExceptionDispatcher();
- return;
- }
+ /*
+ * Let usermode try and handle the exception
+ */
+ Tf->Esp = Tf->Esp -
+ (12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT));
+ Stack = (PULONG)Tf->Esp;
+ CDest = 3 + (ROUND_UP(sizeof(EXCEPTION_RECORD), 4) / 4);
+ /* Return address */
+ Stack[0] = 0;
+ /* Pointer to EXCEPTION_RECORD structure */
+ Stack[1] = (ULONG)&Stack[3];
+ /* Pointer to CONTEXT structure */
+ Stack[2] = (ULONG)&Stack[CDest];
+ memcpy(&Stack[3], ExceptionRecord, sizeof(EXCEPTION_RECORD));
+ memcpy(&Stack[CDest], Context, sizeof(CONTEXT));
+
+ Tf->Eip = (ULONG)LdrpGetSystemDllExceptionDispatcher();
+ return;
+ }
- /* FIXME: Forward the exception to the debugger */
+ /* FIXME: Forward the exception to the debugger */
- /* FIXME: Forward the exception to the process exception port */
+ /* FIXME: Forward the exception to the process exception port */
- /* Terminate the offending thread */
- ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
+ /* Terminate the offending thread */
+ DPRINT1("Unhandled UserMode exception, terminating thread\n");
+ ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
- /* If that fails then bugcheck */
- DbgPrint("Could not terminate thread\n");
- KeBugCheck(KMODE_EXCEPTION_NOT_HANDLED);
+ /* If that fails then bugcheck */
+ DPRINT1("Could not terminate thread\n");
+ KeBugCheck(KMODE_EXCEPTION_NOT_HANDLED);
#endif /* LIBCAPTIVE */
- }
- else
- {
- KD_CONTINUE_TYPE Action = kdContinue;
-
- /* PreviousMode == KernelMode */
-
-#ifndef LIBCAPTIVE
- if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_GDB)
- {
- Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
- }
-#ifdef KDBG
- else if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_KDB)
- {
- Action = KdbEnterDebuggerException (ExceptionRecord, Context, Tf);
}
-#endif /* KDBG */
-#endif /* LIBCAPTIVE */
- if (Action != kdHandleException)
+ else
{
+ /* PreviousMode == KernelMode */
Value = RtlpDispatchException (ExceptionRecord, Context);
DPRINT("RtlpDispatchException() returned with 0x%X\n", Value);
* If RtlpDispatchException() does not handle the exception then
* bugcheck
*/
- if (Value != ExceptionContinueExecution)
+ if (Value != ExceptionContinueExecution ||
+ 0 != (ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE))
{
#ifndef LIBCAPTIVE
- KeBugCheck (KMODE_EXCEPTION_NOT_HANDLED);
+ KeBugCheckWithTf(KMODE_EXCEPTION_NOT_HANDLED, 0, 0, 0, 0, Tf);
#else /* !LIBCAPTIVE */
KeBugCheck (0);
#endif /* LIBCAPTIVE */
}
}
- else
- {
+ }
+ else
+ {
#ifndef LIBCAPTIVE
- KeContextToTrapFrame (Context, KeGetCurrentThread()->TrapFrame);
+ KeContextToTrapFrame (Context, KeGetCurrentThread()->TrapFrame);
#else /* !LIBCAPTIVE */
- KeBugCheck(0);
+ KeBugCheck(0);
#endif /* LIBCAPTIVE */
- }
}
}