aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sid.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 01:08:49 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 01:08:49 +0300
commit42f1ad36ef93c98542f9899ada57bd55396a99f5 (patch)
treed0b10dd617764271db739b608a9d6bfaa63d516b /sid.h
parentmake the 'Elevate' button smaller (diff)
downloadprivilege-check-42f1ad36ef93c98542f9899ada57bd55396a99f5.tar.gz
privilege-check-42f1ad36ef93c98542f9899ada57bd55396a99f5.zip
.hpp instead of .h for C++ headers
Diffstat (limited to 'sid.h')
-rw-r--r--sid.h68
1 files changed, 0 insertions, 68 deletions
diff --git a/sid.h b/sid.h
deleted file mode 100644
index 5da8da7..0000000
--- a/sid.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#pragma once
-
-#include "error.h"
-
-#include <Windows.h>
-#include <sddl.h>
-
-#include <array>
-#include <memory>
-#include <string>
-
-constexpr DWORD max_sid_size = SECURITY_MAX_SID_SIZE;
-typedef std::array<unsigned char, max_sid_size> SidBuffer;
-
-namespace sid
-{
- SidBuffer well_known(WELL_KNOWN_SID_TYPE type)
- {
- SidBuffer buffer;
- DWORD cb = static_cast<DWORD>(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<void, FreeSid>{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<unsigned char*>(sid.data()), &s))
- error::raise("ConvertSidToStringSidW");
-
- return std::unique_ptr<wchar_t, DeleteSidString>{s}.get();
- }
-}