KoA: Reckoning BIG File Format

Information and research into the KoA: Reckoning game files and main game executable.
Post Reply
User avatar
atom0s
Site Admin
Posts: 33
Joined: Sun Apr 08, 2018 2:54 pm
Location: 127.0.0.1
Contact:

KoA: Reckoning BIG File Format

Post by atom0s » Thu Apr 12, 2018 8:18 pm

  1. /*
  2. ----------------------------------------------------------------------------------------------------
  3. Kingdoms of Amalur: Reckoning - BIG File Format
  4. Research Paper by atom0s [atom0s@live.com]
  5. Version: 1.0.0
  6. ----------------------------------------------------------------------------------------------------
  7.  
  8.     Please note - this file type is stored in a binary stream format.
  9.  
  10.     You cannot directly cast to the below structures, they are just in structures for ease of reading.
  11.     Some entries are not valid for certain things, such as specific versions of the file!
  12.     Please read the notes carefully!
  13.  
  14.     This data is based on the following game executable:
  15.     Reckoning.exe - Steam Version - v1.0.0.2 (1.0.0.1)
  16.         - CRC32 : DC256122
  17.         - MD5   : 9863F5D6754DAC28CBB96808015E2089
  18.         - SHA1  : 91CC28B28AE6E4926A89DF5EAD8DB2B7D974AE46
  19.    
  20. */
  21.  
  22. /*
  23. ----------------------------------------------------------------------------------------------------
  24. File Header
  25. ----------------------------------------------------------------------------------------------------
  26. */
  27.  
  28. /**
  29.  * Signature
  30.  *      The BIG file signature. Expected value: 0xC2C8C780
  31.  *      This value also determines the endianness of the file depending on how its stored.
  32.  *
  33.  * Version
  34.  *      The BIG file version. Expected value: 0x10 or 0x11
  35.  *      This value determines the tool version the file was made with.
  36.  *      The game will error on the file if this is not 0x10 or 0x11.
  37.  *
  38.  * Unknown0000
  39.  *      Unknown value.
  40.  *      The game will error on the file if this is equal to 0x00.
  41.  *
  42.  * BuildStringLength
  43.  * BuildString
  44.  *      The BIG build too version string length and string.
  45.  *      The build length determines the size of the BuildString buffer size.
  46.  *      Warning: String IS NOT null terminated!
  47.  *
  48.  * Unknown0001
  49.  *      Unknown value.
  50.  *      This value is only read if the header version is 0x10 or greater.
  51.  *      The game does not seem to use this value currently.
  52.  *
  53.  * FileCount
  54.  *      The count of files stored within the BIG file.
  55.  *      The game will error on the file if this is greater than 0x10000.
  56.  *
  57.  *--------------------------------------------------------------------------------------------------
  58.  * Related Functions
  59.  *--------------------------------------------------------------------------------------------------
  60.  * sub_A21010 - Function used to read BIG files.
  61.  * sub_A292B0 - Function used to read data from the file.
  62.  * sub_401BA0 - Function used to read a string from the file.
  63.  *--------------------------------------------------------------------------------------------------
  64.  */
  65. struct BIGFileHeader
  66. {
  67.     uint32_t    Signature;
  68.     uint32_t    Version;
  69.     uint8_t     Unknown0000;
  70.     uint32_t    BuildStringLength;
  71.     uint8_t     BuildString[];
  72.     uint32_t    Unknown0001;
  73.     uint32_t    FileCount;
  74. };
  75.  
  76. /*
  77. ----------------------------------------------------------------------------------------------------
  78. File Entry
  79. ----------------------------------------------------------------------------------------------------
  80. */
  81.  
  82. /**
  83.  * UncompressedSize
  84.  *      The uncompressed file size.
  85.  *
  86.  * CompressedSize
  87.  *      The compressed file size.
  88.  *
  89.  * Offset
  90.  *      The offset to where the file data starts.
  91.  *
  92.  * NameHash
  93.  *      The hash of the file name.
  94.  *
  95.  * Id
  96.  *      Unknown, does not look to be an id, but instead a file type.
  97.  */
  98. struct BIGFileEntry
  99. {
  100.     uint32_t    UncompressedSize;
  101.     uint32_t    CompressedSize;
  102.     uint32_t    Offset;
  103.     uint32_t    NameHash;
  104.     uint32_t    Id;
  105. };
  106.  
  107. /*
  108. ----------------------------------------------------------------------------------------------------
  109. File Name String Table
  110. ----------------------------------------------------------------------------------------------------
  111.  
  112.     The first entry in a BIG file is the string table holding the file names. This table is generally
  113.     not compressed and is, from what I've seen, always the first file entry.
  114.    
  115.     To locate the file entry that is this string table, first dump all the file entries then find the
  116.     one that has the name hash value of 0xFFFFFFFF. Once found, you can use that entries Offset to go
  117.     to the string table data entry.
  118. */
  119.  
  120. /**
  121.  * StringCount1
  122.  *      The count of strings within the string table.
  123.  *
  124.  * StringCount2
  125.  *      The count of strings within the string table. (Repeat)
  126.  *
  127.  * Unknown0000
  128.  *      Unknown value. Should always equal 0xFFFF.
  129.  *
  130.  * Unknown0001
  131.  *      Unknown value. Should always equal 0x00.
  132.  *
  133.  * StringLength
  134.  * String
  135.  *      String entries that are read like the build string. The length is first, then the string.
  136.  *      This is an array of strings equal to the StringCount1 value.
  137.  *      Warning: String IS NOT null terminated!
  138.  */
  139. struct BIGFileNameStringTable
  140. {
  141.     uint32_t    StringCount1;
  142.     uint32_t    StringCount2;
  143.     uint16_t    Unknown0000;
  144.     uint8_t     Unknown0001;
  145.    
  146.     uint32_t    StringLength;
  147.     uint8_t     String[];
  148. };
  149.  
  150. /*
  151. ----------------------------------------------------------------------------------------------------
  152. File Data
  153. ----------------------------------------------------------------------------------------------------
  154.  
  155.     Other than the file name string table, every other file is read in the same manner.
  156.     Files can either be in their raw format, or compressed using a simple Zlib stream.
  157.    
  158.     If a file entry is not compressed, than the BIGFileEntry 'UncompressedSize' and
  159.     'CompressedSize' will match. In this case, you can then just go to the files Offset
  160.     and dump the UncompressedSize of data for the files data.
  161.    
  162.     If the 'UncompressedSize' and 'CompressedSize' do not match, this means the file is
  163.     compressed using a Zlib stream.
  164.    
  165.     Compressed files are stored in blocks. The blocks are formatted as in the below struct.
  166.    
  167.     Warning: Because the data offers an output file offset, this means that blocks can be stored
  168.     out of order as a means to attempt to prevent reversing or similar. It is important to write
  169.     the data out in the proper order so that the output file is not corrupted.
  170.    
  171.     Blocks are not required to be compressed either. For example, a file can have 4 blocks of data,
  172.     of those 4 blocks, 1 could be uncompressed and the other 3 are compressed. To check for this,
  173.     simply compare the BlockUncompressedSize to BlockCompressedSize. If they are equal, the data is
  174.     not compressed, otherwise it is.
  175. */
  176.  
  177. /**
  178.  * BlockSize
  179.  *      The size of the current block of data.
  180.  *
  181.  * BlockOffset
  182.  *      The offset in the output file of where this block is stored.
  183.  *      (Blocks can be stored out of order because of this!)
  184.  *
  185.  * BlockUncompressedSize
  186.  *      The uncompressed size of the current block.
  187.  *
  188.  * BlockCompressedSize
  189.  *      The compressed size of the current block.
  190.  */
  191. struct CompressedDataBlock
  192. {
  193.     uint32_t BlockSize;
  194.     uint32_t BlockOffset;
  195.     uint32_t BlockUncompressedSize;
  196.     uint32_t BlockCompressedSize;
  197. };
Site Owner

Want to donate to say thanks? Donate via Paypal
https://www.paypal.me/atom0s
Post Reply