SafetyHook
Loading...
Searching...
No Matches
easy.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "safetyhook/common.hpp"
9#include "safetyhook/utility.hpp"
11
12namespace safetyhook {
18[[nodiscard]] InlineHook SAFETYHOOK_API create_inline(
19 void* target, void* destination, InlineHook::Flags flags = InlineHook::Default);
20
26template <typename T, typename U>
27[[nodiscard]] InlineHook create_inline(T target, U destination, InlineHook::Flags flags = InlineHook::Default) {
28 return create_inline(reinterpret_cast<void*>(target), reinterpret_cast<void*>(destination), flags);
29}
30
36[[nodiscard]] MidHook SAFETYHOOK_API create_mid(
37 void* target, MidHookFn destination, MidHook::Flags flags = MidHook::Default);
38
44template <typename T>
45[[nodiscard]] MidHook create_mid(T target, MidHookFn destination, MidHook::Flags flags = MidHook::Default) {
46 return create_mid(reinterpret_cast<void*>(target), destination, flags);
47}
48
52[[nodiscard]] VmtHook SAFETYHOOK_API create_vmt(void* object);
53
59template <typename T> [[nodiscard]] VmHook create_vm(VmtHook& vmt, size_t index, T destination) {
60 if (auto hook = vmt.hook_method(index, destination)) {
61 return std::move(*hook);
62 } else {
63 return {};
64 }
65}
66
67} // namespace safetyhook
An inline hook.
Definition inline_hook.hpp:23
Flags
Flags for InlineHook.
Definition inline_hook.hpp:116
@ Default
Default flags.
Definition inline_hook.hpp:117
A mid function hook.
Definition mid_hook.hpp:25
Flags
Flags for MidHook.
Definition mid_hook.hpp:63
@ Default
Default flags.
Definition mid_hook.hpp:64
A hook class that allows for hooking a single method in a VMT.
Definition vmt_hook.hpp:20
A hook class that copies an entire VMT for a given object and replaces it.
Definition vmt_hook.hpp:95
std::expected< VmHook, Error > hook_method(size_t index, T new_function)
Hooks a method in the VMT.
Definition vmt_hook.hpp:147
VmtHook SAFETYHOOK_API create_vmt(void *object)
Easy to use API for creating a VmtHook.
InlineHook SAFETYHOOK_API create_inline(void *target, void *destination, InlineHook::Flags flags=InlineHook::Default)
Easy to use API for creating an InlineHook.
MidHook SAFETYHOOK_API create_mid(void *target, MidHookFn destination, MidHook::Flags flags=MidHook::Default)
Easy to use API for creating a MidHook.
VmHook create_vm(VmtHook &vmt, size_t index, T destination)
Easy to use API for creating a VmHook.
Definition easy.hpp:59
Inline hooking class.
Mid function hooking class.
void(*)(Context &ctx) MidHookFn
A MidHook destination function.
Definition mid_hook.hpp:22
VMT hooking classes.