diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index ffe74e6..cd70384 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt @@ -38,10 +38,14 @@ add_executable(aaruformattool wiiu/convert.c wiiu/reader.c wiiu/reader.h + ngcw/convert.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/aes128.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/ps3/ps3_crypto.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/ps3/ps3_encryption_map.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/wiiu/wiiu_crypto.c + ${CMAKE_CURRENT_SOURCE_DIR}/../src/ngcw/lfg.c + ${CMAKE_CURRENT_SOURCE_DIR}/../src/ngcw/ngcw_junk.c + ${CMAKE_CURRENT_SOURCE_DIR}/../src/ngcw/wii_crypto.c termbox2.h ) diff --git a/tool/aaruformattool.h b/tool/aaruformattool.h index f93bdbe..0b4f091 100644 --- a/tool/aaruformattool.h +++ b/tool/aaruformattool.h @@ -46,5 +46,6 @@ int inject_media_tag(const char *tag_type, const char *media_tag_file, c int convert_ps3(const char *input_path, const char *output_path, const char *disc_key_hex, const char *data1_key_hex, const char *ird_path); int convert_wiiu(const char *input_path, const char *output_path, const char *disc_key_hex); +int convert_ngcw(const char *input_path, const char *output_path); #endif // LIBAARUFORMAT_TOOL_AARUFORMATTOOL_H_ diff --git a/tool/commands.c b/tool/commands.c index 8cd4a00..7c75f95 100644 --- a/tool/commands.c +++ b/tool/commands.c @@ -266,6 +266,26 @@ int cmd_convert_wiiu(int argc, char *argv[]) return result; } +int cmd_convert_ngcw(int argc, char *argv[]) +{ + struct arg_str *input_filename = arg_str1(NULL, NULL, "", "Input ISO or AaruFormat image"); + struct arg_str *output_filename = arg_str1(NULL, NULL, "", "Output AaruFormat image"); + struct arg_end *end = arg_end(10); + void *argtable[] = {input_filename, output_filename, end}; + + if(arg_parse(argc, argv, argtable) > 0) + { + arg_print_errors(stderr, end, "convert-ngcw"); + usage_convert_ngcw(); + arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0])); + return -1; + } + + const int result = convert_ngcw(input_filename->sval[0], output_filename->sval[0]); + arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0])); + return result; +} + Command commands[] = { { "identify", cmd_identify}, { "info", cmd_info}, @@ -280,6 +300,7 @@ Command commands[] = { { "inject-media-tag", cmd_inject_media_tag}, { "convert-ps3", cmd_convert_ps3}, { "convert-wiiu", cmd_convert_wiiu}, + { "convert-ngcw", cmd_convert_ngcw}, }; const size_t num_commands = sizeof(commands) / sizeof(commands[0]); diff --git a/tool/commands.h b/tool/commands.h index 537a5c8..d7ac1a1 100644 --- a/tool/commands.h +++ b/tool/commands.h @@ -44,5 +44,6 @@ int cmd_convert(int argc, char *argv[]); int cmd_upgrade_ddt_to_alpha21(int argc, char *argv[]); int cmd_inject_media_tag(int argc, char *argv[]); int cmd_convert_ps3(int argc, char *argv[]); +int cmd_convert_ngcw(int argc, char *argv[]); #endif // LIBAARUFORMAT_COMMANDS_H diff --git a/tool/ngcw/convert.c b/tool/ngcw/convert.c new file mode 100644 index 0000000..dc543e1 --- /dev/null +++ b/tool/ngcw/convert.c @@ -0,0 +1,34 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2026 Natalia Portillo. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * convert-ngcw command: converts Nintendo GameCube/Wii disc ISO or AaruFormat + * images to AaruFormat with decrypted sector storage and junk removal. + */ + +#include + +#include "../aaruformattool.h" + +int convert_ngcw(const char *input_path, const char *output_path) +{ + (void)input_path; + (void)output_path; + + fprintf(stderr, "convert-ngcw: not yet implemented\n"); + return -1; +} diff --git a/tool/usage.c b/tool/usage.c index 49450d6..d8eb2be 100644 --- a/tool/usage.c +++ b/tool/usage.c @@ -40,6 +40,7 @@ void usage() printf(" convert Converts an AaruFormat image to another AaruFormat image.\n"); printf(" convert-ps3 Converts a PS3 disc image to AaruFormat with decrypted storage.\n"); printf(" convert-wiiu Converts a Wii U disc image to AaruFormat with decrypted storage.\n"); + printf(" convert-ngcw Converts a GameCube/Wii disc image to AaruFormat.\n"); printf(" identify Identifies if the indicated file is a supported AaruFormat image.\n"); printf(" info Prints information about a given AaruFormat image.\n"); printf(" inject-media-tag Injects a media tag into an AaruFormat image.\n"); @@ -199,3 +200,17 @@ void usage_convert_wiiu() printf(" 2. Sidecar files: .disckey, .key\n"); printf(" 3. Source AaruFormat image media tags\n"); } + +void usage_convert_ngcw() +{ + printf("\nUsage:\n"); + printf(" aaruformattool convert-ngcw \n\n"); + printf("Converts a Nintendo GameCube or Wii disc ISO or AaruFormat image to an\n"); + printf("AaruFormat image with decrypted sectors (Wii) and junk regions removed.\n\n"); + printf("Arguments:\n"); + printf(" Path to input ISO or AaruFormat image.\n"); + printf(" Path to output AaruFormat image.\n\n"); + printf("The disc type (GameCube or Wii) is auto-detected from the disc header.\n"); + printf("Wii common keys are hardcoded; no key arguments are needed.\n"); + printf("A .bca sidecar file will be imported if found alongside the input.\n"); +} diff --git a/tool/usage.h b/tool/usage.h index cb2a74e..fafbe9c 100644 --- a/tool/usage.h +++ b/tool/usage.h @@ -35,5 +35,6 @@ void usage_upgrade_ddt_to_alpha21(); void usage_inject_media_tag(); void usage_convert_ps3(); void usage_convert_wiiu(); +void usage_convert_ngcw(); #endif // LIBAARUFORMAT_USAGE_H