D3D EndScene Hook dont work
Hey, this is the source of purple.d1amonds d3d9 Hook Tutorial.
I inject the .dll in the wow process, but nothing happend. Can anyone say me where the error is please ? The .dll is successfully loading, i have test it with a messagebox.

Thanks
N1GHTLIFE
I inject the .dll in the wow process, but nothing happend. Can anyone say me where the error is please ? The .dll is successfully loading, i have test it with a messagebox.
Code:
#include "stdafx.h"
#include <windows.h>
#include <cstdio>
#include <d3d9.h>
#include <d3dx9.h>
typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
EndScene_t pEndScene;
void DrawRect(LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color){
D3DRECT rect = {X,Y,X+L,Y+H};
}
bool hkEndScene(LPDIRECT3DDEVICE9 pDevice){
const D3DCOLOR txtPink = D3DCOLOR_ARGB(255,255, 0, 255);
DrawRect( pDevice, 10, 10, 200, 200, txtPink);
return pEndScene(pDevice);
}
void* DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len); jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}
void InitHook()
{
HMODULE hModule;
hModule = GetModuleHandleA("d3d9.dll");
unsigned dwBeginScene;
unsigned dwEndScene;
unsigned dwReset;
unsigned dwDrawIndexedPrimitive;
unsigned dwSetViewPort;
dwBeginScene = (DWORD)hModule + 0x87010;
dwEndScene = (DWORD)hModule + 0x871A0;
dwReset = (DWORD)hModule + 0x636B0;
dwDrawIndexedPrimitive = (DWORD)hModule + 0x88830;
dwSetViewPort = (DWORD)hModule + 0x82F70 ;
pEndScene = (EndScene_t)(DetourFunc((PBYTE)dwEndScene,(PBYTE)hkEndScene, 5));
MessageBoxA(NULL, "Funktion wurde aufgerufen","Done",NULL);
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0,0,(LPTHREAD_START_ROUTINE) InitHook,0,0,0);
}
return TRUE;
}

Thanks
N1GHTLIFE
.


.