Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cHookJump Class Reference

#include <cHookJump.h>

Public Member Functions

 cHookJump () noexcept
 
 ~cHookJump ()
 
bool isHookInstalled () const noexcept
 
bool isHookValid () const noexcept
 
bool isChainable () const noexcept
 
FARPROC GetChainFunc () const
 
bool InstallHook (FARPROC pFuncOrig, FARPROC pFuncNew)
 
void RemoveHook ()
 

Static Public Attributes

static const BYTE k_I_NULL = 0x00
 
static const int k_LEN_J = 1
 size of the jump instruction. 0xe9 = k_JUMP_I More...
 
static const int k_LEN_P = 4
 size of the relative pointer. NOT same as sizeof(FARPROC) or INT_PTR More...
 
static const int k_LEN_A = 8
 k_LEN_D aligned to 8 (for 32 bit code) More...
 
static const int k_LEN_D = k_LEN_J + k_LEN_P
 ( k_LEN_J+k_LEN_P ) = size of actual instruction More...
 

Protected Member Functions

bool SwapOld () noexcept
 
void SwapReset () noexcept
 

Protected Attributes

FARPROC m_pFuncOrig
 Pointer to the original/old function. The one i will replace. Inject code here. More...
 
BYTE m_OldCode [k_LEN_D]
 what was at m_pFuncOrig previously. NOTE: What if this uses k_LEN_J the m_Lock isn't needed ?!!! More...
 
BYTE m_Jump [k_LEN_D]
 what do i want to replace m_pFuncOrig with. jump to pFuncNew More...
 
cThreadLockFast m_Lock
 prevent multiple threads from using this at the same time. More...
 

Friends

class cHookSwapLock
 
class cHookSwapChain
 
class cHookJumpTests
 

Constructor & Destructor Documentation

◆ cHookJump()

Gray::cHookJump::cHookJump ( )
inlinenoexcept

◆ ~cHookJump()

Gray::cHookJump::~cHookJump ( )
inline

Member Function Documentation

◆ GetChainFunc()

FARPROC Gray::cHookJump::GetChainFunc ( ) const

◆ InstallHook()

bool Gray::cHookJump::InstallHook ( FARPROC  pFuncOrig,
FARPROC  pFuncNew 
)
Note
X86 ONLY!! 32 or 64 bit.

◆ isChainable()

bool Gray::cHookJump::isChainable ( ) const
inlinenoexcept

◆ isHookInstalled()

bool Gray::cHookJump::isHookInstalled ( ) const
inlinenoexcept

◆ isHookValid()

bool Gray::cHookJump::isHookValid ( ) const
inlinenoexcept
Note
sometimes DLLs' can reload themselves and destroy our hook behind our backs.

◆ RemoveHook()

void Gray::cHookJump::RemoveHook ( )

◆ SwapOld()

bool Gray::cHookJump::SwapOld ( )
inlineprotectednoexcept

put back saved code fragment. temporary to call previous version of the function. ASSUME use of cHookSwapLock m_Lock

◆ SwapReset()

void Gray::cHookJump::SwapReset ( )
inlineprotectednoexcept

put back original JMP instruction again ASSUME use of cHookSwapLock m_Lock

Friends And Related Function Documentation

◆ cHookJumpTests

friend class cHookJumpTests
friend

◆ cHookSwapChain

friend class cHookSwapChain
friend

◆ cHookSwapLock

friend class cHookSwapLock
friend

Member Data Documentation

◆ k_I_NULL

const BYTE Gray::cHookJump::k_I_NULL = 0x00
static

◆ k_LEN_A

const int Gray::cHookJump::k_LEN_A = 8
static

k_LEN_D aligned to 8 (for 32 bit code)

◆ k_LEN_D

const int Gray::cHookJump::k_LEN_D = k_LEN_J + k_LEN_P
static

( k_LEN_J+k_LEN_P ) = size of actual instruction

◆ k_LEN_J

const int Gray::cHookJump::k_LEN_J = 1
static

size of the jump instruction. 0xe9 = k_JUMP_I

◆ k_LEN_P

const int Gray::cHookJump::k_LEN_P = 4
static

size of the relative pointer. NOT same as sizeof(FARPROC) or INT_PTR

◆ m_Jump

BYTE Gray::cHookJump::m_Jump[k_LEN_D]
protected

what do i want to replace m_pFuncOrig with. jump to pFuncNew

◆ m_Lock

cThreadLockFast Gray::cHookJump::m_Lock
protected

prevent multiple threads from using this at the same time.

◆ m_OldCode

BYTE Gray::cHookJump::m_OldCode[k_LEN_D]
protected

what was at m_pFuncOrig previously. NOTE: What if this uses k_LEN_J the m_Lock isn't needed ?!!!

◆ m_pFuncOrig

FARPROC Gray::cHookJump::m_pFuncOrig
protected

Pointer to the original/old function. The one i will replace. Inject code here.


The documentation for this class was generated from the following files: