SafetyHook: C:/M/B/src/safetyhook-0.6.5/include/safetyhook/easy.hpp Source File

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"
7#include "safetyhook/inline_hook.hpp"
8#include "safetyhook/mid_hook.hpp"
9#include "safetyhook/utility.hpp"
10#include "safetyhook/vmt_hook.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
59 template <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
safetyhook::InlineHook
An inline hook.
Definition inline_hook.hpp:23
safetyhook::InlineHook::Flags
Flags
Flags for InlineHook.
Definition inline_hook.hpp:116
safetyhook::InlineHook::Default
@ Default
Default flags.
Definition inline_hook.hpp:117
safetyhook::MidHook
A mid function hook.
Definition mid_hook.hpp:25
safetyhook::MidHook::Flags
Flags
Flags for MidHook.
Definition mid_hook.hpp:63
safetyhook::MidHook::Default
@ Default
Default flags.
Definition mid_hook.hpp:64
safetyhook::VmHook
A hook class that allows for hooking a single method in a VMT.
Definition vmt_hook.hpp:20
safetyhook::VmtHook
A hook class that copies an entire VMT for a given object and replaces it.
Definition vmt_hook.hpp:95
safetyhook::VmtHook::hook_method
std::expected< VmHook, Error > hook_method(size_t index, T new_function)
Hooks a method in the VMT.
Definition vmt_hook.hpp:147
safetyhook::create_vmt
VmtHook SAFETYHOOK_API create_vmt(void *object)
Easy to use API for creating a VmtHook.
safetyhook::create_inline
InlineHook SAFETYHOOK_API create_inline(void *target, void *destination, InlineHook::Flags flags=InlineHook::Default)
Easy to use API for creating an InlineHook.
safetyhook::create_mid
MidHook SAFETYHOOK_API create_mid(void *target, MidHookFn destination, MidHook::Flags flags=MidHook::Default)
Easy to use API for creating a MidHook.
safetyhook::create_vm
VmHook create_vm(VmtHook &vmt, size_t index, T destination)
Easy to use API for creating a VmHook.
Definition easy.hpp:59
inline_hook.hpp
Inline hooking class.
mid_hook.hpp
Mid function hooking class.
safetyhook::MidHookFn
void(*)(Context &ctx) MidHookFn
A MidHook destination function.
Definition mid_hook.hpp:22
vmt_hook.hpp
VMT hooking classes.