Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 15:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[D3D8/D3D9] Simple Hooking for any Games in [Directx8/Directx9]

Discussion on [D3D8/D3D9] Simple Hooking for any Games in [Directx8/Directx9] within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
darkopp's Avatar
 
elite*gold: 0
Join Date: Oct 2008
Posts: 127
Received Thanks: 10
[D3D8/D3D9] Simple Hooking for any Games in [Directx8/Directx9]

I think this will help you !

D3D8:
Quote:
// Typedef of reset and present

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


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



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

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

_asm POPAD;

return pReset(pDevice, pPresentationParameters);
}



HRESULT __stdcall nPresent ( LPDIRECT3DDEVICE8 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 hD3D8Dll;
do{
Tools.AddLog("%s - Loading d3d8.dll->",Tools.AddTime());
hD3D8Dll = GetModuleHandle("d3d8.dll");
Sleep(20);
Tools.AddLog("OK!\n");
} while(!hD3D8Dll);

Tools.AddLog("%s - Enable Device [Metin2]->",Tools.AddTime());
DWORD_PTR * VtablePtr = cHook.FindDevice((DWORD)hD3D8Dll,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[15],(LPBYTE)nPresent,6);
pReset = (Reset_t) Tools.bDetourA((PBYTE)VTable[14],(LPBYTE)nReset,6);
Tools.AddLog("OK!\n");


return(0);
}



bool __stdcall DllMain ( HMODULE hDll, unsigned long Reason , LPVOID LPReserved )
{
DisableThreadLibraryCalls(hDll);
switch ( Reason )
{

case DLL_PROCESS_ATTACH :

CreateThread(0,0,(LPTHREAD_START_ROUTINE)StaticHoo k ,0,0,0);

break;

case DLL_PROCESS_DETACH : break;

}
return (1);
}
D3D9:
Quote:
// Typedef of reset and present

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);
}
darkopp is offline  
Reply


Similar Threads Similar Threads
D3D9 & D3D8 Test Enviroment
11/05/2011 - WarRock - 5 Replies
D3D8 & D3D9 Test Enviroment For Your VTable Hooks http://i40.tinypic.com/122e109.jpg How it works : Only Inject Your Menu into this Test Enviroment ! And you can see how your Menu works !
Hooking d3d8 device
11/26/2010 - Perfect World - 5 Replies
Hello ppl, I don't know if anyone can help me out but I'm working on a bot and wanted to display my menu ingame using a d3d8 device hook. Thing is, all functions are hooking fine except reset. Was just wondering if anyone had an idea why. Because without reset you can't really draw anything. Here's my log file. Adress of Reset: 0x298FF84 Adress of Present: 0x298FF7C Adress of BeginScene: 0x298FF88 Adress of EndScene: 0x298FF80 Adress of DrawindexedPrimitive: 0x298FF74 Adress of...
D3D framework for D3D8 and D3D9
10/09/2010 - Soldier Front Hacks, Bots, Cheats & Exploits - 2 Replies
*Content Removed
D3D framework for D3D8 and D3D9
07/31/2010 - Soldier Front Hacks, Bots, Cheats & Exploits - 14 Replies
D3D framework for D3D8 and D3D9 This is a complete D3D framework containing: - D3D Base, all basic stuff, hooks, font manipulation - D3D Menu with folders - Transparent Background function - Optimized D3Dfont, centered and right aligned text - Code works for d3d8 or d3d9 (define it in d3dbase.h) - test programs for d3d8 and d3d9 - All within a 9.5 kb dll
D3D8/D3D9 Device Hook
01/30/2008 - Soldier Front - 4 Replies
http://rapidshare.com/files/86461541/d3dx8.zip.htm l http://rapidshare.com/files/86461553..._v2.3.zip. html http://rapidshare.com/files/86461559..._v2.3.zip. html



All times are GMT +1. The time now is 15:12.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.