Code:
DWORD jump_Font,jump_Present,jump_DrawIndexedPrimitive;
/*========================================*/
__declspec(naked) DWORD __stdcall pPresent( LPDIRECT3DDEVICE9 pDevice, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)
{
__asm
{
MOV EDI,EDI
PUSH EBP
MOV EBP,ESP
jmp jump_Present
}
}
HRESULT _stdcall my_Present(LPDIRECT3DDEVICE9 pDevice, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)
{
return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
/*========================================*/
__declspec(naked) DWORD __stdcall pDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
{
__asm
{
MOV EDI,EDI
PUSH EBP
MOV EBP,ESP
jmp jump_DrawIndexedPrimitive
}
}
HRESULT _stdcall my_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
{
return pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
}
/*========================================*/
/*========================================*/
__declspec(naked) DWORD __stdcall D3DXCreateFont(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E, DWORD F, DWORD G, DWORD H, DWORD I, DWORD J, DWORD K, DWORD L)
{
__asm
{
MOV EDI,EDI
PUSH EBP
MOV EBP,ESP
jmp jump_Font
}
}
DWORD __stdcall MyD3DXCreateFont(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E, DWORD F, DWORD G, DWORD H, DWORD I, DWORD J, DWORD K, DWORD L)
{
DWORD thisa = *(DWORD*)A;
/*=====Present Hook=====*/
DWORD old_Present;
DWORD PSAddress = thisa + 68;//17*4 Present
DWORD MID_Present = *(DWORD*)PSAddress;
jump_Present = MID_Present+5;
VirtualProtect((LPVOID)MID_Present, 5, PAGE_EXECUTE_READWRITE, &old_Present);
*(PBYTE)MID_Present = 0xE9;
*(PULONG)(MID_Present+1) = (DWORD)my_Present - (MID_Present + 5);
/*=====Present Hook=====*/
/*=====DrawIndexedPrimitive Hook=====*/
DWORD OLD_DrawIndexedPrimitive;
DWORD DIPAddress = thisa + 328;//82*4 DrawIndexedPrimitive
DWORD MID_DrawIndexedPrimitive = *(DWORD*)DIPAddress;
jump_DrawIndexedPrimitive = MID_DrawIndexedPrimitive +5;
VirtualProtect((LPVOID)MID_DrawIndexedPrimitive, 5, PAGE_EXECUTE_READWRITE, &OLD_DrawIndexedPrimitive);
*(PBYTE)MID_DrawIndexedPrimitive = 0xE9;
*(PULONG)(MID_DrawIndexedPrimitive+1) = (DWORD)my_DrawIndexedPrimitive - (MID_DrawIndexedPrimitive + 5);
/*=====DrawIndexedPrimitive Hook=====*/
*(PULONG)(jump_Font-5) = 0x0000008b;
*(PULONG)(jump_Font-4) = 0xEC8B55FF;
return D3DXCreateFont(A,B,C,D,E,F,G,H,I,J,K,L);
}
/*========================================*/
void MID_D3DX9_29()
{
DWORD OLD_Font;
HMODULE H_D3DX9_29 = LoadLibraryA("d3dx9_29.dll");
PVOID Address_Font = (PVOID)GetProcAddress(H_D3DX9_29, eCreateFont);
VirtualProtect(Address_Font, 5, PAGE_EXECUTE_READWRITE, &OLD_Font);
jump_Font = (DWORD)Address_Font + 0x5;
*(PULONG)Address_Font = 0xE9;
*(PULONG)((DWORD)Address_Font +0x1) = (DWORD)MyD3DXCreateFont - ((DWORD)Address_Font + 0x5);
}