read/write of x86 segment registers should modify selector field not base field
This commit is contained in:
parent
101f14285a
commit
f3dc2522a0
|
@ -260,22 +260,22 @@ int x86_reg_read(struct uc_struct *uc, unsigned int regid, void *value)
|
|||
*(int16_t *)value = READ_WORD(X86_CPU(uc, mycpu)->env.eip);
|
||||
break;
|
||||
case UC_X86_REG_CS:
|
||||
*(int32_t *)value = X86_CPU(uc, mycpu)->env.segs[R_CS].base;
|
||||
*(int32_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_CS].selector;
|
||||
break;
|
||||
case UC_X86_REG_DS:
|
||||
*(int32_t *)value = X86_CPU(uc, mycpu)->env.segs[R_DS].base;
|
||||
*(int32_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_DS].selector;
|
||||
break;
|
||||
case UC_X86_REG_SS:
|
||||
*(int32_t *)value = X86_CPU(uc, mycpu)->env.segs[R_SS].base;
|
||||
*(int32_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_SS].selector;
|
||||
break;
|
||||
case UC_X86_REG_ES:
|
||||
*(int32_t *)value = X86_CPU(uc, mycpu)->env.segs[R_ES].base;
|
||||
*(int32_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_ES].selector;
|
||||
break;
|
||||
case UC_X86_REG_FS:
|
||||
*(int32_t *)value = X86_CPU(uc, mycpu)->env.segs[R_FS].base;
|
||||
*(int32_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_FS].selector;
|
||||
break;
|
||||
case UC_X86_REG_GS:
|
||||
*(int32_t *)value = X86_CPU(uc, mycpu)->env.segs[R_GS].base;
|
||||
*(int32_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_GS].selector;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -412,22 +412,22 @@ int x86_reg_read(struct uc_struct *uc, unsigned int regid, void *value)
|
|||
*(int16_t *)value = READ_WORD(X86_CPU(uc, mycpu)->env.eip);
|
||||
break;
|
||||
case UC_X86_REG_CS:
|
||||
*(int64_t *)value = X86_CPU(uc, mycpu)->env.segs[R_CS].base;
|
||||
*(int64_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_CS].selector;
|
||||
break;
|
||||
case UC_X86_REG_DS:
|
||||
*(int64_t *)value = X86_CPU(uc, mycpu)->env.segs[R_DS].base;
|
||||
*(int64_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_DS].selector;
|
||||
break;
|
||||
case UC_X86_REG_SS:
|
||||
*(int64_t *)value = X86_CPU(uc, mycpu)->env.segs[R_SS].base;
|
||||
*(int64_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_SS].selector;
|
||||
break;
|
||||
case UC_X86_REG_ES:
|
||||
*(int64_t *)value = X86_CPU(uc, mycpu)->env.segs[R_ES].base;
|
||||
*(int64_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_ES].selector;
|
||||
break;
|
||||
case UC_X86_REG_FS:
|
||||
*(int64_t *)value = X86_CPU(uc, mycpu)->env.segs[R_FS].base;
|
||||
*(int64_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_FS].selector;
|
||||
break;
|
||||
case UC_X86_REG_GS:
|
||||
*(int64_t *)value = X86_CPU(uc, mycpu)->env.segs[R_GS].base;
|
||||
*(int64_t *)value = (uint16_t)X86_CPU(uc, mycpu)->env.segs[R_GS].selector;
|
||||
break;
|
||||
case UC_X86_REG_R8:
|
||||
*(int64_t *)value = READ_QWORD(X86_CPU(uc, mycpu)->env.regs[8]);
|
||||
|
@ -667,22 +667,22 @@ int x86_reg_write(struct uc_struct *uc, unsigned int regid, const void *value)
|
|||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_CS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_CS].base = *(uint32_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_CS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_DS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_DS].base = *(uint32_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_DS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_SS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_SS].base = *(uint32_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_SS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_ES:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_ES].base = *(uint32_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_ES].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_FS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_FS].base = *(uint32_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_FS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_GS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_GS].base = *(uint32_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_GS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -829,22 +829,22 @@ int x86_reg_write(struct uc_struct *uc, unsigned int regid, const void *value)
|
|||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_CS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_CS].base = *(uint64_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_CS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_DS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_DS].base = *(uint64_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_DS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_SS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_SS].base = *(uint64_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_SS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_ES:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_ES].base = *(uint64_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_ES].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_FS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_FS].base = *(uint64_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_FS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_GS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_GS].base = *(uint64_t *)value;
|
||||
X86_CPU(uc, mycpu)->env.segs[R_GS].selector = *(uint16_t *)value;
|
||||
break;
|
||||
case UC_X86_REG_R8:
|
||||
X86_CPU(uc, mycpu)->env.regs[8] = *(uint64_t *)value;
|
||||
|
|
Loading…
Reference in New Issue