VFF

From WiiBrew
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

VFF is a "virtual FAT filesystem", which is used as a container for primarily WC24 downloaded content, as well as E-Mail storage.

Header

Start Length Typical value Description
0 4 'VFF ' 4-byte magic
4 2 feff Byte-order-marker?
6 2 0100 ? (2's complement of previous field ?)
8 4 01400000 Total file size
12 2 0020 Size of header
14 18 zeroes padding

Following the header is two FATs, which are FAT16. Each FAT is the size of a sector. The format of the FAT is not regular FAT16, there's unknown flags and values, so it's currently not possible to process cluster chains. Following the FATs is the root directory cluster, 8 sectors long. Following the root cluster is the data "clusters". The data "clusters" have one sector per "cluster". The size of a sector is determined by the following algorithm:

u32 base = (filesize / 0x200) - 8;//This algo doesn't work exactly for files over 1MB. To get the correct size, try multiplying the result of this algo with various values.
u32 sectorsz = base;
if(base % 0x200)//Should always be executed.
{
     if(base<0x200)
     {
          sectorsz+= (base % 0x200);
     }
     else
     {
          sectorsz++;
     }
}