Steps for Hooking

Posts 1–8 of 8 · Page 1 of 1
Steps for Hooking
What are the steps I would need to take to hook Present/EndScene, so I can draw?
Patch the Vtable
OMG. A new computer vocabulary word...what is a VTable?
Virtual Table. Its a table of function that a class inherits.

When one class say called Dog is derived from the base class Animal, it can call all the inheritable methods and access all the inheritable data Animal can. This list of virtual functions is stored in memory as a pointer at the beginning of the class structure. Whenever Dog calls a function it inherited from Animal, or one it has overridden the vtable is used.

More Details: Virtual method table - Wikipedia, the free encyclopedia
Very good explanation @why06
Nice explanation. Question though, do I need to find the Device Pointer or is this method completely different?
Quote Originally Posted by aanthonyz View Post
Nice explanation. Question though, do I need to find the Device Pointer or is this method completely different?
VTable is hooked to find the pattern for device pointer.

Go look at the hook in whit's base v3. notice how it finds the device pointer to use VTable in hook.
or you can simply create a normal device... .. hmm i think i should got the code here, but you can create the temporary device and get the pointer from it.

[highlight=VB.NET]
DWORD VTABLE(int INDEX)
{ DWORD hD3D;
// wait for the d3dx dll
hD3D=0;
do {
hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
Sleep(10);
} while(!hD3D);
LPDIRECT3D9 pD3d9 = NULL;
LPDIRECT3DDEVICE9 pD3DDevice = NULL;
pD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
if(pD3d9 == NULL){
return -1;
}
D3DPRESENT_PARAMETERS pPresentParms;
ZeroMemory(&pPresentParms,sizeof(pPresentParms));
pPresentParms.Windowed = TRUE;
pPresentParms.BackBufferFormat = D3DFMT_UNKNOWN;
pPresentParms.SwapEffect = D3DSWAPEFFECT_DISCARD;
if(FAILED(pD3d9->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,Ge tDesktopWindow(),D3DCREATE_SOFTWARE_VERTEXPROCESSI NG,&pPresentParms,&pD3DDevice))){
return -1;
}
DWORD * dwTable = ( DWORD* )pD3DDevice;
dwTable = ( DWORD* ) dwTable[0];
/*
dwTable[16];//reset
dwTable[17];//present
dwTable[82];//DrawIndexedPrimitive
dwTable[100];//SetStreamSource
dwTable[41];//BeginScene
dwTable[42];//EndScene
*/
return dwTable[INDEX];
}
[/highlight]
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us