diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index 82680785..98bd0444 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -42,6 +42,7 @@ namespace winstd class WINSTD_API user_impersonator; class WINSTD_API vmemory; class WINSTD_API reg_key; + class WINSTD_API security_id; } @@ -825,6 +826,31 @@ namespace winstd virtual void free_internal(); }; + + /// + /// SID wrapper class + /// + class WINSTD_API security_id : public handle + { + HANDLE_IMPL(security_id) + + public: + /// + /// Closes a handle to the SID. + /// + /// \sa [FreeSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa446631.aspx) + /// + virtual ~security_id(); + + protected: + /// + /// Closes a handle to the SID. + /// + /// \sa [FreeSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa446631.aspx) + /// + virtual void free_internal(); + }; + /// @} } diff --git a/src/Win.cpp b/src/Win.cpp index eb05d5a1..8d494551 100644 --- a/src/Win.cpp +++ b/src/Win.cpp @@ -309,3 +309,20 @@ void winstd::reg_key::free_internal() { RegCloseKey(m_h); } + + +////////////////////////////////////////////////////////////////////// +// winstd::security_id +////////////////////////////////////////////////////////////////////// + +winstd::security_id::~security_id() +{ + if (m_h) + FreeSid(m_h); +} + + +void winstd::security_id::free_internal() +{ + FreeSid(m_h); +}