diff --git a/meson.build b/meson.build index df16f2e..e30d622 100644 --- a/meson.build +++ b/meson.build @@ -67,7 +67,7 @@ else endif if funchook_disasm == 'Zydis' - funchook_deps += dependency( + zydis_dep = dependency( 'zydis', version: '>=4.0.0', default_options: { @@ -76,6 +76,20 @@ if funchook_disasm == 'Zydis' }, ) cdata.set10('DISASM_ZYDIS', true) + + cdata.set10( + 'DISASM_ZYDIS_V5', + cc.has_member( + 'ZydisDecodedOperandMem', + 'disp.size', + dependencies: zydis_dep.partial_dependency(compile_args: true, includes: true), + prefix: ''' + #include + ''', + ), + ) + + funchook_deps += zydis_dep elif disasm == 'capstone' funchook_deps += dependency( 'capstone', diff --git a/src/disasm_Zydis.c b/src/disasm_Zydis.c index c2b585c..9490e74 100644 --- a/src/disasm_Zydis.c +++ b/src/disasm_Zydis.c @@ -130,7 +130,11 @@ void funchook_disasm_x86_rip_relative(funchook_disasm_t *disasm, const funchook_ int i; for (i = 0; i < insn->insn.operand_count; i++) { const ZydisDecodedOperand *op = &insn->operands[i]; +#if DISASM_ZYDIS_V5 + if (op->mem.disp.size != 0 && op->mem.base == ZYDIS_REGISTER_RIP) { +#else if (op->mem.disp.has_displacement && op->mem.base == ZYDIS_REGISTER_RIP) { +#endif // Fix IP-relative addressing such as: // mov eax, dword ptr [rip + 0x236eda] // jmp qword ptr [rip + 0x239468] diff --git a/subprojects/zydis.wrap b/subprojects/zydis.wrap index a204554..c0cb84c 100644 --- a/subprojects/zydis.wrap +++ b/subprojects/zydis.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/zyantific/zydis.git -revision = cb487f1cb477b2c03345aa72baf7eda725b77507 +revision = bffbb610cfea643b98e87658b9058382f7522807 depth = 1 [provide]