From 71995f03434be1a7f8b9877089af1bda24e8720b Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Sat, 6 Jan 2018 03:51:34 +0200 Subject: preload openssl dlls (probably unnecessary but can help troubleshooting openssl issues) --- src/main.cpp | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 3e02a4a7..c64e2d8d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -419,6 +419,29 @@ void setupPath() ::SetEnvironmentVariableW(L"PATH", newPath.c_str()); } +static void preloadSsl() +{ + QString appPath = QDir::toNativeSeparators(QCoreApplication::applicationDirPath()); + if (GetModuleHandleA("libeay32.dll")) + qWarning("libeay32.dll already loaded?!"); + else { + QString libeay32 = appPath + "\\libeay32.dll"; + if (!QFile::exists(libeay32)) + qWarning("libeay32.dll not found: %s", qPrintable(libeay32)); + else if (!LoadLibraryW(libeay32.toStdWString().c_str())) + qWarning("failed to load: %s, %d", qPrintable(libeay32), GetLastError()); + } + if (GetModuleHandleA("ssleay32.dll")) + qWarning("ssleay32.dll already loaded?!"); + else { + QString ssleay32 = appPath + "\\ssleay32.dll"; + if (!QFile::exists(ssleay32)) + qWarning("ssleay32.dll not found: %s", qPrintable(ssleay32)); + else if (!LoadLibraryW(ssleay32.toStdWString().c_str())) + qWarning("failed to load: %s, %d", qPrintable(ssleay32), GetLastError()); + } +} + static QString getVersionDisplayString() { VS_FIXEDFILEINFO version = GetFileVersion(ToWString(QApplication::applicationFilePath())); @@ -442,6 +465,13 @@ int runApplication(MOApplication &application, SingleInstance &instance, #endif ); +#if !defined(QT_NO_SSL) + preloadSsl(); + qDebug("ssl support: %d", QSslSocket::supportsSsl()); +#else + qDebug("non-ssl build"); +#endif + QString dataPath = application.property("dataPath").toString(); qDebug("data path: %s", qPrintable(dataPath)); @@ -618,12 +648,6 @@ int main(int argc, char *argv[]) setupPath(); - #if !defined(QT_NO_SSL) - qDebug("ssl support: %d", QSslSocket::supportsSsl()); - #else - qDebug("non-ssl build"); - #endif - bool forcePrimary = false; if (arguments.contains("update")) { arguments.removeAll("update"); -- cgit v1.3.1