Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 534175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:35:04+00:00 2026-05-13T09:35:04+00:00

I want to detour EndScene from an arbitrary DirectX 9 application to create a

  • 0

I want to detour EndScene from an arbitrary DirectX 9 application to create a small overlay. As an example, you could take the frame counter overlay of FRAPS, which is shown in games when activated.

I know the following methods to do this:

  1. Creating a new d3d9.dll, which is then copied to the games path. Since the current folder is searched first, before going to system32 etc., my modified DLL gets loaded, executing my additional code.
    Downside: You have to put it there before you start the game.

  2. Same as the first method, but replacing the DLL in system32 directly.
    Downside: You cannot add game specific code. You cannot exclude applications where you don’t want your DLL to be loaded.

  3. Getting the EndScene offset directly from the DLL using tools like IDA Pro 4.9 Free. Since the DLL gets loaded as is, you can just add this offset to the DLL starting address, when it is mapped to the game, to get the actual offset, and then hook it.
    Downside: The offset is not the same on every system.

  4. Hooking Direct3DCreate9 to get the D3D9, then hooking D3D9->CreateDevice to get the device pointer, and then hooking Device->EndScene through the virtual table.
    Downside: The DLL cannot be injected, when the process is already running. You have to start the process with the CREATE_SUSPENDED flag to hook the initial Direct3DCreate9.

  5. Creating a new Device in a new window, as soon as the DLL gets injected. Then, getting the EndScene offset from this device and hooking it, resulting in a hook for the device which is used by the game.
    Downside: as of some information I have read, creating a second device may interfere with the existing device, and it may bug with windowed vs. fullscreen mode etc.

  6. Same as the third method. However, you’ll do a pattern scan to get EndScene.
    Downside: doesn’t look that reliable.

How can I hook EndScene from an injected DLL, which may be loaded when the game is already running, without having to deal with different d3d9.dll‘s on other systems, and with a method which is reliable? How does FRAPS for example perform it’s DirectX hooks?
The DLL should not apply to all games, just to specific processes where I inject it via CreateRemoteThread.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:35:05+00:00Added an answer on May 13, 2026 at 9:35 am

    You install a system wide hook. (SetWindowsHookEx) With this done, you get to be loaded into every process.

    Now when the hook is called, you look for a loaded d3d9.dll.

    If one is loaded, you create a temporary D3D9 object, and walk the vtable to get the address of the EndScene method.

    Then you can patch the EndScene call, with your own method. (Replace the first instruction in EndScene by a call to your method.

    When you are done, you have to patch the call back, to call the original EndScene method. And then reinstall your patch.

    This is the way FRAPS does it. (Link)


    You can find a function address from the vtable of an interface.

    So you can do the following (Pseudo-Code):

    IDirect3DDevice9* pTempDev = ...;
    const int EndSceneIndex = 26 (?);
    
    typedef HRESULT (IDirect3DDevice9::* EndSceneFunc)( void );
    
    BYTE* pVtable = reinterpret_cast<void*>( pTempDev );
    EndSceneFunc = pVtable + sizeof(void*) * EndSceneIndex;
    

    EndSceneFunc does now contain a pointer to the function itself. We can now either patch all call-sites or we can patch the function itself.

    Beware that this all depends on the knowledge of the implementation of COM-Interfaces in Windows. But this works on all windows versions (either 32 or 64, not both at the same time).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Want to create an alarm application, that will play a music file at a
Want to add a HTML (div) element conditionally. But code exerpt from my Create.cshtml
Want to check that my site map contains a page. Could just iterate through
Want to extract the text value from a lookup table's column in a db.
want declarative transactional management example in spring aop........ Actually Here <aop:config> <aop:advisor advice-ref=addAdvice pointcut=execution(*
Want to create animation dll for Window XP Is it ok to create Java2d
Want to play the YouTube video in my application directly in landscape mode. I
Want to create web sites with data on Dynamics AX. We want not to
Want to write a typing test application (GUI, windows). Is simple terms. app shows
Want i want to do is i get a number from a php script.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.