Sign in to follow this  

Hooking another directx application

Recommended Posts

My ultimate goal here is to be able to display the FPS of another directx application, and to render the FPS in the other directx application. I would assume the first step is to hook the D3DDevice of the other application. Then hook a function on the other application such as endscene, so I can do all the rendering I need to do, then let the application continue. I don't even know if I have the right approach? If anyone knows any articles or anything, or could be of any help on how to pull this off, it would be greatly appreciated. -Dev578

Share this post

Link to post
Share on other sites
I did a commercial project a little while ago that hooked into an MMORPG, read the memory that store player information, and rendered a positional radar, with the MMORPG's D3D Device. It was pretty difficult.

CodeProject has a lot of good articles on hooking. Just search for them - this is a pretty good one.

Basically, I hooked the MMORPG's Direct3DCreate9 function. At that point, I created my own IDirect3D9 interface, and returned that pointer instead. However, instead of creating the standard IDirect3D9 interface, I created a custom interface which was inherited from IDirect3D9.

I did the same for the IDirect3DDevice9 interface. I put my additional rendering code in MyDirect3DDevice9::EndScene(). That way, the game was finished with it's rendering, so I was okay to do mine.

For example:
HRESULT __stdcall NewIDirect3DDevice9::EndScene()
// Do all special rendering here
// Fonts, sprites, whatever...
return pD3DDevice9->EndScene();

Most of the functions just looked like this:
UINT __stdcall NewIDirect3DDevice9::GetAvailableTextureMem()
return pD3DDevice9->GetAvailableTextureMem();

And the overridden interfaces were declared like this:

interface NewIDirect3DDevice9 : public IDirect3DDevice9
// LOTS AND LOTS of functions!
// You need all of them...

In essence, I wrapped the main Direct3D interfaces, and added my own custom code where needed.

Hopefully, I remembered that correctly - it's been a while, and it was complicated [smile]. If you want some more code, feel free to ask. It was a challenging project, but it was pretty interesting.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this