Quake 2 PAK Format ___________________ Thanks and kudos to Pete McCormick (petra@force.net), who like me takes no responsibility for problems caused by use of this information. The format of PAK files is such. The first 12 bytes of the files are the header. This is seperated into three, 4 byte blocks as follows: -Header- - Signature (4 bytes of char, equals 'PACK' in ALL cases. If it doesn't then it is not considered a pack file.) - Directory Offset (4 bytes, single integer. Specifies the position of the first of X Directory areas in the file.) - Directory Length (4 bytes, single integer. Specifies the length of the X dirextory areas.) (Note: We can find the number X by dividing the length by the 64, because each directory section is 64 bytes. If the mod of this division is not zero then we have a corruption.) -Directory section- - File name (56 bytes of char, specifies the name of the file pointed to by the File Position data. Includes path info. ie maps/base1.bsp) - File Position (4 bytes, single integer. The first byte(address) of the file named by File Name) - File Length (4 bytes, single integer. The length of the file named by File Name) Notes: Normally, the header is at the start of the file and the X number of directory areas at the very end. The file data is usually in between. Schematically(view in a non proportional font or it will look a little odd) : ________________________________ HEADER starts here ---> | - Signature (4 bytes) | | - Directory Offset (4 bytes) | | - Directory Length (4 bytes) | |________________________________| FILE DATA starts here ---> | | | | | BINARY DATA | | (pointed to by the | | File Position data) | | | ~~~~~ ~~~~~ ~~~~~ ~~~~~ | | | | | | | | |________________________________| DIRECTORY SECTION starts here ---> | - File name (56 bytes) | | - File Position (4 bytes) | | - File Length (4 bytes) | |________________________________| | - File name (56 bytes) | | - File Position (4 bytes) | | - File Length (4 bytes) | |________________________________| | | ~~~~~ ~~~~~ ~~~~~ ~~~~~ |________________________________| | - File name (56 bytes) | | - File Position (4 bytes) | | - File Length (4 bytes) | |________________________________| Albie Cunningham (albert.cunningham@osi.varian.com)