HelpHow to make a hook for d3d9 hack game

Posts 14 of 4 · Page 1 of 1
How to make a hook for d3d9 hack game
Hello there,
I have some problem with hooking game, and i dunno how make a hook for my D3D menu,
coz my menu did'nt work on my game... i guess maybe the hook has not work again,
i want to ask how to find new hook and make hook in c++ ...

Thanks before
I have to ask, are you looking for a new way to hook or are you just looking for a new detour function?

Often people mistake these things, a new detour function might just be using different operands instead of just "JMP [distance]" and a new hook might use your old detour function but maybe unhook sometimes and rehook or hook a different part of the desired function.

Also your game could have an anti cheat system that could interfere with the hooking process.
perhaps the game protection that is not letting you hookar it, tried to use the same in some other game?, you bypasseou protection?, what protection is?, x-trap?

 
D3D9 Simple Hook

Code:
HRESULT __stdcall nReset ( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );
typedef HRESULT ( APIENTRY* Reset_t ) ( LPDIRECT3DDEVICE8 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );
Reset_t pReset;


HRESULT __stdcall nPresent ( LPDIRECT3DDEVICE9 pDevice,CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion );
typedef HRESULT ( APIENTRY* Present_t)( LPDIRECT3DDEVICE9 pDevice,CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion );
Present_t pPresent;



HRESULT __stdcall nReset ( LPDIRECT3DDEVICE9 pDevice , D3DPRESENT_PARAMETERS* pPresentationParameters )
{
_asm PUSHAD;

Tools.AddLog("Hook Reset\n");

_asm POPAD;

return pReset(pDevice, pPresentationParameters);
}



HRESULT __stdcall nPresent ( LPDIRECT3DDEVICE9 pDevice,CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion )
{
_asm PUSHAD;

Tools.AddLog("Hook Present\n");

_asm POPAD;

return pPresent (pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}


DWORD_PTR * Hook :: FindDevice ( DWORD Base, DWORD Len )
{
unsigned long i = 0, n = 0;

for( i = 0; i < Len; i++ )
{
if(*(BYTE *)(Base+i+0x00)==0xC7)n++;
if(*(BYTE *)(Base+i+0x01)==0x06)n++;
if(*(BYTE *)(Base+i+0x06)==0x89)n++;
if(*(BYTE *)(Base+i+0x07)==0x86)n++;
if(*(BYTE *)(Base+i+0x0C)==0x89)n++;
if(*(BYTE *)(Base+i+0x0D)==0x86)n++;
if( n == 6 ) return ( DWORD_PTR * ) ( Base + i + 2 ); n = 0;
}
return(0);
}


int __fastcall StaticHook ( void )
{

HMODULE hD3D9Dll;
do{
Tools.AddLog("%s - Loading d3d9.dll->",Tools.AddTime());
hD3D9Dll = GetModuleHandle("d3d9.dll");
Sleep(20);
Tools.AddLog("OK!\n");
} while(!hD3D9Dll);

Tools.AddLog("%s - Enable Device d3d9->",Tools.AddTime());
DWORD_PTR * VtablePtr = cHook.FindDevice((DWORD)hD3D9Dll,0x128000);
Tools.AddLog("OK!\n");

if ( VtablePtr == NULL )
{
MessageBox(NULL,"Device Not Found !! Please try again",0,MB_ICONSTOP);
ExitProcess(TRUE);
}

Tools.AddLog("%s - Type Device->",Tools.AddTime());
DWORD_PTR* VTable = 0;
*(DWORD_PTR*)&VTable = *(DWORD_PTR *)VtablePtr;
Tools.AddLog("OK!\n");

Tools.AddLog("%s - Hooking Class->",Tools.AddTime());
pPresent = (Present_t) Tools.bDetourA((PBYTE)VTable[17],(LPBYTE)nPresent,6);
pReset = (Reset_t) Tools.bDetourA((PBYTE)VTable[16],(LPBYTE)nReset,6);
Tools.AddLog("OK!\n");


return(0);
}
credits darkopp
Game Protection is Game Guard. how to create or search hook undetected by game guard?
please teach me step by step. or videos how to find it.
Posts 14 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?