[英]c++ how to run an .exe file whose contents are stored in a char array?
I'm making a specific program and i just wondered if I could do this: run a file whose contents are stored in a char array ON WINDOWS. 我正在制作一个特定的程序,我只是想知道是否可以这样做:运行一个文件,其内容存储在WINDOWS上的char数组中。
this is the code that reads the executable and stores it in a char array: 这是读取可执行文件并将其存储在char数组中的代码:
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();
I heard something about RunPE and I did some searching, I haven't succeeded in finding any piece of C++ code to use. 我听到了有关RunPE的一些信息,并进行了一些搜索,但未能成功找到要使用的任何C ++代码。
This shows how to Load an EXE File and Run It from Memory : http://www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx 这显示了如何加载EXE文件并从内存运行它: http : //www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx
Additional readings here : CreateProcess from memory buffer and here : How to run unmanaged executable from memory rather than disc 这里的其他阅读: 来自内存缓冲区的CreateProcess和这里: 如何从内存而不是光盘运行不受管的可执行文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.