Commit Graph

12478 Commits

Author SHA1 Message Date
David Korth
5538794477 Missed a few TinyXML2 remnants. Updated for PugiXML. 2025-04-02 00:19:34 -04:00
David Korth
e92eeeea63 Merge branch 'feature/pugixml.v2' 2025-04-02 00:17:18 -04:00
David Korth
8f4648eb38 [libromdata/tests] ImageDecoderTest: Change the max file size constants to off64_t.
Fixes a compile warning (error) in the 64-bit MSVC 2015 build on AppVeyor:

extlib\googletest\googletest\include\gtest/gtest.h(1438): error C2220: warning treated as error - no 'object' file generated [build\src\libromdata\tests\ImageDecoderTest.vcxproj]
  src\libromdata\tests\img\ImageDecoderTest.cpp(297): note: see reference to function template instantiation 'testing::AssertionResult testing::internal::CmpHelperLE<off64_t,std::size_t>(const char *,const char *,const T1 &,const T2 &)' being compiled
          with
          [
              T1=off64_t,
              T2=std::size_t
          ]
extlib\googletest\googletest\include\gtest/gtest.h(1438): warning C4018: '<=': signed/unsigned mismatch [build\src\libromdata\tests\ImageDecoderTest.vcxproj]
2025-04-01 23:19:24 -04:00
David Korth
e984a074ce [libromdata] WiiUPackage, Wim, EXE_PE: Show warnings if XML parsing failed or if XML parsing is disabled.
WiiUPackage already showed a message if XML parsing is disabled, but
none of the other classes did.

TODO: EXE_PE: Check if a manifest is present before showing this message.
2025-04-01 20:39:47 -04:00
David Korth
bf94073355 [libromdata] WiiUPackagePrivate::getProductCodeAndApplType_xml(): Add a DelayLoad check here.
The other XML functions had DelayLoad checks, but not this one, so if
pugixml.dll (or previously tinyxml-11.dll) was missing, the program
would crash.
2025-04-01 20:39:47 -04:00
David Korth
096c78f48e [libromdata] Win_xml.cpp: Add DelayLoad checks. 2025-04-01 20:39:47 -04:00
David Korth
aee196afa8 [libromdata] EXE_delayload.cpp: Fix the DelayLoad check.
A new PugiXML document isn't technically "empty" because it still has
a root node. Check that the root node is, in fact, a root node instead.
2025-04-01 20:25:33 -04:00
David Korth
64218c8af6 [libromdata] XMLDocument -> xml_document 2025-04-01 20:16:51 -04:00
David Korth
745a18f9d3 [libromdata] Wim: Split the XML parsing code into Wim_xml.cpp. 2025-04-01 20:14:54 -04:00
David Korth
55c04f9e78 [libwin32common] DelayLoadHelper.c: Fix pugixml's DLL filename.
Was missing a '.' .
2025-04-01 20:13:17 -04:00
David Korth
fd88c84ead [libwin32darkmode] NppDarkMode_TabControl_drawItem(): Cast _tcslen() to int.
src\libwin32darkmode\NppDarkMode.cpp(145,37): warning C4267: 'argument':
conversion from 'size_t' to 'int', possible loss of data
2025-04-01 20:06:41 -04:00
David Korth
fa8f35dc78 [librpbyteswap] byteswap_neon.c: Use vrev instead of vtbl.
I initially used vtbl because it was a direct port from the SSSE3 version,
which uses pshufb. It turns out ARM NEON has another instruction, vrev,
that's specifically designed for byteswapping. vrev has the following
advantages over vtbl:

- No shuffle mask (lookup table) is needed.
- Has 128-bit vector versions on ARMv7. (Or, at the very least, MSVC
  for ARMv7 has 128-bit vector versions. It didn't have them for the
  vtbl instruction when I tried it out.)

Tested on my phone (Pixel 8 Pro) and ByteswapTest passed with vrev.

Fixes #443: Use VREV for byteswapping with NEON?
Reported by @ccawley2011.
2025-04-01 19:40:42 -04:00
David Korth
3ab17acba1 NEWS.md: Mention the XML parser switch. 2025-04-01 19:19:24 -04:00
David Korth
95e1b19473 [extlib] Enable pugixml's built-in DLL postfix option.
pugixml uses "_d" instead of "d".

[pugixml] CMakeLists.txt: Disable options. The cmake_dependent_option()
setup for PUGIXML_USE_POSTFIX prevented the postfix from working because
the top-level source directory is not the same as PugiXML's directory.

[libwin32common] DelayLoadHelper: Handle PugiXML's "_d" postfix.

DelayLoadHelper.cmake has new variables for debug/release only DLLs,
which is used for PugiXML due to the different debug postfix.
2025-04-01 19:19:20 -04:00
David Korth
55f86d1158 Add an internal copy of PugiXML and remove TinyXML2 completely.
TODO:
- Add the 'd' postfix to the debug DLL.
- Configure PugiXML options and hide them from the user, since these are
  configured by rom-properties.
2025-04-01 19:19:20 -04:00
David Korth
74007ac6f5 [gtk,kde,win32] AboutTab: Switch from TinyXML2 to PugiXML.
Add the PugiXML include path to the GTK and KDE targets
It was already added in the Windows target (as TinyXML2).

This likely didn't cause any problems before because TinyXML2 is usually
installed system-wide on Linux systems.
2025-04-01 19:19:20 -04:00
David Korth
1b2137f3d5 [libromdata] Use angle brakcets for #include <pugixml.hpp> instead of double-quotes.
On Linux systems, PugiXML is usually installed system-wide.
2025-04-01 19:19:20 -04:00
David Korth
5aa2d7a43a [libromdata] WiiUPackage, EXE: s/TinyXML/PugiXML/ 2025-04-01 19:19:20 -04:00
David Korth
65f466223a [libromdata] CMakeLists.txt: Remove the HAVE_TINYXML2_XMLELEMENT_INTTEXT check.
TODO: Replace the TinyXML2 check with PugiXML, and add an internal
copy of PugiXML.
2025-04-01 19:19:20 -04:00
David Korth
f9e9e497fb [libromdata] Update the DelayLoad check to look for PugiXML instead of TinyXML2. 2025-04-01 19:19:20 -04:00
David Korth
a325a53183 [libromdata] EXE_manifest.cpp: Port to PugiXML.
PugiXML's in-place functionality also works here, since EXE manifests
use UTF-8 encoding, not UTF-16LE.

TODO: Switch the DelayLoad check to PugiXML.
2025-04-01 19:19:20 -04:00
David Korth
0f301f8102 [libromdata] WiiUPackage_xml.cpp, Wim.cpp: Use xml_size more consistently. 2025-04-01 19:19:20 -04:00
David Korth
4b9f91bf74 [libromdata] WiiUPackage_xml.cpp: Port to PugiXML.
PugiXML's in-place functionality actually works here, since Wii U XMLs
use UTF-8 encoding, not UTF-16LE.

TODO: Switch the DelayLoad check to PugiXML.
2025-04-01 19:19:20 -04:00
David Korth
a27a08a58f [libromdata] WimPrivate::addFields_XML(): "Short read?" -> "Read error." 2025-04-01 19:19:20 -04:00
David Korth
aeaf77ee27 [libromdata] WimPrivate::addFields_XML(): Transfer buffer ownership to PugiXML.
Need to switch from std::unique_ptr<> to PugiXML's own allocation
and deallocation functions.

Note that because we're converting from UTF-16LE to UTF-8, PugiXML
will end up deallocating our buffer immediately after the text
conversion, so it isn't really "in-place". For other RomData subclasses
that use UTF-8 XML files, e.g. WiiUPackage, it *will* be in-place.
2025-04-01 19:19:20 -04:00
David Korth
fded19cd7d Add libpugixml-dev to appveyor-dpkg.sh and debian/control.
This will allow us to test the PugiXML code on AppVeyor.

TODO:
- Add an internal copy of PugiXML.
- Port everything from TinyXML2 to PugiXML.
- Remove TinyXML2.
2025-04-01 19:19:20 -04:00
David Korth
c9ec4da9d0 [libromdata] WimPrivate::addFields_XML(): Simplify some stuff by taking advantage of xml_text::as_string(const char*).
This lets us specify a default value if the element either doesn't exist
or has no text.

This actually does have a visible change. Previously, if an image was
missing NAME, DESCRIPTION, DISPLAYNAME, or DISPLAYDESCRIPTION, those
fields would show up blank. If they existed but had no text, they'd
show up with "(none)". With this change, they show up as "(none)" if
they either don't exist or have no text.
2025-04-01 19:19:20 -04:00
David Korth
1182858ff3 [libromdata] Wim: Port to PugiXML.
PugiXML's API is a lot more straightforward than TinyXML's:
- Uses handle objects instead of pointers. (The handles are essentially
  structs containing pointers, but it's a bit easier to work with.)
- Text nodes can be cast to bool and will return true if they have text,
  or false if they don't.
- Most functions will return a valid, but empty, handle if the requested
  node doesn't exist, so we don't have to do explicit nullptr checking.
- Built-in support for UTF-16, so we don't need to use librptext.
- Supports in-place parsing, so it doesn't have to make another copy.
  (This doesn't work if encoding conversion is needed, but that's handled
  automatically.)
- xml_text::as_int() exists at least as far back as 1.7, which is included
  in Ubuntu 16.04. On the other hand, TinyXML 2.2.0, also included in
  Ubuntu 16.04, does not have XMLElement::IntText(). Since as_int() is
  available, we can get rid of XMLElement_IntText().

Optimizations related to PugiXML:
- Simplify creationTime parsing by taking advantage of the fact that
  xml_nodes can never dereference a nullptr.

Other changes:
- Add a sanity check verifying that the WIM file contains at least 1
  image.
- Move the image count sanity check to before xml_document parsing.

TODO: Simplify some more parsing.
2025-04-01 19:19:20 -04:00
David Korth
7a986d3053 Merge branch 'bugfix/msvc-WX-fixes.2025-04-01' 2025-04-01 19:18:20 -04:00
David Korth
e6b8b9d6f9 [librptext] config.librptext.h.in: "yo uhave" -> "you have" 2025-04-01 19:17:55 -04:00
David Korth
cd14d1f8e3 [libromdata/tests] GcnFstTest: Use 0UL instead of 0 when comparing to file_info.size_filename.
extlib\googletest\googletest\include\gtest/gtest.h(1444): error C2220: warning treated as error - no 'object' file generated (compiling source file src\libromdata\tests\disc\GcnFstTest.cpp)
  src\libromdata\tests\disc\GcnFstTest.cpp(546): note: see reference to function template instantiation 'testing::AssertionResult testing::internal::CmpHelperGT<unsigned long,int>(const char *,const char *,const T1 &,const T2 &)' being compiled
          with
          [
              T1=unsigned long,
              T2=int
          ]
extlib\googletest\googletest\include\gtest/gtest.h(1444): warning C4018: '>': signed/unsigned mismatch (compiling source file src\libromdata\tests\disc\GcnFstTest.cpp)
2025-04-01 19:17:55 -04:00
David Korth
531e540bc4 [libromdata] TCreateThumbnail.hpp: Add typename to the using statements.
This fixes issues with MSVC 2015 and some other versions with different
C++ standards levels.

src\libromdata/img/TCreateThumbnail.hpp(109): warning C4346: 'std::is_pointer<_Ty>::value':
dependent name is not a type (compiling source file src\win32\RP_ExtractIcon.cpp)
2025-04-01 19:17:19 -04:00
David Korth
8b4b48a69c [platform] msvc.cmake: Disable warning C4503.
'identifier': decorated name length exceeded, name was truncated

This is generated by RomHeaderTest due to the lots of tests.

NOTE: Only generated by MSVC 2015 and earlier. MSVC 2017 and later
don't emit this warning.

https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4503?view=msvc-170
2025-04-01 19:17:19 -04:00
David Korth
778a49b632 [librptext] conversion_win32.cpp, cpN_to_utf16(): Another MSVC warning fix.
I thought I got this one earlier...

src\librptext\conversion_win32.cpp(176): warning C4267: 'argument':
conversion from 'size_t' to 'int', possible loss of data
2025-04-01 19:17:19 -04:00
David Korth
dcd2b47094 [libromdata] J2ME.cpp: Use std::numeric_limits<size_t>::max() instead of ~0ULL.
32-bit MSVC 2015 didn't like this:

src\libromdata\Handheld\J2ME.cpp(146): warning C4309: 'static_cast': truncation of constant value
2025-04-01 19:17:19 -04:00
David Korth
56a033ea79 [platform] msvc.cmake: Fix ENDIF() for "^/guard:". 2025-04-01 19:17:19 -04:00
David Korth
0c0ff2e595 [libpng] pngrutil.c: Missed a few png_structrp/png_inforp changes. 2025-04-01 19:17:11 -04:00
David Korth
f3bdc04bd9 [platform] msvc.cmake: Disable some more warnings that are causing errors now.
Disabled these warnings:
- C4005: macro redefinition (libpng's intprefix.out.tf1 is breaking on this...)
- C4091: 'typedef ': ignored on left of 'tagGPFIDL_FLAGS' when no variable is declared
- C4800: 'BOOL': forcing value to bool 'true' or 'false' (performance warning)

TODO:
- Re-enable C4800 as not-an-error?
- Figure out how to fix libpng's C4005 warnings.
2025-04-01 19:17:11 -04:00
David Korth
dd4251101c [zstd] zstd_compress.c, ZSTD_convertBlockSequences(): Add const to make it match the declaration in zstd_compress_internal.h.
MSVC 2015 is complaining now:

extlib\zstd\compress\zstd_compress.c(7321): error C2220: warning treated as error - no 'object' file generated [build\extlib\zstd\zstd.vcxproj]
extlib\zstd\compress\zstd_compress.c(7321): warning C4028: formal parameter 4 different from declaration [build\extlib\zstd\zstd.vcxproj]
2025-04-01 19:17:11 -04:00
David Korth
54e8215488 [platform] msvc.cmake: Add -D_SCL_SECURE_NO_WARNINGS.
[fmt] chrono.h: Revert the MSVC C4996 warning pragma. It didn't work.
Adding `-D_SCL_SECURE_NO_WARNINGS` *should* fix it.
2025-04-01 19:17:11 -04:00
David Korth
fc26afa3f6 [libromdata] WiiUPackagePrivate::addMetaData_System_XMLs(): Remove appXml and cosXml.
This function only uses metaXml.
2025-04-01 19:17:11 -04:00
David Korth
7542e50883 [libromdata] WiiUPackagePrivate::parseUnsignedInt(): Return defval if the attributes and/or elements can't be found. 2025-04-01 19:17:11 -04:00
David Korth
119de9f956 [fmt] chrono.h, color.h: Suppress some MSVC warnings.
These warnings (now handled as errors) appeared in the AppVeyor build
with MSVC 2015:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\algorithm(1669): error C2220: warning treated as error - no 'object' file generated [build\src\amiibo-data\amiiboc.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\algorithm(1669): warning C4996: 'std::reverse_copy::_Unchecked_iterators::_Deprecate': Call to 'std::reverse_copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' [build\src\amiibo-data\amiiboc.vcxproj]
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\algorithm(1669): note: see declaration of 'std::reverse_copy::_Unchecked_iterators::_Deprecate'
  extlib\fmt\include\fmt/chrono.h(659): note: see reference to function template instantiation '_OutIt *std::reverse_copy<char*,char*>(_BidIt,_BidIt,_OutIt)' being compiled
          with
          [
              _OutIt=char *,
              _BidIt=char *
          ]
extlib\fmt\include\fmt\color.h(410): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) [build\src\amiibo-data\amiiboc.vcxproj]
  extlib\fmt\include\fmt\color.h(409): note: while compiling class template member function 'bool fmt::v11::detail::ansi_color_escape<Char>::has_emphasis(fmt::v11::emphasis,fmt::v11::emphasis) noexcept'
          with
          [
              Char=wchar_t
          ]
  extlib\fmt\include\fmt\color.h(371): note: see reference to function template instantiation 'bool fmt::v11::detail::ansi_color_escape<Char>::has_emphasis(fmt::v11::emphasis,fmt::v11::emphasis) noexcept' being compiled
          with
          [
              Char=wchar_t
          ]
  extlib\fmt\include\fmt\color.h(450): note: see reference to class template instantiation 'fmt::v11::detail::ansi_color_escape<Char>' being compiled
          with
          [
              Char=wchar_t
          ]
  extlib\fmt\include\fmt/xchar.h(328): note: see reference to function template instantiation 'void fmt::v11::detail::vformat_to<T>(fmt::v11::detail::buffer<T> &,const fmt::v11::text_style &,fmt::v11::basic_string_view<wchar_t>,fmt::v11::basic_format_args<fmt::v11::wformat_context>)' being compiled
          with
          [
              T=wchar_t
          ]
2025-04-01 19:17:11 -04:00
David Korth
f6398a63ee [libromdata] WimPrivate::addFields_XML(): Fix copy/paste error for FILETIMEs.
Both lastmodtime_high and lastmodtime_low were being initialized to
strtoul(s_highPart, ...).

Testing Windows 10 (10.0.19041.5363) recovery image: (winre.wim)
- HIGHPART: 0x01D5ACCD
- LOWPART:  0x97A856C3
- Decimal: 132201763089962691

Timestamp conversions before and after: (using TZ=UTC)
- Before: 12/07/2019 07:07:37 AM
- After:  12/07/2019 07:11:48 AM

Manually converting it using a website:
- Saturday, December 7, 2019 7:11:48 AM

TODO: Split the XML code into a separate .cpp file and add DelayLoad checks.
2025-03-31 22:19:49 -04:00
David Korth
924ed20e29 [platform] msvc.cmake: Simplify the "/guard*" check by using a regex. 2025-03-31 22:10:21 -04:00
David Korth
ea747492bf [libromdata] WiiUPackage_p.hpp: Mark parseHexBinary32() as inline.
Probably not strictly necessary...
2025-03-31 21:59:54 -04:00
David Korth
06dfe53611 [libwin32common] DelayLoadHelper.c: Update the TinyXML2 version number.
This was updated in DelayLoadHelper.cmake when TinyXML2 was updated, but
I forgot to update it here.

FIXME: Define this somewhere else so we don't forget to update it later.
2025-03-31 21:56:15 -04:00
David Korth
37670b6e93 [libromdata] Fix MSVC /W3 /WX warnings in the 32-bit (i386) Windows build.
Mostly related to converting `off64_t` (file sizes) to `size_t`.

J2MEPrivate::loadFileFromZip():
- Cast the default max_size parameter to `size_t`.
- Cast file_info.uncompressed_size to `size_t` as well. This should be
  optimized out in 64-bit builds.

ELF:
- Need to cast d_tag values to `size_t` before using it with operator[].

CdiReader, GdiReader:
- Cast std::numeric_limits<>::max() to `size_t` before comparing it
  with idx.
2025-03-31 21:55:32 -04:00
David Korth
78cb92f273 [libmspack-xenia] lzxd.c: Fix some warnings in the 32-bit (i386) MSVC build. 2025-03-31 21:55:21 -04:00
David Korth
3be503184b [libpng] Fix incorrect signatures for the APNG functions.
png_structp -> png_structrp
png_infop -> png_inforp

TODO: Re-apply the APNG patch now that it's been rebased to 1.6.47.
2025-03-31 21:42:46 -04:00