SafetyHook
Loading...
Searching...
No Matches
safetyhook::VmtHook Class Referencefinal

A hook class that copies an entire VMT for a given object and replaces it. More...

#include <vmt_hook.hpp>

Classes

struct  Error
 Error type for VmtHook. More...
 

Public Member Functions

 VmtHook (const VmtHook &)=delete
 
 VmtHook (VmtHook &&other) noexcept
 
VmtHookoperator= (const VmtHook &)=delete
 
VmtHookoperator= (VmtHook &&other) noexcept
 
void apply (void *object)
 Applies the hook.
 
void remove (void *object)
 Removes the hook.
 
void reset ()
 Removes the hook from all objects.
 
template<typename T>
std::expected< VmHook, Errorhook_method (size_t index, T new_function)
 Hooks a method in the VMT.
 

Static Public Member Functions

static std::expected< VmtHook, Errorcreate (void *object)
 Creates a new VmtHook object. Will clone the VMT of the given object and replace it.
 

Detailed Description

A hook class that copies an entire VMT for a given object and replaces it.

Member Function Documentation

◆ apply()

void safetyhook::VmtHook::apply ( void * object)

Applies the hook.

Parameters
objectThe object to apply the hook to.
Note
This will replace the VMT of the object with the new VMT. You can apply the hook to multiple objects.

◆ create()

static std::expected< VmtHook, Error > safetyhook::VmtHook::create ( void * object)
staticnodiscard

Creates a new VmtHook object. Will clone the VMT of the given object and replace it.

Parameters
objectThe object to hook.
Returns
The VmtHook object or a VmtHook::Error if an error occurred.

◆ hook_method()

template<typename T>
std::expected< VmHook, Error > safetyhook::VmtHook::hook_method ( size_t index,
T new_function )
inlinenodiscard

Hooks a method in the VMT.

Parameters
indexThe index of the method to hook.
new_functionThe new function to use.

◆ remove()

void safetyhook::VmtHook::remove ( void * object)

Removes the hook.

Parameters
objectThe object to remove the hook from.

The documentation for this class was generated from the following file: