如何删除正在运行的exe。 [英] How to delete running exe.

查看:339
本文介绍了如何删除正在运行的exe。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,每个人

我知道exe文件被复制到内存中并执行,如果我运行exe文件。

但为什么我不能删除exe文件?



任何人都可以解释一下吗?

Hi, everybody
I know exe file is copied into memory and is executed, if I run exe file.
But why can't I delete an exe file?

Can anyone please explain me?

推荐答案

删除内存中加载的任何文件都是不可能的执行。删除它的唯一方法是终止使用该文件的进程,例如,使用 TerminateProcess

https://msdn.microsoft.com/en-us/library/windows/desktop/ ms686714%28v = vs.85%29.aspx [ ^ ]。



但要注意:如果您需要删除此类文件,这是某种滥用的非常明确的迹象。如果您确实需要删除某个应用程序使用的可执行模块的文件而无法执行此操作,则表示该应用程序存在一些您必须修复的错误。或者应用程序不是设计为在那时终止,因此您不应删除它使用的任何文件。等等...







顺便说一句,您对EXE如何工作的理解是错误:exe文件被复制到内存中并被执行。如果您这样做,则无法根据应用程序代码启动该过程。应用程序加载由软件的重要部分 loader 完成,它可以完成许多复杂的工作。其中一个重要的部分是:在保护模式下基于x86架构的系统,由于基于硬件的执行,你根本不能在应用程序模式下执行任何加载到内存中的代码片段预防的;准备一段代码存储器是外部中不允许的内核模式操作之一。



-SA
It is impossible to delete any file loaded in memory for execution. The only way to delete it is to kill the process which uses the file, say, with TerminateProcess:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686714%28v=vs.85%29.aspx[^].

But beware: if you have a need to delete such file, it's a pretty certain indication of some kind of misuse. If you really have a need to delete a file which is an executable module used by some application and cannot do it, it means that the application has some bugs which you have to fix. Or the application is not designed to be terminated at that moment, so you should not delete any file it uses. And so on…



By the way, your understanding of how EXE works is wrong: "exe file is copied into memory and is executed". If you did it, you could not start the process based on the application code. Application is loaded by an important part of software, the loader, which does a number of sophisticated things. One important part of it is: on systems based on x86 architecture in protected mode, you cannot execute any piece of code loaded in memory in the application mode at all, due to hardware-based execution prevention; preparation of the piece of code memory is one of the kernel-mode operations not allowed in the outer ring.

—SA


这篇关于如何删除正在运行的exe。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆