MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / SetPrivilege

Function SetPrivilege

Libraries/unrar/win32acl.cpp:115–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114
115bool SetPrivilege(LPCTSTR PrivName)
116{
117 bool Success=false;
118
119 HANDLE hToken;
120 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
121 {
122 TOKEN_PRIVILEGES tp;
123 tp.PrivilegeCount = 1;
124 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
125
126 if (LookupPrivilegeValue(NULL,PrivName,&tp.Privileges[0].Luid) &&
127 AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL) &&
128 GetLastError() == ERROR_SUCCESS)
129 Success=true;
130
131 CloseHandle(hToken);
132 }
133
134 return Success;
135}

Callers 2

SetACLPrivilegesFunction · 0.85
CreateReparsePointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected