U8 Archives
From WADder Wiki
The U8 Archive is an archive format used in many places on the Wii, with many different headers and compression types. The name U8 comes from the file header of a U8 archive, which begins with "U.8-", if there is no additional header.
Contents |
Notes
You can extract and pack U8 Archives with a variety of tools, namely: u8it, U8Tool, and many more. u8it is generally considered the best, though it does not support as many header types as U8Tool does.
Technical info
Description from WiiBrew.org
First comes a header:
struct U8_archive_header
{
u32 tag; // 0x55AA382D "U.8-"
u32 rootnode_offset; // offset to root_node, always 0x20.
u32 header_size; // size of header from root_node to end of string table.
u32 data_offset; // offset to data -- this is rootnode_offset + header_size, aligned to 0x40.
u8 zeroes[16];
};
Then comes a series of file nodes. The first one is the root node; it determines how many nodes there are in total.
struct U8_node
{
u16 type;
u16 name_offset;
u32 data_offset;
u32 size;
};
The name_offset gives the offset from the start of the string table to the start of this file's name. This is used for both files and directories.
For normal files, type is 0x0000. In this case the data_offset gives the address to where the data for this file is. This is given as an absolute offset from the start of the U8 header. The size is the size of the file.
For directories, type is 0x0100. In this case, the data_offset has no meaning. (It seems to be 0 or 1; it might signify the level of recursion even though this is redundant.) The size field is used to indicate which files are included in this directory. The value given is the node number of the last file included, counting the root node as node number 1.
An example: In opening.bnr, there are five nodes:
1: root 2: "meta" 3: "banner.bin" 4: "icon.bin" 5: "sound.bin"
The root and "meta" are directories. Both of them have 5 as their size, which means that sound.bin is the last file included in the root directory, and it also is the last file included in the meta directory.
Alternative text explanation by icefire
U8 files are an archive format, with optional compression and headers. Right now, I’m just going to discuss the standard U8 format.
First, all U8 Archives start with the standard header. This starts itself with the U8 identifier, “U.8-” (or 0×55AA382D in hex). This is at the start (or after a header) of every U8 file and tells that it is one. After this comes the “Root node offset” (four bytes long) — or how far from the start of the file to the Root Node (the Root Node is the base node, it is in all U8 files and it is used to specify how many files are in it).
Following the Root Node offset is the header size (four bytes long), which says how long it is until the data starts, counting from the start of the root node (0×20). This size also includes the String Table, which is where the filenames are stored. After that, you get the Data Offset (four bytes), which is the offset from the start of the file to the data, rounded to 0×40. The start of the data is also padded with 0×00’s to 0×40, so it lines up with the Data Offset. The header size does not include this padding.
After that is 16 bytes of zeroes, bringing us to the root node. The root node is stored as a standard U8 Node, which I will now describe:
Each U8 Node (12 bytes total) starts with the type of the node, which is 0×0100 for folders, and 0×0000 for files. After that type, it has the String Table Offset (two bytes), which tells where in the string table the file name is stored (file names end with 0×00, or a NULL byte). And then you get the Data Offset (four bytes), which is the offset from the START of the file (not the data section) to the file’s data. For folders, this stores the level of recursion (number of subdirectories the folder is in).
After that, you get the “Size”. The size (four bytes) stores the file’s size if it is a file, otherwise it stores the node “Number” (what node is it in the file) of the last file included in the folder (including in subdirectories!). The size for the Root Node is always the number of files and directories in the archive.
BTW, this is all in Big Endian (look it up if you don’t know what it is), but most computers are in Little Endian. You probably need to convert it :).
