所有 我最近需要获得进程的完整性级别,并且我从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的dwIntegrityLevel为0x00004100L,那么进程A的完整性级别是多少? SECURITY_MANDATORY_HIGH_RID和SECURITY_MANDATORY_SYSTEM_RID?这是否意味着一个进程有SECURITY_MANDATORY_SYSTEM_RID级别也有一个SECURITY_MANDATORY_HIGH_RID?
如果示例代码错误,那么确定流程完整性级别的正确方法是什么?
答案 0 :(得分:3)
注意WinNT.h中的等效声明:
#define SECURITY_MANDATORY_MEDIUM_PLUS_RID (SECURITY_MANDATORY_MEDIUM_RID + 0x100)
所以听起来你遇到了一个SYSTEM_PLUS的过程。
答案 1 :(得分:0)
我建议您看一下https://github.com/chromium/chromium/blob/master/base/process/process_info_win.cc上的Chrome / Chromium GetCurrentProcessIntegrityLevel 实现。这可能是一个值得信赖的参考。