|
1 | 1 | #include "FFPlatform_private.h" |
2 | 2 | #include "common/io.h" |
3 | 3 | #include "common/library.h" |
| 4 | +#include "common/mallocHelper.h" |
4 | 5 | #include "common/stringUtils.h" |
5 | 6 | #include "common/windows/unicode.h" |
6 | 7 | #include "common/windows/registry.h" |
7 | 8 | #include "common/windows/nt.h" |
8 | 9 |
|
9 | 10 | #include <windows.h> |
10 | 11 | #include <shlobj.h> |
| 12 | +#include <sddl.h> |
11 | 13 |
|
12 | 14 | #define SECURITY_WIN32 1 // For secext.h |
13 | 15 | #include <secext.h> |
@@ -148,9 +150,28 @@ static void getUserName(FFPlatform* platform) |
148 | 150 | } |
149 | 151 |
|
150 | 152 | wchar_t buffer[256]; |
151 | | - DWORD len = ARRAY_SIZE(buffer); |
152 | | - if (GetUserNameExW(NameDisplay, buffer, &len)) |
| 153 | + DWORD size = ARRAY_SIZE(buffer); |
| 154 | + if (GetUserNameExW(NameDisplay, buffer, &size)) |
153 | 155 | ffStrbufSetWS(&platform->fullUserName, buffer); |
| 156 | + |
| 157 | + size = 0; |
| 158 | + DWORD refDomainSize = 0; |
| 159 | + SID_NAME_USE sidNameUse = SidTypeUnknown; |
| 160 | + LookupAccountNameA(NULL, userName, NULL, &size, NULL, &refDomainSize, &sidNameUse); |
| 161 | + if (size > 0) |
| 162 | + { |
| 163 | + FF_AUTO_FREE PSID sid = (PSID) malloc(size); |
| 164 | + FF_AUTO_FREE char* refDomain = (char*) malloc(refDomainSize); |
| 165 | + if (LookupAccountNameA(NULL, userName, sid, &size, refDomain, &refDomainSize, &sidNameUse)) |
| 166 | + { |
| 167 | + LPWSTR sidString; |
| 168 | + if (ConvertSidToStringSidW(sid, &sidString)) |
| 169 | + { |
| 170 | + ffStrbufSetWS(&platform->sid, sidString); |
| 171 | + LocalFree(sidString); |
| 172 | + } |
| 173 | + } |
| 174 | + } |
154 | 175 | } |
155 | 176 |
|
156 | 177 | static void getHostName(FFPlatform* platform) |
|
0 commit comments