1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
bool AdjustAutorisation()
}
HANDLE hToken;
LUID takeOwnershipValue;
TOKEN_PRIVILEGES tkp;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return false;
if (!LookupPrivilegeValue(0, SE_SHUTDOWN_NAME, &takeOwnershipValue))
return false;
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = takeOwnershipValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, &tkp, sizeof(TOKEN_PRIVILEGES), 0, 0);
if (GetLastError()) return false;
return true;
}
if (AdjustAutorisation())
ExitWindowsEx(EWX_FORCE | EWX_SHUTDOWN,0); |