Documentation ¶
Overview ¶
Package info defines binary structures and constants used by the MPQ format
Index ¶
- Constants
- Variables
- func ReadBlockTableEntry(reader io.Reader, block_table_entry *BlockTableEntry) error
- func ReadHashTableEntry(reader io.Reader, hash_table_entry *HashTableEntry) error
- func ReadHeader(reader io.Reader, header *Header) (err error)
- func ReadUserData(reader io.Reader, user_data *UserData) (err error)
- type BlockTableEntry
- type FileFlag
- type HashTableEntry
- type Header
- type Header0
- type Header1
- type Header2
- type Header3
- type UserData
- type UserDataPrefix
Constants ¶
View Source
const ( HashTableIndex = 0x000 HashNameA = 0x100 HashNameB = 0x200 HashFileKey = 0x300 HashKey2Mix = 0x400 )
View Source
const ( HashTerminator uint32 = 0xFFFFFFFF HashRemoved uint32 = 0xFFFFFFFE )
Special block indices
View Source
const BlockTableEntrySize = 16
View Source
const HashTableEntrySize = 16
The bytes needed to store a HashTableEntry in binary format
View Source
const MaxHeaderSize = 0x17FF
View Source
const MaxUserDataSize = 0x17FF
Variables ¶
View Source
var ( UserDataSignature = []byte("MPQ\x1B") HeaderDataSignature = []byte("MPQ\x1A") )
Functions ¶
func ReadBlockTableEntry ¶
func ReadBlockTableEntry(reader io.Reader, block_table_entry *BlockTableEntry) error
Read a BlockTableEntry from a Reader in binary
func ReadHashTableEntry ¶
func ReadHashTableEntry(reader io.Reader, hash_table_entry *HashTableEntry) error
Read a HashTableEntry from a Reader in binary
Types ¶
type BlockTableEntry ¶
type BlockTableEntry struct { // Offset of the beginning of the file, relative to the beginning of the archive. FilePos uint32 // Compressed file size CompressedSize uint32 // Only valid if the block is a file; otherwise meaningless, and should be 0. // If the file is compressed, this is the size of the uncompressed file data. DecompressedSize uint32 // Flags for the file Flag FileFlag }
type FileFlag ¶
type FileFlag uint32
const ( FileImplode FileFlag = 0x00000100 // Implode method (By PKWARE Data Compression Library) FileCompress FileFlag = 0x00000200 // Compress methods (By multiple methods) FileEncrypted FileFlag = 0x00010000 // Indicates an encrypted file FileKey_v2 FileFlag = 0x00020000 // Indicates an encrypted file with key v2 FilePatchFile FileFlag = 0x00100000 // The file is a patch file. Raw file data begin with TPatchInfo structure FileSingleUnit FileFlag = 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) FileDeleteMarker FileFlag = 0x02000000 // File is a deletion marker. Used in MPQ patches, indicating that the file no longer exists. FileSectorCRC FileFlag = 0x04000000 // File has checksums for each sector. Ignored if file is not compressed or imploded. FileSignature FileFlag = 0x10000000 // Present on STANDARD.SNP\(signature). The only occurence ever observed FileExists FileFlag = 0x80000000 // Set if file exists, reset when the file was deleted FileCompressMask FileFlag = 0x0000FF00 // Mask for a file being compressed FileFixKey FileFlag = 0x00020000 // Obsolete, do not use )
type HashTableEntry ¶
type HashTableEntry struct { // The hash of the file path, using method A. Name1 uint32 // The hash of the file path, using method B. Name2 uint32 // The language of the file. This is a Windows LANGID data type, and uses the same values. // 0 indicates the default language (American English), or that the file is language-neutral. Locale uint16 // The platform the file is used for. 0 indicates the default platform. // No other values have been observed. Platform uint8 Reserved uint8 // If the hash table entry is valid, this is the index into the block table of the file. // Otherwise, one of the following two values: // - FFFFFFFFh: Hash table entry is empty, and has always been empty. // Terminates searches for a given file. // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). // Does not terminate searches for a given file. BlockIndex uint32 }
type Header0 ¶
type Header0 struct { // Size of MPQ archive // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive // is calculated as the size from the beginning of the archive to the end of the hash table, // block table, or extended block table (whichever is largest). ArchiveSize uint32 // 0 = Format 1 (up to The Burning Crusade) // 1 = Format 2 (The Burning Crusade and newer) // 2 = Format 3 (WoW - Cataclysm beta or newer) // 3 = Format 4 (WoW - Cataclysm beta or newer) Version uint16 // Power of two exponent specifying the number of 512-byte disk sectors in each logical sector // in the archive. The size of each logical sector in the archive is 512 * 2^wBlockSize. SectorSize uint16 // Offset to the beginning of the hash table, relative to the beginning of the archive. HashTablePos uint32 // Offset to the beginning of the block table, relative to the beginning of the archive. BlockTablePos uint32 // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. HashTableSize uint32 // Number of entries in the block table BlockTableSize uint32 }
type Header3 ¶
type Header3 struct { // Compressed size of the hash table HashTableSize64 uint64 // Compressed size of the block table BlockTableSize64 uint64 // Compressed size of the hi-block table HiBlockTableSize64 uint64 // Compressed size of the HET block HetTableSize64 uint64 // Compressed size of the BET block BetTableSize64 uint64 // Size of raw data chunk to calculate MD5. // MD5 of each data chunk follows the raw file data. RawChunkSize uint32 // Array of MD5's // MD5 of the block table before decryption MD5_BlockTable [md5.Size]byte // MD5 of the hash table before decryption MD5_HashTable [md5.Size]byte // MD5 of the hi-block table MD5_HiBlockTable [md5.Size]byte // MD5 of the BET table before decryption MD5_BetTable [md5.Size]byte // MD5 of the HET table before decryption MD5_HetTable [md5.Size]byte // MD5 of the MPQ header from signature to (including) MD5_HetTable MD5_MpqHeader [md5.Size]byte }
type UserData ¶
type UserData struct {
UserDataPrefix
}
type UserDataPrefix ¶
Click to show internal directories.
Click to hide internal directories.