FastFiles and Zone files (MW2)

From COD Engine Research
Revision as of 21:21, 29 December 2013 by CraigChrist8239 (talk | contribs) (Created page with "Category:FastFiles Category:MW2 == Main FastFile Structure == enum language_t { LANGUAGE_ENGLISH = 0x1, LANGUAGE_FRENCH = 0x2, LANGUAGE_GERMAN = 0x3, LA...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Main FastFile Structure

enum language_t
{
  LANGUAGE_ENGLISH = 0x1,
  LANGUAGE_FRENCH = 0x2,
  LANGUAGE_GERMAN = 0x3,
  LANGUAGE_ITALIAN = 0x4,
  LANGUAGE_SPANISH = 0x5,
  LANGUAGE_BRITISH = 0x6,
  LANGUAGE_RUSSIAN = 0x7,
  LANGUAGE_POLISH = 0x8,
  LANGUAGE_KOREAN = 0x9,
  LANGUAGE_TAIWANESE = 0xA,
  LANGUAGE_JAPANESE = 0xB,
  LANGUAGE_CHINESE = 0xC,
  LANGUAGE_THAI = 0xD,
  LANGUAGE_LEET = 0xE,
  LANGUAGE_CZECH = 0xF,
  MAX_LANGUAGES
};

struct DB_AuthHeader
{
  char magic[8];
  int version;
  bool allowOnlineUpdate;
  unsigned __int64 fileCreationTime;
  language_t region;
  int entryCount;
  Entry entries[];
  int fileSize;
  int maxFileSize;
};

Magic

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

Version

Helps to dictate the version of the FF, so Modern Warfare 3 FastFiles cannot be loaded on Modern Warfare 2. The Modern Warfare 2 version is 0x10D for console systems and 0x114 for PC.

AllowOnlineUpdate

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

Entries

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

Xbox 360

for (int32 i = 0; i < 0x0f; i++)
{
  if (((1 << i) & language) == 0)
    continue;
  else
    ReadBytes(((entryCount << 1) + entryCount) << 2);
}

PS3

if (entryCount > 0 && language == region.english)
  readBytes(((entryCount * 4) >> 4) * 0x50);

File Sizes

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

Subheader

The rest of the FF is read depending on what the main FF magic was. If the magic was "IWff0100" then the FF is signed. If it was "IWffu100", the FF is unsigned.

Unsigned Files

Unsigned files are used for SP data and are very simple. The only data remaining is compressed zlib data. 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_AuthXBlock
{
  DB_AuthHash blockSignature[0x100];
  char blockData[0x200000];
};

struct DB_AuthHeader
{
  char magic[8];
  int reserved;
  DB_AuthHash subheaderHash;
  DB_AuthSignatureHash signedSubheaderHash;
  DB_AuthSubHeader subheader;
  DB_AuthXBlock xBlocks[];
};

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. Once all the signatures are checked, then the data is combined and decompressed to give the zone file.

Magic

The subheader magic is always "IWffs100".

XBlocks

XBlocks are used until they are no longer needed. If the compressed data can fit into 1, then only 1 will exist.