简体   繁体   English

在资源文件夹中执行文件,而不将其复制到磁盘

[英]Execute file in resourses folder without copying it to disk

I have an executable file in the resources folder. 我在资源文件夹中有一个可执行文件。 I am able to run that file by writing it to the disk then locating the file and use the Process.Start method to run the executable. 我可以通过将文件写入磁盘然后找到该文件并使用Process.Start方法运行可执行文件来运行该文件。 Here is an example of how I do this: 这是我如何执行此操作的示例:

在此处输入图片说明

How can I execute the file without writing it to the disk. 我如何执行文件而不将其写入磁盘。 Is there a way I can execute the file from memory? 有没有办法可以从内存中执行文件? Or maybe execute it directly from the resources folder? 还是直接从资源文件夹执行它?

You can't. 你不能 One of the very hard requirements of Windows, an executable must exist on disk. Windows的非常严格的要求之一是,可执行文件必须存在于磁盘上。 It is fundamental to its architecture. 它是其体系结构的基础。 Slowing down the malware authors is a happy side-effect. 放慢恶意软件作者的速度是一个快乐的副作用。 Google "memory mapped file" if you want to learn more about it. 如果您想了解更多关于Google的“内存映射文件”。

If it's a .NET exe try Assembly.Load(byte[]) . 如果是.NET exe,请尝试Assembly.Load(byte[]) Be wary of CAS though. 不过要警惕CAS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM