| 393 | } |
| 394 | |
| 395 | void 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 | |
| 410 | void SetPrivilege(const wchar_t* privilege, bool enablePrivilege) |
| 411 | { |