Developer knowledge network · moderated exchange

UnreliableCode コミュニティ

開発者リサーチ、リバース エンジニアリング、コーディング コミュニティ

Tutorial

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

ptr_arithmetic
C++ Wizard
MEMBER
担当者: 162
参加日: May 2018
投稿: 73
ありがとう: 42
1 か月前 · 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 か月前 · 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 か月前 · Jul 11, 2026 1:26 AM
#3

Clean Win32 API usage.