4

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.

animuson
  • 53,861
  • 28
  • 137
  • 147
  • 1
    See http://stackoverflow.com/questions/1236460/c-using-windows-named-pipes – Ed Heal Jan 04 '12 at 06:45
  • 1
    On which operating system? If it is Windows only (as I guess), please tag the question as such. And why do you want to do that? Why can't you write your executable into a temporary executable file?? – Basile Starynkevitch Jan 04 '12 at 06:45

1 Answers1

2

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

Community
  • 1
  • 1
Software_Designer
  • 8,490
  • 3
  • 24
  • 28