From 5f2b243942464176a260d760e62c7bd9a32af3e4 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 12 Jun 2025 14:20:13 +0200 Subject: [PATCH] =?UTF-8?q?system:=20basic=5Fsys=5Fobject::get=20=E2=86=92?= =?UTF-8?q?=20basic=5Fsys=5Fobject::operator=20T?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handle validation is done with valid() method now, so using operator T to auto-retrieve object handle should not provide ambiguities any more. As long as we remember to use valid() for testing! Signed-off-by: Simon Rozman --- include/stdex/sys_info.hpp | 6 +++--- include/stdex/system.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/stdex/sys_info.hpp b/include/stdex/sys_info.hpp index 2efeb22ff..1162d6097 100644 --- a/include/stdex/sys_info.hpp +++ b/include/stdex/sys_info.hpp @@ -193,12 +193,12 @@ namespace stdex TOKEN_ELEVATION elevation; DWORD size = sizeof(TOKEN_ELEVATION); - if (GetTokenInformation(token_h, TokenElevation, &elevation, sizeof(elevation), &size)) + if (GetTokenInformation(token, TokenElevation, &elevation, sizeof(elevation), &size)) elevated = elevation.TokenIsElevated; - GetTokenInformation(token.get(), TokenGroups, NULL, 0, &size); + GetTokenInformation(token, TokenGroups, NULL, 0, &size); std::unique_ptr groups((TOKEN_GROUPS*)new uint8_t[size]); - if (GetTokenInformation(token.get(), TokenGroups, (LPVOID)groups.get(), size, &size)) { + if (GetTokenInformation(token, TokenGroups, (LPVOID)groups.get(), size, &size)) { SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY; PSID sid_admins_h = NULL; if (AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &sid_admins_h)) { diff --git a/include/stdex/system.hpp b/include/stdex/system.hpp index d7ee4b081..43e64bdff 100644 --- a/include/stdex/system.hpp +++ b/include/stdex/system.hpp @@ -198,7 +198,7 @@ namespace stdex /// /// Returns object handle /// - T get() const noexcept { return m_h; } + operator T() const noexcept { return m_h; } protected: T m_h;