From 615f4e770f4e612f4918c29dc34ae5aa656dc0bc Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 21 Jul 2024 04:21:02 -0700 Subject: [PATCH] Support RIP relative memory operands in patched instructions. --- src/core/cpu_patches.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index 39cfc239..2a9cf5e2 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -44,6 +44,10 @@ static Xbyak::Address ZydisToXbyakMemoryOperand(const ZydisDecodedOperand& opera ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_MEMORY, "Expected memory operand, got type: {}", static_cast(operand.type)); + if (operand.mem.base == ZYDIS_REGISTER_RIP) { + return ptr[rip + operand.mem.disp.value]; + } + Xbyak::RegExp expression{}; if (operand.mem.base != ZYDIS_REGISTER_NONE) { expression = expression + ZydisToXbyakRegister(operand.mem.base);