Hook vtable like this:
mov ecx,dword ptr [eax+0xA8] //EndScene index*4
mov [pEndScene],ecx //save original address to restore in call.
lea ebx,fEndScene //my EndScene
mov dword ptr [eax+0xA8],ebx //hook function
google-site-verification: googlebaca44933768a824.html
typedef HRESULT(__stdcall* EndScene_)(LPDIRECT3DDEVICE9 pDev); EndScene_ pEndScene;
HRESULT __stdcall fEndScene(LPDIRECT3DDEVICE9 pDev) { //Draw code ... .... .... .... return pEndScene(pDev); }
HRESULT __stdcall fEndScene(LPDIRECT3DDEVICE9 pDev) { HRESULT r=NULL; __asm { mov eax,gDev //Global for testing mov eax,[eax] mov eax,[eax] mov ecx,[pEndScene] mov dword ptr [eax+0xA8],ecx } r=pDev->EndScene(); __asm { mov eax,gDev mov eax,[eax] mov eax,[eax] mov ecx,dword ptr [eax+0xA8] mov [pEndScene],ecx lea ebx,fEndScene mov dword ptr [eax+0xA8],ebx } return r; }
HRESULT __stdcall fStream(LPDIRECT3DDEVICE9 pDev,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) { HRESULT r=0; Vtable[100]=(DWORD)*Stream; //UnHook r=pDev->SetStreamSource(StreamNumber,pStreamData,OffsetInBytes,Stride); Vtable[100]=(DWORD)fStream; //Hook veces++; //Count calls if (r==D3DERR_INVALIDCALL) // if error { MessageBox(0,"a","a",64); } return r; }
VTable[100] = OriginalFunction; VTable->100dredFunction(); VTable[100] = MyHook;
OriginalFunction();
QuitarHook(42); QuitarHook(82); QuitarHook(100); r=Stream(pDev,StreamNumber,pStreamData,OffsetInBytes,Stride); PonerHook(42,fEndScene); PonerHook(100,fStream); PonerHook(82,fPrimi);
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, personalize advertising, and to analyze site activity. We may share certain information about our users with our advertising and analytics partners. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment