diff --git a/ntoskrnl/include/internal/i386/asmmacro.S b/ntoskrnl/include/internal/i386/asmmacro.S index f7af217cc9f..543ce3f1bc4 100644 --- a/ntoskrnl/include/internal/i386/asmmacro.S +++ b/ntoskrnl/include/internal/i386/asmmacro.S @@ -207,6 +207,10 @@ set_sane_segs: mov fs, ax endif + /* Save ExceptionList, since the C handler might use SEH */ + mov eax, fs:[KPCR_EXCEPTION_LIST] + mov [esp + KTRAP_FRAME_EXCEPTION_LIST], eax + #if DBG /* Keep the frame chain intact */ mov eax, [esp + KTRAP_FRAME_EIP] diff --git a/ntoskrnl/include/internal/i386/trap_x.h b/ntoskrnl/include/internal/i386/trap_x.h index 06443c9dc90..cd79c2a40c4 100644 --- a/ntoskrnl/include/internal/i386/trap_x.h +++ b/ntoskrnl/include/internal/i386/trap_x.h @@ -349,8 +349,12 @@ FORCEINLINE VOID KiEnterV86Trap(IN PKTRAP_FRAME TrapFrame) { - /* Save exception list */ - TrapFrame->ExceptionList = KeGetPcr()->NtTib.ExceptionList; + PVOID ExceptionList; + + /* Check exception list */ + ExceptionList = KeGetPcr()->NtTib.ExceptionList; + ASSERTMSG("V86 trap handler must not register an SEH frame\n", + ExceptionList == TrapFrame->ExceptionList); /* Save DR7 and check for debugging */ TrapFrame->Dr7 = __readdr(7); @@ -368,8 +372,12 @@ FORCEINLINE VOID KiEnterInterruptTrap(IN PKTRAP_FRAME TrapFrame) { - /* Save exception list and terminate it */ - TrapFrame->ExceptionList = KeGetPcr()->NtTib.ExceptionList; + PVOID ExceptionList; + + /* Check exception list and terminate it */ + ExceptionList = KeGetPcr()->NtTib.ExceptionList; + ASSERTMSG("Interrupt handler must not register an SEH frame\n", + ExceptionList == TrapFrame->ExceptionList); KeGetPcr()->NtTib.ExceptionList = EXCEPTION_CHAIN_END; /* Default to debugging disabled */ @@ -398,8 +406,12 @@ FORCEINLINE VOID KiEnterTrap(IN PKTRAP_FRAME TrapFrame) { - /* Save exception list */ - TrapFrame->ExceptionList = KeGetPcr()->NtTib.ExceptionList; + PVOID ExceptionList; + + /* Check exception list */ + ExceptionList = KeGetPcr()->NtTib.ExceptionList; + ASSERTMSG("Trap handler must not register an SEH frame\n", + ExceptionList == TrapFrame->ExceptionList); /* Default to debugging disabled */ TrapFrame->Dr7 = 0;