6 #ifndef _INC_cHookJump_H
7 #define _INC_cHookJump_H
25 static const BYTE k_I_NULL = 0x00;
27 static const BYTE k_I_JUMP = 0xe9;
29 static const int k_LEN_J = 1;
31 static const int k_LEN_P = 4;
33 static const int k_LEN_A = 16;
35 static const int k_LEN_A = 8;
37 static const int k_LEN_D = k_LEN_J + k_LEN_P;
44 BYTE m_OldCode[k_LEN_D];
55 cMem::Copy((
void*)m_pFuncOrig, m_OldCode,
sizeof(m_OldCode));
62 if (!isHookInstalled() || m_pFuncOrig ==
nullptr)
64 cMem::Copy((
void*)m_pFuncOrig, m_Jump,
sizeof(m_Jump));
69 : m_pFuncOrig(
nullptr)
71 m_OldCode[0] = k_I_NULL;
81 return m_Jump[0] == k_I_JUMP;
86 if (!isHookInstalled() || m_pFuncOrig ==
nullptr)
88 if (::memcmp((
const void*)m_pFuncOrig, m_Jump,
sizeof(m_Jump)))
97 return m_OldCode[0] == k_I_JUMP;
100 FARPROC GetChainFunc()
const;
102 bool InstallHook(FARPROC pFuncOrig, FARPROC pFuncNew);
121 m_bSwapOld = swap ? m_rJump.
SwapOld() :
false;
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
Definition: cHookJump.h:18
bool isHookValid() const noexcept
Definition: cHookJump.h:83
bool isChainable() const noexcept
Definition: cHookJump.h:93
cHookJump() noexcept
Definition: cHookJump.h:68
void SwapReset() noexcept
Definition: cHookJump.h:58
FARPROC GetChainFunc() const
Definition: cHookJump.cpp:15
~cHookJump()
Definition: cHookJump.h:74
cThreadLockFast m_Lock
prevent multiple threads from using this at the same time.
Definition: cHookJump.h:46
FARPROC m_pFuncOrig
Pointer to the original/old function. The one i will replace. Inject code here.
Definition: cHookJump.h:43
bool SwapOld() noexcept
Definition: cHookJump.h:49
bool isHookInstalled() const noexcept
Definition: cHookJump.h:79
Definition: cHookJump.h:133
FARPROC m_pFuncChain
Definition: cHookJump.h:135
cHookSwapChain(cHookJump &rJump)
Definition: cHookJump.h:137
Definition: cHookJump.h:109
cHookSwapLock(cHookJump &rJump, bool swap=true)
Definition: cHookJump.h:117
~cHookSwapLock() noexcept
Definition: cHookJump.h:123
bool m_bSwapOld
Definition: cHookJump.h:114
cHookJump & m_rJump
The code we are locking for use.
Definition: cHookJump.h:113
Definition: cThreadLock.h:205
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
static void Copy(void *pDst, const void *pSrc, size_t nSizeBlock) noexcept
Definition: cMem.h:132