Author: aandrejevic Date: Thu Nov 6 05:37:50 2014 New Revision: 65281
URL: http://svn.reactos.org/svn/reactos?rev=65281&view=rev Log: [FAST486] We can't load the stack segment until after we've updated the CPL.
Modified: trunk/reactos/lib/fast486/opcodes.c
Modified: trunk/reactos/lib/fast486/opcodes.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.c?rev=6... ============================================================================== --- trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] Thu Nov 6 05:37:50 2014 @@ -4496,7 +4496,13 @@ /* 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 @@ /* 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,7 +4732,22 @@ /* Exception */ return; } - + } + + /* Update the CPL */ + State->Cpl = GET_SEGMENT_RPL(CodeSel); + + /* Set the new flags */ + if (Size) State->Flags.Long = NewFlags.Long & PROT_MODE_FLAGS_MASK; + else State->Flags.LowWord = NewFlags.LowWord & PROT_MODE_FLAGS_MASK; + State->Flags.AlwaysSet = TRUE; + + /* Set additional flags */ + if (OldCpl <= State->Flags.Iopl) State->Flags.If = NewFlags.If; + if (OldCpl == 0) State->Flags.Iopl = NewFlags.Iopl; + + if (State->Cpl > OldCpl) + { /* Load new SS */ if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) { @@ -4743,22 +4758,7 @@ /* 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(CodeSel); - - /* Set the new flags */ - if (Size) State->Flags.Long = NewFlags.Long & PROT_MODE_FLAGS_MASK; - else State->Flags.LowWord = NewFlags.LowWord & PROT_MODE_FLAGS_MASK; - State->Flags.AlwaysSet = TRUE; - - /* Set additional flags */ - if (OldCpl <= State->Flags.Iopl) State->Flags.If = NewFlags.If; - if (OldCpl == 0) State->Flags.Iopl = NewFlags.Iopl; - - if (State->Cpl > OldCpl) - { + /* Check segment security */ for (i = 0; i < FAST486_NUM_SEG_REGS; i++) {