FastFiles and Zone files (AW)
FastFile Structure
enum compress_type_t
{
zlib = 1,
lzx = 2
};
//Entry point for the FF.
struct DB_Header
{
char magic[8]; // S1ff0100
int version;
bool allowOnlineUpdate;
compress_type_t compressionType;
char unknown1;
char unknown2;
int unknown3;
int unknown4;
int padding;
int fileSize;
int maxFileSize;
};
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("Fastfile for zone '%s' is newer than client executable (version %d, expecting %d)", version, 0x72E);
else if (version < 0x72E)
Com_Error("Fastfile for zone '%s' is out of date (version %d, expecting %d)", 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.