From 69c422090f5faa96304e062d9e87cfa7b5b9f7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Sat, 16 Nov 2024 20:42:53 +0800 Subject: [PATCH] noinline --- cpp/LunaHook/LunaHook/main.cc | 4 +++- cpp/LunaHook/LunaHook/main.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cpp/LunaHook/LunaHook/main.cc b/cpp/LunaHook/LunaHook/main.cc index d6a1bc54..b636ff88 100644 --- a/cpp/LunaHook/LunaHook/main.cc +++ b/cpp/LunaHook/LunaHook/main.cc @@ -2,10 +2,12 @@ #include "MinHook.h" void HIJACK(); void detachall(); +std::unordered_map> emuaddr2jitaddr; +std::unordered_map> jitaddr2emuaddr; HMODULE hLUNAHOOKDLL; WinMutex viewMutex; CommonSharedMem *commonsharedmem; -Synchronized>> delayinserthook; // 谜之这个必须在这里定义(可以extern+cpp里定义,或者只在这里写),不能在main.h里inline定义,否则会在v141_xp上编译后会崩。 +Synchronized>> delayinserthook; namespace { AutoHandle<> hookPipe = INVALID_HANDLE_VALUE, diff --git a/cpp/LunaHook/LunaHook/main.h b/cpp/LunaHook/LunaHook/main.h index 47c6bfc8..c3268fe2 100644 --- a/cpp/LunaHook/LunaHook/main.h +++ b/cpp/LunaHook/LunaHook/main.h @@ -18,8 +18,10 @@ inline SearchParam spDefault; // EOF int HookStrLen(HookParam *, BYTE *data); -inline std::unordered_map> emuaddr2jitaddr; -inline std::unordered_map> jitaddr2emuaddr; + +// v141_xp上,定义inline std::map会直接导致dll detach后发生崩溃。 +extern std::unordered_map> emuaddr2jitaddr; +extern std::unordered_map> jitaddr2emuaddr; void jitaddraddr(uint64_t em_addr, uintptr_t jitaddr, JITTYPE); void context_get(hook_stack *, PCONTEXT);