VanHooks
C++23 · Hooking
Function hooking for Windows, Linux and macOS on x86, x64 and ARM64. Seventeen hook kinds, from trampolines and import tables to hardware breakpoints and TLS callbacks, with std::expected errors and RAII lifetime.
#include <vh/vh.hpp>
static decltype(&MessageBoxW) orig_mbw = nullptr;
int WINAPI hk_mbw(HWND h, LPCWSTR text, LPCWSTR cap, UINT type) {
return orig_mbw(h, L"[Intercepted]", cap, type);
}
auto r = vh::api_hook("user32", "MessageBoxW", &hk_mbw, &orig_mbw);
if (!r) return log(vh::error_to_string(r.error()));
// unhooked when `hook` is destroyed
vh::Hook hook = std::move(*r);



