From e1f0787e48ba9ab92c47332880539cf9a1f733c6 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Thu, 9 May 2024 17:50:02 -0400 Subject: [PATCH] Fix Layering Iverwrites --- dependencies/symbol-processor/src | 2 +- launcher/src/client/available-feature-flags | 3 ++- libreborn/include/libreborn/patch.h | 15 +++++++++------ libreborn/src/patch/patch.cpp | 5 ++++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/dependencies/symbol-processor/src b/dependencies/symbol-processor/src index 853481bd9a..9697b35de4 160000 --- a/dependencies/symbol-processor/src +++ b/dependencies/symbol-processor/src @@ -1 +1 @@ -Subproject commit 853481bd9ae617747fd1a5d0b6255bdf3946c6dd +Subproject commit 9697b35de4d783282afdd3a4c643951ce49a0158 diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index c1a758d8c6..e365ed544f 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -61,4 +61,5 @@ TRUE Add Splashes TRUE Display Date In Select World Screen TRUE Optimized Chunk Sorting TRUE Disable Buggy Held Item Caching -TRUE Add Reborn Info To Options \ No newline at end of file +TRUE Add Reborn Info To Options +FALSE Track FPS \ No newline at end of file diff --git a/libreborn/include/libreborn/patch.h b/libreborn/include/libreborn/patch.h index 9600011f25..bb8fda3c22 100644 --- a/libreborn/include/libreborn/patch.h +++ b/libreborn/include/libreborn/patch.h @@ -27,13 +27,12 @@ void _overwrite_call(const char *file, int line, void *start, void *target); static name##_t _helper_for_##target = __overwrite_helper_for_##name(target, _original_for_##target) // Replace All Calls To Method start With target -void _overwrite_calls(const char *file, int line, void *start, void *target); +void *_overwrite_calls(const char *file, int line, void *start, void *target); #define overwrite_calls_manual(start, target) _overwrite_calls(__FILE__, __LINE__, start, target) #define overwrite_calls(start, target) \ { \ _setup_fancy_overwrite(start, start, target); \ - overwrite_calls_manual((void *) start, (void *) _helper_for_##target); \ - start = _helper_for_##target; \ + start = (start##_t) overwrite_calls_manual((void *) start, (void *) _helper_for_##target); \ } // Replace All Calls To Virtual Method start With target @@ -45,7 +44,12 @@ void _overwrite_calls(const char *file, int line, void *start, void *target); // Replace All Calls To start With target Within [to, from) void _overwrite_calls_within(const char *file, int line, void *from, void *to, void *start, void *target); -#define overwrite_calls_within(from, to, start, target) _overwrite_calls_within(__FILE__, __LINE__, from, to, start, target) +#define overwrite_calls_within_manual(from, to, start, target) _overwrite_calls_within(__FILE__, __LINE__, from, to, start, target) +#define overwrite_calls_within(from, to, start, target) \ + { \ + start##_t type_check = target; \ + overwrite_calls_within_manual(from, to, (void *) start, (void *) type_check); \ + } // Get Target Address From BL Instruction void *extract_from_bl_instruction(unsigned char *from); @@ -55,9 +59,8 @@ void _overwrite(const char *file, int line, void *start, void *target); #define overwrite_manual(start, target) _overwrite(__FILE__, __LINE__, (void *) start, (void *) target) #define overwrite(start, target) \ { \ - _check_if_method_is_new(start); \ start##_t type_check = target; \ - overwrite_manual(start, (void *) type_check); \ + overwrite_manual((void *) start, (void *) type_check); \ } // Patch Instruction diff --git a/libreborn/src/patch/patch.cpp b/libreborn/src/patch/patch.cpp index b6c4ebd07f..831b3d02fa 100644 --- a/libreborn/src/patch/patch.cpp +++ b/libreborn/src/patch/patch.cpp @@ -77,7 +77,7 @@ static int _overwrite_calls_within_internal(const char *file, int line, void *fr #define TEXT_END 0x1020c0 // Overwrite All B(L) Intrusctions That Target The Specified Address #define NO_CALLSITE_ERROR "(%s:%i) Unable To Find Callsites For %p" -void _overwrite_calls(const char *file, int line, void *start, void *target) { +void *_overwrite_calls(const char *file, int line, void *start, void *target) { // Add New Target To Code Block void *code_block = update_code_block(target); @@ -93,6 +93,9 @@ void _overwrite_calls(const char *file, int line, void *start, void *target) { if (found < 1) { ERR(NO_CALLSITE_ERROR, file, line, start); } + + // Return + return code_block; } void _overwrite_calls_within(const char *file, int line, void *from /* inclusive */, void *to /* exclusive */, void *target, void *replacement) { // Add New Target To Code Block