Easy VTable Hook (D3D9)

Posts 1–6 of 6 · Page 1 of 1
Easy VTable Hook (D3D9)
Yo MPGH peoplz,

I just want to share my method to get the VTable which points to the neat functions like Present/EndScene/DrawIndexedPrimitive etc.
Since I didn't found an easier or similar method I just can pray I didn't double post this:

Code:
DWORD* GetVTable()
{
     D3DPRESENT_PARAMETERS D3D_Present_Param={0,0,D3DFMT_UNKNOWN,0,D3DMULTISAMPLE_NONE,0,D3DSWAPEFFECT_DISCARD,0,1,0,D3DFMT_UNKNOWN,0,0,0};
     IDirect3DDevice9* pDummy;
     Direct3DCreate9(D3D_SDK_VERSION)->CreateDevice(0,D3DDEVTYPE_HAL,GetForegroundWindow(),D3DCREATE_SOFTWARE_VERTEXPROCESSING,&D3D_Present_Param,&pDummy);
     return (DWORD*)((DWORD*)pDevice)[0];
}
This method is based on creating your own IDirect3DDevice9* (with some lame standard parameters).
You can just use it like this:

Code:
DWORD* pVTable=GetVTable();
//Present example:
pPresent=(nPresent)DetourFunction(pVTable[17],hkPresent);
I don't know who came up with the idea of creating your own dummy device first so I can't give any credits

Anyways I hope this is usefull to some of you

Ps. I know this isn't nicely coded - it's just as compact as possible. To make it more save make sure the d3d9.dll is loaded and CreateDevice/Direct3DCreate9 didn't fail. And don't c-cast like I did if you want a stable code
You are using the Microsoft Detour right ? They are detected or you know for VAC3 or ??
Hooking via VTable is detected by VAC.
Quote Originally Posted by Superspinne View Post
Hooking via VTable is detected by VAC.
No, it isn't.
Quote Originally Posted by blackstab1337 View Post
No, it isn't.
Got banned for hooking present once via VTable - in my opinion I call that detected.
VAC isn't be that dumb to not check the well known d3d9 functions.
If people have trouble using this - I'm just dumb. There's a typo in the return line.
It should (of course) be:
return (DWORD*)((DWORD*)pDummy)[0];
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Talk with us