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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,12 @@ const int X86_REGS_STORAGE_SIZE = offsetof(CPUX86State, tlb_table);
static void x86_set_pc(struct uc_struct *uc, uint64_t address)
{
((CPUX86State *)uc->current_cpu->env_ptr)->eip = 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;
}
void x86_release(void *ctx);