From 82f6f6f5e8177b051245c66555159cd7d476ae2e Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Tue, 30 Nov 2021 20:34:07 +0100 Subject: [PATCH] fixed up dynld_module, actually loads and sets pointers correct now (tested against libpcap) --- src/qt/qt_platform.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 11cded7be..47a771442 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -347,14 +347,23 @@ void plat_language_code_r(uint32_t lcid, char* outbuf, int len) { void* dynld_module(const char *name, dllimp_t *table) { - auto lib = std::unique_ptr(new QLibrary(name)); + QString libraryName = name; + QFileInfo fi(libraryName); + QStringList removeSuffixes = {"dll", "dylib", "so"}; + if (removeSuffixes.contains(fi.suffix())) { + libraryName = fi.completeBaseName(); + } + + auto lib = std::unique_ptr(new QLibrary(libraryName)); if (lib->load()) { for (auto imp = table; imp->name != nullptr; imp++) { - if ((imp->func = reinterpret_cast(lib->resolve(imp->name))) != nullptr) - { + auto ptr = lib->resolve(imp->name); + if (ptr == nullptr) { return nullptr; } + auto imp_ptr = reinterpret_cast(imp->func); + *imp_ptr = reinterpret_cast(ptr); } } else { return nullptr;