Windows 和系统进程
注意:我已经在超级用户上以类似的格式问过这个问题,但看起来它可能更适合这里。 它肯定也与编程有关,因为它涉及 Win32 API、一般 Windows 和进程管理的部分内容。
因此,有些进程无法使用 taskkill
终止 - 一般而言是系统进程。但也有,例如我的防病毒程序,使其自身“不可终止”。
Windows下如何访问和主要终止系统进程? (微软的kill.exe不起作用)
防病毒程序等进程如何保护自身?那么,如何才能再次关闭它们呢?
Note: I've asked this question in a similiar format on superuser but it seems like it may fit here on SO better.
It definitely also is about programming as it concerns parts of the Win32 API, Windows in general and process management.
So there are these processes that can't be terminated with taskkill
- system processes in general. But there also is, for example my Anti Virus program that makes itself "unterminateable".
How can I access and mainly terminate system processes under windows? (kill.exe by Microsoft doesn't work)
How do processes like anti-virus programs protect themselves? How can you turn them off again, then?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要 API 挂钩来防止进程终止。 API 挂钩并不容易,因为它需要系统范围的 dll 注入和内存编辑或设备驱动程序。阅读本文来了解一下。
幸运的是,有现有的库,例如这个,不幸的是我认为它现在是共享软件。我还发现了这个,你可能可以在谷歌上找到更多免费软件的东西。
要回答您的第一个问题,终止系统进程相当简单。在 C# 中,使用 Process.Kill 方法您可以终止系统进程并导致蓝屏如果从 Windows 系统服务执行此操作,至少在 Windows 7 上(我通过惨痛的教训才了解到这一点...)。使用 TerminateProcess() 函数执行此操作仅当您启用某些权限时,从服务外部才能工作: http://www.codase .com/search/call?name=AdjustTokenPrivileges - 如果我没记错的话,您需要启用 SE_DEBUG_NAME。
要关闭您的防病毒软件,他们通常有一个菜单:)。要强制终止它们,您必须使用它们不挂钩的终止方法。 此页面描述了很多内容。
这是一个可以终止您想要的进程的示例,假设所使用的 API 函数没有被挂钩。 除非您知道自己在做什么,否则请勿运行此程序,因为它可能会导致蓝屏!
You will need API hooking to guard your process against termination. API hooking is not easy, as it requires either system-wide dll injection and memory editing or a device driver. Read this to get an idea.
Luckily, there are existing libraries out there, like this one, which I think is shareware now unfortunately. I also found this, and you can probably find more freeware stuff on google.
To answer your first question, terminating system processes is fairly easy. In C# using the Process.Kill method you can terminate system processes and cause a blue screen if doing it from a windows system service, at least on Windows 7 (I learned this the hard way...). Doing it using the TerminateProcess() function from outside a service will only work if you enable certain permissions: http://www.codase.com/search/call?name=AdjustTokenPrivileges - if I'm not mistaken you need to enable SE_DEBUG_NAME.
To turn off your antivirus, well, they usually have a menu for that :). To forcefully terminate them, you'll have to use a termination method that they don't hook. This page describes a lot.
Here's a sample that can terminate the processes you want, supposing the used API functions aren't hooked. DO NOT RUN THIS UNLESS YOU KNOW WHAT YOU'RE DOING AS IT CAN CAUSE A BLUE SCREEN!
如果以“正常”方式终止进程不起作用,则需要采取更极端的措施。您可以尝试提高安全级别,但这可能不起作用。
这里有两种相当暴力的方法,您可以尝试,都要求您能够成功注入目标应用程序(NT 4 上的失败率为 2%,XP 上的失败率为 5%,Vista、Windows 7 等上的失败率更高) )。
并在注入的 DLL 的 DLLMain 中执行以下操作之一:
大量有关使用 CreateRemoteThread 注入的文章
If terminating a process the "normal" way doesn't work, then more extreme measures are required. You can try elevating your security level, but that may not work.
Here are two rather brute force methods you can try, both requiring you to be able to successfully inject into the target application (2% failure rate on NT 4, 5% failure rate on XP, higher failure rate on Vista, Windows 7, etc).
You could try injecting a DLL into the application using CreateRemoteThread() and in the DLLMain for the injected DLL do one of the following:
Plenty of articles on injecting using CreateRemoteThread