wiithon.builder.directory_source module
Building a partition from a directory tree on disk
- wiithon.builder.directory_source.build_from_directory_tree(files_dir)[source]
Build a file system table mirroring a directory
Directories are walked recursively. Entries are sorted by name, case insensitively, so the resulting tree is stable across platforms and filesystems
File nodes carry the size read from disk and an offset of zero, since the builder assigns real offsets when it writes the data
- class wiithon.builder.directory_source.DirectoryPartitionSource(path, partition_type)[source]
Bases:
PartitionSourceFeeds the builder from a partition extracted to disk
The layout expected is the one produced by extraction tools such as wit:
<path>/ ticket.bin tmd.bin cert.bin sys/ boot.bin bi2.bin apploader.img main.dol files/ ...
Everything except the file contents is read in the constructor. File data is read from disk on demand as the builder asks for it
Note
h3.binanddisc/are ignored if present. The H3 table is recomputed while encrypting, and the region belongs to the disc rather than to a partition, so you pass it toWiiDiscBuilderyourselfExample
>>> source = DirectoryPartitionSource("extracted/DATA", WiiPartType.DATA)
See also
CopyPartitionSourceto build from an existing ISO instead- Parameters:
path (
str)partition_type (
WiiPartType)
- encrypted_header: DiscHeader
Internal disc header, with encryption and hash verification forced on
- certificates: List[Certificate]
Certificate chain read from
cert.bin
- get_partition_type()[source]
Return the type of the partition
- Return type:
- Returns:
A
WiiPartTypevalue
- 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_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_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]
Read one file from the
filesdirectory- Parameters:
path (
List[str]) – Path split into components, from the root of the partition- Return type:
- Returns:
The file content
- Raises:
FileNotFoundError – If the file disappeared between the construction of the tree and this call