From 03aed19145d1e9966871db2c274879e86f050d0c Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 22 Mar 2016 15:17:56 +0800 Subject: [PATCH] UC_OPT_WINDOWS_TIB: Windows 64 uses GS segment rather than FS segment for TIB --- qemu/target-i386/unicorn.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qemu/target-i386/unicorn.c b/qemu/target-i386/unicorn.c index 6f5435d2..b187cf9e 100644 --- a/qemu/target-i386/unicorn.c +++ b/qemu/target-i386/unicorn.c @@ -1128,8 +1128,18 @@ static uc_err x86_option(struct uc_struct *uc, uc_opt_type type, size_t value) if (type != UC_OPT_WINDOWS_TIB) return UC_ERR_OPT_INVALID; - // TODO: setup limit? - X86_CPU(uc, mycpu)->env.segs[R_FS].base = value; + switch(uc->mode) { + default: + break; + case UC_MODE_32: + // TODO: setup limit? + X86_CPU(uc, mycpu)->env.segs[R_FS].base = value; + break; + case UC_MODE_64: + // TODO: setup limit? + X86_CPU(uc, mycpu)->env.segs[R_GS].base = value; + break; + } return UC_ERR_OK; }