summaryrefslogtreecommitdiffstats
path: root/src/hooks.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hooks.h')
-rw-r--r--src/hooks.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/hooks.h b/src/hooks.h
new file mode 100644
index 0000000..084698f
--- /dev/null
+++ b/src/hooks.h
@@ -0,0 +1,28 @@
1#ifndef HL2H_HOOKS_H
2#define HL2H_HOOKS_H
3
4#include <cstddef>
5
6// One patched vtable slot. `original` receives the untouched function pointer
7// (it may be null if the caller does not need it).
8struct VtablePatch {
9 int slot;
10 void *replacement;
11 void **original;
12};
13
14// Clone `iface`'s vtable (preserving the Itanium ABI header), apply all
15// patches, and install the clone on the object. All slots belong to the same
16// interface. Returns false and leaves the object untouched if cloning fails or
17// any slot is out of range.
18bool hooks_install_vtable(void *iface, size_t slots, const VtablePatch *patches,
19 int count);
20
21// Restore every patched interface's original vtable in reverse install order.
22// Intended for tests and shutdown; the cheat normally lives as long as the
23// process does.
24void hooks_restore_all();
25
26int hooks_installed_count();
27
28#endif