From 3ccc0774066ee173955342338eb2b07d7a622195 Mon Sep 17 00:00:00 2001 From: Andy Fillebrown Date: Mon, 25 Mar 2019 16:34:05 -0400 Subject: [PATCH] Let native callbacks be defined in shared libraries. --- src/native/QmlNet/Hosting/CoreHost.cpp | 6 +++++- src/native/QmlNet/Hosting/CoreHost.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/native/QmlNet/Hosting/CoreHost.cpp b/src/native/QmlNet/Hosting/CoreHost.cpp index ff272a43..6e3aec6d 100644 --- a/src/native/QmlNet/Hosting/CoreHost.cpp +++ b/src/native/QmlNet/Hosting/CoreHost.cpp @@ -18,9 +18,11 @@ #define HOSTFXR_DLL_NAME "libhostfxr.so" #endif +static QString nativeModule; + static void* getExportedFunction(const char* symbolName) { #ifdef _WIN32 - HMODULE library = GetModuleHandle(nullptr); + HMODULE library = GetModuleHandle(nativeModule.toLocal8Bit()); FARPROC symbol = GetProcAddress(library, symbolName); return (void*)symbol; #else @@ -132,6 +134,8 @@ CoreHost::HostFxrContext CoreHost::findHostFxr() int CoreHost::run(QGuiApplication& app, QQmlApplicationEngine& engine, runCallback runCallback, RunContext runContext) { + nativeModule = runContext.nativeModule; + QList execArgs; execArgs.push_back(runContext.entryPoint); execArgs.push_back("exec"); diff --git a/src/native/QmlNet/Hosting/CoreHost.h b/src/native/QmlNet/Hosting/CoreHost.h index 1ee83c15..d32394c2 100644 --- a/src/native/QmlNet/Hosting/CoreHost.h +++ b/src/native/QmlNet/Hosting/CoreHost.h @@ -26,6 +26,7 @@ public: QString entryPoint; QString managedExe; QList args; + QString nativeModule; }; enum LoadHostFxrResult