From 190ff781eaee33e7a61aab44fc4133718cc0515b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 13 Jun 2026 00:36:59 +0200 Subject: add .clang-format --- src/sid.cpp | 94 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'src/sid.cpp') diff --git a/src/sid.cpp b/src/sid.cpp index 7a0e252..1a69763 100644 --- a/src/sid.cpp +++ b/src/sid.cpp @@ -3,69 +3,69 @@ // For details, see https://github.com/egor-tensin/privilege-check. // Distributed under the MIT License. -#include "error.hpp" #include "sid.hpp" +#include "error.hpp" + +/* clang-format off */ #include #include +/* clang-format on */ #include #include -namespace sid -{ - SidBuffer well_known(WELL_KNOWN_SID_TYPE type) - { - SidBuffer buffer; - DWORD cb = static_cast(buffer.size()); +namespace sid { - if (!CreateWellKnownSid(type, NULL, buffer.data(), &cb)) - error::raise("CreateWellKnownSid"); +SidBuffer well_known(WELL_KNOWN_SID_TYPE type) { + SidBuffer buffer; + DWORD cb = static_cast(buffer.size()); - return buffer; - } + if (!CreateWellKnownSid(type, NULL, buffer.data(), &cb)) + error::raise("CreateWellKnownSid"); - 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); - } + return buffer; +} + +SidBuffer builtin_administrators() { + /* + void* sid = nullptr; + SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY; - namespace + if (!AllocateAndInitializeSid( + &authority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &sid)) { - struct LocalDelete - { - void operator()(wchar_t* s) const - { - LocalFree(s); - } - }; + error::raise("AllocateAndInitializeSid"); } - std::wstring to_string(const SidBuffer& sid) - { - wchar_t* s = nullptr; + return std::unique_ptr{sid}; + */ + + return well_known(WinBuiltinAdministratorsSid); +} - if (!ConvertSidToStringSidW(const_cast(sid.data()), &s)) - error::raise("ConvertSidToStringSidW"); +namespace { - return std::unique_ptr{s}.get(); +struct LocalDelete { + void operator()(wchar_t* s) const { + LocalFree(s); } +}; + +} // namespace + +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(); } + +} // namespace sid -- cgit v1.3