Commit Graph

928 Commits

Author SHA1 Message Date
David Korth
1a204f9cbc [debian] Update qrvthtool; add wadresign and nusresign packages.
The qrvthtool package now includes the .desktop file, icons, and the
metainfo XML file.
2022-08-06 11:10:07 -04:00
David Korth
9fcc17d6bf [qrvthtool] Add an AppStream metainfo XML.
Unlike rom-properties, this is only installed as part of qrvthtool.

The metainfo XML lists all of the installed executables, not just
qrvthtool.
2022-08-06 11:05:16 -04:00
David Korth
01334c3a97 [cmake] gcc.cmake: Reorder DT_RELR detection to show the status message before checking ld. 2022-08-06 02:05:28 -04:00
David Korth
420fa1bc31 [cmake] platform/gcc.cmake: Initial support for detecting DT_RELR.
Currently only supported if using glibc-2.36 and binutils-2.38.

TODO:
- Detect more systems with DT_RELR.
- Handle cross-compiling better?
2022-08-05 00:43:45 -04:00
David Korth
08e76cc03c [librvth] recrypt.cpp: Add more reader->flush() calls when writing. 2022-08-04 23:36:04 -04:00
David Korth
1a992e41ff [qrvthtool] CMakeLists.txt: Use macros for the XDG paths.
Rename the .desktop file to com.gerbilsoft.qrvthtool.desktop.

TODO: Maybe com.gerbilsoft.rvthtool.qrvthtool.desktop? Not that
I'd be making a GTK+ UI frontend anytime soon...
2022-08-03 18:44:01 -04:00
David Korth
6e6ce69afe [librvth] RefFile: Un-inline RefFile::flush().
HANDLE is defined in Windows SDK headers, and we don't want to include
those in RefFile.hpp, so move it to RefFile.cpp.
2022-08-02 00:49:30 -04:00
David Korth
a2093854f2 [locale] Updated the translation files using lupdate.sh. 2022-08-02 00:18:54 -04:00
David Korth
7afdb08d9a [qrvthtool] AboutDialog: +'.' 2022-08-02 00:15:48 -04:00
David Korth
f35f2c1513 [rvthtool] list-banks.cpp: free() the string from rvth_get_device_serial_number() after it's no longer needed.
This fixes a small memory leak.
2022-08-01 23:58:07 -04:00
David Korth
223a67f81b [qrvthtool] Show a status bar message when opening an RVT-H Reader device.
It takes around 2-3 seconds to open for me for some reason.

Also cleaned up some stuff with native separators. librvth expects
filenames to use native separators, but QFileDialog does not.
2022-08-01 21:52:57 -04:00
David Korth
dd2fdeea98 [librvth] extract.cpp, copyToGcm(): Disable the extra flushes.
It's not as important when extracting from an RVT-H Reader as it is
when importing *to* an RVT-H Reader. This should improve performance
by a bit in some cases.
2022-08-01 21:45:57 -04:00
David Korth
78d938e25d [librvth] extract.cpp: Call flush() after every write().
This is basically the same as O_SYNC, though we have up to a 1 MB buffer
that gets written to disk at once.

I tried with 32 MB flushing at first, but it just resulted in the
progress bar going up in 32 MB increments with freezes due to the
32 MB hitting the I/O cache first.

RefFile::flush(): Call fsync() on Linux and FlushFileBuffers() on Windows
to ensure the file is actually flushed to disk. fflush() only clears the
stdio buffers.

TODO: Use Win32 and/or POSIX I/O directly? I tried this with open(),
lseek(), read(), write(), etc., but it wasn't able to read the ticket/TMD
signatures for some reason. This solution should be good enough for now.
2022-08-01 21:24:03 -04:00
David Korth
08a108b6bf [librvth] RefFile::makeWritable(): FIXME: O_SYNC breaks recryption with New Super Mario Bros. Wii.
Not sure why this happens...

TODO: Rewrite RefFile to use raw I/O instead of stdio, then use O_DIRECT
with 512-byte aligned buffers and maybe O_SYNC again.
2022-08-01 20:51:50 -04:00
David Korth
12609b8a62 [qrvthtool] QRvtHToolWindow::workerObject_finished(): Call d->updateActionEnableStatus().
Needed to ensure the buttons are in the correct state after
importing a disc image.
2022-08-01 20:07:30 -04:00
David Korth
af5b6c59c6 [qrvthtool] QRvtHToolWindow: Update BankEntryView after importing a bank.
TODO: Occurs after importing *or* extracting. We should limit it
to only update after importing.

Added some convenience functions to get the selected bank entry,
either as a bank number or as a bank entry.
2022-08-01 20:00:49 -04:00
David Korth
f006b2fa26 [qrvthtool] RvtHModel: Increase the V component of "deleted" banks when using dark themes. 2022-08-01 19:53:45 -04:00
David Korth
76c1511ba2 [qrvthtool] qrvthtool.desktop: Remove Version; add StartupNotify and Terminal.
Version indicates the Desktop Entry Specification version,
not the application version.
2022-08-01 19:41:16 -04:00
David Korth
624a4a4c35 [qrvthtool] QRvtHToolWindow: Call d->updateActionEnableStatus() when necessary.
Otherwise, the actions don't get enabled/disabled properly.

Among other things, the "Close" action remains enabled on startup with
no device loaded, and remains enabled after closing a device in some
cases.
2022-08-01 19:18:24 -04:00
David Korth
c853e94705 [qrvthtool] CMakeLists.txt: s/QT_ADD_DBUS_INTERFACE/QT_ADD_DBUS_INTERFACES/
Fixes D-Bus interface generation on Qt 5.5.1.
2022-08-01 19:11:21 -04:00
David Korth
8b8cc807e5 [qrvthtool] CMakeLists.txt: Fix the QT_WRAP_*() functions on Qt 5.5.1.
QT_WRAP_CPP is somehow being detected as a "command", even though
it's not a valid function. Use a version check instead.

This fixes QT_WRAP_*() issues on Xubuntu 16.04, which has Qt 5.5.1.
2022-08-01 19:07:56 -04:00
David Korth
1d98eb4eee [qrvthtool] SelectDeviceDialog.cpp: #include <cassert> 2022-08-01 19:01:34 -04:00
David Korth
e0b94c8eda [qrvthtool] LanguageMenu.cpp: #include <assert>: fix QString::split() for Qt <5.14. 2022-08-01 18:45:44 -04:00
David Korth
07c078dcd1 [qrvthtool] qrvthtool.cpp: QCoreApplication::setDesktopFileName() was added in Qt 5.7. 2022-08-01 18:41:23 -04:00
David Korth
2e04a36303 [locale] CMakeLists.txt: Fix QT_ADD_TRANSLATION check.
Fixes the build on Qt5 versions earlier than 5.15.
2022-08-01 18:29:52 -04:00
David Korth
93b8a615fc [qrvthtool] Fix the window icon on Wayland.
On Wayland systems, the window icon is obtained from the .desktop file,
so we need to call QGuiApplication::setDesktopFileName().

QRvtHToolWindow.cpp: Update the Mac proxy icon comment.
2022-07-24 05:28:42 -04:00
David Korth
0ac25bfd59 NEWS.md: Mention nusresign. 2022-07-20 22:00:42 -04:00
David Korth
e823bc7b27 [qrvthtool] LanguageMenu: Hide the menu if only one language is available.
- Moved init() into the private class constructor.
- Moved actLanguageSysDefault creation from retranslateSystemDefault()
  to the private class constructor.
2022-07-15 18:52:19 -04:00
David Korth
08e3f66cee Fix a bunch of PVS-Studio warnings.
- Use fseeko()/ftello() instead of fseek()/ftell().
- Explicitly check memcmp() != 0.
- Reorganized a few structs to use less memory.
- Save pointers instead of calling functions repeatedly.
- Remove NULL checks for delete.

MessageWidget::paintEvent(): Reduce the scope of painter so it's only
constructed when it's needed.

QRvtHToolWindow::openRvtH(): Properly delete rvth_tmp instead of deleting
d->rvth again, which may result in a double-free.

QRvtHToolWindow::on_actionOpenDevice_triggered(): delete selectdeviceDialog
when we're done using it.

SelectDeviceDialog.hpp, DeviceQueryData(): Initialize size in the zero-arg
constructor.

libwiicrypto/cert.c, cert_fakesign_ticket(): Use size_t for signing_offset.
2022-07-14 23:23:31 -04:00
David Korth
2d0c965422 Port over the off64_t changes from rom-properties.
Use off64_t where necessary.

config.libc.h is now force-included in every translation unit.

FIXME: Some things are truncating 64-bit file sizes to uint32_t...
2022-07-14 02:53:17 -04:00
David Korth
484efeeec9 [librvth] query_udev.c, rvth_listener_thread(): Missing 'pErr' parameter. 2022-07-14 02:28:18 -04:00
David Korth
f588ffd8c2 [nusresign, wadresign] main.c: Remove the stray ')'s. 2022-07-14 02:26:18 -04:00
David Korth
35710d7b1c [nusresign, wadresign] main.c: Don't use _T() with fputs(). 2022-07-14 02:12:27 -04:00
David Korth
557dd540e3 [nusresign, wadresign] main.c: _T() doesn't seem to work with the RP_GIT_* strings.
The RP_GIT_* strings are made up of multiple strings themselves, so MSVC
gets confused.

From the AppVeyor build:

src\nusresign\main.c(135): error C2308: concatenating mismatched strings [C:\projects\rvthtool\build\src\nusresign\nusresign.vcxproj]
          Concatenating wide "NUS Resigner v1.1.1+
  Copyright (c) 2018-2022 by David Korth.
  git: " with narrow "(no branch)"
2022-07-14 02:11:10 -04:00
David Korth
367d93997e [librvth] query_udev.c: rvth_parse_udev_device(): Return an error code if malloc() fails.
Similar to the query_win32.c version.
2022-07-14 02:05:51 -04:00
David Korth
7fe60c5c8e [librvth] query_win32.c: Split parsing the device node out of rvth_query_devices().
Similar to the query_udev.c version.
2022-07-14 02:05:26 -04:00
David Korth
37833e42e9 [nusresign, wadresign] Use TCHAR printf() functions where possible.
This lets us consolidate sets of fputs() and printf()-style functions
into a single printf(), which reduces code size. Note that it will
definitely increase the size on Windows due to more UTF-16 strings.

- Converted some more printf()-style functions to fputs()-style.
  gcc does this automatically if possible, but MSVC does not.

- Updated copyright years.

[nusresign] main.c: Remove a few extra leading spaces in print_help().

[nusresign] resign-nus.cpp:
- Removed a line of debugging code.
- Ticket type change from Disc to Installable should be on stdout,
  not stderr.

TODO: There's a few more functions that need TCHAR conversions, but they
require changing more code elsewhere.

Code size differences: (64-bit Gentoo Linux, gcc-12.1.0, release build, no LTO)
[NOTE: Windows builds will increase due to more TCHAR usage.]

   text    data     bss     dec     hex filename
   3151     160       0    3311     cef main.c.o [wadresign, before]
   3132     160       0    3292     cdc main.c.o [wadresign, after]
    -19       0       0     -19     -13 Difference

   text    data     bss     dec     hex filename
   6581       0       0    6581    19b5 print-info.c.o [wadresign, before]
   6146       0       0    6146    1802 print-info.c.o [wadresign, after]
   -435       0       0    -435    -1b3 Difference

   text    data     bss     dec     hex filename
  14164       8       0   14172    375c resign-wad.cpp.o [wadresign, before]
  11888       8       0   11896    2e78 resign-wad.cpp.o [wadresign, after]
  -2276       0       0   -2276    -8e4 Difference

   text    data     bss     dec     hex filename
   2561      96       0    2657     a61 main.c.o [nusresign, before]
   2526      96       0    2622     a3e main.c.o [nusresign, after]
    -35       0       0     -35     -23 Difference

   text    data     bss     dec     hex filename
   8787       8       0    8795    225b print-info.cpp.o [nusresign, before]
   8574       8       0    8582    2186 print-info.cpp.o [nusresign, after]
   -213       0       0    -213     -d5 Difference

   text    data     bss     dec     hex filename
   5374       8       0    5382    1506 resign-nus.cpp.o [nusresign, before]
   5341       8       0    5349    14e5 resign-nus.cpp.o [nusresign, after]
    -33       0       0     -33     -21 Difference
2022-07-14 01:33:32 -04:00
David Korth
6eafbf3ff4 [librvth] query: Add is_readable, is_writable, and not_readable_error.
This lets the query interface know if the device is accessible.

NOTE: Currently only implemented on Linux/udev.

[rvthtool] query.c: On Linux, print the device accessibility.
If not accessible, the access() error will be displayed.

TODO: qrvthtool; Windows support.
2022-07-14 00:09:00 -04:00
David Korth
3cb4f1e78f Add stdboolx.h.in from rom-properties.
Add #include "stdboolx.h" where necessary.

[libwiicrypto] common.h: Remove our own stdbool implementation.
2022-07-13 23:59:52 -04:00
David Korth
eeb9ae7b67 [wadresign] resign-wad.cpp: Fix fputs() shenanigans. 2022-07-13 22:33:46 -04:00
David Korth
69faaee2fc [wadresign] resign-wad.cpp: Use unique_ptr<>; optimize some printf()s.
Use _fputts(_tcserror()) instead of using strerror() as an argument
to fprintf().
2022-07-13 20:31:10 -04:00
David Korth
8095c22d10 [wadresign] resign-wad.c -> resign-wad.cpp
This will make it easier to simplify some things by using e.g.
unique_ptr<>, similar to nusresign.
2022-07-13 20:13:59 -04:00
David Korth
31bd1567c6 [qrvthtool] SelectDeviceDialog: Hacky method for auto-refresh on Windows.
Listen for device notifications. If we get a notification that a disk
device was added or removed, refresh the entire list. This isn't as
nice as the udev method, since that one only adds or removes the
specific device, but it works for now.

TODO: Make the Windows one a listener by creating a hidden window?
2022-07-13 20:06:46 -04:00
David Korth
7a7899a9ec [qrvthtool] BankEntryView: Some minor improvements.
- Don't cache the QLocale.

- Iterate through q->children() to hide all the widgets instead of
  hard-coding them.

- QEvent::LocaleChange should retranslate the UI instead of just
  caching the locale.
2022-07-13 20:06:22 -04:00
David Korth
ce85d0481e Ported over C99 and C++11 compatibility changes from rom-properties.
Among other things, we're no longer defining `nullptr` in C code,
so remove all uses of `nullptr` in C code.
2022-07-13 19:26:14 -04:00
David Korth
3c0574dabc [locale] Updated the translation files using lupdate.sh. 2022-07-13 01:22:43 -04:00
David Korth
41516609fd [qrvthtool] BankEntryView: Show megabytes instead of gigabytes.
Wii discs can't be larger than around 8 GB, so we should show megabytes
as the largest unit instead of gigabytes.
2022-07-13 01:21:48 -04:00
David Korth
b1b24cfd7b [qrvthtool] QRvtHToolWindow: s/automaticlaly/automatically/ 2022-07-13 01:21:33 -04:00
David Korth
8c87baca05 [qrvthtool] QRvtHToolWindow: Mark the UI as busy when opening the RVT-H Reader.
markUiBusy(), markUiNotBusy(): Call QCoreApplication::processEvents()
to make sure the mouse cursor actually gets set, since opening the
RVT-H Reader is a blocking operation.
2022-07-13 01:15:04 -04:00
David Korth
fa990d126e [qrvthtool] TranslationManager: s/MemCard Recover/rvthtool/ 2022-07-13 01:08:22 -04:00