Top > Programming > Master of Orion 2 > .lbx File Format
Offset | Length | Contents |
---|---|---|
0x00 | 2 | Number of files in archive (n). Little-endian. |
0x02 | 4 | Signature. Always equal to AD FE 00 00. |
0x06 | 2 | "Version". Equal to 00 00 for all MOO2 files and most MOO1 and MOM files |
0x08 | 4 | Offset of first file in archive (off1). |
0x0C | 4 | End of first file / start of next file (off2). Repeated n times. |
off1 | off2-off1 | First file. This pattern is repeated n times. |
The majority of the data for Master of Orion 2 is stored in .lbx files. These files are very simple archives. They do not store the names of the files they contain, nor a directory structure, nor any other metadata about the file (except for its size, and even that is done indirectly). Basically, an .lbx file is a small header (generally less than 2kB) header containing the offsets of files within, followed by a simple concatenation of files.
The first two bytes of the .lbx file say how many files are in this archive. Remember that everything is little endian: first the low-order byte, followed by higher-order bytes. So, for example, the file TECHNAME.LBX starts with the bytes 06 00, which means there are 0 * 256^1 + 6 * 256^0 = 6 files.
The next four bytes are, I believe, a sort of signiture or id that says "this is an LBX archive": AD FE 00 00. Following that is a pair of bytes that I'm going to designate the version. All the files in MOO2 are version 0 (00 00), but a few of the MOO1 files have other versions (for example, DIPLOMAT.LBX is version 5 (05 00)).
Starting at byte 9, there is a list of 4-byte offsets. Each offset except the last is the start of a file, and each offset except the first is the end of the previous file. The space between the last offset (there are filecount + 1 offsets total) and the beginning of the first file is free territory. In most files it's filled with zeros, but with a few files (RACENAME.LBX and RACES.LBX, for example) there's some garbage in there.
Ok, now for a sample. The following is exerpted from TECHNAME.LBX.
00 00: | 06 00 AD FE 00 00 00 00 | 00 08 00 00 9D 29 00 00 | File count Sig Version | Offset 1 Offset 2 |
00 10: | CE 4D 00 00 9D 76 00 00 | AC 9D 00 00 B6 C2 00 00 | Offset 3 Offset 4 | Offset 5 Offset 6 |
00 20: | 53 E4 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | Offset EOF Filler | Filler |
... | ||||
08 00: | 53 74 61 72 74 69 6E 67 | 20 54 65 63 68 00 41 64 | Start of first file | |
... | ||||
29 90: | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 41 75 73 | End of first file | Start of second file |
Hopefully that's a little bit clearer now. It often helps to see it in action, so to speak.
I wrote a small program to help me figure out the format, and as a tool to work with .lbx files. It now supports extracting files, either one or many. The sourcecode and compiled executable are available below.
This program takes an archive filename and reports how many files it contains.
Filename | Size | Description | |
---|---|---|---|
![]() |
lbx.source.zip | 4.22k | C++ source |
![]() |
lbx.bin.zip | 81.6k | Compiled program for Win32 platforms |
If you have any information on this (corrections or additional details), or suggestions for or problems with the program, please let me know.