|
CommonLib
|
#include <functional>#include "../thirdparty/Detours/src/detours.h"#include "host/common.h"#include "mem/mem.h"#include "ut/os/preprocessor_win32.h"#include "hook_usercall_win32.h"Go to the source code of this file.
Namespaces | |
| namespace | hedgedev |
| namespace | hedgedev::csl |
| namespace | hedgedev::csl::hook |
Macros | |
| #define | FUNCTION_PTR(RETURN_TYPE, CALLING_CONVENTION, FUNCTION_NAME, ADDRESS, ...) |
| #define | DLL_IMPORT_FUNCTION_PTR(RETURN_TYPE, LIBRARY_NAME, FUNCTION_NAME, ...) |
| #define | HOOK(RETURN_TYPE, CALLING_CONVENTION, FUNCTION_NAME, ADDRESS, ...) |
| #define | STATIC_HOOK(RETURN_TYPE, CALLING_CONVENTION, FUNCTION_NAME, ADDRESS, ...) |
| #define | GET_STATIC_HOOK_RESULT(FUNCTION_NAME) |
| #define | THISCALL __fastcall |
| #define | THISCALL_PARAMS(CLASS_NAME) |
| Expands to the necessary function parameters required by __thiscall calling convention. | |
| #define | THISCALL_RETURN_PARAMS |
| Expands to the necessary function arguments required by __thiscall calling convention for calling the original function. | |
| #define | VFTABLE_HOOK(RETURN_TYPE, CALLING_CONVENTION, CLASS_NAME, FUNCTION_NAME, FUNCTION_INDEX, ...) |
| #define | ASM_HOOK(NAME, ADDRESS) |
| Creates an assembly hook. | |
| #define | STATIC_ASM_HOOK(NAME, ADDRESS) |
| Creates an assembly hook, and installs it upon initialisation. | |
| #define | ASM_HOOK(NAME, ADDRESS) |
| Creates an assembly hook. | |
| #define | STATIC_ASM_HOOK(NAME, ADDRESS) |
| Creates an assembly hook, and installs it upon initialisation. | |
| #define | ASM_HOOK_RETURN(NAME) |
| Returns from an assembly hook and executes the original code. | |
| #define | ASM_HOOK_BRANCH(NAME) |
| Returns from an assembly hook and skips the original code. | |
| #define | INSTALL_HOOK(NAME) |
| #define | INSTALL_HOOK_EXPLICIT(NAME, ADDRESS) |
| #define | UNINSTALL_HOOK(NAME) |
| #define | INSTALL_VFTABLE_HOOK(INSTANCE, CLASS_NAME, FUNCTION_NAME) |
| #define | INSTALL_VFTABLE_HOOK_EXPLICIT(INSTANCE, CLASS_NAME, FUNCTION_NAME, FUNCTION_INDEX) |
| #define | UNINSTALL_VFTABLE_HOOK(CLASS_NAME, FUNCTION_NAME) |
Functions | |
| void * | hedgedev::csl::hook::_get_post_hook_address (void *in_hook) |
| #define ASM_HOOK | ( | NAME, | |
| ADDRESS ) |
Creates an assembly hook.
| NAME | The name of the hook. |
| ADDRESS | The address to hook. |
mod.cpp
mod.cpp
my_asm_hook.asm
| #define ASM_HOOK | ( | NAME, | |
| ADDRESS ) |
Creates an assembly hook.
| NAME | The name of the hook. |
| ADDRESS | The address to hook. |
mod.cpp
mod.cpp
my_asm_hook.asm
| #define ASM_HOOK_BRANCH | ( | NAME | ) |
Returns from an assembly hook and skips the original code.
| NAME | The name of the hook. |
| #define ASM_HOOK_RETURN | ( | NAME | ) |
Returns from an assembly hook and executes the original code.
| NAME | The name of the hook. |
| #define DLL_IMPORT_FUNCTION_PTR | ( | RETURN_TYPE, | |
| LIBRARY_NAME, | |||
| FUNCTION_NAME, | |||
| ... ) |
Loads a dynamic link library into memory and declares a pointer to an exported function from it.
| RETURN_TYPE | The return type of the function. |
| LIBRARY_NAME | The name of the dynamic link library. |
| FUNCTION_NAME | The name of the exported function. |
| __VA_ARGS__ | The parameters of the exported function. |
| #define FUNCTION_PTR | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| FUNCTION_NAME, | |||
| ADDRESS, | |||
| ... ) |
Declares a pointer to a function in memory.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function (e.g. __cdecl, __stdcall, __fastcall, etc). For custom calling conventions on x86, such as __usercall or __userpurge, see hook_usercall_win32.h. |
| FUNCTION_NAME | The name of the function. |
| ADDRESS | The address of the function. |
| __VA_ARGS__ | The parameters of the function. |
| #define GET_STATIC_HOOK_RESULT | ( | FUNCTION_NAME | ) |
Gets the installation result of a hook defined with STATIC_HOOK, STATIC_USER_HOOK or STATIC_ASM_HOOK.
| FUNCTION_NAME | The name of the function that was hooked. |
| #define HOOK | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| FUNCTION_NAME, | |||
| ADDRESS, | |||
| ... ) |
Defines the body of a hook for a function in memory.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function (e.g. __cdecl, __stdcall, __fastcall, etc). For custom calling conventions on x86, such as __usercall or __userpurge, see hook_usercall_win32.h. |
| FUNCTION_NAME | The name of the function. |
| ADDRESS | The address of the function. |
| __VA_ARGS__ | The parameters of the function. |
| #define INSTALL_HOOK | ( | NAME | ) |
Installs a hook defined with HOOK or ASM_HOOK.
| NAME | The name of the hook to install. |
| #define INSTALL_HOOK_EXPLICIT | ( | NAME, | |
| ADDRESS ) |
Installs a hook defined with HOOK or ASM_HOOK at an explicit address.
| NAME | The name of the hook to install. |
| ADDRESS | The address to install the hook to. |
| #define INSTALL_VFTABLE_HOOK | ( | INSTANCE, | |
| CLASS_NAME, | |||
| FUNCTION_NAME ) |
Installs a hook defined with VFTABLE_HOOK.
| INSTANCE | A pointer to an instance of the class to extract the virtual function table pointer from. |
| CLASS_NAME | The name of the class that owns the function being hooked. |
| FUNCTION_NAME | The name of the function being hooked. |
| #define INSTALL_VFTABLE_HOOK_EXPLICIT | ( | INSTANCE, | |
| CLASS_NAME, | |||
| FUNCTION_NAME, | |||
| FUNCTION_INDEX ) |
Installs a hook defined with VFTABLE_HOOK at an explicit index.
| INSTANCE | A pointer to an instance of the class to extract the virtual function table pointer from. |
| CLASS_NAME | The name of the class that owns the function being hooked. |
| FUNCTION_NAME | The name of the function being hooked. |
| FUNCTION_INDEX | The index of the function in the virtual function table. |
| #define STATIC_ASM_HOOK | ( | NAME, | |
| ADDRESS ) |
Creates an assembly hook, and installs it upon initialisation.
| NAME | The name of the hook. |
| ADDRESS | The address to hook. |
mod.cpp
mod.cpp
my_asm_hook.asm
| #define STATIC_ASM_HOOK | ( | NAME, | |
| ADDRESS ) |
Creates an assembly hook, and installs it upon initialisation.
| NAME | The name of the hook. |
| ADDRESS | The address to hook. |
mod.cpp
mod.cpp
my_asm_hook.asm
| #define STATIC_HOOK | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| FUNCTION_NAME, | |||
| ADDRESS, | |||
| ... ) |
Defines the body of a hook for a function in memory, and installs it upon initialisation.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function (e.g. __cdecl, __stdcall, __fastcall, etc). For custom calling conventions on x86, such as __usercall or __userpurge, see hook_usercall_win32.h. |
| FUNCTION_NAME | The name of the function. |
| ADDRESS | The address of the function. |
| __VA_ARGS__ | The parameters of the function. |
| #define THISCALL __fastcall |
An alias for __fastcall.
This is intended for use with the other THISCALL macros to make setting up function pointers and hooks with this calling convention easier.
__thiscall is a calling convention that stores a pointer to this in ECX, before falling back to using the stack, similar to __fastcall.
| #define THISCALL_PARAMS | ( | CLASS_NAME | ) |
Expands to the necessary function parameters required by __thiscall calling convention.
| CLASS_NAME | The name of the class this function is from. |
| #define THISCALL_RETURN_PARAMS |
Expands to the necessary function arguments required by __thiscall calling convention for calling the original function.
| #define UNINSTALL_HOOK | ( | NAME | ) |
Uninstalls a hook installed with INSTALL_HOOK.
| NAME | The name of the hook to uninstall. |
| #define UNINSTALL_VFTABLE_HOOK | ( | CLASS_NAME, | |
| FUNCTION_NAME ) |
Uninstalls a hook installed with INSTALL_VFTABLE_HOOK.
| CLASS_NAME | The name of the class that owns the function that was hooked. |
| FUNCTION_NAME | The name of the function to unhook. |
| #define VFTABLE_HOOK | ( | RETURN_TYPE, | |
| CALLING_CONVENTION, | |||
| CLASS_NAME, | |||
| FUNCTION_NAME, | |||
| FUNCTION_INDEX, | |||
| ... ) |
Defines the body of a hook for a function in a virtual function table in memory.
| RETURN_TYPE | The return type of the function. |
| CALLING_CONVENTION | The calling convention of the function (e.g. __cdecl, __stdcall, __fastcall, etc). This does not support optimised calling conventions, such as __usercall or __userpurge. |
| CLASS_NAME | The name of the class that contains the function being hooked. |
| FUNCTION_NAME | The name of the function. |
| FUNCTION_INDEX | The index of the function in the virtual function table. |
| __VA_ARGS__ | The parameters of the function. |