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
