From 582438ac6102c1e7e6dba5c41bc138c893f86592 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 1 Oct 2024 16:37:35 +0200 Subject: [PATCH] sys_info: fix to compile for _WIN32 Signed-off-by: Simon Rozman --- include/stdex/sys_info.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/stdex/sys_info.hpp b/include/stdex/sys_info.hpp index 7d850e034..630148757 100644 --- a/include/stdex/sys_info.hpp +++ b/include/stdex/sys_info.hpp @@ -11,6 +11,7 @@ #include "system.hpp" #if defined(_WIN32) #include "windows.h" +#include #include #include #else @@ -232,18 +233,20 @@ namespace stdex #endif #ifdef _WIN32 +#if defined(SECURITY_WIN32) || defined(SECURITY_KERNEL) { TCHAR szStackBuffer[0x100]; ULONG ulSize = _countof(szStackBuffer); - if (GetUserNameEx(NameFormat, szStackBuffer, &ulSize)) + if (GetUserNameEx(NameSamCompatible, szStackBuffer, &ulSize)) username.assign(szStackBuffer, ulSize); if (GetLastError() == ERROR_MORE_DATA) { // Allocate buffer on heap and retry. username.resize(ulSize - 1); - if (!GetUserNameEx(NameFormat, &username[0], &ulSize)) + if (!GetUserNameEx(NameSamCompatible, &username[0], &ulSize)) username.clear(); } } +#endif #else { struct passwd *pw = getpwuid(geteuid());