Hey, ich habe mir das Tutorial von purple.d1amond angeschaut, und habe als Test ( da ich noch nie ne D3D Funktion gehooked habe ) mal den Source aus dem Tut abgetippt und wollte ihn testen. Ich habe die .dll anschließend mit Winject in den Prozess von wow injected. Doch es passiert nichts, da wo eigentlich ein Rechteck sein sollte ( oben Rechts ) ist nichts :D )
Habe ich was falsch gemacht ? :
mfG
Habe ich was falsch gemacht ? :
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 = NULL;
while(!hModule)
{
hModule = GetModuleHandleA("d3d9.dll");
Sleep(100);
}
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));
}
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;
}