[FAST486]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 13 May 2014 23:22:49 +0000 (23:22 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 13 May 2014 23:22:49 +0000 (23:22 +0000)
Fix a BOP-related stack corruption.
CORE-8199 #resolve #comment Fixed in revision r63286.

svn path=/trunk/; revision=63286

reactos/include/reactos/libs/fast486/fast486.h
reactos/lib/fast486/fast486.c
reactos/lib/fast486/opcodes.c

index 339ecb6..5fa7291 100644 (file)
@@ -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
index c47814b..1c35d8f 100644 (file)
@@ -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)
index 3dffdaa..1a8f126 100644 (file)
@@ -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;
         }