FastFiles and Zone files (AW): Difference between revisions

From COD Engine Research
Therifboy (talk | contribs)
No edit summary
Line 4: Line 4:
== FastFile Structure ==
== FastFile Structure ==
<source lang="cpp">
<source lang="cpp">
enum compress_type_t
enum DB_CompressorType
{
{
   zlib = 1,
   DB_COMPRESSOR_INVALID = 0xFFFFFFFF,
   lzx = 2
   DB_COMPRESSOR_ZLIB = 0x1,
  DB_COMPRESSOR_LZX = 0x2,
  DB_COMPRESSOR_PASSTHROUGH = 0x3,
};
};
   
   
struct Entry
struct GfxImageStreamData
{
{
   int unknown[3];
   int unknown[3];
};
};


//Entry point for the FF.
struct FF_Header
struct DB_Header
{
{
   char magic[8]; // S1ff0100
   char magic[8]; // S1ff0100
   int version;
   int version;
   bool allowOnlineUpdate;
   bool compress;
   compress_type_t compressionType;
   compress_type_t compressType;
   char unknown1;
   char sizeOfPointer;
   char unknown2;
   char sizeOfLong;
   int unknown3;
   int fileTimeHigh;
   int unknown4;
   int fileTimeLow;
   int entryCount;
   int imageCount;
   Entry entries[];
   GfxImageStreamData imageData[imageCount];
   int fileSize;
   int baseFileLen;
   int maxFileSize;
   int totalFileLen;
};
};
</source>
</source>

Revision as of 07:31, 22 December 2014


FastFile Structure

enum DB_CompressorType
{
  DB_COMPRESSOR_INVALID = 0xFFFFFFFF,
  DB_COMPRESSOR_ZLIB = 0x1,
  DB_COMPRESSOR_LZX = 0x2,
  DB_COMPRESSOR_PASSTHROUGH = 0x3,
};
 
struct GfxImageStreamData
{
  int unknown[3];
};

struct FF_Header
{
  char magic[8]; // S1ff0100
  int version;
  bool compress;
  compress_type_t compressType;
  char sizeOfPointer;
  char sizeOfLong;
  int fileTimeHigh;
  int fileTimeLow;
  int imageCount;
  GfxImageStreamData imageData[imageCount];
  int baseFileLen;
  int totalFileLen;
};

Magic

The magic is a string that is 8 characters long. It is either "S1ff0100" or "S1ffu100". It indicates what is read after maxFileSize. If it is "S1ff0100" then this fastfile is signed. If it is "S1ffu100", then this fastfile is unsigned.

Version

Helps to dictate the version of the fastfile, so Ghosts fastfiles cannot be loaded on Advanced Warfare. The Advanced Warfare version is 0x72E for the Playstation 3 and Xbox 360 consoles, and the same for PC.

 if (version > 0x72E)
  Com_Error(ERR_DROP, "Fastfile for zone '%s' is newer than client executable (version %d, expecting %d)", filename, version, 0x72E);
 else if (version < 0x72E)
  Com_Error(ERR_DROP, "Fastfile for zone '%s' is out of date (version %d, expecting %d)", filename, version, 0x72E);

AllowOnlineUpdate

Whether or not assets in this fastfile may be replaced by a fastfile loaded at a later time.

Entries

These are still not entirely understood. Most fastfile systems simply parse past them.

Playstation 3 & Xbox 360

 ReadBytes(entryCount * 0x0C);

File Sizes

The fileSize is the size of the fastfile, everything included. The maxFileSize is the highest number that fileSize can be, and in most fastfiles they are equal.

Sub Header

The rest of the fastfile is read depending on what the main fastfile magic was. If the magic was "S1ff0100" then the fastfile is signed. If it was "S1ffu100", the fastfile is unsigned.

Unsigned Files

The only data remaining is compressed data, depending on the enum in the header of the fastfile. Decompressing the data yields the zone file.

Signed Files

 struct DB_AuthHash
 {
   char bytes[32];
 };
 
 struct DB_AuthSignatureHash
 {
   char bytes[256];
 };
 
 struct DB_AuthSubheader
 {
   char fastfileName[32];
   int reserved;
   DB_AuthHash masterBlockHashes[244];
 };
 
 struct DB_AuthHeader
 {
   char magic[8]; // S1ffS100
   int reserved;
   DB_AuthHash subheaderHash;
   DB_AuthSignatureHash signedSubheaderHash;
   DB_AuthSubHeader subheader;
   char signatureBlock[0x1E030];
 };

The signatures on the XBlocks are checked as the fastfile loads. Then the sub-header master block hashes are checked, followed by the signedSubheaderHash, and lastly the subheaderHash. If any fail, then the loading of the FF is aborted. Only Activision and the game developers can generate the RSA signatures.

Magic

The subheader magic is always "S1ffS100".

PS3

After the zone file is created, it is split into blocks each 0x10000 bytes. Each block is compressed using default zlib compression. The size of the compressed block is stored as an unsigned 16 bit integer over the zlib header (0x78DA). Compressed blocks are concatenated and appended to the fastfile.

Zone File

The zone file is the decompressed data from an FF.