diff --git a/reactos/include/reactos/libs/fast486/fast486.h b/reactos/include/reactos/libs/fast486/fast486.h index 339ecb6a77e..5fa729159fb 100644 --- a/reactos/include/reactos/libs/fast486/fast486.h +++ b/reactos/include/reactos/libs/fast486/fast486.h @@ -159,7 +159,8 @@ typedef enum _FAST486_INT_STATUS { FAST486_INT_NONE = 0, FAST486_INT_EXECUTE = 1, - FAST486_INT_SIGNAL = 2 + FAST486_INT_SIGNAL = 2, + FAST486_INT_DELAYED = 3 } FAST486_INT_STATUS, *PFAST486_INT_STATUS; typedef diff --git a/reactos/lib/fast486/fast486.c b/reactos/lib/fast486/fast486.c index c47814bb526..1c35d8feb17 100644 --- a/reactos/lib/fast486/fast486.c +++ b/reactos/lib/fast486/fast486.c @@ -121,6 +121,11 @@ Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command) /* Set the interrupt status to execute on the next instruction */ State->IntStatus = FAST486_INT_EXECUTE; } + else if (State->IntStatus == FAST486_INT_DELAYED) + { + /* Restore the old state */ + State->IntStatus = FAST486_INT_EXECUTE; + } } while ((Command == FAST486_CONTINUE) || (Command == FAST486_STEP_OVER && ProcedureCallCount > 0) diff --git a/reactos/lib/fast486/opcodes.c b/reactos/lib/fast486/opcodes.c index 3dffdaacc18..1a8f1260484 100644 --- a/reactos/lib/fast486/opcodes.c +++ b/reactos/lib/fast486/opcodes.c @@ -4397,6 +4397,17 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeLdsLes) /* Call the BOP handler */ State->BopCallback(State, BopCode); + /* + * If an interrupt should occur at this time, delay it. + * We must do this because if an interrupt begins and the BOP callback + * changes the CS:IP, the interrupt handler won't execute and the + * stack pointer will never be restored. + */ + if (State->IntStatus == FAST486_INT_EXECUTE) + { + State->IntStatus = FAST486_INT_DELAYED; + } + /* Return success */ return TRUE; }