Code:
typedef HRESULT(WINAPI* DrawIndexedPrimitive_)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT primCount);
DrawIndexedPrimitive_ org_DrawIndexedPrimitive;
HRESULT WINAPI hook_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT primCount)
{
if(GOOD_GUYS)
{
//blabla
}
if(BAD_GUYS)
{
//blabla
}
return org_DrawIndexedPrimitive(pDevice, Type,BaseIndex, MinIndex,NumVertices,StartIndex,primCount);
}
int D3DHooks()
{
DWORD D3DPattern,*vTable, DXBase=NULL;
DXBase = (DWORD)LoadLibraryA("d3d9.dll");
while(!DXBase);
{
D3DPattern = FindPattern(DXBase, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
}
if(D3DPattern)
{
memcpy(&vTable,(void *)(D3DPattern+2),4);
org_EndScene = (EndScene_)DetourFunction((PBYTE)vTable[42],(PBYTE)hook_EndScene);
org_DrawIndexedPrimitive = (DrawIndexedPrimitive_)DetourFunction((PBYTE)vTable[82],(PBYTE)hook_DrawIndexedPrimitive);
}
return 0;
}
BOOL WINAPI DllMain (HMODULE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinstDLL );
{
}
main_hinstDLL = hinstDLL;
ENGINE.isOn = true;
CreateThread(NULL, NULL, ENGINE.HooK, NULL, NULL, NULL);
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3DHooks, NULL, NULL, NULL);
break;
case DLL_PROCESS_DETACH:
ENGINE.isOn = false;
CreateThread(NULL, NULL, ENGINE.HooK, NULL, NULL, NULL);
break;
}
return 1;
}
Bookmarks