我想在parasoft c ++测试软件中编译和测试样本内联嵌入式汇编代码。
源代码:
DuplicateTokenEx
代码有错误。每个单词的错误是:
public static WindowsIdentity GetProcessIdentity(Process process)
{
SafeTokenHandle token = SafeTokenHandle.InvalidHandle;
try
{
if (!Methods.OpenProcessToken(process.Handle, TokenAccessLevels.Query | TokenAccessLevels.Duplicate, out token))
{
throw new Win32Exception();
}
return new WindowsIdentity(token.DangerousGetHandle());
}
finally
{
token.Dispose();
}
}
private static TokenElevationType GetTokenElevation(IntPtr token)
{
var elevationTypeLength = Marshal.SizeOf(typeof (int));
var elevationType = (TokenElevationType) 0;
if (!Methods.GetTokenInformation(token,
TokenInformationClass.TokenElevationType,
ref elevationType, elevationTypeLength, out elevationTypeLength))
{
throw new Win32Exception();
}
return elevationType;
}
public static bool IsProcessElevated(Process process)
{
WindowsIdentity processIdentity = GetProcessIdentity(process);
var tokenElevation = GetTokenElevation(processIdentity.Token);
if (tokenElevation == TokenElevationType.Limited)
{
return false;
}
if (tokenElevation == TokenElevationType.Full)
{
return true;
}
// Do we have a Default elevation type? Then the process elevation status depends directly
// to the owner user being a member of the Administrative group.
return new WindowsPrincipal(processIdentity).IsInRole(WindowsBuiltInRole.Administrator);
}
我该怎么办?
答案 0 :(得分:1)
很可能这不是Parasoft C ++测试本身检测到的错误,而是来自Eclipse CDT IDE(代码编辑器)的提示。您可能正在使用Parasoft C ++测试作为Eclipse插件。