From d4f2cb5e8d9cceeee8be4725f94b5b57b6fac223 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sat, 27 Sep 2025 20:49:55 +0200 Subject: [PATCH] Add the possibility to retrieve address with an offset (depending on opcode) --- Memory/Memory.cpp | 4 ++-- Memory/Memory.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Memory/Memory.cpp b/Memory/Memory.cpp index 672a479..a078992 100644 --- a/Memory/Memory.cpp +++ b/Memory/Memory.cpp @@ -12,7 +12,7 @@ static std::shared_ptr _log; std::unordered_map Memory::patches; -uint8_t* Memory::GetOffsetFromOpcode(uint8_t* opcode) +uint8_t* Memory::GetOffsetFromOpcode(uint8_t* opcode, int extraOffset) { if (!opcode) return nullptr; @@ -24,7 +24,7 @@ uint8_t* Memory::GetOffsetFromOpcode(uint8_t* opcode) return nullptr; // optionnel : gérer ou pas les offsets négatifs // Retourne l'adresse "offsetée" (base + disp) - return opcode + 4 + disp; // +4 car disp32 fait 4 octets + return opcode + 4 + disp + extraOffset; // +4 car disp32 fait 4 octets } const char* Memory::Float32ToHexBytes(float value) { diff --git a/Memory/Memory.hpp b/Memory/Memory.hpp index 992d654..e880a04 100644 --- a/Memory/Memory.hpp +++ b/Memory/Memory.hpp @@ -19,7 +19,7 @@ class Memory * * @param opcode : The address where the offset begins. */ - static uint8_t* GetOffsetFromOpcode(uint8_t* opcode); + static uint8_t* GetOffsetFromOpcode(uint8_t* opcode, int extraOffset = 0); /** * Converts flkoat 32 bits into a char*.