Developer knowledge network · moderated exchange

Сообщество UnreliableCode

Сообщество разработчиков, обратного проектирования и кодирования

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.