|
CommonLib
|
#include <bit>#include <functional>#include <optional>#include <typeindex>#include <type_traits>#include <vector>#include "../thirdparty/Detours/src/detours.h"#include "host/common.h"#include "mem/mem.h"Go to the source code of this file.
Classes | |
| struct | hedgedev::csl::hook::usercall_info |
Namespaces | |
| namespace | hedgedev |
| namespace | hedgedev::csl |
| namespace | hedgedev::csl::hook |
Macros | |
| #define | __usercall 0 |
| #define | __userpurge 1 |
| #define | USER_REGISTER(REGISTER) |
| #define | USER_RETURN(REGISTER) |
| #define | USER_RETURN_VOID USER_RETURN(none) |
| #define | USER_PARAM(INDEX, REGISTER) |
| #define | USER_FUNCTION_PTR(RETURN_TYPE, CALLING_CONVENTION, FUNCTION_NAME, ADDRESS, REGISTERS, PARAM_COUNT, ...) |
| #define | USER_HOOK(RETURN_TYPE, CALLING_CONVENTION, FUNCTION_NAME, ADDRESS, REGISTERS, PARAM_COUNT, ...) |
| #define | STATIC_USER_HOOK(RETURN_TYPE, CALLING_CONVENTION, FUNCTION_NAME, ADDRESS, REGISTERS, PARAM_COUNT, ...) |
| #define | INSTALL_USER_HOOK(FUNCTION_NAME) |
| #define | INSTALL_USER_HOOK_EXPLICIT(FUNCTION_NAME, ADDRESS) |
| #define | UNINSTALL_USER_HOOK(FUNCTION_NAME) |
Functions | |
| user_register_family | hedgedev::csl::hook::get_register_family (user_register in_register) |
| int | hedgedev::csl::hook::get_register_id (user_register in_register) |
| bool | hedgedev::csl::hook::is_protected_register (user_register in_register) |
| void * | hedgedev::csl::hook::emit_user_trampoline (const usercall_info &in_info, void *in_address, bool in_to_original=false) |
| #define __usercall 0 |
A custom calling convention that stores arguments in optimised locations, before falling back to using the stack, similar to __fastcall.
This calling convention puts the responsibility of cleaning up stack arguments on the caller.
This identifier cannot be used as a standard calling convention.
| #define __userpurge 1 |
A custom calling convention that stores arguments in optimised locations, before falling back to using the stack, similar to __fastcall.
This calling convention puts the responsibility of cleaning up stack arguments on the callee.
This identifier cannot be used as a standard calling convention.
| #define INSTALL_USER_HOOK | ( | FUNCTION_NAME | ) |
Installs a hook defined with USER_HOOK.
| FUNCTION_NAME | The name of the function to call before the original. |
| #define INSTALL_USER_HOOK_EXPLICIT | ( | FUNCTION_NAME, | |
| ADDRESS ) |
Installs a hook defined with USER_HOOK at an explicit address.
| FUNCTION_NAME | The name of the function to call before the original. |
| ADDRESS | The address of the function to hook. |
| #define STATIC_USER_HOOK | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| FUNCTION_NAME, | |||
| ADDRESS, | |||
| REGISTERS, | |||
| PARAM_COUNT, | |||
| ... ) |
Defines the body of a hook for a function with custom calling convention in memory, and installs it upon initialisation.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function, such as __usercall or __userpurge. |
| FUNCTION_NAME | The name of the function. |
| ADDRESS | The address of the function. |
| REGISTERS | The registers used by the return value and parameters. If a parameter has an unspecified register, it'll automatically be put on the stack. |
| PARAM_COUNT | The total number of parameters in __VA_ARGS__. |
| __VA_ARGS__ | The parameters of the function. |
For an optimised function with the following prototype:
A hook should be set up like the following:
| #define UNINSTALL_USER_HOOK | ( | FUNCTION_NAME | ) |
Uninstalls a hook installed with INSTALL_USER_HOOK.
| FUNCTION_NAME | The name of the function to unhook. |
| #define USER_FUNCTION_PTR | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| FUNCTION_NAME, | |||
| ADDRESS, | |||
| REGISTERS, | |||
| PARAM_COUNT, | |||
| ... ) |
Declares a pointer to a function with custom calling convention in memory.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function, such as __usercall or __userpurge. |
| FUNCTION_NAME | The name of the function. |
| ADDRESS | The address of the function. |
| REGISTERS | The registers used by the return value and parameters. If a parameter has an unspecified register, it'll automatically be put on the stack. |
| PARAM_COUNT | The total number of parameters in __VA_ARGS__. |
| __VA_ARGS__ | The parameters of the function. |
For an optimised function with the following prototype:
A function pointer should be set up like the following:
| #define USER_HOOK | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| FUNCTION_NAME, | |||
| ADDRESS, | |||
| REGISTERS, | |||
| PARAM_COUNT, | |||
| ... ) |
Defines the body of a hook for a function with custom calling convention in memory.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function, such as __usercall or __userpurge. |
| FUNCTION_NAME | The name of the function. |
| ADDRESS | The address of the function. |
| REGISTERS | The registers used by the return value and parameters. If a parameter has an unspecified register, it'll automatically be put on the stack. |
| PARAM_COUNT | The total number of parameters in __VA_ARGS__. |
| __VA_ARGS__ | The parameters of the function. |
For an optimised function with the following prototype:
A hook should be set up like the following:
| #define USER_PARAM | ( | INDEX, | |
| REGISTER ) |
Specify the register to use for a specific parameter.
| INDEX | The index of the parameter. |
| REGISTER | The register to use for the parameter. |
| #define USER_REGISTER | ( | REGISTER | ) |
| #define USER_RETURN | ( | REGISTER | ) |
Specify the register to use for the return value.
| REGISTER | The register to use for the return value. |
| #define USER_RETURN_VOID USER_RETURN(none) |
Specifies the hook has no return value.