Index: traphdlr.c =================================================================== --- ntoskrnl/ke/i386/traphdlr.c (revision 74238) +++ ntoskrnl/ke/i386/traphdlr.c (working copy) @@ -419,11 +419,38 @@ TrapFrame); } +static ULONG vdm_instructions; +#define HISTORY_SIZE 100 +static USHORT last_cs[HISTORY_SIZE]; +static USHORT last_ip[HISTORY_SIZE]; +static ULONG history_index; + DECLSPEC_NORETURN VOID FASTCALL KiTrap01Handler(IN PKTRAP_FRAME TrapFrame) { + /* Check for V86 debug event */ + if (__builtin_expect(KiV86Trap(TrapFrame), 1)) + { + /* Enter V86 trap */ + KiEnterV86Trap(TrapFrame); + + /* Must be a VDM process */ + ASSERT(PsGetCurrentProcess()->VdmObjects); + + ++vdm_instructions; + + last_cs[history_index] = TrapFrame->SegCs; + last_ip[history_index] = TrapFrame->Eip; + history_index = (history_index + 1) % HISTORY_SIZE; + + //DPRINT1("V86: %x:%x\n", TrapFrame->SegCs, TrapFrame->Eip); + + /* Do a quick V86 exit if possible */ + KiExitV86Trap(TrapFrame); + } + /* Save trap frame */ KiEnterTrap(TrapFrame); @@ -1299,8 +1326,21 @@ } #endif /* Check for VDM trap */ - ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + if (KiVdmTrap(TrapFrame)) + { + ULONG i; + i = history_index; + do + { + DPRINT1("V86: %x:%x\n", last_cs[i], last_ip[i]); + i = (i + 1) % HISTORY_SIZE; + } while (i != history_index); + DPRINT1("Total instructions: %lu\n", vdm_instructions); + + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + } + /* Either kernel or user trap (non VDM) so dispatch exception */ if (Status == STATUS_ACCESS_VIOLATION) { @@ -1755,7 +1795,7 @@ FASTCALL KiCheckForSListAddress(IN PKTRAP_FRAME TrapFrame) { - UNIMPLEMENTED; + UNIMPLEMENTED; } /*