12#define __builtin_expect(a,b) (a)
34 DbgPrint(
"DbgEbp: %x\n", TrapFrame->DbgEbp);
35 DbgPrint(
"DbgEip: %x\n", TrapFrame->DbgEip);
36 DbgPrint(
"DbgArgMark: %x\n", TrapFrame->DbgArgMark);
37 DbgPrint(
"DbgArgPointer: %x\n", TrapFrame->DbgArgPointer);
38 DbgPrint(
"TempSegCs: %x\n", TrapFrame->TempSegCs);
39 DbgPrint(
"TempEsp: %x\n", TrapFrame->TempEsp);
40 DbgPrint(
"Dr0: %x\n", TrapFrame->Dr0);
41 DbgPrint(
"Dr1: %x\n", TrapFrame->Dr1);
42 DbgPrint(
"Dr2: %x\n", TrapFrame->Dr2);
43 DbgPrint(
"Dr3: %x\n", TrapFrame->Dr3);
44 DbgPrint(
"Dr6: %x\n", TrapFrame->Dr6);
45 DbgPrint(
"Dr7: %x\n", TrapFrame->Dr7);
46 DbgPrint(
"SegGs: %x\n", TrapFrame->SegGs);
47 DbgPrint(
"SegEs: %x\n", TrapFrame->SegEs);
48 DbgPrint(
"SegDs: %x\n", TrapFrame->SegDs);
49 DbgPrint(
"Edx: %x\n", TrapFrame->Edx);
50 DbgPrint(
"Ecx: %x\n", TrapFrame->Ecx);
51 DbgPrint(
"Eax: %x\n", TrapFrame->Eax);
52 DbgPrint(
"PreviousPreviousMode: %x\n", TrapFrame->PreviousPreviousMode);
53 DbgPrint(
"ExceptionList: %p\n", TrapFrame->ExceptionList);
54 DbgPrint(
"SegFs: %x\n", TrapFrame->SegFs);
55 DbgPrint(
"Edi: %x\n", TrapFrame->Edi);
56 DbgPrint(
"Esi: %x\n", TrapFrame->Esi);
57 DbgPrint(
"Ebx: %x\n", TrapFrame->Ebx);
58 DbgPrint(
"Ebp: %x\n", TrapFrame->Ebp);
59 DbgPrint(
"ErrCode: %x\n", TrapFrame->ErrCode);
60 DbgPrint(
"Eip: %x\n", TrapFrame->Eip);
61 DbgPrint(
"SegCs: %x\n", TrapFrame->SegCs);
62 DbgPrint(
"EFlags: %x\n", TrapFrame->EFlags);
63 DbgPrint(
"HardwareEsp: %x\n", TrapFrame->HardwareEsp);
64 DbgPrint(
"HardwareSegSs: %x\n", TrapFrame->HardwareSegSs);
65 DbgPrint(
"V86Es: %x\n", TrapFrame->V86Es);
66 DbgPrint(
"V86Ds: %x\n", TrapFrame->V86Ds);
67 DbgPrint(
"V86Fs: %x\n", TrapFrame->V86Fs);
68 DbgPrint(
"V86Gs: %x\n", TrapFrame->V86Gs);
77 TrapFrame->DbgArgPointer = TrapFrame->Edx;
78 TrapFrame->DbgArgMark = 0xBADB0D00;
79 TrapFrame->DbgEip = TrapFrame->Eip;
80 TrapFrame->DbgEbp = TrapFrame->Ebp;
81 TrapFrame->PreviousPreviousMode = (
ULONG)-1;
84#define DR7_RESERVED_READ_AS_1 0x400
86#define CheckDr(DrNumner, ExpectedValue) \
88 ULONG DrValue = __readdr(DrNumner); \
89 if (DrValue != (ExpectedValue)) \
91 DbgPrint("Dr%ld: expected %.8lx, got %.8lx\n", \
92 DrNumner, ExpectedValue, DrValue); \
105 if (StopChecking)
return;
116 if (TrapFrame->DbgArgMark != 0xBADB0D00)
118 DbgPrint(
"Exiting with an invalid trap frame? (No MAGIC in trap frame)\n");
126 DbgPrint(
"Exiting with an invalid FS: %lx\n", Ke386GetFs());
131 if (
KeGetPcr()->NtTib.ExceptionList == 0)
133 DbgPrint(
"Exiting with NULL exception chain: %p\n",
KeGetPcr()->NtTib.ExceptionList);
138 if (TrapFrame->ExceptionList == 0)
140 DbgPrint(
"Entered a trap with a NULL exception chain: %p\n", TrapFrame->ExceptionList);
145 if (SkipPreviousMode && (TrapFrame->PreviousPreviousMode != (
ULONG)-1))
147 DbgPrint(
"Exiting a trap witout restoring previous mode, yet previous mode seems valid: %lx\n", TrapFrame->PreviousPreviousMode);
161 CheckDr(0, TrapFrame->Dr0);
162 CheckDr(1, TrapFrame->Dr1);
163 CheckDr(2, TrapFrame->Dr2);
164 CheckDr(3, TrapFrame->Dr3);
165 CheckDr(7, TrapFrame->Dr7 | DR7_RESERVED_READ_AS_1);
179 StopChecking =
FALSE;
183#define KiExitTrapDebugChecks(x, y)
184#define KiFillTrapFrameDebug(x)
315 if (__builtin_expect(!
Thread->ApcState.UserApcPending, 1))
break;
350 ExceptionList =
KeGetPcr()->NtTib.ExceptionList;
351 ASSERTMSG(
"V86 trap handler must not register an SEH frame\n",
352 ExceptionList == TrapFrame->ExceptionList);
373 ExceptionList =
KeGetPcr()->NtTib.ExceptionList;
374 ASSERTMSG(
"Interrupt handler must not register an SEH frame\n",
375 ExceptionList == TrapFrame->ExceptionList);
407 ExceptionList =
KeGetPcr()->NtTib.ExceptionList;
408 ASSERTMSG(
"Trap handler must not register an SEH frame\n",
409 ExceptionList == TrapFrame->ExceptionList);
#define EFLAGS_INTERRUPT_MASK
#define KeGetCurrentIrql()
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
#define KeGetCurrentThread
void __cdecl _disable(void)
void __cdecl _enable(void)
void __cdecl __debugbreak(void)
__INTRIN_INLINE unsigned int __readdr(unsigned int reg)
__INTRIN_INLINE uintptr_t __readeflags(void)
__INTRIN_INLINE void __writedr(unsigned reg, unsigned int value)
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
#define DR7_RESERVED_MASK
#define EXCEPTION_CHAIN_END
#define ASSERTMSG(msg, exp)
#define DECLSPEC_NORETURN
DECLSPEC_NORETURN VOID FASTCALL KiEoiHelper(IN PKTRAP_FRAME TrapFrame)
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
KPROCESSOR_STATE ProcessorState
KSPECIAL_REGISTERS SpecialRegisters
DECLSPEC_NORETURN VOID FASTCALL KiTrapReturnNoSegmentsRet8(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE VOID KiEnterV86Trap(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE VOID KiHandleDebugRegistersOnTrapEntry(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE DECLSPEC_NORETURN VOID KiExitV86Trap(IN PKTRAP_FRAME TrapFrame)
DECLSPEC_NORETURN VOID FASTCALL KiTrapReturn(IN PKTRAP_FRAME TrapFrame)
#define KiFillTrapFrameDebug(x)
FORCEINLINE VOID KiHandleDebugRegistersOnTrapExit(PKTRAP_FRAME TrapFrame)
DECLSPEC_NORETURN VOID FASTCALL KiSystemCallTrapReturn(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE VOID KiEnterTrap(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE VOID KiEnterInterruptTrap(IN PKTRAP_FRAME TrapFrame)
DECLSPEC_NORETURN VOID FASTCALL KiEditedTrapReturn(IN PKTRAP_FRAME TrapFrame)
DECLSPEC_NORETURN VOID FASTCALL KiSystemCallSysExitReturn(IN PKTRAP_FRAME TrapFrame)
PFAST_SYSTEM_CALL_EXIT KiFastCallExitHandler
VOID(FASTCALL * PFAST_SYSTEM_CALL_EXIT)(IN PKTRAP_FRAME TrapFrame)
DECLSPEC_NORETURN VOID FASTCALL KiTrapReturnNoSegments(IN PKTRAP_FRAME TrapFrame)
#define KiExitTrapDebugChecks(x, y)
DECLSPEC_NORETURN VOID FASTCALL KiSystemCallReturn(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE VOID KiDumpTrapFrame(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE BOOLEAN KiUserTrap(IN PKTRAP_FRAME TrapFrame)
FORCEINLINE VOID KiExitSystemCallDebugChecks(IN ULONG SystemCall, IN PKTRAP_FRAME TrapFrame)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql