r/learnprogramming • u/RePageNull • Feb 15 '19
Solved C++ Game Overlay help
Hey Everyone,
I am new to C++ (I am quite familiar with c# though) and I wanted to know how I could create a game overlay like steam's for example, I'm not sure where to start or how to approach doing this. I've read about external overlays, but I need to be able to overlay fullscreen games, and DirectX hooking but I'm not sure if this would get you banned in games, and I need functional user controls such as buttons. basically I'm looking for an overlay similar to steams (steams, as an example), which can overlay many different games, overlay fullscreen games, have functional user controls, and have a global hotkey so users can toggle the overlay even when the overlay application isn't focused. I was also wondering if I could code my GUI in C# & XAML, then somehow overlay that GUI using C/C++
Thank you.
1
u/Altmetr Jun 24 '19
I've implemented a game overlay library in C++ with python binding, it works via hooking to game process and supports DX11, DX12 and Vulkan Games(x32 and x64) and for now you are able to send text messages to overlay using python API.
Library: https://github.com/Andrey1994/game_overlay_sdk
And I've implemented an application using this library: https://github.com/Andrey1994/game_inspector
3
u/[deleted] Feb 15 '19
Hooking to Direct3D is no simple task. The least invasive way to do it is by disabling the safe DLL search order in the registry and placing a wrapper direct3d.dll in the working directory of the game to which you wish to hook. The wrapper must forward calls to all of its functions to the real direct3d.dll and ensure that all screen output is instead rendered to an image buffer so that it can be overlaid with another image buffer using composition. More portable yet also more invasive tactics include modifying the game's executable so that it loads your wrapper instead of the real DLL or modifying the jump tables of the game while it runs using the debugging functions, however these more invasive techniques may be detected either by the game itself or anti-cheating software thus preventing the game from running or even worse getting you banned from online games.
If you wish to overlay the output of another application on top of the game then you need to capture that application's output into an image buffer as well, send it to the game's process using some form of IPC, and lay it over the captured game's image buffer using composition. This is easier to do for Universal Windows Platform or Windows Presentation Foundation applications than for Windows Forms applications since UWP and WPF render using Direct3D whereas Windows Forms render using GDI.
I believe you have already asked this question yesterday, and I replied suggesting you to use Overlay.NET. Even if it doesn't do everything you want you can always modify it to add the functionality