Home > Software engineering >  Please great monotheistic my ascension process monitoring tools SeDebugPrivilege permissions?
Please great monotheistic my ascension process monitoring tools SeDebugPrivilege permissions?

Time:10-12

Recently found a small process monitoring tools, want to learn, good. No problem with VC6.0 compiler, but run is debugging said could not set SeDebugPrivilege some options may not work,

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;
}
  • Related