Commit Graph

550 Commits

Author SHA1 Message Date
David Korth
a6cbd897c3 [wadresign] Change the default behavior of format conversion.
If no parameters are specified, the encryption key is changed, but
the format is kept the same. This also applies if the encrpytion key
is specified but the format is not.

If the format is specified but the key is not specified, then only
the format is changed.
2020-06-18 20:02:36 -04:00
David Korth
c91fee0e84 [wadresign] Added the CRL field; renamed "footer" and "name" to "meta".
NOTE: CRL is not currently copied for either format, and metadata is
only copied when the destination format is WAD.
2020-06-18 19:53:14 -04:00
David Korth
e32c53544e [wadresign] resign-wad.c: Use a bool for isDestBwf; fix a bunch of logic errors.
Stupid logic errors for wad->wad, wad->bwf, etc. due to hard-to-understand
comparisons instead of using boolean logic.

All of my local tests work now.

TODO: Handle the meta and crl sections better.
2020-06-18 19:36:11 -04:00
David Korth
35f1d5eade [wadresign] resign-wad.c: Allow converting BWF to WAD without recryption.
Tested with a devel-signed BootMii and it worked.
2020-06-18 19:27:55 -04:00
David Korth
58ede14a1b [wadresign] main.c: The standard format uses "wad", not "standard". 2020-06-18 19:20:22 -04:00
David Korth
f1af2ec6b8 [wadresign] Added BWF output format.
This allows conversion of retail BWF to debug and vice-versa.

BWFs are no longer converted to WAD format by default. Specify the
`--format` option to select the format.

TODO:
- BWF->BWF was tested. Need to test BWF->WAD.
- Allow converting just the format without recrypting.
2020-06-18 19:18:15 -04:00
David Korth
f8f1872481 [wadresign] resign-wad.c: Fix copying WAD contents that isn't a multiple of 16 bytes.
While the actual contents might not be a multiple of 16 bytes, AES
operates in blocks of 16 bytes, so we have to copy the extra unused
bytes in order to decrypt the data properly.

This fixes recryption of various IOSes (including IOS58-64-v6176.wad)
and possibly other WADs.

This fixes issue #7: wadresign: Re-signing an IOS misses the last 8
data bytes, resulting in a broken WAD.
2020-06-18 17:50:52 -04:00
David Korth
28e0c89724 [libwiicrypto] common.h: Renamed ALIGN() to ALIGN_BYTES().
ALIGN() is already defined in FreeBSD's machine/align.h. It takes a
single parameter (byte count) which it aligns to the system's native
register size.

ALIGN_BYTES() takes a byte count and aligns it to the specified value.

Based on rom-properties commit b9bd306bb57bc28fb94a87865db4870403b73e57.
2020-06-18 17:50:24 -04:00
David Korth
cc131991c1 [wadresign] Improved labelling of BroadOn WAD Format files.
Also indicate the actual WAD types instead of the two-byte codes.
2020-06-01 17:19:57 -04:00
David Korth
5aab0a0540 [doc] COMPILING.md: +cmake for Debian systems. 2020-06-01 17:19:36 -04:00
David Korth
4de6105c56 [wadresign] wad-fns.[ch]: Convert from CRLF to LF line endings.
Not sure how that happened...
2020-02-20 21:32:13 -05:00
David Korth
c0c24c9d09 [wadresign] Increase maximum footer size from 128 KB to 1 MB.
Pokémon Rumble and My Pokémon Ranch both have large footers for some
reason. These might be actual data files instead of build info.

resign-wad.c: Print the footer size, not the TMD size, when printing
an error indicating that the footer size is too big.
2020-02-20 20:35:25 -05:00
David Korth
9a5c2b1815 [librvth] RefFile.hpp: #include <cerrno>
This should fix the Mac OS X build on travis-ci.
2020-02-18 20:44:00 -05:00
David Korth
1c73d0e416 tchar.x: Moved up to src/; synchronized with rom-properties. 2020-02-18 20:43:37 -05:00
David Korth
599b40f069 [rvthtool] list-banks.cpp: Remove an extra newline when listing non-HDD images. 2020-01-06 01:29:15 -05:00
David Korth
4c0b05ea54 [qrvthtool] Removed some unnecessary Q_D() and Q_Q() macros. 2020-01-06 01:26:52 -05:00
David Korth
f12e2f4da3 [qrvthtool] QRvtHToolWindow: Show NHCD status as both a status message and in the frame title.
Frame title shows "!NHCD", "MBR?", or "GPT?", depending on status.
2020-01-06 01:14:38 -05:00
David Korth
3e3e4d5d20 [qrvthtool] QRvtHToolWindow: Disable writing actions if writing is disabled due to a missing NHCD table. 2020-01-06 01:10:56 -05:00
David Korth
b137965cd7 Updated some copyright headers for 2020 and using SPDX-License-Identifier.
All of these files were modified in the previous two commits.
2020-01-06 01:05:15 -05:00
David Korth
c1bf04b661 [qrvthtool] QRvtHToolWindow: Show a warning for missing NHCD tables.
TODO: Actually disable writing operations in the UI if the NHCD table is
missing. Currently, the buttons are still enabled, but attempting to do
a write operation will fail with an error message. (Well, error code,
since it doesn't show an actual message yet...)
2020-01-06 01:02:23 -05:00
David Korth
bbce6e7729 [librvth] Detect if the HDD is partitioned using MBR or GPT if there's no NHCD header.
This usually means the user specified the wrong device.

[rvthtool] list-banks.cpp: Show a warning if the HDD is partitioned
using MBR or GPT.
2020-01-06 00:56:34 -05:00
David Korth
2c654ed80a [rvthtool] Added an option to change the IOS version when importing a disc image.
This is useful for e.g. Super Smash Bros. Brawl, which uses IOS36.
The debug version of IOS36 seems to be MIA, so we can change it to
IOS56 and it basically works, though Apploader will show a warning.

TODO: Detect the IOS mismatch and show an Apploader warning here
when listing bank information.
2019-12-30 16:50:36 -05:00
David Korth
10deb96898 Added a notice saying this program is NOT licensed or endorsed by Nintendo Co., Ltd. 2019-12-30 15:19:12 -05:00
David Korth
63aff8465c [qrvthtool] BankEntryView: Show type and size for empty and unknown banks. 2019-12-30 15:14:59 -05:00
David Korth
0a5e36f73a NEWS.md: Mention the dual-layer import fix. 2019-12-30 15:01:56 -05:00
David Korth
9b85b08517 [qrvthtool] BankEntryView.ui: Set lblGameTitle's vertical size policy to Minimum.
MinimumExpanding made it use too much space if the selected bank was
deleted.
2019-12-30 14:59:06 -05:00
David Korth
e34d19f02d [qrvthtool] QRvtHToolWindow: Use the windowFilePath property.
If we don't set windowTitle, then Qt will use windowFilePath to
automatically prepend the filename portion to the application title.

It will also automatically handle the Mac OS X proxy icon.
(TODO: Adjust our own proxy icon code for this?)
2019-12-30 14:58:13 -05:00
David Korth
a66cd48ad5 [qrvthtool] Added an About dialog.
Based on GCN MemCard Recover's version, with some changes from
rom-properties' KDE rp-config.

The scroll area code from mcrecover is kept here because I think that's
needed for certain Windows versions, whereas rom-properties doesn't use
Qt on Windows.
2019-12-30 14:47:41 -05:00
David Korth
1245d127b7 [cmake] FindNettle.cmake: Use CPU_* instead of CMAKE_SYSTEM_PROCESSOR.
The 32-bit AppVeyor build ended up using lib.amd64, which failed.
2019-12-30 14:29:02 -05:00
David Korth
666f02a98f [qrvthtool] MessageWidgetStack: Use a lambda function instead of QSignalMapper. 2019-12-30 14:21:13 -05:00
David Korth
36aaca94aa [nettle] Updated the Win32 precompiled build of Nettle from 3.4 to 3.5.1.
Reorganized directories to match rom-properties' gettext.win32 layout.
- Single include directory.
- lib.i386 and lib.amd64 library directories.
2019-12-30 14:16:18 -05:00
David Korth
feda58ac7e [extlib] Moved the precompiled Win32 Nettle from win32/ to extlib/nettle.win32/. 2019-12-30 13:33:07 -05:00
David Korth
4200b256b7 [qrvthtool] LanguageMenu: Use lambda functions instead of QSignalMapper.
QSignalMapper is deprecated, and using a lambda function reduces
code size slightly.
2019-12-30 13:30:20 -05:00
David Korth
57cf00cf59 [wadresign] print_wad_info_FILE(): wad_filename is const TCHAR*, not const char*. 2019-12-30 13:29:09 -05:00
David Korth
2716a4eee1 [cmake] FindNettle.cmake: DirInstallPaths is still needed for the install destinations. 2019-12-30 13:17:41 -05:00
David Korth
5f7d92636e [cmake] FindNettle.cmake: ${arch} isn't set by DirInstallPaths anymore. 2019-12-30 13:13:57 -05:00
David Korth
67c4bd045e [cmake] Copied CMake updates from rom-properties. 2019-12-30 13:10:03 -05:00
David Korth
6931de19a2 [rvthtool] import(): s/GCM/disc/ 2019-12-30 12:15:08 -05:00
David Korth
a7d94cade9 [rvthtool] import(): Print the source disc information. 2019-12-30 12:13:15 -05:00
David Korth
78af024d2d [librvth] Also delete the RvtH object after checking for errors.
Fixes some memory leaks that are probably unnoticeable because rvthtool
exits immediately afterwards.
2019-12-30 12:06:48 -05:00
David Korth
e57f4d89d9 [rvthtool] Fix RvtH constructor error checking.
`new RvtH` will *always* return non-NULL. Check the value of `ret`
and rvth->isOpen() instead.
2019-12-30 12:04:46 -05:00
David Korth
7eef42fbfa [librvth] query.c: 1xxxxxxx vs. 2xxxxxxx does NOT necessarily indicate HUA vs. HMA.
Both wired and wireless systems have been seen with 2xxxxxxx
serial numbers.

TODO: Find a reliable method to determine this.
2019-12-30 11:57:53 -05:00
David Korth
7d7e0be020 [librvth] extract.cpp: Fix statvfs() for relative paths without a "./" prefix if the file doesn't exist.
There's no slashes in these relative paths, so we end up trying to
statvfs() a file that doesn't exist, which results in ENOENT.

This is probably a regression from commit 6683d7fbc7.
([librvth] RvtH::extract(): Check free disk space before extracting.)
2019-05-03 20:13:41 -04:00
David Korth
84ddbf6d51 [wadresign] Handle larger tickets correctly for verification and resigning.
cert_fakesign_ticket() and cert_realsign_ticket() now take uint8_t* and
size parameters instead of RVL_Ticket*. This allows us to correctly sign
larger tickets.

TODO: librvth, rvthtool: Handle larger tickets. I haven't seen any larger
tickets in disc images yet, though...
2019-04-07 13:32:53 -04:00
David Korth
5518029a4b Wrap rvth_get_device_serial_number() calls in #ifdef HAVE_QUERY.
This should fix the Mac OS X build on travis-ci.
2019-04-07 13:14:44 -04:00
David Korth
45b0dd818f [wadresign] Handle a larger ticket as a warning instead of an error.
Some broken WAD files have a slightly-too-big ticket for some reason.
2019-04-07 13:11:45 -04:00
David Korth
21caac7e63 [libwiicrypto] cert_store.c: Handle an empty issuer as unknown.
The root certificate isn't found on discs or WADs, so that's not a valid
return value here.

This fixes an issue where certain broken WADs with a NULL byte located
before the issuer showed up as signed by "Root". (Should be unknown.)
2019-04-07 13:05:40 -04:00
David Korth
7e161ee93e [wadresign] main.c: Allow specifying multiple filenames for the 'verify' command. 2019-04-07 13:01:35 -04:00
David Korth
784b28c050 [wadresign] main.c: Allow specifying multiple filenames for the 'info' command.
Also handles no command.
2019-04-07 12:59:56 -04:00
David Korth
c39dd0c9e3 [wadresign] print-info.c: Print the WAD filename before printing information. 2019-04-07 12:54:33 -04:00