Windows:创建自己的杀死程序
Windows: kill program that creates itself
我偶然创建了一个程序,该程序继续自行呼叫createProcess-导致无限循环。
一旦该程序开始运行,我将如何杀死该程序?我试图通过任务管理器杀死这一点,但是由于该程序要求自己开始并立即死亡,因此它继续消失并重新出现在任务管理器中,从而使其"不可阻挡"。
停止此操作的唯一方法似乎是PC的重新启动,这可能非常不便。
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow )
{
using namespace std;
CreateProcess( L"self.exe",
NULL, // No command line arguments
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
NULL, // Set handle inheritance to NULL
NULL, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&lpStartupInfo, // Pointer to STARTUPINFO structure
&lpProcessInfo // Pointer to PROCESS_INFORMATION structure
);
return 0;
//return (int)msg.wParam;
}
从最终用户的角度来看,简单的解决方案是按 ctrl alt alt del BD>并注销。如果要使会话保持生命,则像这样的叉炸弹的唯一解决方案就是使用了解过程树的工具。taskkill /T /IM self.exe
如评论或Process Explorer中的"杀死过程树"功能。子进程可能仍然能够偷偷摸摸,因此您可能必须多次执行杀死命令。
如果我为此编程了杀戮工具,我将列举这些过程,当发现目标过程时,您打开了一个手柄,并尝试将其与作业对象相关联。工作对象允许您拒绝创建子过程,并可以轻松终止工作中的所有过程。只需致电TerminateProcess
如果无法将过程添加到作业中。
您需要在循环中运行此枚举代码,直到您杀死了所有所需的过程。
相关文章:
- 分发我自己的程序的几个问题
- C++联系人处理程序与自己的动态模板向量类
- 如何将用户代码合并到我自己的应用程序中?
- Windows:创建自己的杀死程序
- C 程序要读取包含两个双重值的Excel数据的单列,这些值由逗号分隔并存储在自己的数组中
- 预览一些自己的应用程序
- 在您自己的Qt应用程序中使用您自己的静态库
- 是否可以使程序的执行跳过 fprintf-语句/如何创建我自己的 fprintf 函数
- 从自己的程序获取程序元数据
- 我们如何让C++程序自己修复超出范围的数组索引
- 在C程序中创建我自己的std::vector
- 如何将TortoiseOverlays与我自己的处理程序一起使用
- 我从哪里开始编写自己的计算器程序
- 如何使程序能够在运行时写入自己的可执行文件
- 我该如何编写一个通过从shell运行来编译自己的c++程序
- 如何将CodeSynthesis XSD包含到自己的应用程序中
- boost.log std::异常格式化程序找不到运算符<< 自己的命名空间中的重载
- 在自己的应用程序中插入具有WebRTC支持的web框架
- 为什么我们需要写一个自己的复制程序,而我们可以使用复制shell命令
- 为什么可以'd '从管道读取比我自己的程序使用ifstream更快