Commit Graph

928 Commits

Author SHA1 Message Date
David Korth
abd8543660 [qrvthtool] MSVC 2013 doesn't like concatenated strings within QStringLiteral.
We're still using MSVC 2013 in the AppVeyor build right now.

Also, the APLERR_SIMMEMSIZE_NOT_LE_PHYSMEMSIZE message was missing a space
after the first line. In the rvthtool CLI, a newline is used instead of a
space.
2023-11-25 11:09:08 -05:00
David Korth
bc65a8b5a1 [qrvthtool] Use the multi-string QString::arg() functions instead of repeated arg() calls where possible. 2023-11-25 10:58:28 -05:00
David Korth
22ce6af987 [qrvthtool] Use QStringLiteral instead of QLatin1String, QString::fromLatin1(), or QString::fromUtf8() where possible.
QStringLiteral encodes a QString struct directly into the executable.
This has some more overhead compared to a Latin-1 or UTF-8 string,
but it means nothing needs to be copied into RAM at runtime.

Related changes:
- Consolidate some string building into QStringLiteral().arg().
- Update copyrights for 2023 where applicable.
2023-11-25 10:53:23 -05:00
David Korth
5e0a1ba149 [qrvthtool] QRvtHToolWindowPrivate::getDisplayFileName(): Use a case-insensitive string comparison on Windows.
Similar to qrvthtool.cpp.
2023-11-25 10:49:25 -05:00
David Korth
0f4d834813 [qrvthtool] qrvthtool.cpp: Also fix Qt::CaseInsensitive's position.
It's an argument for filename.startsWith(), not QLatin1String().

This seemingly didn't cause a problem with QLatin1String, since the
constructor takes an optional size parameter. It didn't *work*
correctly, though.

This *does* cause a problem when switching to QStringLiteral.
2023-11-25 10:43:55 -05:00
David Korth
c68875d5c0 [qrvthtool] qrvthtool.cpp: The device name check was backwards.
It's "\\\\.\\PhysicalDrive" for Windows, and "/dev/" for Linux and other
Unix-like operating systems.
2023-11-25 10:41:22 -05:00
David Korth
64e16c74bd [qrvthtool] qrvthtool.cpp: Remove ".desktop" from the desktop filename.
Qt6 complains:

QGuiApplication::setDesktopFileName: the specified desktop file name ends
with .desktop. For compatibility reasons, the .desktop suffix will be
removed. Please specify a desktop file name without .desktop suffix
2023-11-25 10:20:43 -05:00
David Korth
3dc3a473ed [qrvthtool] MessageWidgetStack: Delete all MessageWidgets before clearing d->messageWidgets.
Otherwise, stray deletion signals could trigger messageWidget_destroyed_slot()
after the std::set is deleted, which results in a crash.
2023-11-25 10:17:16 -05:00
David Korth
46430299a7 [qrvthtool] MessageWidgetStack: Use std::set instead of QSet.
It's crashing on Windows if a MessageWidget is visible when closing
the main window. Something is trying to use the std::set (and previously
the QSet) after it's destroyed...
2023-11-25 10:13:51 -05:00
David Korth
43372103cb Port over CMake changes from rom-properties.
- CPUInstructionSetFlags.cmake: Add more CPU architectures.

- DirInstallPaths.cmake: Set ${TARGET_CPU_ARCH} and add more
  CPU architectures.

- FindNETTLE.cmake: Use ${TARGET_CPU_ARCH}.

- SplitDebugInformation.cmake: Add the `mold` workaround.

- options.cmake: Disable split debug by default on macOS.

- platform.cmake: Minor cleanups.

- gcc.cmake: Code coverage cleanup, check for "--no-undefined" and
  "--no-allow-shlib-undefined" (but only allow them on Linux),
  and check for "-ftree-vectorize".

- msvc.cmake:
  - Add: /we4477 /MP /guard:cf /guard:ehcont /permissive-
  - On i386 only: /SAFESEH
  - Disable /Zc:externC /Zc:noexceptTypes on Clang.
  - Disable thread-safe statics only on i386 and amd64.

- win32-gcc.cmake, win32-msvc.cmake:
  - Various flag changes.
2023-11-25 10:09:48 -05:00
David Korth
6b49dfaa0f CMakeLists.txt: FIXME: Windows SDK prior to 10.0.18362.0 has issues when compiling as either C11 or C17.
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8816,5): warning C5105: macro expansion producing 'defined' has undefined behavior
C:\Program Files (x86)\Windows Kits\8.1\Include\um\oaidl.h(473,17): warning C5103: pasting '/' and '/' does not result in a valid preprocessing token
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\wtypes.h(742,1): message : in expansion of macro '_VARIANT_BOOL'
C:\Program Files (x86)\Windows Kits\8.1\Include\um\oaidl.h(473,17): error C2059: syntax error: '/'

Force C99 when compiling with MSVC for now.
2023-11-25 09:44:46 -05:00
David Korth
af560c4ee9 Use CMAKE_<LANG>_STANDARD instead of custom macros.
CMake 3.1 added CMAKE_<LANG>_STANDARD, which allows CMake to determine
what flags are needed to select a particular language version.

Set it to C17 and C++17. Previously, we were using C11 and C++11,
though gcc11 switched the default C++ version to C++17. The custom
macro handled this by not adding flags for C++, but it still added
the C11 flag, which prevented use of C17.

Ported over from rom-properties.
2023-11-25 09:43:53 -05:00
David Korth
f43a461c35 [rvthtool] verify.cpp: Fix a few TCHAR errors. [missing _T() macros]
verify.cpp(180,13): warning C4477: 'wprintf' : format string '%s' requires
an argument of type 'wchar_t *', but variadic argument 3 has type 'const char *'

verify.cpp(182,13): warning C4477: 'wprintf' : format string '%s' requires
an argument of type 'wchar_t *', but variadic argument 2 has type 'const char *'
2023-11-25 09:37:14 -05:00
David Korth
95d3c50b7f .gitignore: Don't ignore .a files.
Add the 64-bit versions of libhogweed.dll.a and libnettle.dll.a
to the repository.

NOTE: This was originally done on 2022/08/07 06:25 PM EDT, but I forgot
to commit the changes...
2023-11-25 09:31:53 -05:00
Cynthia
595be12d74 use hex specifiers 2023-05-06 10:35:41 -06:00
Cynthia
53bdcd6b4f added show-table command, for inspecting NHCDTable
since you mentioned wanting to add in a command for repairing a
NHCD Bank Table, I figured a command to inspect your current NHCD
Bank Table would also be useful.

even in the absence of a repair command, it still would be useful
to see the bank table status. I was particularly curious if my RVT-H
had it's bank fully zero'd or if only a few values were unexpected.

this only adds the command to the CLI, as displaying raw bytes in a
QT window didn't feel like the best way to print that information.
If you want it to be there a UI before merging I understand, and can try
playing around with QT to get something decent.
2023-05-04 12:39:55 -06:00
David Korth
a2bcb8ac1e [librvth] Reader.cpp: Add some more SDK header detection code from rom-properties. 2022-09-17 21:11:33 -04:00
David Korth
4179a5dcdf [rvthtool] verify.cpp: Print better messages for disc images. 2022-08-16 01:04:26 -04:00
David Korth
d92bfecd7b [rvthtool] verify.cpp: Print the total number of hash errors.
[librvth] RvtH::verifyWiiPartitions(): Accept a pointer to a 5-element
unsigned int array to get the total number of hash errors. This is for
both actual hash errors and hash table copy errors.
2022-08-16 01:00:42 -04:00
David Korth
5601647630 [rvthtool] query.c: #include "tcharx.h"
The no-query path uses _fputts(), which requires tcharx.h on Linux.
2022-08-16 00:48:49 -04:00
David Korth
1c3b110143 [doc] disc_image.md: Add some missing backticks for monospaced text. 2022-08-10 22:33:09 -04:00
David Korth
93489d8561 [librvth] query_udev.c: Actually check listener->stop to stop the listener thread.
Otherwise, if qrvthtool's "Select Device" dialog is opened and closed,
and then an RVT-H Reader is connected or disconnected, the program will
crash, since it tries sending a message to the now-deleted dialog.
2022-08-08 18:51:46 -04:00
David Korth
99917b6273 [qrvthtool] CMakeLists.txt: Exclude QtSvg when copying the Windows DLLs.
windeployqt copies over QtSvg even though we're not using it:

  Creating C:\projects\rvthtool\build\src\qrvthtool\windeployqt...
  C:\projects\rvthtool\build\bin\Debug\qrvthtool.exe 32 bit, debug executable
  Adding Qt5Svg for qsvgicond.dll
  Skipping plugin qtvirtualkeyboardplugind.dll due to disabled dependencies.
  Direct dependencies: Qt5Core Qt5Gui Qt5Widgets
  All dependencies   : Qt5Core Qt5Gui Qt5Widgets
  To be deployed     : Qt5Core Qt5Gui Qt5Svg Qt5Widgets

Explicitly disable QtSvg to prevent it from being copied over.
2022-08-08 00:32:12 -04:00
David Korth
a1e23b5880 [qrvthtool] CMakeLists.txt: Add Nettle includes for AboutDialog.
This should fix the AppVeyor build.
2022-08-08 00:17:34 -04:00
David Korth
9b81bcfd6e appveyor.cmd: The MSVC 2013 VMs only have Qt 5.8.
I'd need to switch to the MSVC 2019 VMs for Qt 5.15.2 or Qt 6.
2022-08-08 00:11:28 -04:00
David Korth
a65321428e appveyor.cmd: Try to find *.cmake in C:\Qt\. 2022-08-08 00:09:05 -04:00
David Korth
099065207d appveyor.cmd: Try to fix Qt5 build issues on AppVeyor.
It doesn't set Qt5_DIR properly for some reason.
2022-08-08 00:00:30 -04:00
David Korth
1296392e2f appveyor.cmd: Set Qt5_DIR to build qrvthtool. 2022-08-07 21:36:24 -04:00
David Korth
011e261972 [cmake] FindNETTLE.cmake: Set NETTLE_FOUND and HAVE_NETTLE on Windows.
Otherwise, the include paths aren't set correctly, and the AppVeyor
build fails.
2022-08-07 21:33:31 -04:00
David Korth
be979181cc [librvth] rvth_init_BankEntry_AppLoader(): Verify that lba_start is in range.
Corrupted disk images could put it out of range, resulting in an
assertion failure.
2022-08-07 20:06:18 -04:00
David Korth
0ee8f055f9 [qrvthtool] AboutDialog: Use RichText in the Libraries tab.
Also optimized linebreak usage to be more constant.

Code size difference: (64-bit Gentoo Linux, gcc-12.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
  17797       8       0   17805    458d AboutDialog.cpp.o [before]
  16616       8       0   16624    40f0 AboutDialog.cpp.o [after]
  -1181       0       0   -1181    -49d Difference
2022-08-07 19:43:13 -04:00
David Korth
994ae2046b [qrvthtool] AboutDialog: Display the GNU Nettle version.
[libwiicrypto] config.libwiicrypto.h.in: Nettle version macros.

[cmake] CheckNettle2or3.cmake: Check if it's Nettle 3.x.

TODO: The Libraries tab needs to be RichText now.
2022-08-07 19:33:45 -04:00
David Korth
fa08e296c8 [cmake] FindNETTLE.cmake: s/Nettle/NETTLE/
This fixes a CMake warning:

CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (Nettle)
  does not match the name of the calling package (NETTLE).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/libs/FindNETTLE.cmake:22 (find_package_handle_standard_args)
  src/CMakeLists.txt:74 (FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.
2022-08-07 19:15:00 -04:00
David Korth
31ee8efcfb [cmake] Renamed 'modules' to 'libs'. 2022-08-07 19:13:14 -04:00
David Korth
8b6e4377e5 [nettle] Updated the Win32 precompiled build of Nettle from 3.7.2 to 3.8.1.
Compiled using gcc-12.1.0 and MinGW-w64 10.0.0.
2022-08-07 19:10:18 -04:00
David Korth
9431c1ed57 [qrvthtool] UnityLauncher.cpp: Update the .desktop filename.
The .desktop fileanme was changed last week, but UnityLauncher.cpp wasn't
updated with the new filename, which broke the progress bar functionality.

This fixes a regression from commit 1a992e41ff.
([qrvthtool] CMakeLists.txt: Use macros for the XDG paths.)
2022-08-07 19:05:09 -04:00
David Korth
7f5079b9ff [qrvthtool] QRvtHToolWindow.ui: Add the "Close" button to the toolbar. 2022-08-07 19:00:53 -04:00
David Korth
a3f197c32a [qrvthtool] Install Qt DLLs when running cpack on Windows builds.
References:
- https://stackoverflow.com/questions/41193584/deploy-all-qt-dependencies-when-building
- https://stackoverflow.com/a/41199492
2022-08-07 19:00:41 -04:00
David Korth
41977b819b [cmake] DirInstallPaths.cmake: Don't install to architecture-specific subdirectories.
This is needed for rom-properties, since we have to provide both
32-bit and 64-bit DLLs for proper shell integration, but rvthtool
is only packaged for a single architecture.
2022-08-07 18:02:01 -04:00
David Korth
ae7ef2d241 [rvthtool] list-banks.cpp: Another TCHAR fix.
src\rvthtool\list-banks.cpp(387,12): warning C4477: 'wprintf' :
	format string '%s' requires an argument of type 'wchar_t *',
	but variadic argument 3 has type 'const char *'
2022-08-07 17:58:54 -04:00
David Korth
911fd8f9ab [qrvthtool] CMakeLists.txt: MessageSound.hpp doesn't have any QObjects.
Don't wrap it using QT_WRAP_CPP().
2022-08-07 17:57:38 -04:00
David Korth
38673d19f5 [debian] *.install: Remove the leading slashes.
Not needed, and can potentially cause issues when building.
2022-08-07 15:08:31 -04:00
David Korth
a3ed8f82cd [debian] Added the rvthtool-lang package.
TODO: After 2.0, switch to gettext like rom-properties, and localize
the command line tools?
2022-08-07 15:08:03 -04:00
David Korth
d61158dbbc [rvthtool] Need to use fputs() for rvth_error().
TODO: Add a TCHAR version.
2022-08-06 13:07:45 -04:00
David Korth
767126305d [rvthtool] main.c: Fix some more TCHAR string concatenation issues.
This one was caused by missing _T() macros.
2022-08-06 13:03:52 -04:00
David Korth
a5029d9788 [qrvthtool] LanguageMenu: d->locale =, not ==.
Found using scan-build from clang-14.0.6:

src/qrvthtool/widgets/LanguageMenu.cpp:249:13: warning: equality comparison result unused [-Wunused-comparison]
                d->locale == locale;
                ~~~~~~~~~~^~~~~~~~~
src/qrvthtool/widgets/LanguageMenu.cpp:249:13: note: use '=' to turn this equality comparison into an assignment
                d->locale == locale;
                          ^~
                          =
2022-08-06 12:56:59 -04:00
David Korth
1a9f3d9452 [libwiicrypto] bin2h.c: free(basename) before returning.
Found using scan-build from clang-14.0.6:

src/libwiicrypto/bin2h.c:93:3: warning: Potential leak of memory pointed to by 'p' [unix.Malloc]
                fprintf(stderr, "*** ERROR creating destination file: %s\n", strerror(errno));
                ^~~~~~~
2022-08-06 12:55:44 -04:00
David Korth
54b54ae20d MSVC didn't like turning RP_GIT_VERSION into a TCHAR string.
src\nusresign\main.c(136): error C2308: concatenating mismatched strings
          Concatenating wide "git: " with narrow "(no branch)"

TODO: Get this working.
2022-08-06 11:35:49 -04:00
David Korth
1445d532b3 Consolidate multiple stdout/stderr function calls by using TCHAR more consistently.
This lets us combine e.g. fputs() + _fputts() + fputs() into a single
_fputts(), which reduces overhead. It also makes it slightly faster on
Windows, since it won't have to do ANSI conversion for these strings.

Code size differences: (64-bit Gentoo Linux, gcc-12.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
 108526    2980      80  111586   1b3e2 rvthtool [before]
 108014    2980      80  111074   1b1e2 rvthtool [after]
   -512       0       0    -512    -200 Difference

   text    data     bss     dec     hex filename
  57537    1992      80   59609    e8d9 wadresign [before]
  57334    1984      80   59398    e806 wadresign [after]
   -203      -8       0    -211     -d3 Difference

   text    data     bss     dec     hex filename
  53384    1976      80   55440    d890 nusresign [before]
  53464    1976      80   55520    d8e0 nusresign [after]
    +80       0       0     +80     +50 Difference

Interestingly, nusresign only had one change, and it caused the code size
to go up by a bit.
2022-08-06 11:15:23 -04:00
David Korth
57da28509f [qrvthtool] CMakeLists.txt: Actually install the AppStream metainfo XML file. 2022-08-06 11:11:17 -04:00