View Single Post
  #309  
Old 12th November 2008, 02:36 AM
Ice Mario's Avatar
Ice Mario Ice Mario is offline
Rarewitch Hero
 
Join Date: Apr 1999
Location: United Kingdom
Total Awards: 5
SteamLink Verified INFECTED - B1K1 RWP Podcast Awesome Default Medal Thread Starter 
Here is some of my preliminary investigative notes on the CAFF. I cannot guarantee that the information here is exactly right, but for extracting data, it serves it's purpose. Hopefully I've not made any typos, but if I have then with a little investigation, it should be apparent what it is supposed to be.

CAFF (most likely stands for Common Asset File Format) and has been used by Rare since it's days on the original Xbox.

Code:
Header (size 0x78)
offset	size	desc
0x00	0x04	FourCC (CAFF)
0x04	0x10	Version (char) 07.08.06.0036
0x14	0x04	Size of header (0x78)
0x18	0x04	Header Checksum
0x1c	0x04	Number of Symbols
0x20	0x04	Number of File Parts
0x48	0x01	Type
0x49	0x01	Number of Sections
0x50	0x04	DataBase (offset from the end of the caff header (0x78) )
0x60	0x04	DataBase
0x64	0x04	DataOffs (add to DataBase to get start of section data)
0x74	0x04	DataOffs
Then follows a SectionInfo structure for each Section

Code:
Section Info	(size 0x21)
offset	size	desc
0x09	0x04	Data Length
0x1d	0x04	Data Length
Next follows the null terminated section names

0x00 0x04 Length of Symbols Buffer

Then follows an offset value for each Symbol. This is an offset into the Symbol Buffer

Then the null-terminated Symbols

Then follows a entry for each file part. So, if a file has data in more than one section, it would have multiple entries here, tied together by the FileID member.

Code:
FileInfo	(size 0x14)
offset	size	desc
0x01	0x02	FileID
0x03	0x04	Data Offset
0x07	0x04	Data Len
0x0B	0x01	Section
Then the data sections

It is fairly easy to extract section data by iterating through the sectionInfo structures, adding the lengths to make data offsets

Extracting actual files can be achieved by iterating through the symbols list, and then getting it's data from each section by using the FileInfo table.


TYPES

.data
Generic data. For example: information describing the texture, such as type, width, height

.texturegpu
The data that will be loaded into the gpu. i.e raw texture data that has been converted to the correct format for the target platform.

.stream
data that will be streamed. Information about this layout is likely to be described in the .data section

The are more types, but I've not had to look at any more yet, but obviously when extracting models the .gpu section will come into play

It must be noted that some sections can be compressed. This was the case on Perfect Dark Zero, but I've not come across any that are compressed in Nuts & Bolts.

HTH
__________________
On Rails Fails!