MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / SetPrivilege

Function SetPrivilege

Win32Lib/Win32Lib.cpp:395–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395void SetPrivilege(HANDLE hToken, const wchar_t* privilege, bool enablePrivilege)
396{
397 TOKEN_PRIVILEGES tp;
398 LUID luid;
399 if (!LookupPrivilegeValue(nullptr, privilege, &luid))
400 ThrowLastError("LookupPrivilegeValue");
401
402 tp.PrivilegeCount = 1;
403 tp.Privileges[0].Luid = luid;
404 tp.Privileges[0].Attributes = enablePrivilege ? SE_PRIVILEGE_ENABLED : 0;
405
406 if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), nullptr, nullptr))
407 ThrowLastError("AdjustTokenPrivileges");
408}
409
410void SetPrivilege(const wchar_t* privilege, bool enablePrivilege)
411{

Callers 3

ScopedTimezoneBiasMethod · 0.85
~ScopedTimezoneBiasMethod · 0.85
MainFunction · 0.85

Calls 1

ThrowLastErrorFunction · 0.85

Tested by 2

ScopedTimezoneBiasMethod · 0.68
~ScopedTimezoneBiasMethod · 0.68