c++如何运行一个内容存储在char数组中的.exe文件

c++ how to run an .exe file whose contents are stored in a char array?

本文关键字:数组 char 存储 文件 exe 一个 何运行 运行 c++      更新时间:2023-10-16

我正在制作一个特定的程序,我只是想知道我是否可以做到这一点:在WINDOWS上运行其内容存储在字符数组中的文件。

这是读取可执行文件并将其存储在字符数组中的代码:

filetoopen.open (C:blahlbah.exe, ios::binary);
filetoopen.seekg (0, ios::end);
length = filetoopen.tellg();
filetoopen.seekg (0, ios::beg);
buffer = new char [length];
filetoopen.read (buffer, length);
filetoopen.close();

我听说了一些关于RunPE的东西,我做了一些搜索,我还没有成功地找到任何可以使用的C++代码。

这显示了如何加载EXE文件并从内存运行它:http://www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx

此处的其他阅读内容:从内存缓冲区创建进程,此处:如何从内存而不是光盘运行非托管可执行文件