Skip to content

Commit 97cbf1e

Browse files
committed
[libromdata] EXEPrivate::addFields_PE_Manifest(): Check for DelayLoad here.
Previously, we were checking for DelayLoad in loadWin32ManifestResource(). This doesn't actually work properly because it takes a reference to XMLDocument, which means XMLDocument must have been constructed prior to calling loadWin32ManifestResource(). Check for DelayLoad before calling loadWin32ManifestResource(). This fixes the crash reported in #313: tinyxml2.dll isn't packaged correctly Reported by @ccawley2011.
1 parent 880471d commit 97cbf1e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Diff for: src/libromdata/Other/EXE_manifest.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,15 @@ do { } while (0)
7171
* The XML is loaded and parsed using the specified
7272
* TinyXML document.
7373
*
74+
* NOTE: DelayLoad must be checked by the caller, since it's
75+
* passing an XMLDocument reference to this function.
76+
*
7477
* @param doc [in/out] XML document.
7578
* @param ppResName [out,opt] Pointer to receive the loaded resource name. (statically-allocated string)
7679
* @return 0 on success; negative POSIX error code on error.
7780
*/
7881
int EXEPrivate::loadWin32ManifestResource(XMLDocument &doc, const char **ppResName) const
7982
{
80-
#if defined(_MSC_VER) && defined(XML_IS_DLL)
81-
// Delay load verification.
82-
// TODO: Only if linked with /DELAYLOAD?
83-
int ret_dl = DelayLoad_test_TinyXML2();
84-
if (ret_dl != 0) {
85-
// Delay load failed.
86-
return ret_dl;
87-
}
88-
#endif /* defined(_MSC_VER) && defined(XML_IS_DLL) */
89-
9083
// Make sure the resource directory is loaded.
9184
int ret = const_cast<EXEPrivate*>(this)->loadPEResourceTypes();
9285
if (ret != 0) {
@@ -201,6 +194,16 @@ int EXEPrivate::loadWin32ManifestResource(XMLDocument &doc, const char **ppResNa
201194
*/
202195
int EXEPrivate::addFields_PE_Manifest(void)
203196
{
197+
#if defined(_MSC_VER) && defined(XML_IS_DLL)
198+
// Delay load verification.
199+
// TODO: Only if linked with /DELAYLOAD?
200+
int ret_dl = DelayLoad_test_TinyXML2();
201+
if (ret_dl != 0) {
202+
// Delay load failed.
203+
return ret_dl;
204+
}
205+
#endif /* defined(_MSC_VER) && defined(XML_IS_DLL) */
206+
204207
const char *pResName = nullptr;
205208
XMLDocument doc;
206209
int ret = loadWin32ManifestResource(doc, &pResName);

Diff for: src/libromdata/Other/EXE_p.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class EXEPrivate final : public LibRpBase::RomDataPrivate
185185
* The XML is loaded and parsed using the specified
186186
* TinyXML document.
187187
*
188+
* NOTE: DelayLoad must be checked by the caller, since it's
189+
* passing an XMLDocument reference to this function.
190+
*
188191
* @param doc [in/out] XML document.
189192
* @param ppResName [out,opt] Pointer to receive the loaded resource name. (statically-allocated string)
190193
* @return 0 on success; negative POSIX error code on error.

0 commit comments

Comments
 (0)