void AdjustPrivilege(int pid, BOOL bEnable)
{
    HANDLE    hProcess;
    HANDLE    hToken
=0;
    TOKEN_PRIVILEGES tkp;
    tkp.PrivilegeCount 
= 1;  
    tkp.Privileges[
0].Attributes = 0;
    
if (bEnable)
        tkp.Privileges[
0].Attributes = SE_PRIVILEGE_ENABLED;
    
if (LookupPrivilegeValue(NULL, "SeDebugPrivilege"&tkp.Privileges[0].Luid))
    {
        
if (hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid))
        {
            
if (OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken))
            {
                
if (AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL))
                {
                    CloseHandle(hToken);
                }
            }
            CloseHandle(hProcess);
        }
    }
}

 

相关文章:

  • 2021-10-14
  • 2022-01-14
  • 2021-08-08
  • 2021-06-23
  • 2022-01-23
  • 2022-01-19
  • 2021-12-15
猜你喜欢
  • 2022-02-12
  • 2022-01-08
  • 2021-09-23
  • 2022-12-23
  • 2022-01-17
  • 2021-07-04
相关资源
相似解决方案