Hey guys, I don't really know where to post this, but browsing the wow section shows that many of you guys are experts at this and I really need some help here. Ive been stuck on this too long.
I'm trying to hook endscene in d3d9 so that I can write things to the screen.
Code :
PHP Code:
void EndSceneVtab()
{
HMODULE dx = NULL;
while (!dx)
{
dx = GetModuleHandle(L"d3d9.dll");
Sleep(100);
}
VtableStart = 0;
DWORD vtableLookUp = dwFindPattern((DWORD)dx, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
VtableStart = (DWORD*)*(DWORD*)(vtableLookUp + 2);
EndScene = VtableStart[ENDSCENE_VTAB];
MEMORY_BASIC_INFORMATION mbi;
VirtualQuery((LPCVOID)VtableStart, &mbi, sizeof(mbi));
VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect);
VtableStart[ENDSCENE_VTAB] = (DWORD)HookDraw;
VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &mbi.Protect);
}
void __fastcall HookDraw(IDirect3DDevice9 * This)
{
if (This)
{
DrawLine(52.0, 41.0, 52.0, 52.0, 50, 50, 50, 50, This);
__asm {
jmp[EndScene]
}
}
}
void DrawLine(float x, float y, float xx, float yy, int r, int g, int b, int a, IDirect3DDevice9 * device)
{
if (!p_Line)
{
D3DXCreateLine(device, &p_Line);
}
if (p_Line)
{
D3DXVECTOR2 projmatrix[2];
p_Line->SetWidth(1);
projmatrix[0].x = x;
projmatrix[0].y = y;
projmatrix[1].x = xx;
projmatrix[1].y = yy;
p_Line->Draw(projmatrix, 2, txt);
}
}
The problem :
The pointer in the vtable is patched, but there is no drawing taking place. Can someone please help me out here.