Fix Layering Iverwrites

This commit is contained in:
TheBrokenRail 2024-05-09 17:50:02 -04:00
parent 37e1abbdd3
commit e1f0787e48
4 changed files with 16 additions and 9 deletions

@ -1 +1 @@
Subproject commit 853481bd9ae617747fd1a5d0b6255bdf3946c6dd
Subproject commit 9697b35de4d783282afdd3a4c643951ce49a0158

View File

@ -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
TRUE Add Reborn Info To Options
FALSE Track FPS

View File

@ -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

View File

@ -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