wiithon.builder.copy_source module
Building a partition from one already present in an ISO
- class wiithon.builder.copy_source.CopyPartitionSource(reader, partition, fst_modifier=None, dol_modifier=None, file_overrides=None)[source]
Bases:
PartitionSourceFeeds the builder from a partition of an existing disc
Everything is read in the constructor, so building an instance opens the partition and pulls its system files immediately. The optional callbacks run at that point too, which means the FST and the DOL handed to the builder are already modified
File data is streamed later, on demand, straight from the source ISO. Only the files you override are held in memory
This is what
WiiIsoPatcheruses for every partition of the disc it rebuildsExample
>>> with WiiIsoReader("game.iso") as reader: ... entry = reader.get_data_partition() ... source = CopyPartitionSource(reader, entry, file_overrides={"opening.bnr": new_banner})
- Parameters:
- partition_info: WiiPartitionInfo
Partition opened from the source ISO, used to read file data on demand
- certificates: List[Certificate]
Certificate chain of the source partition
- encrypted_header: DiscHeader
Internal disc header of the source partition
- get_partition_type()[source]
Return the type of the partition
- Return type:
- Returns:
A
WiiPartTypevalue
- 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:
- Returns:
The ticket, written at offset 0 of the partition
- get_tmd()[source]
Return the title metadata
- Return type:
- 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
- get_certificates()[source]
Return the certificate chain of the partition
- Return type:
- Returns:
The certificates, written back to back in the order given. Retail discs carries three
- 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:
- Returns:
The header to place at the beginning of the partition data
- get_apploader()[source]
Return the apploader, the code that boots the game
- Return type:
- Returns:
The complete apploader, its own header included
- get_dol()[source]
Serialise the executable, including any patch applied by
dol_modifier- Return type:
- Returns:
The DOL as raw bytes
- 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:
- Returns:
The tree of directories and files
- get_file_data(path)[source]
Return the content of one file, from the overrides or from the source disc
Paths present in
file_overridesare served from memory. Everything else is read from the source ISO at the offset the node had before the builder started moving files around- Parameters:
path (
List[str]) – Path split into components, from the root of the partition- Return type:
- Returns:
The file content
- Raises:
FstFileNotFoundError – If the path matches no file, which also covers the case of a path resolving to a directory