我正在制作一个特定的程序,我只是想知道我是否可以这样做: 在 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
此处的其他阅读 Material :CreateProcess from memory buffer这里:How to run unmanaged executable from memory rather than disc
关于c++如何运行其内容存储在char数组中的.exe文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8723039/