Results 1 to 2 of 2
  1. #1
    konsowa7's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    19
    Reputation
    10
    Thanks
    0
    My Mood
    Confused

    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.

  2. #2
    Xipher's Avatar
    Join Date
    Jul 2011
    Gender
    male
    Location
    Melbourne, AU.
    Posts
    1,780
    Reputation
    472
    Thanks
    1,690
    My Mood
    Innocent
    You need to hook Present instead.

Similar Threads

  1. EndScene Hook Test
    By Departure in forum Combat Arms Coding Help & Discussion
    Replies: 16
    Last Post: 12-05-2010, 08:50 PM
  2. [Question] Hook EndScene
    By Departure in forum Combat Arms Coding Help & Discussion
    Replies: 30
    Last Post: 12-05-2010, 06:02 PM
  3. D3D EndScene Hook dont work
    By inmate in forum C++/C Programming
    Replies: 8
    Last Post: 07-20-2010, 06:10 AM
  4. Hook EndScene
    By inmate in forum C++/C Programming
    Replies: 1
    Last Post: 07-18-2010, 05:24 AM
  5. New Hacks Announced & Warrock DX Hook Update
    By Dave84311 in forum Hack/Release News
    Replies: 17
    Last Post: 03-02-2007, 03:54 PM