标签:str ble led proc token mem bool val null
bool AdjustPrivileges() {
HANDLE hToken = NULL;
TOKEN_PRIVILEGES tp;
TOKEN_PRIVILEGES oldtp;
DWORD dwSize = sizeof(TOKEN_PRIVILEGES);
LUID luid;
OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {
CloseHandle(hToken);
OutputDebugString(TEXT("提升权限失败,LookupPrivilegeValue"));
return false;
}
ZeroMemory(&tp, sizeof(tp));
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
/* Adjust Token Privileges */
if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &oldtp, &dwSize)) {
CloseHandle(hToken);
OutputDebugString(TEXT("提升权限失败 AdjustTokenPrivileges"));
return false;
}
// close handles
CloseHandle(hToken);
return true;
}
标签:str ble led proc token mem bool val null
原文地址:https://www.cnblogs.com/iBinary/p/10749280.html