About this I also found a used to improve access code, look at should be right, but I still don't know how to do, I hope you can help me, thank you very much!
CodePudding user response:
In the beginning to ascend, DebugPrivilege (SE_DEBUG_NAME, TRUE);At the end of the reduction, DebugPrivilege (SE_DEBUG_NAME, FALSE);
Bool DebugPrivilege (const char * PName, bool bEnable)
{
BOOL bResult=TRUE;
HANDLE hToken;
The TOKEN_PRIVILEGES TokenPrivileges;
if (! OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, & amp; HToken))
{
BResult=FALSE;
Return bResult;
}
TokenPrivileges. PrivilegeCount=1;
TokenPrivileges. Privileges [0]. Attributes=bEnable? SE_PRIVILEGE_ENABLED: 0;
LookupPrivilegeValue (NULL, PName, & amp; TokenPrivileges. Privileges [0]. Luid);
AdjustTokenPrivileges (hToken, FALSE, & amp; TokenPrivileges, sizeof (TOKEN_PRIVILEGES), NULL, NULL);
If (GetLastError ()!=ERROR_SUCCESS)
{
BResult=FALSE;
}
The CloseHandle (hToken);
Return bResult;
}