Skip to content

Commit 5bae470

Browse files
committed
MHWilds: Completely patch out memory scanning code
1 parent 8358c55 commit 5bae470

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/mods/IntegrityCheckBypass.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,45 @@ void IntegrityCheckBypass::immediate_patch_dd2() {
760760
if (crasher_fn) {
761761
spdlog::info("[IntegrityCheckBypass]: Found crasher_fn!");
762762

763+
auto crasher_fn_ref = utility::scan_displacement_reference(game, *crasher_fn);
764+
765+
if (crasher_fn_ref) {
766+
spdlog::info("[IntegrityCheckBypass]: Found crasher_fn_ref");
767+
}
768+
769+
if (crasher_fn_ref && *(uint8_t*)(*crasher_fn_ref - 1) == 0xE9) {
770+
crasher_fn_ref = utility::find_function_start(*crasher_fn_ref - 1);
771+
} else {
772+
crasher_fn_ref = *crasher_fn;
773+
}
774+
775+
if (crasher_fn_ref) {
776+
spdlog::info("[IntegrityCheckBypass]: Found crasher fn (real)");
777+
778+
// We have to use this because I think that the AVX2 scan is broken here for some reason... uh oh...
779+
const auto scanner_fn_middle = utility::scan_relative_reference_scalar((uintptr_t)game, game_size - 0x1000, *crasher_fn_ref, [](uintptr_t addr) {
780+
return *(uint8_t*)(addr - 1) == 0xE8;
781+
});
782+
783+
if (scanner_fn_middle) {
784+
spdlog::info("[IntegrityCheckBypass]: Found scanner_fn_middle");
785+
786+
const auto scanner_fn = utility::find_function_start_unwind(*scanner_fn_middle);
787+
788+
if (scanner_fn) {
789+
spdlog::info("[IntegrityCheckBypass]: Found scanner_fn!");
790+
static auto nuke_patch = Patch::create(*scanner_fn, { 0xC3 }, true); // ret
791+
spdlog::info("[IntegrityCheckBypass]: Patched scanner_fn!");
792+
} else {
793+
spdlog::error("[IntegrityCheckBypass]: Could not find scanner_fn!");
794+
}
795+
} else {
796+
spdlog::error("[IntegrityCheckBypass]: Could not find scanner_fn_middle! (3)");
797+
}
798+
} else {
799+
spdlog::error("[IntegrityCheckBypass]: Could not find crasher_fn_ref! (2)");
800+
}
801+
763802
// Make function just ret
764803
//static auto patch = Patch::create(*crasher_fn, { 0xC3 }, true);
765804

0 commit comments

Comments
 (0)