wiithon.disc.partition module

Access to the contents of a decrypted disc partition

Instances of WiiPartitionInfo are produced by wiithon.disc.reader.WiiIsoReader.open_partition(). They are not meant to be built directly

class wiithon.disc.partition.WiiPartitionInfo(header, tmd, certificates, internal_header, fst, crypto, partition_offset)[source]

Bases: object

A decrypted partition and everything it contains

All reads go through a CryptPartReader, which decrypts blocks on demand. Nothing is held in memory beyond the file system table, so reading a large file costs a disc read, not a full partition decryption

Parameters:
header: WiiPartitionHeader

Partition header, holding the ticket and the offsets to the TMD, certificates, H3 table and data

tmd: TMD

Title metadata, describing the contents and their SHA-1 hashes

certificates: List[Certificate]

The partition certificate chain

internal_header: DiscHeader

Disc header found at offset 0x000 of the decrypted data, also known as boot.bin. This is where the DOL and FST offsets live

fst: FST

Parsed file system table

crypto: CryptPartReader

Decrypting reader used for every access to partition data

partition_offset: int

Absolute offset of the partition within the ISO

read_file(path)[source]

Read a file from the partition

Parameters:

path (str) – Path inside the partition, using / as separator, for example "StageData/HeavensDoorGalaxy.arc"

Return type:

bytes

Returns:

The decrypted file contents

Raises:
read_apploader()[source]

Read the apploader, the code that boots the game

The apploader header declares two payload sizes. Both are read along with the header itself

Return type:

bytes

Returns:

The complete apploader, header included

read_dol()[source]

Read and parse the main executable

The DOL has no explicit size on disc, so it is computed as the furthest end of any text or data section declared in its header

Return type:

DOL

Returns:

The parsed DOL

read_bi2()[source]

Read bi2.bin, the disc configuration block that follows the header

Return type:

bytes

Returns:

The raw block, read at its fixed offset and size

list_files(node=None, prefix='')[source]

List every file in the partition, recursively

Directories are traversed but not listed. Only files appear in the result

Parameters:
  • node (Optional[FSTNode], default: None) – Directory to start from. Defaults to the root of the FST

  • prefix (str, default: '') – Path prefix prepended to each result

Return type:

List[str]

Returns:

Full paths, using / as separator

Note

node and prefix drive the recursion and are not meant to be passed by callers. On a large disc the whole list is built in memory, so prefer callback_all_files() when you only need to walk it

callback_all_files(callback, node=None)[source]

Walk every file in the partition and invoke a callback on each

Directories are traversed but never passed to the callback

Parameters:
  • callback (Callable[[FSTNode], None]) – Called once per file, with the FST node as its only argument

  • node (Optional[FSTNode], default: None) – Directory to start from. Defaults to the root of the FST

Return type:

None

Note

The callback receives the node, not the full path. If you need paths, use list_files()