Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool SetProcessSEPrivilege(HANDLE process, PrivilegeOption option)
- {
- DWORD flags = TOKEN_ADJUST_PRIVILEGES;
- base::win::ScopedHandle token;
- if (!OpenProcessToken(process, flags, token.Receive()))
- {
- return false;
- }
- LUID uid;
- if (!LookupPrivilegeValueW(nullptr, SE_DEBUG_NAME, &uid))
- {
- return false;
- }
- TOKEN_PRIVILEGES tp;
- tp.PrivilegeCount = 1;
- tp.Privileges[0].Luid = uid;
- tp.Privileges[0].Attributes = (option == PrivilegeOption::ENABLE) ? SE_PRIVILEGE_ENABLED : 0;
- BOOL rv = AdjustTokenPrivileges(token.Get(), FALSE, &tp, sizeof(tp), nullptr, nullptr);
- return !!rv;
- }
Add Comment
Please, Sign In to add comment