Hooking EndScene

Posts 1–2 of 2 · Page 1 of 1
Hooking EndScene
Hey guys, umm i was trying to hook endscene using detours and i used a method that i hooked many other functions with before but it just doesnt seem to work.
Here is what i have:
Code:
DWORD ThreadID;
LPDIRECT3DDEVICE9 pDEVICE;
D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);
Hacks hack;

HRESULT (APIENTRY *oEndScene)(LPDIRECT3DDEVICE9 pDevice);

HRESULT APIENTRY dEndScene(LPDIRECT3DDEVICE9 pDevice)
{
	DrawBorderBox(50, 50, 200 , 200, 10, fontRed, pDevice);
	
	return oEndScene(pDevice);
}

void APIENTRY HookAPI(LPVOID param)
{
	HANDLE Endsceneaddy = GetProcAddress(GetModuleHandleA("d3d9.dll"),"EndScene");

	if (Endsceneaddy)
	{
		oEndScene = (HRESULT (WINAPI *)(LPDIRECT3DDEVICE9 pDevice))(DetourFunction((PBYTE)Endsceneaddy,(PBYTE)dEndScene));
	}
};



bool __stdcall DllMain(HINSTANCE hinst,  DWORD _Reason, _In_opt_ LPVOID _Reserved)
{
	DisableThreadLibraryCalls(hinst);

	CreateThread(0,0,(LPTHREAD_START_ROUTINE)HookAPI,0,0,&ThreadID);

	return true;
}

void Hacks::DrawBorderBox( int x, int y, int w, int h, int thickness, D3DCOLOR Colour, IDirect3DDevice9 *pDevice)
{
	//Top horiz line
	DrawFilledRect( x, y, w, thickness,  Colour, pDevice );
	//Left vertical line
	DrawFilledRect( x, y, thickness, h, Colour, pDevice );
	//right vertical line
	DrawFilledRect( (x + w), y, thickness, h, Colour, pDevice );
	//bottom horiz line
	DrawFilledRect( x, y + h, w+thickness, thickness, Colour, pDevice );
}


//We receive the 2-D Coordinates the colour and the device we want to use to draw those colours with
void Hacks::DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
{
	//We create our rectangle to draw on screen
	D3DRECT BarRect = { x, y, x + w, y + h }; 
	//We clear that portion of the screen and display our rectangle
	dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}
I have no idea y this code does not seem to work
Please help me
Thanks,
Konsowa.
You need to hook Present instead.
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us