Hi
I'm trying to set a privilege value, but LookupPrivilegeValue returns error code 997, from GetLastError() Code:
Code:
DWORD eh = GetLastError();
SetLastError(0);
HANDLE tokenHandle;
TOKEN_PRIVILEGES tp;
LUID luid;
if (GetVersion() >= 0)
{
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle))
{
eh = GetLastError();
MessageBox(NULL, "Error opening process token", "Error", MB_OK);
return false;
}
eh = GetLastError();
if (!LookupPrivilegeValue(NULL, "SeDebugPrivilege", &luid))
{
eh = GetLastError();
MessageBox(NULL, "Error looking up privilege", "Error", MB_OK);
return false;
}
tp.Privileges->Luid = luid;
eh = GetLastError();
tp.PrivilegeCount = 1;
tp.Privileges->Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(tokenHandle, false, &tp, 0, 0, 0))
{
eh = GetLastError();
MessageBox(NULL, "Error adjusting token", "Error", MB_OK);
}
}
Does anyone knows whats wrong here?
Thanks in advance
The Wazaa