| 945 | } |
| 946 | |
| 947 | std::string GetCurrentProcessUserStringSid() |
| 948 | { |
| 949 | static std::string CachedResult = ([]() -> std::string |
| 950 | { |
| 951 | std::string Result; |
| 952 | |
| 953 | HANDLE CurrentProcessToken = nullptr; |
| 954 | if (::OpenProcessToken( |
| 955 | ::GetCurrentProcess(), |
| 956 | TOKEN_ALL_ACCESS, |
| 957 | &CurrentProcessToken)) |
| 958 | { |
| 959 | DWORD Length = 0; |
| 960 | ::GetTokenInformation( |
| 961 | CurrentProcessToken, |
| 962 | TOKEN_INFORMATION_CLASS::TokenUser, |
| 963 | nullptr, |
| 964 | 0, |
| 965 | &Length); |
| 966 | if (ERROR_INSUFFICIENT_BUFFER == ::GetLastError()) |
| 967 | { |
| 968 | PTOKEN_USER Information = reinterpret_cast<PTOKEN_USER>( |
| 969 | ::MileAllocateMemory(Length)); |
| 970 | if (Information) |
| 971 | { |
| 972 | if (::GetTokenInformation( |
| 973 | CurrentProcessToken, |
| 974 | TOKEN_INFORMATION_CLASS::TokenUser, |
| 975 | Information, |
| 976 | Length, |
| 977 | &Length)) |
| 978 | { |
| 979 | LPWSTR StringSid = nullptr; |
| 980 | if (::ConvertSidToStringSidW( |
| 981 | Information->User.Sid, |
| 982 | &StringSid)) |
| 983 | { |
| 984 | Result = Mile::ToString( |
| 985 | CP_UTF8, |
| 986 | std::wstring(StringSid)); |
| 987 | ::LocalFree(StringSid); |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | ::MileFreeMemory(Information); |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | ::CloseHandle(CurrentProcessToken); |
| 996 | } |
| 997 | |
| 998 | return Result; |
| 999 | }()); |
| 1000 | |
| 1001 | return CachedResult; |
| 1002 | } |
| 1003 | |
| 1004 | HWND ShowOperationWaitingWindow( |
no outgoing calls
no test coverage detected