Fix IP value for UC_MODE_16 (#1321)

This commit is contained in:
lazymio
2020-09-10 10:02:22 +08:00
committed by GitHub
parent c03f50f76a
commit c1c0baec7d

View File

@ -27,6 +27,11 @@ const int X86_REGS_STORAGE_SIZE = offsetof(CPUX86State, tlb_table);
static void x86_set_pc(struct uc_struct *uc, uint64_t address) static void x86_set_pc(struct uc_struct *uc, uint64_t address)
{ {
CPUState* cpu = uc->cpu;
int16_t cs = (uint16_t)X86_CPU(uc, cpu)->env.segs[R_CS].selector;
if(uc->mode == UC_MODE_16)
((CPUX86State *)uc->current_cpu->env_ptr)->eip = address - cs*16;
else
((CPUX86State *)uc->current_cpu->env_ptr)->eip = address; ((CPUX86State *)uc->current_cpu->env_ptr)->eip = address;
} }