DiscordOverlay.Helpers
is a proof of concept C# library designed to demonstrate how to use Discord's overlay for drawing custom graphics. It utilizes SkiaSharp for graphics rendering and system-level functions for memory manipulation.
- Direct Memory Management: Leverages kernel32.dll for memory operations within Discord's process.
- Graphics Rendering: Utilizes SkiaSharp for high-quality 2D graphics.
- Overlay Management: Controls the overlay in Discord, with capabilities for various graphical operations.
- The library interacts with Discord's process memory using
Memory
class methods likeOpenFileMapping
andMapViewOfFile
. - These methods access and map Discord's memory, enabling the overlay to be drawn within its graphical interface.
- SkiaSharp is used for drawing graphics onto the overlay.
- The
Drawing
class offers methods such asDrawLine
,DrawRectangle
,DrawString
, andDrawCircle
.
- Frame Management:
GraphicsPipe
manages the connection to Discord, handling the shared memory for frame data. - Frame Representation: The
Frame
class represents each graphics frame, storing dimensions and pixel data. - Buffer Writing Process:
- The graphics drawn using SkiaSharp are rendered onto a frame buffer (
Frame.Buffer
). - This buffer is a byte array representing pixel data for the entire frame.
- The
GraphicsPipe.SendFrame
method is used to send this frame to the shared memory. - It involves copying the frame buffer to the shared memory location mapped to Discord's process.
- The header (
GraphicsPipe.Header
) is updated with the new frame's dimensions and frame count. - This process ensures that each new frame is accurately rendered in the overlay.
- The graphics drawn using SkiaSharp are rendered onto a frame buffer (