[PATCH v2 1/2] ntdll: Add emulation for UMIP instructions.

Andrew Wesie awesie at gmail.com
Wed Nov 13 21:51:54 CST 2019


On Thu, Nov 14, 2019 at 7:29 AM Brendan Shanks <bshanks at codeweavers.com> wrote:
> ...
> +/***********************************************************************
> + *           INSTR_GetOperandAddr
> + *
> + * Return the address of an instruction operand (from the mod/rm byte).
> + */
> +static int INSTR_GetOperandAddr( CONTEXT *context, BYTE *instr, unsigned int instr_len,
> +                                 int long_addr, int segprefix, int *len, void **addr )
> +{
> ...
> +    /* FIXME: we assume that all segments have a base of 0 */
> +    *addr = (void *)(base + (index << ss));
> +    return 1;

Does this FIXME need to be resolved? I don't have an easy way to test
UMIP but would the code example below give the correct output with
this patch? (This is not based on any real program, so it may be a
moot point.)

#include <stdio.h>
#include <stdlib.h>

int main()
{
    unsigned int ldt = 0x4141;
    unsigned short ldt2 = 0x4141;
    unsigned short ldt3 = 0x4141;
    asm volatile ("sldt %0" : "=a" (ldt));
    asm volatile ("sldt (%0)" : : "r" (&ldt2));
#if defined(__x86_64__) || defined(__amd64__)
    asm volatile ("sldt %%gs:(%0)" :: "r" (0x1250));
    asm volatile ("movw %%gs:0x1250, %0" : "=r" (ldt3));
#elif defined(__i386__)
    asm volatile ("sldt %%fs:(%0)" :: "r" (0xBF4));
    asm volatile ("movw %%fs:0xBF4, %0" : "=r" (ldt3));
#endif
    printf("ldt = %x\n", ldt);
    printf("ldt2 = %x\n", ldt2);
    printf("ldt3 = %x\n", ldt3);
    return 0;
}

-Andrew



More information about the wine-devel mailing list