Jump to content
  • Advertisement
Sign in to follow this  
quant

.exe inside a .exe

This topic is 5100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to store a .exe withing a .exe, similar to how resource files work, but with executable code. How would i run the code?

Share this post


Link to post
Share on other sites
Advertisement
It's possible, and just a little bit tricky. You can basically stick anything you want on the end of an EXE file if you do it right. I usually pad the first EXE with null characters (byte 0) until the file is an even multiple of 24KB. After the padding I add the second EXE. In the first EXE's code, I will know how many multiples of 24KB the padding is, so I can hardcode the starting position of the second EXE and extract the file with normal file I/O routines.

The easiest way to run the code would be to extract the second EXE into a temporary file, and run that will ShellExecute(). When it's done you can just delete the temp file.

Share this post


Link to post
Share on other sites
Well, you could store an exe as a resource, which you could then extract and execute (you would have to actually write it back to a file). The exe would just be a standalone program though, not part of your program.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!