SafetyHook: safetyhook::VmtHook Class Reference

SafetyHook

Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
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
VmtHook & | operator= (const VmtHook &)=delete
VmtHook & | operator= (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, Error > | hook_method (size_t index, T new_function)
| Hooks a method in the VMT.

## Static Public Member Functions
static std::expected< VmtHook, Error > | create (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

  object | The 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

  object | The 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

  index | The index of the method to hook.
  new_function | The new function to use.

## ◆ remove()

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

Removes the hook.

Parameters

  object | The object to remove the hook from.

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

- C:/M/B/src/safetyhook-0.6.5/include/safetyhook/vmt_hook.hpp