From e0ae6837d0985a9c792c54ebc8105da30070b2e6 Mon Sep 17 00:00:00 2001 From: Quentin Date: Tue, 12 Sep 2023 20:19:24 +0200 Subject: [PATCH] Fix #1545 - ERR_MEM_EMBEDDEDALLOC_ALLOC Crash (#2116) --- src/hooks/misc/queue_dependency.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/hooks/misc/queue_dependency.cpp b/src/hooks/misc/queue_dependency.cpp index 4cddc7fe..0f4e0710 100644 --- a/src/hooks/misc/queue_dependency.cpp +++ b/src/hooks/misc/queue_dependency.cpp @@ -35,7 +35,7 @@ namespace big return value == 0xE9; } - bool is_unwanted_dependency(__int64 cb) + bool is_unwanted_dependency(__int64 cb, uint64_t caller_addr_offset) { auto f1 = *(__int64*)(cb + 0x60); auto f2 = *(__int64*)(cb + 0x100); @@ -44,12 +44,24 @@ namespace big if (!is_address_in_game_region(f1) || !is_address_in_game_region(f2) || !is_address_in_game_region(f3)) return false; + // These must run, otherwise we'll at some point run out of sysMemSimpleAllocator memory. + if (caller_addr_offset == 0xAA03D4 || caller_addr_offset == 0xAA0A21 || caller_addr_offset == 0xAA0902) + { + return false; + } + return is_jump(f1) || is_jump(f2) || is_jump(f3); } void hooks::queue_dependency(void* dependency) { - if (is_unwanted_dependency((__int64)dependency)) + uint64_t caller_addr_offset = (uint64_t)_ReturnAddress(); + + static auto module_base = (uint64_t)GetModuleHandle(0); + + caller_addr_offset -= module_base; + + if (is_unwanted_dependency((__int64)dependency, caller_addr_offset)) { return; }