diff --git a/reactos/include/reactos/libs/fast486/fast486.h b/reactos/include/reactos/libs/fast486/fast486.h index d4f3cf18a96..1f64daff688 100644 --- a/reactos/include/reactos/libs/fast486/fast486.h +++ b/reactos/include/reactos/libs/fast486/fast486.h @@ -515,6 +515,7 @@ struct _FAST486_STATE FAST486_REG GeneralRegs[FAST486_NUM_GEN_REGS]; FAST486_SEG_REG SegmentRegs[FAST486_NUM_SEG_REGS]; FAST486_REG InstPtr, SavedInstPtr; + FAST486_REG SavedStackPtr; FAST486_FLAGS_REG Flags; FAST486_TABLE_REG Gdtr, Idtr; FAST486_LDT_REG Ldtr; diff --git a/reactos/lib/fast486/common.c b/reactos/lib/fast486/common.c index 9a580af2f16..a5deaf86eb8 100644 --- a/reactos/lib/fast486/common.c +++ b/reactos/lib/fast486/common.c @@ -579,6 +579,9 @@ Fast486ExceptionWithErrorCode(PFAST486_STATE State, /* Restore the IP to the saved IP */ State->InstPtr = State->SavedInstPtr; + /* Restore the SP to the saved SP */ + State->GeneralRegs[FAST486_REG_ESP] = State->SavedStackPtr; + /* Get the interrupt vector */ if (!Fast486GetIntVector(State, ExceptionCode, &IdtEntry)) { @@ -1040,7 +1043,7 @@ Fast486CallGate(PFAST486_STATE State, OldEsp, FALSE, ParamBuffer, - Gate->ParamCount * sizeof(ULONG))) + Gate->ParamCount * (GateSize ? sizeof(ULONG) : sizeof(USHORT)))) { /* Exception occurred */ return FALSE; diff --git a/reactos/lib/fast486/fast486.c b/reactos/lib/fast486/fast486.c index 4db9b864c43..e2ff4562b21 100644 --- a/reactos/lib/fast486/fast486.c +++ b/reactos/lib/fast486/fast486.c @@ -61,7 +61,11 @@ Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command) { NextInst: /* Check if this is a new instruction */ - if (State->PrefixFlags == 0) State->SavedInstPtr = State->InstPtr; + if (State->PrefixFlags == 0) + { + State->SavedInstPtr = State->InstPtr; + State->SavedStackPtr = State->GeneralRegs[FAST486_REG_ESP]; + } /* Perform an instruction fetch */ if (!Fast486FetchByte(State, &Opcode))