sys_info: fix to compile for _WIN32
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
8844c4059d
commit
582438ac61
@ -11,6 +11,7 @@
|
|||||||
#include "system.hpp"
|
#include "system.hpp"
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
#include <security.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#else
|
#else
|
||||||
@ -232,18 +233,20 @@ namespace stdex
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#if defined(SECURITY_WIN32) || defined(SECURITY_KERNEL)
|
||||||
{
|
{
|
||||||
TCHAR szStackBuffer[0x100];
|
TCHAR szStackBuffer[0x100];
|
||||||
ULONG ulSize = _countof(szStackBuffer);
|
ULONG ulSize = _countof(szStackBuffer);
|
||||||
if (GetUserNameEx(NameFormat, szStackBuffer, &ulSize))
|
if (GetUserNameEx(NameSamCompatible, szStackBuffer, &ulSize))
|
||||||
username.assign(szStackBuffer, ulSize);
|
username.assign(szStackBuffer, ulSize);
|
||||||
if (GetLastError() == ERROR_MORE_DATA) {
|
if (GetLastError() == ERROR_MORE_DATA) {
|
||||||
// Allocate buffer on heap and retry.
|
// Allocate buffer on heap and retry.
|
||||||
username.resize(ulSize - 1);
|
username.resize(ulSize - 1);
|
||||||
if (!GetUserNameEx(NameFormat, &username[0], &ulSize))
|
if (!GetUserNameEx(NameSamCompatible, &username[0], &ulSize))
|
||||||
username.clear();
|
username.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
struct passwd *pw = getpwuid(geteuid());
|
struct passwd *pw = getpwuid(geteuid());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user