19 TOKEN_PRIVILEGES tpPrevious;
20 DWORD cbPrevious =
sizeof(TOKEN_PRIVILEGES);
22 if (!LookupPrivilegeValue(
nullptr, Privilege, &luid)) {
26 tp.PrivilegeCount = 1;
27 tp.Privileges[0].Luid = luid;
28 tp.Privileges[0].Attributes = 0;
30 AdjustTokenPrivileges(
34 sizeof(TOKEN_PRIVILEGES),
39 if (GetLastError() != ERROR_SUCCESS) {
43 tpPrevious.PrivilegeCount = 1;
44 tpPrevious.Privileges[0].Luid = luid;
46 if (bEnablePrivilege) {
47 tpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED);
50 tpPrevious.Privileges[0].Attributes ^= (SE_PRIVILEGE_ENABLED & tpPrevious.Privileges[0].Attributes);
53 AdjustTokenPrivileges(
62 if (GetLastError() != ERROR_SUCCESS) {