diff --git a/modules/title/iospatcher.py b/modules/title/iospatcher.py index 27d3476..5f99417 100644 --- a/modules/title/iospatcher.py +++ b/modules/title/iospatcher.py @@ -105,6 +105,12 @@ def handle_iospatch(args): " compatible with this IOS.") if patch_count > 0 or args.version is not None or args.slot is not None: + # Set patched content to non-shared if that argument was passed. + if args.no_shared is not None: + ios_patcher.title.content.content_records[ios_patcher.es_module_index].content_type = 1 + if ios_patcher.dip_module_index != -1: + ios_patcher.title.content.content_records[ios_patcher.dip_module_index].content_type = 1 + ios_patcher.title.fakesign() # Signature is broken anyway, so fakesign for maximum installation openings if args.output is not None: output_path = pathlib.Path(args.output) diff --git a/modules/title/nus.py b/modules/title/nus.py index 84221f1..e7a2dd1 100644 --- a/modules/title/nus.py +++ b/modules/title/nus.py @@ -112,10 +112,7 @@ def handle_nus_title(args): print(" - Decrypting content " + str(content + 1) + " of " + str(len(title.tmd.content_records)) + " (Content ID: " + str(title.tmd.content_records[content].content_id) + ")...") dec_content = title.get_content_by_index(content) - content_file_name = hex(title.tmd.content_records[content].content_id)[2:] - while len(content_file_name) < 8: - content_file_name = "0" + content_file_name - content_file_name = content_file_name + ".app" + content_file_name = f"{title.tmd.content_records[content].content_id:08X}".lower() + ".app" dec_content_out = open(output_dir.joinpath(content_file_name), "wb") dec_content_out.write(dec_content) dec_content_out.close() @@ -159,9 +156,7 @@ def handle_nus_content(args): # Use the supplied output path if one was specified, otherwise generate one using the Content ID. if out is None: - content_file_name = hex(content_id)[2:] - while len(content_file_name) < 8: - content_file_name = "0" + content_file_name + content_file_name = f"{content_id:08X}".lower() output_path = pathlib.Path(content_file_name) else: output_path = pathlib.Path(out) @@ -223,3 +218,37 @@ def handle_nus_content(args): file.close() print("Downloaded content with Content ID \"" + cid + "\"!") + + +def handle_nus_tmd(args): + tid = args.tid + version = args.version + out = args.output + + # Check if --version was passed, because it'll be None if it wasn't. + if args.version is not None: + try: + title_version = int(args.version) + except ValueError: + print("Enter a valid integer for the Title Version.") + return + + # Use the supplied output path if one was specified, otherwise generate one using the Title ID. + if out is None: + output_path = pathlib.Path(tid + ".tmd") + else: + output_path = pathlib.Path(out) + + # Try to download the TMD, and catch the ValueError libWiiPy will throw if it can't be found. + print("Downloading TMD for title " + tid + "...") + try: + tmd_data = libWiiPy.title.download_tmd(tid, version) + except ValueError: + print("The Title ID or version you specified could not be found!") + return + + file = open(output_path, "wb") + file.write(tmd_data) + file.close() + + print("Downloaded TMD for title \"" + tid + "\"!") diff --git a/wiipy.py b/wiipy.py index 9b596fc..f804b6a 100644 --- a/wiipy.py +++ b/wiipy.py @@ -76,6 +76,8 @@ if __name__ == "__main__": iospatch_parser.add_argument("-s", "--slot", metavar="SLOT", type=int, help="set the slot that this IOS will install to") iospatch_parser.add_argument("-a", "--all", action="store_true", help="apply all patches (overrides other options)") + iospatch_parser.add_argument("-ns", "--no-shared", action="store_true", + help="set all patched content to be non-shared") # Argument parser for the NUS subcommand. nus_parser = subparsers.add_parser("nus", help="download data from the NUS", @@ -108,6 +110,14 @@ if __name__ == "__main__": nus_content_parser.add_argument("-o", "--output", metavar="OUT", type=str, help="path to download the content to (optional)") nus_content_parser.add_argument("-d", "--decrypt", action="store_true", help="decrypt this content") + # TMD NUS subcommand. + nus_tmd_parser = nus_subparsers.add_parser("tmd", help="download a tmd from the NUS", + description="download a tmd from the NUS") + nus_tmd_parser.set_defaults(func=handle_nus_tmd) + nus_tmd_parser.add_argument("tid", metavar="TID", type=str, help="Title ID the TMD is for") + nus_tmd_parser.add_argument("-v", "--version", metavar="VERSION", type=int, help="version of the TMD to download") + nus_tmd_parser.add_argument("-o", "--output", metavar="OUT", type=str, + help="path to download the TMD to (optional)") # Argument parser for the U8 subcommand. u8_parser = subparsers.add_parser("u8", help="pack/unpack a U8 archive",