[ros-dev] [ros-diffs] [fireball] 48745: [NTOS] - Daniel Zimmermann: Fix POPF bugs in VDM mode, namely truncation of the stackpointer to 16 bit and setting proper flags in the trapframe eflags register. This fixes proble...

Timo Kreuzer timo.kreuzer at web.de
Sun Sep 12 01:54:18 UTC 2010


fireball at svn.reactos.org wrote:
> Author: fireball
> Date: Sat Sep 11 09:20:26 2010
> New Revision: 48745
>   
...
>          /* Save EFlags */
> +        Esp -= 4;
> +        *(PULONG)(Esp - 2) = V86EFlags;
>   
This looks wrong to me. The (Esp - 2) I mean.


> +    if (KiVdmGetPrefixFlags(Flags) & PFX_FLAG_OPER32)
> +    {
> +        /* Read EFlags */
> +        EFlags = *(PULONG)Esp;
> +        Esp += 4;
> +    }
> +    else
> +    {
> +        /* Read EFlags */
> +        EFlags = *(PUSHORT)Esp;
> +        Esp += 2;
>          /* Read correct flags and use correct stack address */
> -        Esp -= 2;
>          EFlags &= 0xFFFF;
>   
Here the comment got broken a bit.

>      /* Set new ESP */
> -    TrapFrame->HardwareEsp = Esp;
> +    TrapFrame->HardwareEsp = (USHORT)Esp;
>   
This is not correct. We earlier calculated the flat Esp from Ss and Sp.
Example:
HardwareSegSs = 0x10, HardwareEsp = 0x10 -> flat Esp = 0x110, then you
substract 4, and get 0x10C. But this is not the value of the new
HardwareEsp. TrapFrame->HardwareEsp needs to be either modified in
parallel to the flat Esp or calculated like (USHORT)(Esp -
(TrapFrame->HardwareSegSs << 4)).

Regards,
Timo




More information about the Ros-dev mailing list