tags:

views:

422

answers:

3

Hey there :) I'm currently trying to display some information (as an overlay) to the user inside a DirectX-based game, much like the frame count which Fraps displayed, but I have no clue where to start. I don't expect a full solution to my problem, just a few hints where I can start and where to get more information about the topic ;)

Thanks in advance.

PS: The project I'm working on is written in C# (.NET 3.5)

PPS: To clarify: I mean hooking into any random DX-based game. Start my app, start any game, display some kind of overlay.

+2  A: 

Well one way is to place a d3d9.dll alongside the executable. The DLL search pattern will ALWAYS search the current directory first.

Now its just the "small" matter of implementing the DirectX interface to pass through everything to the REAL d3d9.dll. After you've done this then every time the user calls present you can inject some rendering of your own. In the case of the frame rate example you can measure the time between present calls.

Intercepting loading of the D3D9.dll without placing your own DLL in the way is a LOT more complex.

This website has a load of information on how to inject your own DLL into a process.

Goz
+1  A: 

Thanks to Goz, I also found the following interesting resources on the topic:

Seems like Microsoft Detours is the way to go... Haven't had time to try it out yet, though.

x3ro
+1  A: 

Hi x3ro, not sure if you're still looking for ideas on this one, but for you or anyone else that might be trying this out, here is an example of hooking the IDirect3DDevice9 methods in C# that I've prepared.

It uses EasyHook for the DLL injection + method hooking, and a small C++ utility dll to determine the function address to hook at runtime. EasyHook picks up where Microsoft Detours left off.

Justin S.