/* User mode exception, was it first-chance? */
if (FirstChance)
{
- /* Make sure a debugger is present, and ignore user-mode if requested */
- if ((KiDebugRoutine) &&
- (!(PsGetCurrentProcess()->DebugPort)))
+ /*
+ * Break into the kernel debugger unless a user mode debugger
+ * is present or user mode exceptions are ignored, unless this is
+ * a breakpoint or a debug service in which case we have to
+ * handle it.
+ */
+ if ((!(PsGetCurrentProcess()->DebugPort) &&
+ !(KdIgnoreUmExceptions)) ||
+ (KdIsThisAKdTrap(ExceptionRecord,
+ &Context,
+ PreviousMode)))
{
- /* Call the debugger */
+ /* Call the kernel debugger */
if (KiDebugRoutine(TrapFrame,
ExceptionFrame,
ExceptionRecord,
}
/* Forward exception to user mode debugger */
- if (DbgkForwardException(ExceptionRecord, TRUE, FALSE)) goto Exit;
+ if (DbgkForwardException(ExceptionRecord, TRUE, FALSE)) return;
/* Set up the user-stack */
DispatchToUser:
}
/* Try second chance */
- if (DbgkForwardException(ExceptionRecord, TRUE, FALSE))
+ if (DbgkForwardException(ExceptionRecord, TRUE, TRUE))
{
/* Handled, get out */
- goto Exit;
+ return;
}
else if (DbgkForwardException(ExceptionRecord, FALSE, TRUE))
{
/* Handled, get out */
- goto Exit;
+ return;
}
/* 3rd strike, kill the process */
TrapFrame,
Context.ContextFlags,
PreviousMode);
-Exit:
return;
}
NTAPI
KeRaiseUserException(IN NTSTATUS ExceptionCode)
{
- NTSTATUS Status = STATUS_SUCCESS;
ULONG OldEip;
PTEB Teb = KeGetCurrentThread()->Teb;
PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Save exception code */
- Status = _SEH2_GetExceptionCode();
+ /* Return the exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
- if (!NT_SUCCESS(Status)) return Status;
/* Get the old EIP */
OldEip = TrapFrame->Eip;