Skip to content

Commit

Permalink
Support Zydis V5
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Jan 7, 2025
1 parent 8eb226f commit 35183b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ else
endif

if funchook_disasm == 'Zydis'
funchook_deps += dependency(
zydis_dep = dependency(
'zydis',
version: '>=4.0.0',
default_options: {
Expand All @@ -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 <Zydis/Zydis.h>
''',
),
)

funchook_deps += zydis_dep
elif disasm == 'capstone'
funchook_deps += dependency(
'capstone',
Expand Down
4 changes: 4 additions & 0 deletions src/disasm_Zydis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/zydis.wrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[wrap-git]
url = https://github.com/zyantific/zydis.git
revision = cb487f1cb477b2c03345aa72baf7eda725b77507
revision = bffbb610cfea643b98e87658b9058382f7522807
depth = 1

[provide]
Expand Down

0 comments on commit 35183b4

Please sign in to comment.