Hooking another directx application

Started by
3 comments, last by S1CA 19 years, 7 months ago
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
Advertisement
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{public:   // 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.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
What MMO?
Dark Age of Camelot, I believe. The product is probably still out there, somewhere. I'm not quite sure what happened to it after I completed it and turned it over.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
BTW, the Detours library may be of interest to you too: http://research.microsoft.com/sn/detours/

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement