[C++] EndScene Hook Problems menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    ejt's Avatar Contributor
    Reputation
    210
    Join Date
    Mar 2008
    Posts
    166
    Thanks G/R
    3/112
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    [C++] EndScene Hook Problems

    Hello,

    I would first like to say that I have checked the forum for some time and also google so don't give me "google is your friend" and stuff like that.

    I'm trying to hook EndScene function so that I can continue with calling of FrameBuffer etc. The problem I have is that my endscene hook never gets fired, I have tried alot of different codes from all kinds of sources including alot from this forum. I now ask for your help to sort this out.
    I am kind of a noob in ASM and my code will probably hurt your eyes, if you can't stand it, press the back button and read another thread.

    Heres my code:

    Getting EndScene function from VTable:

    Code:
    void Memory::GetDirectX9EndScene(HWND hWnd)
    { // hWnd is my window I create inside my DLL and is valid.
    	D3DPRESENT_PARAMETERS d3dpp;
    	LPDIRECT3DDEVICE9 d3dDevice;
    	LPDIRECT3D9 d3d;
    
    	ZeroMemory(&d3dpp, sizeof(d3dpp));
    
    	d3d = Direct3DCreate9(D3D_SDK_VERSION);
    
    	d3dpp.Windowed = TRUE;
    	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    	d3dpp.hDeviceWindow = hWnd;
    
    	d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3dDevice);
    
    	pVTable = (u32*)*((u32*)d3dDevice); // unsigned int*
    	pEndScene = (void*)pVTable[42]; // void*
    
    // I already know I don't clean up after myself but don't need you to tell me that :)
    }
    My hook function that never gets fired:

    Code:
    HRESULT WINAPI EndScene_Hook(IDirect3DDevice9 *pDevice)
    {
    	MessageBox(0, "", "", MB_OK);
    	return EndScene_Orig(pDevice); // Yes, I know this isn't set to anything
    }
    How I try to install my hook:

    Code:
    bool Memory::InstallEndSceneHook()
    {
    	BYTE* bCode = new BYTE[5];
    	memset(bCode, 0x90, 5);
    	DWORD dwFunc = (DWORD)EndScene_Hook - ((DWORD)pEndScene + 5);
    
    	bCode[0] = 0xE9; // JMP
    	*(DWORD*)&bCode[1] = dwFunc;
    
    	DWORD dwOld;
    
    	if(!VirtualProtect((void*)pEndScene, 5, PAGE_READWRITE, &dwOld))
    		return false;
    
    	memcpy((void*)pEndScene, (void*)bCode, 5);
    
    	VirtualProtect((void*)pEndScene, 5, dwOld, &dwOld);
    
    	return true;
    }
    Any help is very much appreciated .

    [C++] EndScene Hook Problems
  2. #2
    DarthTon's Avatar Contributor
    Reputation
    171
    Join Date
    Apr 2010
    Posts
    108
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you checked pEndScene value? Is it correct and points to correct function? Are you sure you run DX 9 and not DX 11?
    Simple debugging can tell you more about possible causes.

  3. #3
    ejt's Avatar Contributor
    Reputation
    210
    Join Date
    Mar 2008
    Posts
    166
    Thanks G/R
    3/112
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DarthTon View Post
    Have you checked pEndScene value? Is it correct and points to correct function? Are you sure you run DX 9 and not DX 11?
    Simple debugging can tell you more about possible causes.
    *hits face in desk*

    Wow was reset to DX11 thats why it didnt work. Thank you for your help.

Similar Threads

  1. [C# DLL] aHook, use ASM through EndScene hook
    By JuJuBoSc in forum WoW Memory Editing
    Replies: 81
    Last Post: 04-22-2024, 02:55 PM
  2. Is EndScene hooking detectable?
    By xLeo123 in forum WoW Memory Editing
    Replies: 9
    Last Post: 01-13-2010, 03:49 PM
  3. Custom rendering in endscene hook
    By ggg898 in forum WoW Memory Editing
    Replies: 3
    Last Post: 09-11-2009, 09:38 AM
  4. [Test Theory] EndScene hook without Native Code (Kinda)
    By Apoc in forum WoW Memory Editing
    Replies: 7
    Last Post: 09-04-2009, 12:46 PM
  5. EndScene Hook not changing anything
    By lanman92 in forum WoW Memory Editing
    Replies: 32
    Last Post: 06-01-2009, 11:46 PM
All times are GMT -5. The time now is 12:18 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search