See what's going on with flipcode!




 

Data Stored In Executables
Question submitted by (22 December 1999)




Return to The Archives
 
  How does Future Crew, just like any demo group and game programmers embed data into exe, making the only thing your run is an .exe. How they put music and graphic into exe.

Okay , you can put *.bmp into exe using resources within Visual C++ 6.0 But how about *.mod files or *.st3 files? And how to use it with procedure that requires a filename such as LoadSong(CString szfilename) Does FILE is a handle to array of byte?
 
 

 
  They don't actually embed the data into the EXE. Instead, they tack it onto the end. Like this:
copy /b demo.exe + mydata.dat elegance.exe
If you want to store more than one file, you'll probably want to create a filesystem in a file (like Doom's WAD files, for example) and concatenate that onto the end of the EXE. By doing this, you don't disturb the EXE itself. It will run fine ignoring the data at the end.

There's just one missing piece of information here. You need to know where the EXE ends and your data begins. For this, I simply added the size of the data file at the end of the new EXE.

Once the program was running, I would read the last four bytes in the EXE file, rewind the file pointer by that many bytes and began reading the data.



Response provided by Paul Nettle
 
 

This article was originally an entry in flipCode's Fountain of Knowledge, an open Question and Answer column that no longer exists.


 

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.