diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fba96be..4f21cc32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,13 +134,13 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(bddisasm) -message(STATUS "Fetching kananlib (ccf2e5a32cf4c85a90641ae7a35c2b1d636c7636)...") +message(STATUS "Fetching kananlib (cca66766b139994f478ea48befd67a179b7310ab)...") FetchContent_Declare( kananlib GIT_REPOSITORY https://github.com/cursey/kananlib GIT_TAG - ccf2e5a32cf4c85a90641ae7a35c2b1d636c7636 + cca66766b139994f478ea48befd67a179b7310ab ) FetchContent_MakeAvailable(kananlib) diff --git a/cmake.toml b/cmake.toml index fc8c50e1..5c4767cc 100644 --- a/cmake.toml +++ b/cmake.toml @@ -175,7 +175,7 @@ tag = "v1.34.10" [fetch-content.kananlib] git = "https://github.com/cursey/kananlib" -tag = "ccf2e5a32cf4c85a90641ae7a35c2b1d636c7636" +tag = "cca66766b139994f478ea48befd67a179b7310ab" [target.utility] type = "static" diff --git a/src/HookManager.cpp b/src/HookManager.cpp index 22d3624e..d723c9a4 100644 --- a/src/HookManager.cpp +++ b/src/HookManager.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -127,7 +129,9 @@ void HookManager::HookedFn::on_post_hook() { auto& ret_val = storage->ret_val; //auto& ret_addr = storage->ret_addr_post; - for (const auto& cb : cbs) { + // Iterate in reverse because it helps with the hook storage we use in Lua + // It should help with any other system that wants to use a stack-based storage system. + for (const auto& cb : cbs | std::views::reverse) { if (cb.post_fn) { // Valid return address in recursion scenario is no longer supported with this API. // We just pass ret_addr_pre for now, even though it's not accurate. diff --git a/src/mods/ScriptRunner.hpp b/src/mods/ScriptRunner.hpp index 81a07749..8a79348f 100644 --- a/src/mods/ScriptRunner.hpp +++ b/src/mods/ScriptRunner.hpp @@ -178,7 +178,7 @@ class ScriptState { auto it = m_hook_storage.find(thread_hash); if (it != m_hook_storage.end()) { if (!it->second.empty()) { - it->second.pop_front(); + it->second.pop_back(); } } @@ -196,7 +196,7 @@ class ScriptState { auto it = m_hook_storage.find(thread_hash); if (it != m_hook_storage.end()) { if (!it->second.empty()) { - return it->second.front(); + return it->second.back(); } }