VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Detours.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <khook.hpp>
5
6// KHook's dispatch pointer, declared for every translation unit that installs a hook.
7//
8// Each module carries its own copy, because KHook's header forwards every call through it. The
9// host fills its own from the loader; a plugin defines one in its generated entry point and seeds it from
10// IPluginContext::HookDispatcher(). It lives in Engine because vtable hooks must not depend on the
11// composition root.
12namespace KHook
13{
14extern KHook::IKHook* __exported__khook;
15}
16
17namespace VoltMod
18{
19
20/** What @p vtable's @p index held before a hook patched it, or nullptr. */
21inline const void* ReadOriginalSlot(void** vtable, int index)
22{
23 // The pointer arrives at load; before then there is nothing to query.
24 return KHook::__exported__khook ? KHook::FindOriginalVirtual(vtable, index) : nullptr;
25}
26
27} // namespace VoltMod
KHook::IKHook * __exported__khook
Definition Host.cpp:30
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
const void * ReadOriginalSlot(void **vtable, int index)
Definition Detours.hpp:21