How can I run an executable from RAM using C++?
The executable is in RAM, and I know the address, how do I call into the program from mine?
Do you mean that you have loaded the contents of the EXE file into RAM and now want to run that executable?
Since you're talking about an EXE, I assume you're running under Windows. To my knowledge, Windows can't do this -- your only option is to save the executable back to a file and run that (using CreateProcess
, for example).
Edit Here is how you would run the process.
In C++:
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
if(!CreateProcess("myfilename.exe", NULL, NULL, NULL, FALSE, 0, NULL,
NULL, &si, &pi ))
{
// An error occurred
}
In C#:
using System;
using System.Diagnostics;
Process.Start("myfilename.exe");