Map/audio header/dictionary offsets in EXE files

Tools, assembly, and file formats.
Post Reply
User avatar
Malvineous
Posts: 113
Joined: Sat Mar 13, 2004 12:54 am
Location: Brisbane, Australia
Contact:

Map/audio header/dictionary offsets in EXE files

Post by Malvineous »

Hi all,

I wonder if I could ask for some help - I have just added a table to the ModdingWiki page for Keens 4-6, to show the locations for the map and audio headers, and the Huffman dictionaries, inside each episode's .exe file.

I need a hand populating the table with offsets, so if anyone has these handy from any tools they have written, would you mind editing the page and adding them in?

Many thanks!
User avatar
K1n9_Duk3
Posts: 13
Joined: Tue Jan 19, 2021 9:57 pm

Re: Map/audio header/dictionary offsets in EXE files

Post by K1n9_Duk3 »

Malvineous wrote: Thu Mar 11, 2021 1:28 pmI need a hand populating the table with offsets
I could do that, but I'm not sure which offsets would be the best ones to use.

Depending on which tools you use to decompress the executable, you will get slightly different files as a result. For example, UNP will not produce the same file as UNLZEXE. Decompressing the executable of Keen 6 v1.5 (EGA or CGA) with UNP will produce a file that is 400 bytes smaller than the one produced by UNLZEXE. The only difference is the size of the header data of the executable, the actual code and data in the executable (the "image") should be identical.

I have a list of offsets for UNLZEXE-decompressed executables, which are absolute offsets and will only work if the file was decompressed with UNLZEXE. You can find these offsets inside the .INI file that comes with my Keen:Galaxy level viewer. But I also have a list of offsets that are relative to the start of the "image" inside the executable file, which you can find in the .INI file that comes with my patching utility. Providing these offsets, along with a simple way of calculating the start of the "image" data inside the executable, would make the offsets independent of the decompression tool and perhaps more useful for advanced modders.

On the other hand, having absolute offsets for the most commonly used decompressor would make it easier to extract the data, since you can just use it directly without having to calculate the size of the EXE header data first.
User avatar
Malvineous
Posts: 113
Joined: Sat Mar 13, 2004 12:54 am
Location: Brisbane, Australia
Contact:

Re: Map/audio header/dictionary offsets in EXE files

Post by Malvineous »

That's a very good point! Since UNLZEXE is so widely used for Keen, I was assuming those offsets are the ones to use. A note can be added to the page to say that if UNP is used then 400 should be subtracted from each value, and another value for the raw machine code image too, that way any needed offset can be easily calculated.
User avatar
K1n9_Duk3
Posts: 13
Joined: Tue Jan 19, 2021 9:57 pm

Re: Map/audio header/dictionary offsets in EXE files

Post by K1n9_Duk3 »

The difference between files decompressed by UNP and files decompressed by UNLZEXE won't necessarily always be exactly 400 bytes, and there are other ways to mess with the EXE header size as well.

If absolute file offsets are given in that table, I would add another column to that table, giving either the size of the decompressed executable or the header size for reference. Chances are that if the file the modder is dealing with has a different size, the difference should be added to each offset to compensate for that and get the correct file position.
User avatar
Malvineous
Posts: 113
Joined: Sat Mar 13, 2004 12:54 am
Location: Brisbane, Australia
Contact:

Re: Map/audio header/dictionary offsets in EXE files

Post by Malvineous »

Many thanks for adding all the offsets!

GalaxyView also refers to a tileinfo chunk but I can't find any reference to that on the wiki pages. Is there any documentation about what that data is used for and its format?

EDIT: Of course now I see there is an entry just for this format, which I missed because I was looking on the graphics/map pages, don't mind me!
Post Reply