From fbd6445c68745d484d5df8c75b0c12054185958f Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 16 Sep 2016 01:47:56 +0300 Subject: move source files to src/ --- sid.hpp | 68 ----------------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 sid.hpp (limited to 'sid.hpp') diff --git a/sid.hpp b/sid.hpp deleted file mode 100644 index 15ce73b..0000000 --- a/sid.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include "error.hpp" - -#include -#include - -#include -#include -#include - -constexpr DWORD max_sid_size = SECURITY_MAX_SID_SIZE; -typedef std::array SidBuffer; - -namespace sid -{ - SidBuffer well_known(WELL_KNOWN_SID_TYPE type) - { - SidBuffer buffer; - DWORD cb = static_cast(buffer.size()); - - if (!CreateWellKnownSid(type, NULL, buffer.data(), &cb)) - error::raise("CreateWellKnownSid"); - - return buffer; - } - - SidBuffer builtin_administrators() - { - /* - void* sid = nullptr; - SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY; - - if (!AllocateAndInitializeSid( - &authority, - 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, - &sid)) - { - error::raise("AllocateAndInitializeSid"); - } - - return std::unique_ptr{sid}; - */ - - return well_known(WinBuiltinAdministratorsSid); - } - - struct DeleteSidString - { - void operator()(wchar_t* s) const - { - LocalFree(s); - } - }; - - std::wstring to_string(const SidBuffer& sid) - { - wchar_t* s = nullptr; - - if (!ConvertSidToStringSidW(const_cast(sid.data()), &s)) - error::raise("ConvertSidToStringSidW"); - - return std::unique_ptr{s}.get(); - } -} -- cgit v1.2.3