Internal Discord drawing, externally. (very externally, you can even use a different device to draw on the target one)
After hooking the target process, Discord initializes an Electron window that loads a URL similar to this https://discord.com/overlay?build_id=x&rpc=y&rpc_auth_token=z&pid=w
Then it copies this window's frame buffer and draws it on the game window.
By having Discord load a locally hosted WebGL 2.0 renderer, we can communicate with it to draw on games and (potentially) get keyboard input.
You can set up the overlay using two different methods:
Replace Discord's request URL with your loopback URL in the file AppData\Local\Discord\app*\modules\discord_overlay2-1\discord_overlay2\host.js
function createRenderer(pid, url) {
...
urlWithPid.searchParams.append('pid', pid.toString());
url = urlWithPid.toString();
// Begin page hijacking.
url = "http://127.0.0.1:4001/";
// End page hijacking.
renderers[pid] = {
pid: pid,
...
}
In the CSharp project, there is a method that automatically patches Discord with a given IP address and port.
To unpatch it (and restore the original overlay) you just have to remove the url = "xxx";
line from host.js
.
This is the recommended method because you are not touching Discord's files, and the result will be maintained, even after software updates.
You can build this project on either Windows or Linux.
The shared library build allows you to use it within your existing projects. An example of how to use it this way is DiscoverSharp inside the bindings folder.
- Run
setup.sh
- Run the build script for the output you desire.
- Make sure Discord is closed and launch the program.
- Open Discord.
- Enable
GameOverlay
if it's not enabled yet. - Launch any game and enjoy internal drawing.