NewMask |= DR_MASK(DR7_OVERRIDE_V);
/* Set DR7 override */
- *DrMask |= DR7_OVERRIDE_MASK;
+ *Dr7Ptr |= DR7_OVERRIDE_MASK;
}
else
{
IN BOOLEAN FirstChance)
{
CONTEXT Context;
- ULONG_PTR Stack, NewStack;
- ULONG Size;
EXCEPTION_RECORD LocalExceptRecord;
- EXCEPTION_RECORD SehExceptRecord;
/* Increase number of Exception Dispatches */
KeGetCurrentPrcb()->KeExceptionDispatchCount++;
/* 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:
_SEH2_TRY
{
+ ULONG Size;
+ ULONG_PTR Stack, NewStack;
+
/* Make sure we have a valid SS and that this isn't V86 mode */
if ((TrapFrame->HardwareSegSs != (KGDT_R3_DATA | RPL_MASK)) ||
(TrapFrame->EFlags & EFLAGS_V86_MASK))
/* Dispatch exception to user-mode */
_SEH2_YIELD(return);
}
- _SEH2_EXCEPT((RtlCopyMemory(&SehExceptRecord, _SEH2_GetExceptionInformation()->ExceptionRecord, sizeof(EXCEPTION_RECORD)), EXCEPTION_EXECUTE_HANDLER))
+ _SEH2_EXCEPT((RtlCopyMemory(&LocalExceptRecord, _SEH2_GetExceptionInformation()->ExceptionRecord, sizeof(EXCEPTION_RECORD)), EXCEPTION_EXECUTE_HANDLER))
{
/* Check if we got a stack overflow and raise that instead */
- if (SehExceptRecord.ExceptionCode ==
+ if ((NTSTATUS)LocalExceptRecord.ExceptionCode ==
STATUS_STACK_OVERFLOW)
{
/* Copy the exception address and record */
- SehExceptRecord.ExceptionAddress =
+ LocalExceptRecord.ExceptionAddress =
ExceptionRecord->ExceptionAddress;
RtlCopyMemory(ExceptionRecord,
- (PVOID)&SehExceptRecord,
+ (PVOID)&LocalExceptRecord,
sizeof(EXCEPTION_RECORD));
/* Do the exception again */
}
/* 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 = ExceptionCode;
+ /* Return the exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
- if (!NT_SUCCESS(Status)) return Status;
/* Get the old EIP */
OldEip = TrapFrame->Eip;