Developer knowledge network · moderated exchange

Супольнасць UnreliableCode

Супольнасць распрацоўшчыкаў даследаванняў, зваротнага праектавання і кадавання

Knowledge indexжыць
4Categories
919Threads
2.8KПаведамленні
Release

RAII Smart Handle Wrappers for Windows Kernel Objects & Shared Memory [v2.4 Technical Discussion]

ptr_arithmetic
C++ Wizard
MEMBER
прадстаўнік: 162
Дата далучэння: May 2018
Паведамленні: 73
Дзякуй: 42
3 тыдняў таму · Jul 29, 2026 8:13 PM
#1

Modern C++20 RAII handle management to eliminate handle leaks:

CPP
struct HandleDeleter { void operator()(HANDLE h) const { if (h && h != INVALID_HANDLE_VALUE) CloseHandle(h); } };
using UniqueHandle = std::unique_ptr<void, HandleDeleter>;

UniqueHandle hProcess(OpenProcess(PROCESS_ALL_ACCESS, FALSE, targetPid));
if (!hProcess) return false;
// Automatically calls CloseHandle when exiting scope!

Guarantees exception safety and zero dangling zombie process handles!

null_deref
Reverse Engineer
MEMBER
прадстаўнік: 79
Дата далучэння: Jan 2019
Паведамленні: 42
Дзякуй: 46
3 тыдняў таму · Jul 30, 2026 3:47 AM
#2

RAII smart handles prevent resource leaks during early error return branches. Clean modern C++.

vtable_slayer
Senior Reverser
MEMBER
прадстаўнік: 215
Дата далучэння: Mar 2018
Паведамленні: 86
Дзякуй: 61
3 тыдняў таму · Jul 30, 2026 10:07 AM
#3

Simple, elegant, and crash-proof.