this post was submitted on 21 Sep 2024
29 points (100.0% liked)
Rust
5989 readers
57 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
There's two main options to approach this: either you inject into the game like how MangoHUD does it, or you make an overlay window that your window manager/compositor helpfully places on top for you.
The second option is pretty simple as any GUI library will give you the window, you just need some help from the compositor side to do the rest. That part can also be pretty easy thanks to Wayland nesting: you can use whatever compositor you want for this, not just the one from your DE. Gamescope for example might work, if not wlroots+layer-shell.
You can also be your own nested compositor by using Smithay, which is in Rust and was made by System76 to be the library behind COSMIC's compositor. Looking at the examples, it looks not too crazy to use. Then you just run the game under yourself and you can do whatever you want.
Injecting into the game isn't too crazy either, you compile to a library and force load it with LD_PRELOAD and override some OpenGL/Vulkan functions that lets you add your own draw commands on top before the frame is finished.
I think avoiding injecting into the game is cleaner and easier as you're completely independent from the game client, so you won't crash the game and you can also just test out your code as a regular window, and restart it mid game. Injecting would also trigger anticheat if present. Which, what you're doing kind of is, even though anyone could also just pen and paper it.
Thanks so much for taking the time to write that long post. I have lots of things to dig into now. I think I'd prefer not injecting anything into the game for the reasons you mentioned, the most important consideration being the anticheat risk. I don't know what the company behind the game have implemented of that nature.