FastFiles and Zone files (MW2)
Main FastFile Structure
//Note, on PS3 all values are << 1
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
};
//Entry point for the FF.
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
readBytes(entryCount * 0x14);
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];
};
//Sub DB_AuthHeader, continuation on the earlier.
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.
Zone File
The zone file is the decompressed data from an FF. The last asset in any zone is an empty rawfile containing the name of the FastFile the zone is from.
struct XAsset
{
XAssetType type; //See enum below
XAssetHeader * header;
};
struct XAssetList
{
int scriptStringCount;
const char * * scriptStrings;
int assetCount;
XAsset *assets;
};
struct ZoneHeader
{
int size; // size of XAssetList including assets
#ifdef PS3
int unk1[3];
int imagesSize;
int blockSize;
int unk6[5];
#elif defined XBOX
int unknown1[7];
#endif
XAssetList assetList;
};
General Asset Information
Asset Types
The types of assets loaded are determined by this enum.
enum XAssetType : int
{
physpreset = 0x00,
phys_collmap = 0x01,
xanim = 0x02,
modelsurfs = 0x03,
xmodel = 0x04,
material = 0x05,
pixelshader = 0x06,
techset = 0x07, //On PS3, 0x07 is vertexshader, everything else follows starting with techset at 0x08.
image = 0x08,
sound = 0x09,
sndcurve = 0x0A,
loaded_sound = 0x0B,
col_map_sp = 0x0C,
col_map_mp = 0x0D,
com_map = 0x0E,
game_map_sp = 0x0F,
game_map_mp = 0x10,
map_ents = 0x11,
fx_map = 0x12,
gfx_map = 0x13,
lightdef = 0x14,
ui_map = 0x15, //Not Used
font = 0x16,
menufile = 0x17,
menu = 0x18,
localize = 0x19,
weapon = 0x1A,
snddriverglobals = 0x1B,
fx = 0x1C,
impactfx = 0x1D,
aitype = 0x1E, //Not Used
mptype = 0x1F, //Not Used
character = 0x20, //Not Used
xmodelalias = 0x21, //Not Used
rawfile = 0x22,
stringtable = 0x23,
leaderboarddef = 0x24,
structureddatadef = 0x25,
tracer = 0x26,
vehicle = 0x27,
addon_map_ents = 0x28
};