From 95fb7859d2851ddc10cc8fcd260f5cdb5c216a47 Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 24 Jul 2023 13:24:30 +0300 Subject: [PATCH] Fixup patches --- Utilities/bin_patch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index 1a10a2b517..ba25cf5368 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -1046,7 +1046,7 @@ static usz apply_modification(std::basic_string& applied, patch_engine::pat auto ptr = mem_translate(offset, memory_size); - if (!ptr && memory_size != 0) + if (!ptr && memory_size != 0 && !relocate_instructions_at) { // Memory translation failed continue; @@ -1076,7 +1076,7 @@ static usz apply_modification(std::basic_string& applied, patch_engine::pat } case patch_type::code_alloc: { - const u32 out_branch = vm::try_get_addr(mem_translate(offset & -4, 4)).first; + const u32 out_branch = vm::try_get_addr(relocate_instructions_at ? vm::get_super_ptr(offset & -4) : mem_translate(offset & -4, 4)).first; // Allow only if points to a PPU executable instruction if (out_branch < 0x10000 || out_branch >= 0x4000'0000 || !vm::check_addr<4>(out_branch, vm::page_executable)) @@ -1160,7 +1160,7 @@ static usz apply_modification(std::basic_string& applied, patch_engine::pat case patch_type::jump: case patch_type::jump_link: { - const u32 out_branch = vm::try_get_addr(mem_translate(offset & -4, 4)).first; + const u32 out_branch = vm::try_get_addr(relocate_instructions_at ? vm::get_super_ptr(offset & -4) : mem_translate(offset & -4, 4)).first; const u32 dest = static_cast(p.value.long_value); // Allow only if points to a PPU executable instruction @@ -1176,7 +1176,7 @@ static usz apply_modification(std::basic_string& applied, patch_engine::pat { const std::string& str = p.original_value; - const u32 out_branch = vm::try_get_addr(mem_translate(offset & -4, 4)).first; + const u32 out_branch = vm::try_get_addr(relocate_instructions_at ? vm::get_super_ptr(offset & -4) : mem_translate(offset & -4, 4)).first; const usz sep_pos = str.find_first_of(':'); // Must contain only a single ':' or none