MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / GetCurrentProcessUserSid

Function GetCurrentProcessUserSid

FontLoadInterceptor/RpcClient.cpp:24–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace sfh
23{
24 std::wstring GetCurrentProcessUserSid()
25 {
26 auto hToken = GetCurrentProcessToken();
27 PTOKEN_USER user;
28 std::unique_ptr<char[]> buffer;
29 DWORD returnLength;
30 wil::unique_hlocal_string ret;
31 if (GetTokenInformation(
32 hToken,
33 TokenUser,
34 nullptr,
35 0,
36 &returnLength) == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
37 {
38 buffer = std::make_unique<char[]>(returnLength);
39 user = reinterpret_cast<PTOKEN_USER>(buffer.get());
40 }
41 else
42 {
43 MarkUnreachable();
44 }
45 THROW_LAST_ERROR_IF(GetTokenInformation(
46 hToken,
47 TokenUser,
48 user,
49 returnLength,
50 &returnLength) == FALSE);
51 THROW_LAST_ERROR_IF(ConvertSidToStringSidW(user->User.Sid, ret.put()) == FALSE);
52 return ret.get();
53 }
54
55 class QueryCache
56 {

Callers 6

QueryCacheMethod · 0.85
OpenPipeFunction · 0.85
ImplementationMethod · 0.85
CreateNewNamedPipeMethod · 0.85
HandleProcessCreationMethod · 0.85
SingleInstanceLockMethod · 0.85

Calls 1

MarkUnreachableFunction · 0.70

Tested by

no test coverage detected