wiithon.builder.source module

The contract a partition must fulfil to be written by the builder

class wiithon.builder.source.PartitionSource[source]

Bases: ABC

Describes where the content of one partition comes from

WiiDiscBuilder never reads a disc or a directory itself. It asks a PartitionSource for each piece it needs, in the order below, and writes what it gets back

Two implementations ship with the library:

Implement this class to build a partition from anywhere else

See also

Patching a Wii ISO for the common cases that do not need a custom source

abstractmethod get_partition_type()[source]

Return the type of the partition

Return type:

int

Returns:

A WiiPartType value

abstractmethod get_tmd()[source]

Return the title metadata

Return type:

TMD

Returns:

The TMD. The builder rewrites its H3 hash, its data size and its signature padding before writing it, so the content hashes it carries do not need to be correct

abstractmethod get_certificates()[source]

Return the certificate chain of the partition

Return type:

List[Certificate]

Returns:

The certificates, written back to back in the order given. Retail discs carries three

abstractmethod get_encrypted_header()[source]

Return the disc header stored at offset 0 of the partition data

This is the internal header, also known as boot.bin, not the unencrypted one at the start of the disc. The builder overwrites its DOL and FST offsets once it knows where those landed

Return type:

DiscHeader

Returns:

The header to place at the beginning of the partition data

abstractmethod get_bi2()[source]

Return the BI2

Return type:

bytes

Returns:

The raw block, written at its fixed offset

abstractmethod get_apploader()[source]

Return the apploader, the code that boots the game

Return type:

bytes

Returns:

The complete apploader, its own header included

abstractmethod get_dol()[source]

Return the main executable

Return type:

bytes

Returns:

The DOL as raw bytes, not a parsed DOL. Serialise it yourself if you hold an object

abstractmethod get_fst()[source]

Return the file system table of the partition

The tree drives everything that follows: the builder walks it to know which files to ask for, and rewrites the offset and length of each node once the data is placed

Return type:

FST

Returns:

The tree of directories and files

abstractmethod get_ticket()[source]

Return the ticket of the partition

The builder takes the title key from it to encrypt every block of partition data, so this is the first thing it needs

Return type:

Ticket

Returns:

The ticket, written at offset 0 of the partition

abstractmethod get_file_data(path)[source]

Return the content of one file

Called once per file found in the FST, in the order the builder writes them

Parameters:

path (List[str]) – Path split into components, from the root of the partition down to the file name, for example ["StageData", "AstroDome", "AstroDome.arc"] is “StageData/AstroDome/AstroDome.arc”

Return type:

bytes

Returns:

The file content. Its length overrides whatever the FST node declared