4

我最近需要获得一个进程的完整性级别,我从 MSDN 找到了帮助。示例代码如下所示:

if (GetTokenInformation(hToken, TokenIntegrityLevel, 
     pTIL, dwLengthNeeded, &dwLengthNeeded))
 {
  dwIntegrityLevel = *GetSidSubAuthority(pTIL->Label.Sid, 
    (DWORD)(UCHAR)(*GetSidSubAuthorityCount(pTIL->Label.Sid)-1));

  if (dwIntegrityLevel == SECURITY_MANDATORY_LOW_RID)
  {
   // Low Integrity
   wprintf(L"Low Process");
  }
  else if (dwIntegrityLevel >= SECURITY_MANDATORY_MEDIUM_RID && 
       dwIntegrityLevel < SECURITY_MANDATORY_HIGH_RID)
  {
   // Medium Integrity
   wprintf(L"Medium Process");
  }
  else if (dwIntegrityLevel >= SECURITY_MANDATORY_HIGH_RID)
  {
   // High Integrity
   wprintf(L"High Integrity Process");
  }
  else if (dwIntegrityLevel >= SECURITY_MANDATORY_SYSTEM_RID)
  {
   // System Integrity
   wprintf(L"System Integrity Process");
  }
 }

众所周知,

SECURITY_MANDATORY_LOW_RID == 0x00001000L
SECURITY_MANDATORY_MEDIUM_RID == 0x00002000L
SECURITY_MANDATORY_HIGH_RID == 0x00003000L
SECURITY_MANDATORY_SYSTEM_RID == 0x00004000L.

这是我的问题:如果此示例代码是正确的,那么如果进程 A 具有of ,
那么它的完整性级别是多少?和?是不是说有层次的过程也有层次?dwIntegrityLevel0x00004100LSECURITY_MANDATORY_HIGH_RIDSECURITY_MANDATORY_SYSTEM_RIDSECURITY_MANDATORY_SYSTEM_RIDSECURITY_MANDATORY_HIGH_RID

如果示例代码错误,那么确定进程完整性级别的正确方法是什么?

4

2 回答 2

4

请注意 WinNT.h 中的等效声明:

#define SECURITY_MANDATORY_MEDIUM_PLUS_RID  (SECURITY_MANDATORY_MEDIUM_RID + 0x100)

所以听起来你遇到了一个 SYSTEM_PLUS 进程。

于 2012-10-08T11:46:46.080 回答
0

我建议您查看https://github.com/chromium/chromium/blob/master/base/process/process_info_win.ccGetCurrentProcessIntegrityLevel上的 Chrome/Chromium实现。这可能是一个值得信赖的参考。

于 2020-04-13T13:28:09.113 回答