Store exe in memory and run it.

How can I store a file or exe in memory and then run it?
The normal process of starting a process is via CreateProcess(), which will read the executable file for you and then, well, execute it.

But if you are looking for a way to get things done the hard way, I guess you can read the executable into memory, then examine the contents according to the PE (portable executable) file format, find the main entry point and run it. But before you can run it you need to use VirtualProtect() to grant execution rights to the memory.

But of course that's only what I think it would work. I actually don't know if it DOES work. My guess is it won't work anyway, but you are welcome to try. Who knows (I don't because I have never even tried it).
Compile the executable with /SWAPCD switch and windows loader will do exactly that for you: load the file into memory and then run it (you could delete the file while it is running). No need to be bothered how this is done.
Topic archived. No new replies allowed.