您将不得不做 Internet Explorer(和 Chrome)所做的事情。浏览器选项卡本身是在Low Mandatory Integrity Level运行的独立进程。但是仍然有一个中等级别的父进程。
客户端进程通过命名管道与“父”进程通信,要求父进程执行一些操作。由于父母是中型的,它可以在中型上启动一些东西。
更新:这是一个示例,说明如何无法从低完整性进程创建中等完整性进程:
void CreateLowProcess(String szProcessName; String IntegritySid)
{
hToken: THandle;
hNewToken: THandle;
szIntegritySid: WideString;
pIntegritySid: PSID;
TIL: TOKEN_MANDATORY_LABEL;
ProcInfo: PROCESS_INFORMATION;
startupInfo: TStartupInfo;
const int SE_GROUP_INTEGRITY = 0x00000020;
const int TokenIntegrityLevel = 25;
const String SLowIntegritySid = "S-1-16-4096";
const String SMediumIntegritySid = "S-1-16-8192";
const String SHighIntegritySid = "S-1-16-12288";
const String SSystemIntegritySid = "S-1-16-16384";
/*
Designing Applications to Run at a Low Integrity Level
http://msdn.microsoft.com/en-us/library/bb625960.aspx
*/
// Low integrity SID
if IntegritySid == ""
IntegritySid = SMediumIntegritySid;
pIntegritySid = null;
ZeroMemory(@startupInfo, sizeof(startupInfo));
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_DUPLICATE or TOKEN_ADJUST_DEFAULT or TOKEN_QUERY or TOKEN_ASSIGN_PRIMARY,
ref hToken))
RaiseLastWin32Error;
try
if (not DuplicateTokenEx(hToken, 0, nil, SecurityImpersonation, TokenPrimary, {var}hNewToken)) then
RaiseLastWin32Error;
try
if (not ConvertStringSidToSidW(PWideChar(szIntegritySid), {var}pIntegritySid)) then
RaiseLastWin32Error;
try
TIL._Label.Attributes := SE_GROUP_INTEGRITY;
TIL._Label.Sid := pIntegritySid;
// Set the process integrity level
if (not SetTokenInformation(hNewToken, TTokenInformationClass(TokenIntegrityLevel), @TIL,
sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(pIntegritySid))) then
RaiseLastWin32Error;
//Create the new process at Low integrity
Result := CreateProcessAsUserW(
hNewToken,
nil,
PWideChar(szProcessName),
nil, //ProcessAttributes
nil, //ThreadAttributes
False, //bInheritHandles
0, //dwCreationFlags
nil, //lpEnvironment
nil, //lpCurrentDirectory
startupInfo,
ProcInfo);
finally
LocalFree(Cardinal(pIntegritySid));
end;
finally
CloseHandle(hNewToken);
end;
finally
CloseHandle(hToken);
end;
end;
我放弃将其余部分从 pascal 转码为 C#。无论如何都做不到,这就是答案。