3#include <dynamic_libs/os_types.h>
5#include <telkin/Preprocessor.h>
79 #define tMangle(...) PP_STR(__VA_ARGS__)
81 #define tMangle(...) __builtin_mangle(__VA_ARGS__)
85#define _tBranch3(addr, target, type)
86 tk::BranchHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::BranchHook(tk::DataMagic::BranchHook, reinterpret_cast<u32*>(addr), tMangle(target), type, 0
, 0
, 0
, 0
)
89#define _tBranch4(addr, target, sig, type)
90 tk::BranchHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::BranchHook(tk::DataMagic::BranchHook, reinterpret_cast<u32*>(addr), tMangle(target, sig), type, 0
, 0
, 0
, 0
)
93 PP_CONCAT_VAL(_tBranch, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
96#define tBranchEx(addr, targetSym, type)
97 tk::BranchHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::BranchHook(tk::DataMagic::BranchHook, reinterpret_cast<u32*>(addr), targetSym, type, 0
, 0
, 0
, 0
)
100#define _tPointerCode2(addr, target)
101 tk::PointerHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::PointerHook(tk::DataMagic::PointerHook, reinterpret_cast<u32*>(addr), tMangle(target), false, 0
, 0
, 0
, 0
)
104#define _tPointerCode3(addr, target, sig)
105 tk::PointerHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::PointerHook(tk::DataMagic::PointerHook, reinterpret_cast<u32*>(addr), tMangle(target, sig), false, 0
, 0
, 0
, 0
)
107#define tPointerCode(...)
108 PP_CONCAT_VAL(_tPointerCode, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
110#define tPointerData(addr, target)
111 tk::PointerHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::PointerHook(tk::DataMagic::PointerHook, reinterpret_cast<u32*>(addr), tMangle(target), true, 0
, 0
, 0
, 0
)
114#define tPointerEx(addr, targetSym, isdata)
115 tk::PointerHook _tHook_ ## addr __attribute__((section(".loaderdata"))) = tk::PointerHook(tk::DataMagic::PointerHook, reinterpret_cast<u32*>(addr), targetSym, isdata, 0
, 0
, 0
, 0
)
117#define _tPatch_u(addr, bits, ...)
118 const u##bits _tPatch_Data_ ## addr [] = { __VA_ARGS__ };
119 tk::PatchHook _tPatch_ ## addr __attribute__((section(".loaderdata"))) = tk::PatchHook(tk::DataMagic::PatchHook, reinterpret_cast<u32*>(addr), sizeof(_tPatch_Data_##addr) / sizeof(u##bits), bits, reinterpret_cast<const void*>(&_tPatch_Data_##addr), 0
, 0
, 0
, 0
)
121#define _tPatch_s(addr, bits, ...)
122 const s##bits _tPatch_Data_ ## addr [] = { __VA_ARGS__ };
123 tk::PatchHook _tPatch_ ## addr __attribute__((section(".loaderdata"))) = tk::PatchHook(tk::DataMagic::PatchHook, reinterpret_cast<u32*>(addr), sizeof(_tPatch_Data_##addr) / sizeof(u##bits), bits, reinterpret_cast<const void*>(&_tPatch_Data_##addr), 0
, 0
, 0
, 0
)
125#define _tPatch_f(addr, bits, ...)
126 const f##bits _tPatch_Data_ ## addr [] = { __VA_ARGS__ };
127 tk::PatchHook _tPatch_ ## addr __attribute__((section(".loaderdata"))) = tk::PatchHook(tk::DataMagic::PatchHook, reinterpret_cast<u32*>(addr), sizeof(_tPatch_Data_##addr) / sizeof(u##bits), bits, reinterpret_cast<const void*>(&_tPatch_Data_##addr), 0
, 0
, 0
, 0
)
129#define tPatch8u(addr, ...) _tPatch_u(addr, 8
, __VA_ARGS__)
130#define tPatch16u(addr, ...) _tPatch_u(addr, 16
, __VA_ARGS__)
131#define tPatch32u(addr, ...) _tPatch_u(addr, 32
, __VA_ARGS__)
132#define tPatch64u(addr, ...) _tPatch_u(addr, 64
, __VA_ARGS__)
134#define tPatch8s(addr, ...) _tPatch_s(addr, 8
, __VA_ARGS__)
135#define tPatch16s(addr, ...) _tPatch_s(addr, 16
, __VA_ARGS__)
136#define tPatch32s(addr, ...) _tPatch_s(addr, 32
, __VA_ARGS__)
137#define tPatch64s(addr, ...) _tPatch_s(addr, 64
, __VA_ARGS__)
139#define tPatch32f(addr, ...) _tPatch_f(addr, 32
, __VA_ARGS__)
140#define tPatch64f(addr, ...) _tPatch_f(addr, 64
, __VA_ARGS__)
#define tPatch32u(addr,...)
Definition Hooks.h:131
#define tMangle(...)
Definition Hooks.h:81
#define _tPatch_s(addr, bits,...)
Definition Hooks.h:121
#define _tPatch_f(addr, bits,...)
Definition Hooks.h:125
#define _tPatch_u(addr, bits,...)
Definition Hooks.h:117
DataMagic
Definition Hooks.h:8
@ PointerHook
Definition Hooks.h:10
@ NullHook
Definition Hooks.h:12
@ PatchHook
Definition Hooks.h:11
@ BranchHook
Definition Hooks.h:9
u64(*)() getTitleID_t
Definition Mod.h:16
constexpr int cHookSize
Definition Hooks.h:15
BranchType
Definition Hooks.h:17
@ bl
Definition Hooks.h:19
const char * target
Definition Hooks.h:25
u32 reserved3
Definition Hooks.h:29
BranchType type
Definition Hooks.h:26
u32 reserved2
Definition Hooks.h:28
u32 reserved1
Definition Hooks.h:27
DataMagic magic
Definition Hooks.h:23
u32 * source
Definition Hooks.h:24
u32 reserved4
Definition Hooks.h:30
DataMagic magic
Definition Hooks.h:69
u8 padding[cHookSize - sizeof(DataMagic)]
Definition Hooks.h:70
DataMagic magic
Definition Hooks.h:53
void * addr
Definition Hooks.h:54
u16 dataSize
Definition Hooks.h:56
u32 reserved2
Definition Hooks.h:59
u32 reserved1
Definition Hooks.h:58
u32 reserved3
Definition Hooks.h:60
u16 count
Definition Hooks.h:55
u32 reserved4
Definition Hooks.h:61
const void * data
Definition Hooks.h:57
DataMagic magic
Definition Hooks.h:38
u32 reserved4
Definition Hooks.h:45
u32 isData
Definition Hooks.h:41
const char * target
Definition Hooks.h:40
u32 reserved1
Definition Hooks.h:42
u32 * source
Definition Hooks.h:39
u32 reserved3
Definition Hooks.h:44
u32 reserved2
Definition Hooks.h:43