mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2026-02-17 02:25:39 -05:00
Add module for directly fakesigning a TMD, Ticket, or WAD
This commit is contained in:
38
modules/archive/ash.py
Normal file
38
modules/archive/ash.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# "modules/archive/ash.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
|
||||
|
||||
def handle_ash(args):
|
||||
input_path = pathlib.Path(args.input)
|
||||
output_path = pathlib.Path(args.output)
|
||||
|
||||
# Code for if --compress was passed.
|
||||
# ASH compression has not been implemented in libWiiPy yet, but it'll be filled in here when it has.
|
||||
if args.compress:
|
||||
print("Compression is not implemented yet.")
|
||||
|
||||
# Code for if --decompress was passed.
|
||||
elif args.decompress:
|
||||
# These default to 9 and 11, respectively, so we can always read them.
|
||||
sym_tree_bits = args.sym_bits
|
||||
dist_tree_bits = args.dist_bits
|
||||
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(input_path)
|
||||
|
||||
ash_file = open(input_path, "rb")
|
||||
ash_data = ash_file.read()
|
||||
ash_file.close()
|
||||
|
||||
# Decompress ASH file using the provided symbol/distance tree widths.
|
||||
ash_decompressed = libWiiPy.archive.decompress_ash(ash_data, sym_tree_bits=sym_tree_bits,
|
||||
dist_tree_bits=dist_tree_bits)
|
||||
|
||||
ash_out = open(output_path, "wb")
|
||||
ash_out.write(ash_decompressed)
|
||||
ash_out.close()
|
||||
|
||||
print("ASH file decompressed!")
|
||||
37
modules/archive/u8.py
Normal file
37
modules/archive/u8.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# "modules/archive/u8.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
|
||||
|
||||
def handle_u8(args):
|
||||
input_path = pathlib.Path(args.input)
|
||||
output_path = pathlib.Path(args.output)
|
||||
|
||||
# Code for if the --pack argument was passed.
|
||||
if args.pack:
|
||||
try:
|
||||
u8_data = libWiiPy.archive.pack_u8(input_path)
|
||||
except ValueError:
|
||||
print("Error: Specified input file/folder does not exist!")
|
||||
return
|
||||
|
||||
out_file = open(output_path, "wb")
|
||||
out_file.write(u8_data)
|
||||
out_file.close()
|
||||
|
||||
print("U8 archive packed!")
|
||||
|
||||
# Code for if the --unpack argument was passed.
|
||||
elif args.unpack:
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(args.input)
|
||||
|
||||
u8_data = open(input_path, "rb").read()
|
||||
|
||||
# Output path is deliberately not checked in any way because libWiiPy already has those checks, and it's easier
|
||||
# and cleaner to only have one component doing all the checks.
|
||||
libWiiPy.archive.extract_u8(u8_data, str(output_path))
|
||||
|
||||
print("U8 archive unpacked!")
|
||||
Reference in New Issue
Block a user