Sign in to follow this  

Game overlay

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all! I've been searching through the forum and found some useful answers about what I want to do. But, all of them does not totally satisfy my needs (mainly because they all seems out of date). I'm looking to do some overlay on top of full screen games. I want to display information (1 to 3 small lines at maximum) on the player's screen for 4 or 5 seconds and then disappear. I'm a senior developer (mainly in the .net world) with a strong background in C and C++ but with no game development knowledge at all :'-( I've already installed the latest DirectX SDK on my system. Any hints to how can I achieve this are welcome. Even if a complete library to do overlay will be useful, I want to understand the overall process of doing overlay. Thanks a lot in advance, Ezrille

Share this post


Link to post
Share on other sites
The way this is usually done is by hooking the calls the game uses for rendering, and drawing your own stuff just after the game finishes. The exact functions you hook will depend on the API the game uses (Usually Direct3D or OpenGL, assuming a 3D game).

With Direct3D, one method is to create a proxy DLL. This is a DLL which you name d3d9.dll (Assuming D3D9), and exports a function called Direct3DCreate9(). When that function is called, you should load the real d3d9.dll from the system directory, call the real Direct3DCreate9 to create an IDirect3DDevice9 object, and then return an interface derived from IDirect3D9, where each function in it except CreateDevice() just calls the "real" function.

Your CreateDevice() function should behave in a similar way; it should call the "real" CreateDevice() to get a real device pointer, and all functions except those you're interested in should just call the real version of the function.
When the game tries to call EndScene(), you'll want to draw your overlay stuff and then call the real EndScene().

You can also do this in a similar way by using DLL injection and/or API hooking to hook the call toe Direct3DCreate9.
If you want to do this for any APIs other that D3D9, you'll need to implement them in addition to the above method.

Share this post


Link to post
Share on other sites
Thanks for this answer. If I understand what you said, I need to have some kind of a launcher which will itself starts the real game so it can hook up rendering functions? Unfortunately, this is not an option for what I need to do...

Share this post


Link to post
Share on other sites
No, you can write a proxy DLL and put it into the same folder as the EXE. The EXE will load your DLL thinking it's the real thing, and by acting like the real thing you can draw whatever you want with the app being none the wiser. After that, your options are:

a) do the logic in the DLL, so you don't need a separate program
b) Use IPC, like shared memory, named pipe, sockets, or shared data segments to use another program to control/communicate with the DLL

Share this post


Link to post
Share on other sites
Ok, I better see now. But, if I understand correctly, I can't do it without a proxy DLL? I'm building something generic and not one game centered.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezrille
Ok, I better see now. But, if I understand correctly, I can't do it without a proxy DLL? I'm building something generic and not one game centered.
Correct. That's why E.g. Fraps only works with Direct3D and OpenGL. To complicate things, there could be games you want to patch that don't use Direct3D or OpenGL, but use Windows GDI - which would mean another API to patch.

Share this post


Link to post
Share on other sites
Now that your name it, I'd like to work the same way Fraps works. So I'll focus on Direct3D and OpenGL. By the way, do you know where to start to build a to library to easily add overlay in World of Warcraft?

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezrille
Now that your name it, I'd like to work the same way Fraps works. So I'll focus on Direct3D and OpenGL. By the way, do you know where to start to build a to library to easily add overlay in World of Warcraft?
I believe that WoW uses Direct3D9, which means that This would be a good start.

Share this post


Link to post
Share on other sites
Again, thanks a lot, I'll read that asap (except, I don't want a launcher...)

EDIT: ok, seems the launcher is only there to get the process informations

See you soon :)
Ezrille

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezrille
Again, thanks a lot, I'll read that asap (except, I don't want a launcher...)

EDIT: ok, seems the launcher is only there to get the process informations
If you can install your DLL to the games main directory, you can avoid needing a launcher - the game will load your d3d9.dll from there, thinking its the "real" d3d9.dll.

Share this post


Link to post
Share on other sites
Well, I gave a look at the Mumble source code and try to mock how Mumble is doing overlay. I've extracted the base component successfully but I don't know how to use them. I'm trying to go deeper in their implementation but it seems that I've too many years without C/C++ practices behind me :-)

I'll keep digging their source code, I'll probably need to get the QT library if I want to ease my job.

Finally, I won't use DLL Hooking as I fear the Warden in World of Warcraft could detect this a cheat try, and I don't want my guildmates and I to be banned :-p

Regards,
Ezrille

Share this post


Link to post
Share on other sites

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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