From 122979e3a10bab3109e8d1cbb89ecf16ae6af1e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jan 2025 20:25:26 -0800 Subject: [PATCH] QLibraryInfo/Win: use the ActiveQt-overridden handle for the main module This applies to qaxserverdll only, where "the executable" is actually a DLL. Change-Id: I8ac1bc015b9e6f381de8fffd1f8ee185d923f1f4 Reviewed-by: Oliver Wolff --- src/corelib/global/qlibraryinfo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index da39f1eb6c2..1ecec63aed4 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -14,6 +14,7 @@ #include "qcoreapplication.h" +#include "private/qcoreapplication_p.h" #include "private/qfilesystementry_p.h" #include "archdetect.cpp" #include "qconfig.cpp" @@ -389,7 +390,9 @@ static QString getRelocatablePrefix(QLibraryInfoPrivate::UsageMode usageMode) DWORD pathSize = GetModuleFileName(hModule, buffer, kBufferSize); const QString qtCoreFilePath = QString::fromWCharArray(buffer, int(pathSize)); const QString qtCoreDirPath = QFileInfo(qtCoreFilePath).absolutePath(); - pathSize = GetModuleFileName(NULL, buffer, kBufferSize); + + hModule = reinterpret_cast(QCoreApplicationPrivate::mainInstanceHandle); + pathSize = GetModuleFileName(hModule, buffer, kBufferSize); const QString exeDirPath = QFileInfo(QString::fromWCharArray(buffer, int(pathSize))).absolutePath(); if (QFileInfo(exeDirPath) == QFileInfo(qtCoreDirPath)) { // QtCore DLL is next to the executable. This is either a windeployqt'ed executable or an