This commit is contained in:
恍兮惚兮 2024-11-16 20:24:23 +08:00
parent 272661b640
commit 1b28a2cfad
2 changed files with 5 additions and 8 deletions

View File

@ -5,6 +5,7 @@ void detachall();
HMODULE hLUNAHOOKDLL; HMODULE hLUNAHOOKDLL;
WinMutex viewMutex; WinMutex viewMutex;
CommonSharedMem *commonsharedmem; CommonSharedMem *commonsharedmem;
Synchronized<std::map<uint64_t, std::pair<std::string, HookParam>>> delayinserthook; // 谜之这个必须在这里定义可以extern+cpp里定义或者只在这里写不能在main.h里inline定义否则会在v141_xp上编译后会崩。
namespace namespace
{ {
AutoHandle<> hookPipe = INVALID_HANDLE_VALUE, AutoHandle<> hookPipe = INVALID_HANDLE_VALUE,
@ -252,20 +253,17 @@ bool NewHook_1(HookParam &hp, LPCSTR lpname)
return true; return true;
} }
} }
static std::mutex delayinsertlock;
void delayinsertadd(HookParam hp, std::string name) void delayinsertadd(HookParam hp, std::string name)
{ {
std::lock_guard _(maplock); delayinserthook->insert(std::make_pair(hp.emu_addr, std::make_pair(name, hp)));
delayinserthook[hp.emu_addr] = {name, hp};
ConsoleOutput(INSERTING_HOOK, name.c_str(), hp.emu_addr); ConsoleOutput(INSERTING_HOOK, name.c_str(), hp.emu_addr);
} }
void delayinsertNewHook(uint64_t em_address) void delayinsertNewHook(uint64_t em_address)
{ {
if (delayinserthook.find(em_address) == delayinserthook.end()) if (delayinserthook->find(em_address) == delayinserthook->end())
return; return;
std::lock_guard _(maplock); auto h = delayinserthook->at(em_address);
auto h = delayinserthook[em_address]; delayinserthook->erase(em_address);
delayinserthook.erase(em_address);
NewHook(h.second, h.first.c_str()); NewHook(h.second, h.first.c_str());
} }
bool NewHook(HookParam hp, LPCSTR name) bool NewHook(HookParam hp, LPCSTR name)

View File

@ -25,7 +25,6 @@ void jitaddraddr(uint64_t em_addr, uintptr_t jitaddr, JITTYPE);
void context_get(hook_stack *, PCONTEXT); void context_get(hook_stack *, PCONTEXT);
void context_set(hook_stack *, PCONTEXT); void context_set(hook_stack *, PCONTEXT);
inline std::map<uint64_t, std::pair<std::string, HookParam>> delayinserthook;
void delayinsertadd(HookParam, std::string); void delayinsertadd(HookParam, std::string);
void delayinsertNewHook(uint64_t); void delayinsertNewHook(uint64_t);
inline bool safeautoleaveveh = false; inline bool safeautoleaveveh = false;