example usage (revised from goldfinders basehook)


PHP Code:


#include "mempatcher.h"

void PatchFunc( void )

{

CMemoryPatcher Patcher;

MODULEENTRY32 ProcEntry;



if(
Patcher.Init( ) && Patcher.FindModuleInProcess( "process.exe", GetCurrentProcessId( ), &ProcEntry ) )

{

Func_Address = Patcher.FindPattern( ProcEntry.th32ProcessID, ( BYTE * )0xC0DEFEED, Func_Len, ( DWORD )ProcEntry.modBaseAddr, ProcEntry.modBaseSize );

pFunc = ( TypedefOfFunc_t )RedirectFunction( ProcEntry.th32ProcessID, Func_Address, Func_Len, ( DWORD )&NewFunc );

}

}