From d7897ca1e55bd3806abbe4ea13550df3f981125e Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Thu, 6 Nov 2014 05:37:50 +0000 Subject: [PATCH] [FAST486] We can't load the stack segment until after we've updated the CPL. svn path=/trunk/; revision=65281 --- reactos/lib/fast486/opcodes.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/reactos/lib/fast486/opcodes.c b/reactos/lib/fast486/opcodes.c index 7ac8014702d..e8a6a25040e 100644 --- a/reactos/lib/fast486/opcodes.c +++ b/reactos/lib/fast486/opcodes.c @@ -4496,7 +4496,13 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeRetFar) /* Exception */ return; } + } + /* Update the CPL */ + State->Cpl = GET_SEGMENT_RPL(Segment); + + if (State->Cpl > OldCpl) + { /* Load new SS */ if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) { @@ -4507,13 +4513,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeRetFar) /* Set ESP */ if (Size) State->GeneralRegs[FAST486_REG_ESP].Long = StackPtr; else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); - } - /* Update the CPL */ - State->Cpl = GET_SEGMENT_RPL(Segment); - - if (State->Cpl > OldCpl) - { /* Check segment security */ for (i = 0; i < FAST486_NUM_SEG_REGS; i++) { @@ -4732,17 +4732,6 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeIret) /* Exception */ return; } - - /* Load new SS */ - if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) - { - /* Exception */ - return; - } - - /* Set ESP */ - if (Size) State->GeneralRegs[FAST486_REG_ESP].Long = StackPtr; - else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); } /* Update the CPL */ @@ -4759,6 +4748,17 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeIret) if (State->Cpl > OldCpl) { + /* Load new SS */ + if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) + { + /* Exception */ + return; + } + + /* Set ESP */ + if (Size) State->GeneralRegs[FAST486_REG_ESP].Long = StackPtr; + else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); + /* Check segment security */ for (i = 0; i < FAST486_NUM_SEG_REGS; i++) {