rofl0r / agsutils

contains utils for AGS: game extractor, repacker, disassembler and assembler
44 stars 14 forks source link

restoring exe stub after repack #16

Closed kennyfortune closed 3 years ago

kennyfortune commented 3 years ago

After packing ,i try to run the game and an Microsoft error message shows that it cannt run because of Version mismatch and contact the author

Readme mentions that the new "exe" will miss the original windows exe stub, but is compatible with the opensource AGS engine, as well as with scummvm ags port. that way, a game is about 500 KB smaller after extract and repack as it originally was.

It is the reason why it cannt run correctly after packing? How can i make it correctly?

rofl0r commented 3 years ago

the directory you specified when unpacking contains a file called agspack.exestub which contains the exe that was prepended to the original game data.

so, assuming that you packed the modified data into a file called game.ags you can make the game redistributable using the command cat agspack.exestub game.ags > newgame.exe in a shell (either linux shell or cygwin shell).

the packer currently doesn't restore the exe stub automatically because the game.ags file can be loaded just fine into any standalone AGS engine version (and that's the only way to play the game on linux anyway, unless you use wine, so auto-prepending the stub would just make the game file larger without any benefit). i'll look into adding an option that restores the exe stub automatically.

rofl0r commented 3 years ago

actually i was wrong about being able to just cat the stub and the data into a combined file; as AGS tries to locate the start of the data via an "end signature" containing the offset, rather than just searching for the start signature, so doing it manually as i suggested would involve using a hex editor to change the offset 16 bytes before the end as a 4 byte little endian value to contain the size of the .exestub file. since this is impractical for casual users, i now added the -e option to agspack which does everything automatically.