wiithon.builder.disc_builder module
Assembling a Wii disc image from partitions
WiiDiscBuilder writes partitions one after another, then closes the disc. Where the content comes from is
the job of a PartitionSource
- wiithon.builder.disc_builder.fakesign_tmd(tmd_bytes, h3, data_size)[source]
Patch a TMD in place so Dolphin accepts it without a valid signature
Writes the H3 hash and the partition data size, zeroes the signature, then brute-forces the padding until the SHA-1 of the signed blob starts with a null byte
- Parameters:
- Return type:
Note
The resulting signature is not valid.
- class wiithon.builder.disc_builder.WiiDiscBuilder(header, region)[source]
Bases:
objectWrites a Wii disc image, one partition at a time
Call
add_partition()for each partition, thenfinish()once. Partitions are laid out in the order they are added, starting at the first partition offset, and the builder tracks where the next one goesExample
>>> with open("out.iso", "w+b") as dest: ... builder = WiiDiscBuilder(disc_header, region) ... builder.add_partition(dest, source, None) ... builder.finish(dest)
See also
WiiIsoPatcherdrives this class for you when patching an existing disc- Parameters:
header (
DiscHeader)region (
bytes)
- header: DiscHeader
Unencrypted disc header written at the start of the image
- partitions: List[tuple]
One tuple per partition added so far, consumed by
finish()to write the partition table
- current_data_offset
Offset where the next partition will be written, advanced by
add_partition()
- add_partition(stream, new_partition, progress_cb=None)[source]
Write one partition to the stream
Pulls every piece from the source, writes the ticket, TMD and certificate chain in clear, then the system files and the file data through an encrypting writer. Once the data is placed, the FST is rewritten with the real offsets, the H3 table is stored, and the TMD is fakesigned
The partition is padded to a whole number of encryption groups, and
current_data_offsetis advanced past it- Parameters:
stream (
BinaryIO) – Destination, opened in binary read and write mode. It must be seekablenew_partition (
PartitionSource) – Where the content of this partition comes fromprogress_cb (
Optional[Callable], default:None) – Called with an integer percentage from 0 to 100 as file data is written, orNone.
- Return type:
Note
Progress restarts at 0 for every partition, since the builder has no idea how many will follow
- finish(stream)[source]
Close the disc image
Writes the disc header, the partition table describing every partition added so far, the region and the magic word. Call this once, after the last
add_partition()Warning
A disc image whose
finish()was never called has no partition table and will not boot