diff --git a/include/reactos/libs/soft386/soft386.h b/include/reactos/libs/soft386/soft386.h index 5b4acfe76f1..96c9d467eed 100644 --- a/include/reactos/libs/soft386/soft386.h +++ b/include/reactos/libs/soft386/soft386.h @@ -319,7 +319,7 @@ struct _SOFT386_STATE SOFT386_BOP_PROC BopCallback; SOFT386_REG GeneralRegs[SOFT386_NUM_GEN_REGS]; SOFT386_SEG_REG SegmentRegs[SOFT386_NUM_SEG_REGS]; - SOFT386_REG InstPtr; + SOFT386_REG InstPtr, SavedInstPtr; SOFT386_FLAGS_REG Flags; SOFT386_TABLE_REG Gdtr, Idtr, Ldtr, Tss; ULONGLONG TimeStampCounter; diff --git a/lib/soft386/common.c b/lib/soft386/common.c index defd11e9e70..f7547f6c074 100644 --- a/lib/soft386/common.c +++ b/lib/soft386/common.c @@ -469,6 +469,9 @@ Soft386ExceptionWithErrorCode(PSOFT386_STATE State, return; } + /* Restore the IP to the saved IP */ + State->InstPtr = State->SavedInstPtr; + if (!Soft386GetIntVector(State, ExceptionCode, &IdtEntry)) { /* diff --git a/lib/soft386/soft386.c b/lib/soft386/soft386.c index 14154730362..02d91b0dc56 100644 --- a/lib/soft386/soft386.c +++ b/lib/soft386/soft386.c @@ -56,6 +56,9 @@ Soft386ExecutionControl(PSOFT386_STATE State, INT Command) /* Main execution loop */ do { + /* If this is a new instruction, save the IP */ + if (State->PrefixFlags == 0) State->SavedInstPtr = State->InstPtr; + /* Perform an instruction fetch */ if (!Soft386FetchByte(State, &Opcode)) continue;