Developer knowledge network · moderated exchange

مجتمع الكود غير الموثوق به

أبحاث المطورين، مجتمع الهندسة العكسية والترميز

Knowledge indexيعيش
4Categories
919Threads
2.8Kدعامات
Tutorial

High-Speed Memory Mapped Files (CreateFileMapping) for Zero-Copy IPC

ptr_arithmetic
C++ Wizard
MEMBER
مندوب: 162
تاريخ الانضمام: May 2018
دعامات: 73
شكرًا: 42
1 months ago · Jul 10, 2026 2:39 AM
#1

Instead of slow TCP sockets or named pipes for communicating between a background reader and frontend UI:

CPP
// Server / Reader process
HANDLE hMapFile = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, sizeof(SharedGameState), "Local\\GameOverlayData");
SharedGameState* pShared = (SharedGameState*)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SharedGameState));

// Client / Overlay process
HANDLE hMapFile = OpenFileMappingA(FILE_MAP_READ, FALSE, "Local\\GameOverlayData");
const SharedGameState* pShared = (const SharedGameState*)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, sizeof(SharedGameState));

Both processes read and write to the exact same physical RAM pages mapped into virtual memory. Latency is literally 0 nanoseconds (direct RAM read)!

imgui_artisan
UI Designer
MEMBER
مندوب: 202
تاريخ الانضمام: Apr 2019
دعامات: 54
شكرًا: 28
1 months ago · Jul 10, 2026 7:34 AM
#2

Shared memory mapped files are unbeatable for multi-process overlays. Pair with an alignas(64) std::atomic<uint32_t> frameIndex to synchronize frames.

vtable_slayer
Senior Reverser
MEMBER
مندوب: 215
تاريخ الانضمام: Mar 2018
دعامات: 86
شكرًا: 61
1 months ago · Jul 11, 2026 1:26 AM
#3

Clean Win32 API usage.