@@ -23,16 +23,16 @@ class patch {
2323public:
2424 static void NopRestore (uintptr_t address, bool vp = true );
2525 static void Nop (uintptr_t address, size_t size, bool vp = true );
26- static void RedirectCall (uintptr_t address, void * func, bool vp = true );
27- static void RedirectJump (uintptr_t address, void * func, bool vp = true );
26+ static void RedirectCall (uintptr_t address, injector::memory_pointer_raw func, bool vp = true );
27+ static void RedirectJump (uintptr_t address, injector::memory_pointer_raw func, bool vp = true );
2828 static void SetChar (uintptr_t address, char value, bool vp = true );
2929 static void SetUChar (uintptr_t address, unsigned char value, bool vp = true );
3030 static void SetShort (uintptr_t address, short value, bool vp = true );
3131 static void SetUShort (uintptr_t address, unsigned short value, bool vp = true );
3232 static void SetInt (uintptr_t address, uintptr_t value, bool vp = true );
3333 static void SetUInt (uintptr_t address, uintptr_t value, bool vp = true );
3434 static void SetFloat (uintptr_t address, float value, bool vp = true );
35- static void SetPointer (uintptr_t address, void * value, bool vp = true );
35+ static void SetPointer (uintptr_t address, injector::memory_pointer_raw value, bool vp = true );
3636 static char GetChar (uintptr_t address, bool vp = true );
3737 static unsigned char GetUChar (uintptr_t address, bool vp = true );
3838 static short GetShort (uintptr_t address, bool vp = true );
@@ -43,23 +43,23 @@ class patch {
4343 static void *GetPointer (uintptr_t address, bool vp = true );
4444 static void SetRaw (uintptr_t address, void * value, size_t size, bool vp = true );
4545 static void GetRaw (uintptr_t address, void * ret, size_t size, bool vp = true );
46- static void RedirectShortJump (uintptr_t address, void * dest = nullptr , bool vp = true );
46+ static void RedirectShortJump (uintptr_t address, injector::memory_pointer_raw dest = nullptr , bool vp = true );
4747 static void PutRetn (uintptr_t address, unsigned short BytesToPop = 0 , bool vp = true );
4848 static void PutRetn0 (uintptr_t address, unsigned short BytesToPop = 0 , bool vp = true );
4949 static void PutRetn1 (uintptr_t address, unsigned short BytesToPop = 0 , bool vp = true );
5050
5151 template <typename T>
52- static void Set (uintptr_t address, T value, bool vp = true ) {
52+ static inline void Set (uintptr_t address, T value, bool vp = true ) {
5353 injector::WriteMemory (GetGlobalAddress (address), value, vp);
5454 }
5555
5656 template <typename T>
57- static T Get (uintptr_t address, bool vp = true ) {
57+ static inline T Get (uintptr_t address, bool vp = true ) {
5858 return injector::ReadMemory<T>(GetGlobalAddress (address), vp);
5959 }
6060
6161 template <typename T>
62- static T TranslateCallOffset (uintptr_t address) {
62+ static inline T TranslateCallOffset (uintptr_t address) {
6363 if (GetUChar (address) == 0xE8 ) {
6464 auto offset = GetInt (address + 1 );
6565 offset += (GetGlobalAddress (address) + 5 );
@@ -69,7 +69,7 @@ class patch {
6969 }
7070
7171 template <typename T>
72- static T TranslateJumpOffset (uintptr_t address) {
72+ static inline T TranslateJumpOffset (uintptr_t address) {
7373 if (GetUChar (address) == 0xE9 ) {
7474 auto offset = GetInt (address + 1 );
7575 offset += (GetGlobalAddress (address) + 5 );
@@ -81,52 +81,52 @@ class patch {
8181 static void ReplaceFunction (uintptr_t address, void *func, bool vp = true );
8282 static void ReplaceFunctionCall (uintptr_t address, void *func, bool vp = true );
8383
84- static void SetPointer (std::vector<uintptr_t > const & addresses, void * value, bool vp = true ) {
84+ static inline void SetPointer (std::vector<uintptr_t > const & addresses, injector::memory_pointer_raw value, bool vp = true ) {
8585 for (auto & address : addresses) {
8686 SetPointer (address, value, vp);
8787 }
8888 }
8989
9090 template <typename T>
91- static void Set (std::vector<uintptr_t > const & addresses, T value, bool vp = true ) {
91+ static inline void Set (std::vector<uintptr_t > const & addresses, T value, bool vp = true ) {
9292 for (auto & address : addresses) {
9393 Set (address, value, vp);
9494 }
9595 }
9696
97- static void SetInt (std::vector<uintptr_t > const & addresses, uintptr_t value, bool vp = true ) {
97+ static inline void SetInt (std::vector<uintptr_t > const & addresses, uintptr_t value, bool vp = true ) {
9898 for (auto & address : addresses) {
9999 SetInt (address, value, vp);
100100 }
101101 }
102102
103- static void SetFloat (std::vector<uintptr_t > const & addresses, float value, bool vp = true ) {
103+ static inline void SetFloat (std::vector<uintptr_t > const & addresses, float value, bool vp = true ) {
104104 for (auto & address : addresses) {
105105 SetFloat (address, value, vp);
106106 }
107107 }
108108
109- static void RedirectJump (std::vector<uintptr_t > const & addresses, void * func, bool vp = true ) {
109+ static inline void RedirectJump (std::vector<uintptr_t > const & addresses, injector::memory_pointer_raw func, bool vp = true ) {
110110 for (auto & address : addresses) {
111111 RedirectJump (address, func, vp);
112112 }
113113 }
114114
115- static void RedirectCall (std::vector<uintptr_t > const & addresses, void * func, bool vp = true ) {
115+ static inline void RedirectCall (std::vector<uintptr_t > const & addresses, injector::memory_pointer_raw func, bool vp = true ) {
116116 for (auto & address : addresses) {
117117 RedirectCall (address, func, vp);
118118 }
119119 }
120120
121- static void Nop (std::vector<uintptr_t > const & addresses, size_t size, bool vp = true ) {
121+ static inline void Nop (std::vector<uintptr_t > const & addresses, size_t size, bool vp = true ) {
122122 for (auto & address : addresses) {
123123 Nop (address, size, vp);
124124 }
125125 }
126126
127127 using RegPack = injector::reg_pack;
128128
129- static void StaticHook (uintptr_t start, uintptr_t end, void (*func)(RegPack&)) {
129+ static inline void StaticHook (uintptr_t start, uintptr_t end, void (*func)(RegPack&)) {
130130 struct staticHook {
131131 void (*func)(RegPack&);
132132
@@ -143,8 +143,12 @@ class patch {
143143 injector::MakeInline (start, end, *ptr);
144144 }
145145
146+ static inline void StaticHook (uintptr_t address, void (*func)(RegPack&)) {
147+ StaticHook (address, address + 5 , func);
148+ }
149+
146150 template <typename T>
147- static void StaticHook (uintptr_t start, uintptr_t end) {
151+ static inline void StaticHook (uintptr_t start, uintptr_t end) {
148152 injector::MakeInline<T>(start, end);
149153 }
150154};
0 commit comments