mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-10-07 22:50:03 +08:00
Initial commit
This commit is contained in:
22
include/base/safe_handle.hpp
Normal file
22
include/base/safe_handle.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#define _AMD64_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <handleapi.h>
|
||||
|
||||
namespace base {
|
||||
namespace detail {
|
||||
struct HandleDisposer {
|
||||
using pointer = HANDLE;
|
||||
|
||||
void operator()(const HANDLE handle) const noexcept {
|
||||
if (handle != nullptr && handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(handle);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
using SafeHandle = std::unique_ptr<HANDLE, detail::HandleDisposer>;
|
||||
}
|
Reference in New Issue
Block a user