Changeset View
Changeset View
Standalone View
Standalone View
source/lib/sysdep/os/win/wutil.cpp
Show First 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
WinScopedPreserveLastError s; | WinScopedPreserveLastError s; | ||||
HANDLE hToken; | HANDLE hToken; | ||||
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken)) | if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken)) | ||||
return ERR::_1; | return ERR::_1; | ||||
TOKEN_PRIVILEGES tp; | TOKEN_PRIVILEGES tp; | ||||
if (!LookupPrivilegeValueW(NULL, privilege, &tp.Privileges[0].Luid)) | if (!LookupPrivilegeValueW(nullptr, privilege, &tp.Privileges[0].Luid)) | ||||
return ERR::_2; | return ERR::_2; | ||||
tp.PrivilegeCount = 1; | tp.PrivilegeCount = 1; | ||||
tp.Privileges[0].Attributes = enable? SE_PRIVILEGE_ENABLED : 0; | tp.Privileges[0].Attributes = enable? SE_PRIVILEGE_ENABLED : 0; | ||||
SetLastError(0); | SetLastError(0); | ||||
const BOOL ok = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, 0, 0); | const BOOL ok = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, 0, 0); | ||||
if(!ok || GetLastError() != 0) | if(!ok || GetLastError() != 0) | ||||
return ERR::_3; | return ERR::_3; | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator