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

余生颓废 提交于 2019-12-21 05:28:05

问题


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.

this is the code that reads the executable and stores it in a char array:

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.


回答1:


This shows how to Load an EXE File and Run It from Memory : 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



来源:https://stackoverflow.com/questions/8723039/c-how-to-run-an-exe-file-whose-contents-are-stored-in-a-char-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!