these 3 functions will get your vtable for a d3d9 game, which allows you to hook the functions neccesary for a wallhack and other d3d hacks.
Code:
BOOL bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask)
return false;
return (*szMask) == NULL;
}
DWORD ScanPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, char *szMask)
{
for(DWORD i=0; i < dwLen; i++)
if( bCompare((BYTE*)(dwAddress+i),bMask,szMask))
return (DWORD)(dwAddress+i);
return 0;
}
DWORD *GetVirtualTable(DWORD base, DWORD len)
{
DWORD* pTable = NULL;
DWORD device = ScanPattern(base, len, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
if ( device != 0 )
pTable = *(DWORD**)(device + 2);
return pTable;
}
use as so:
Code:
DWORD* vTable = GetVirtualTable(d3d9handle, 0x1280000);
d3d9handle is a DWORD found by getting the module handle of d3d9.dll and casting it as a DWORD.
Then we hook the d3d9m vtable functions 42 and 82, EndScene and DrawIndexPrimitive respectively.