Hi Leute,
ich hab ein kleines Problem mit meinem D3D-Hook, wenn ich die DLL in Counter Strike, oder irgend eine andere D3D-Anwendung injecte stürzt das Programm sofort ab.
Die EndScene Adresse in der D3D9.dll habe ich schon gefunden:
[Only registered and activated users can see links. Click Here To Register...]
Hier der Source Code:
Wenn der Code funktionieren würde, sollte links oben ein pinkes Viereck zu sehen sein, nur leider macht er das nicht.
Ich hoffe ihr könnt mir helfen, danke schon mal im vorraus.
ich hab ein kleines Problem mit meinem D3D-Hook, wenn ich die DLL in Counter Strike, oder irgend eine andere D3D-Anwendung injecte stürzt das Programm sofort ab.
Die EndScene Adresse in der D3D9.dll habe ich schon gefunden:
[Only registered and activated users can see links. Click Here To Register...]
Hier der Source Code:
Code:
#include <windows.h>
#include <cstdio>
#include <d3d9.h>
#include <d3dx9.h>
//LPDIRECT3DDEVICE9 pDevice;
const D3DCOLOR txtPink = D3DCOLOR_ARGB(255, 255, 0, 255); // Alpha, Rot, Grün, Blau
void InitHook();
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color);
EndScene_t pEndScene;
HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
DrawRect (pDevice, 10, 10, 200, 200, txtPink);
return pEndScene(pDevice);
}
int WINAPI DllMain(HINSTANCE hInst,DWORD reason,LPVOID reserved)
{
switch(reason)
{
case DLL_PROCESS_ATTACH:
// Hier kommt unser Code rein
CreateThread(0, 0, (LPTHREAD_START_ROUTINE) InitHook, 0, 0, 0);
break;
}
return true;
}
void InitHook()
{ HMODULE hModule = NULL;
while( !hModule )
{
hModule = GetModuleHandleA( "d3d9.dll" ); // Handle zur DLL holen
Sleep( 100 ); // 100ms warten
}
pEndScene = ( EndScene_t )DetourFunc((PBYTE)0x74A447AF,(PBYTE)hkEndScene, 5);
}
void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color)
{
D3DRECT rect = {X, Y, X+L, Y+H};
Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0); // bei Google gibt’s näheres
}
void *DetourFunc(BYTE *src, const BYTE *dst, const int len) // credits to gamedeception
{
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);
}
Ich hoffe ihr könnt mir helfen, danke schon mal im vorraus.