Sign in to follow this  
quant

.exe inside a .exe

Recommended Posts

quant    100
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
ApochPiQ    23064
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
Nemesis2k2    1045
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this