Prevent user process from being killed with quot;End Processquot; from Process Explorer(防止用户进程被“结束进程杀死来自进程浏览器)
问题描述
我注意到 GoogleToolbarNotifier.exe 无法从 Process Explorer 中删除.它返回拒绝访问".它以用户身份运行,运行正常"优先级,并从程序文件运行.
I noticed that GoogleToolbarNotifier.exe cannot be killed from Process Explorer. It returns "Access Denied". It runs as the user, it runs "Normal" priority, and it runs from Program Files.
他们是怎么做到的?
我认为可能有一种方法可以修改 ACL,或者将进程标记为关键",但我似乎找不到任何东西.
I think there might be a way to modify the ACL, or mark the process as 'critical', but I cannot seem to locate anything.
更新:
我通过一些挖掘找到了答案.@Alex K. 是正确的,因为该过程删除了 PROCESS_TERMINATE 权限,但我想在代码中提供答案:
I found the answer with a good bit of digging. @Alex K. was correct in that PROCESS_TERMINATE permission was removed for the process, but I wanted to supply the answer in code:
static const bool ProtectProcess()
{
HANDLE hProcess = GetCurrentProcess();
EXPLICIT_ACCESS denyAccess = {0};
DWORD dwAccessPermissions = GENERIC_WRITE|PROCESS_ALL_ACCESS|WRITE_DAC|DELETE|WRITE_OWNER|READ_CONTROL;
BuildExplicitAccessWithName( &denyAccess, _T("CURRENT_USER"), dwAccessPermissions, DENY_ACCESS, NO_INHERITANCE );
PACL pTempDacl = NULL;
DWORD dwErr = 0;
dwErr = SetEntriesInAcl( 1, &denyAccess, NULL, &pTempDacl );
// check dwErr...
dwErr = SetSecurityInfo( hProcess, SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pTempDacl, NULL );
// check dwErr...
LocalFree( pTempDacl );
CloseHandle( hProcess );
return dwErr == ERROR_SUCCESS;
}
推荐答案
当运行我的副本时,在 Terminate 权限上设置了 Deny(进程资源管理器显示了这一点).
When running my copy of that has Deny set on the Terminate permission (Process Explorer shows this).
大概他们调用 SetKernelObjectSecurity 在进程加载时更改/删除 ACL.
Presumably they call SetKernelObjectSecurity to change/remove the ACLs when their process loads.
这篇关于防止用户进程被“结束进程"杀死来自进程浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:防止用户进程被“结束进程"杀死来自进程浏览器
基础教程推荐
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
