Packing into an EXE file

This is a discussion on Packing into an EXE file within the C++ Programming forums, part of the General Programming Boards category; I am creating an engine. It is going good for now. I have an editor. It creates the files. What ...

  1. #1
    Unregistered
    Guest

    Packing into an EXE file

    I am creating an engine. It is going good for now. I have an editor. It creates the files. What I want to do now is pack the files into the interpreter.exe. Interpreter.exe will then load and run the files from within itself.

    How can I do that?

    Basically the question really is: How can I compile my files into a single EXE file?

    Joey

  2. #2
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    You mean like:
    Start program1
    go into program2
    return to program1

  3. #3
    Unregistered
    Guest

    re

    OK. What I mean is, I am making an adventure game engine. It can do a lot of stuff already.

    The engine saves everything to seperate resource files. I now also have an interpreter which will read the resource files and run the game you made.

    What I want to know is how to get the files and put them into the interpreter.exe file and have the program run the files from within itself.

    Basically this is so that instead of distributing a game that has all these files:
    room1.rom
    char.chr
    inventory.inv
    game.exe

    the file will only be:
    game.exe

    Best example of this would be to check out: www.adventuregamestudio.co.uk

    Joey

  4. #4
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Well, I don't know how to do that buyt why not just keep them separate and load them?

  5. #5
    Unregistered
    Guest

    re

    I would just want to offer that option becouse people on my website and other adventure game websites always ask if they can pack everything into one EXE file. It has been done before, so I would love to be able to do it myself.

    Joey

  6. #6
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    The best advic I can give you is to make the files hidden, no, wait, even better, google.com

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    For Windows - Its not difficult......pack in the files as custom resources....extract them at runtime to a temp directory......run them with CreateProcess()

    Look at my post - here

    You might want to find a compression algorithm too though.....otherwise the exe will be quite big

  8. #8
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812

    An Alternative to Custom Resource

    Here's an alternative to using a custom resource. I know it works in windows, and I think it should work generally. But please comment.

    The reason why I developed this idea is because the data I want to pack with my exe is potentially large (i.e. 100's of MBs) and I don't want the machine trying to load all that into memory at once. In fact, my loader problem only loads small sections (blocks of data) from such a file at any one time, and that's how I would want it to work even if it is packed with the exe.

    Here's what I do. I write a program to append a data file to an exe file. At the end of file, I place an ID magic number and the position of where the exe ends and the data starts. I.e. my appended exe file looks like this:

    [app exe][data file][start of data (int)][magic num (int)]

    When the exe is lauched, it looks at the end of its own file for the magic number. If it finds it, then the integer before specifies the start position of the data, which the program seeks to and begins reading.

    When I first tried out this idea, my concern was that the whole file data would be loaded in to memory when the exe is launched. However, this seems NOT to be the case and the program runs as normal. Which is what I want obviously, so it seems to work very well.

    However, it is true that I don't understand the format of the exe binary, so am not sure why this works as it does. Can anyone enlighten me?
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  9. #9
    D3T
    D3T is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    12
    So sort of like quake 3... where the engine extracts all teh .pk3 files and uses tem to run the game... so u can 'simply' make mods by changing the resource (in this case pk3) files?
    [D3T]
    Borland Turbo C++ 3.0 For Dos

    *
    do { war(); } while (nations == hostile);

    ... The best way to prevent wars is to have them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21