C ++如何运行其内容存储在char数组中的.exe文件? [英] c++ how to run an .exe file whose contents are stored in a char array?

查看:60
本文介绍了C ++如何运行其内容存储在char数组中的.exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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();

我听说过有关RunPE的一些知识,并且进行了一些搜索,但未能成功找到

I heard something about RunPE and I did some searching, I haven't succeeded in finding any piece of C++ code to use.

推荐答案

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

This shows how to Load an EXE File and Run It from Memory : http://www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx

此处还有其他内容:来自内存缓冲区的CreateProcess 和此处:如何从内存而非光盘运行非托管可执行文件

Additional readings here : CreateProcess from memory buffer and here : How to run unmanaged executable from memory rather than disc

这篇关于C ++如何运行其内容存储在char数组中的.exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆