Skip to content

Commit

Permalink
MHWilds: Tentative crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Feb 28, 2025
1 parent 4f40265 commit 97ca32b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/mods/IntegrityCheckBypass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,41 @@ void IntegrityCheckBypass::immediate_patch_dd2() {
spdlog::info("[IntegrityCheckBypass]: Scanning DD2...");

const auto game = utility::get_executable();

#if TDB_VER >= 74
const auto query_performance_frequency = &QueryPerformanceFrequency;
const auto query_performance_counter = &QueryPerformanceCounter;

if (query_performance_frequency != nullptr && query_performance_counter != nullptr) {
const auto qpf_import = utility::scan_ptr(game, (uintptr_t)query_performance_frequency);
const auto qpc_import = utility::scan_ptr(game, (uintptr_t)query_performance_counter);

if (qpf_import && qpc_import) {
const auto crasher_fn = utility::find_function_with_refs(game, { *qpf_import, *qpc_import });

if (crasher_fn) {
spdlog::info("[IntegrityCheckBypass]: Found crasher_fn!");

// Make function just ret
//static auto patch = Patch::create(*crasher_fn, { 0xC3 }, true);

const auto cmp_jz = utility::find_pattern_in_path((uint8_t*)*crasher_fn, 1000, false, "39 0C 82 74 ?");

if (cmp_jz) {
static auto patch = Patch::create(cmp_jz->addr + 3, { 0xEB }, true);
spdlog::info("[IntegrityCheckBypass]: Patched crasher_fn!");
} else {
spdlog::error("[IntegrityCheckBypass]: Could not find cmp_jz!");
}
} else {
spdlog::error("[IntegrityCheckBypass]: Could not find crasher_fn!");
}
} else {
spdlog::error("[IntegrityCheckBypass]: Could not find QueryPerformanceFrequency/Counter imports!");
}
}
#endif

const auto conditional_jmp_block = utility::scan(game, "41 8B ? ? 78 83 ? 07 ? ? 75 ?");

if (conditional_jmp_block) {
Expand Down

0 comments on commit 97ca32b

Please sign in to comment.