mirror of
https://github.com/GerbilSoft/rvthtool.git
synced 2025-06-18 11:35:33 -04:00
[rvthtool] extract: Allow the bank number to be omitted for standalone disc images.
This commit is contained in:
parent
1229ff4562
commit
a3384aa9fe
@ -76,10 +76,9 @@ extract bank 1.
|
||||
* If the game is retail-encrypted, it will be converted to debug encryption
|
||||
and signed using the debug keys.
|
||||
* Convert an RVT-R disc image to retail fakesigned:
|
||||
* `$ ./rvthtool extract --recrypt=retail RVT-R.gcm 1 RetailFakesigned.gcm`
|
||||
* NOTE: Currently, disc images are treated as if they're single-bank RVT-H
|
||||
HDD images. This is why a bank number is required, even though it will
|
||||
always be 1.
|
||||
* `$ ./rvthtool extract --recrypt=retail RVT-R.gcm RetailFakesigned.gcm`
|
||||
* The bank number may be omitted if the source file is a standalone disc
|
||||
image instead of an RVT-H HDD image or RVT-H Reader device.
|
||||
* Query available RVT-H Readers:
|
||||
```
|
||||
$ ./rvthtool query
|
||||
|
@ -74,7 +74,7 @@ static bool progress_callback(const RvtH_Progress_State *state)
|
||||
/**
|
||||
* 'extract' command.
|
||||
* @param rvth_filename [in] RVT-H device or disk image filename.
|
||||
* @param s_bank [in] Bank number (as a string).
|
||||
* @param s_bank [in] Bank number (as a string). (If NULL, assumes bank 1.)
|
||||
* @param gcm_filename [in] Filename for the extracted GCM image.
|
||||
* @param recrypt_key [in] Key for recryption. (-1 for default)
|
||||
* @return 0 on success; non-zero on error.
|
||||
@ -95,14 +95,27 @@ int extract(const TCHAR *rvth_filename, const TCHAR *s_bank, const TCHAR *gcm_fi
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Validate the bank number.
|
||||
bank = (unsigned int)_tcstoul(s_bank, &endptr, 10) - 1;
|
||||
if (*endptr != 0 || bank > rvth_get_BankCount(rvth)) {
|
||||
fputs("*** ERROR: Invalid bank number '", stderr);
|
||||
_fputts(s_bank, stderr);
|
||||
fputs("'.\n", stderr);
|
||||
rvth_close(rvth);
|
||||
return -EINVAL;
|
||||
if (s_bank) {
|
||||
// Validate the bank number.
|
||||
bank = (unsigned int)_tcstoul(s_bank, &endptr, 10) - 1;
|
||||
if (*endptr != 0 || bank > rvth_get_BankCount(rvth)) {
|
||||
fputs("*** ERROR: Invalid bank number '", stderr);
|
||||
_fputts(s_bank, stderr);
|
||||
fputs("'.\n", stderr);
|
||||
rvth_close(rvth);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
// No bank number specified.
|
||||
// Assume 1 bank if this is a standalone disc image.
|
||||
// For HDD images or RVT-H Readers, this is an error.
|
||||
if (rvth_get_BankCount(rvth) != 1) {
|
||||
fprintf(stderr, "*** ERROR: Must specify a bank number for this RVT-H Reader%s.\n",
|
||||
rvth_is_hdd(rvth) ? "" : " disk image");
|
||||
rvth_close(rvth);
|
||||
return -EINVAL;
|
||||
}
|
||||
bank = 0;
|
||||
}
|
||||
|
||||
// Print the bank information.
|
||||
|
@ -30,7 +30,7 @@ extern "C" {
|
||||
/**
|
||||
* 'extract' command.
|
||||
* @param rvth_filename RVT-H device or disk image filename.
|
||||
* @param s_bank Bank number (as a string).
|
||||
* @param s_bank Bank number (as a string). (If NULL, assumes bank 1.)
|
||||
* @param gcm_filename Filename for the extracted GCM image.
|
||||
* @param recrypt_key [in] Key for recryption. (-1 for default)
|
||||
* @return 0 on success; non-zero on error.
|
||||
|
@ -222,11 +222,19 @@ int RVTH_CDECL _tmain(int argc, TCHAR *argv[])
|
||||
ret = list_banks(argv[optind+1]);
|
||||
} else if (!_tcscmp(argv[optind], _T("extract"))) {
|
||||
// Extract a bank.
|
||||
if (argc < optind+4) {
|
||||
if (argc < optind+3) {
|
||||
print_error(argv[0], _T("missing parameters for 'extract'"));
|
||||
return EXIT_FAILURE;
|
||||
} else if (argc == optind+3) {
|
||||
// Two parameters specified.
|
||||
// Pass NULL as the bank number, which will be
|
||||
// interpreted as bank 1 for single-disc images
|
||||
// and an error for HDD images.
|
||||
ret = extract(argv[optind+1], NULL, argv[optind+2], recrypt_key);
|
||||
} else {
|
||||
// Three or more parameters specified.
|
||||
ret = extract(argv[optind+1], argv[optind+2], argv[optind+3], recrypt_key);
|
||||
}
|
||||
ret = extract(argv[optind+1], argv[optind+2], argv[optind+3], recrypt_key);
|
||||
} else if (!_tcscmp(argv[optind], _T("import"))) {
|
||||
// Import a bank.
|
||||
if (argc < optind+4) {
|
||||
|
Loading…
Reference in New Issue
Block a user