www
This commit is contained in:
HelenWalker committed 2026-03-08 16:19:24 -06:00
1 parent 3933cd1901
commit 0aa65c433d
98 files changed
+56670

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#pragma once
#include "Common.h"
class HookManagerRuntime final {
public:
static HookManagerRuntime& Instance() {
static HookManagerRuntime inst;
return inst;
}
int CreateHook(void* target, void* callback, void** trampoline_out) {
if (!target || !callback || !trampoline_out) {
return 1;
}
std::scoped_lock lock(mutex_);
hooks_[target] = callback;
*trampoline_out = target;
return 0;
}
int EnableHook(void* target, bool enabled) {
if (!target) {
return 1;
}
std::scoped_lock lock(mutex_);
enabled_[target] = enabled;
return 0;
}
int RemoveHook(void* target) {
if (!target) {
return 1;
}
std::scoped_lock lock(mutex_);
hooks_.erase(target);
enabled_.erase(target);
return 0;
}
private:
HookManagerRuntime() = default;
std::mutex mutex_;
std::unordered_map<void*, void*> hooks_;
std::unordered_map<void*, bool> enabled_;
};