summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-08-31 08:23:30 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-09-03 08:22:25 (GMT)
commit5738dcd705e7edde816940f9c0ab2c364c81ad20 (patch)
treee6be0a4b0f11289a7f0e8f6b4d4cce1de28aee8e
parentdac9e5dd5644d29d6a8dde752e7c594727f16661 (diff)
downloadQt-5738dcd705e7edde816940f9c0ab2c364c81ad20.zip
Qt-5738dcd705e7edde816940f9c0ab2c364c81ad20.tar.gz
Qt-5738dcd705e7edde816940f9c0ab2c364c81ad20.tar.bz2
Ensure that we load system libraries from the correct location.
This was a security hole that has been there for a while, but the public awareness have recently rised so the threat is more imminent now. The solution is to fix all places where we dynamically load system libraries. More specifically, we now load all system libraries with an absolute path that points to a library in the system directory (usually c:\windows\system32). We therefore introduce a small class named QSystemLibrary that only loads libraries located in the system path. This shares some of the API with QLibrary (in order to make the patch as small as possible). We don't fix QLibrary due to risk of regressions. In addition, applications can fix the code that calls QLibrary themselves. The problem does not apply to Windows CE, since the search order is documented as not searching in the current directory. However, it touches some CE-specific code - therefore QSystemLibrary is sometimes used on WinCE (however, it will just do a normal LoadLibrary() since its safe anyway). This change does not affect the testability plugin (it is not clearly documented where that plugin is located, and the plugin should never be used in production code anyway) Loading OpenSSL libraries The ssl libraries are handled specially, and searched in this order (we cannot expect them to always be in the system folder): 1. Application path 2. System libraries path 3. Trying all paths inside the PATH environment variable Task-number: QT-3825 Reviewed-by: Thiago Macieira Reviewed-by: Peter Hartmann
-rw-r--r--qmake/Makefile.win325
-rw-r--r--qmake/qmake.pri3
-rw-r--r--src/activeqt/shared/qaxtypes.cpp4
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp7
-rw-r--r--src/corelib/io/qsettings.cpp6
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp10
-rw-r--r--src/corelib/plugin/plugin.pri7
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp90
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h61
-rw-r--r--src/gui/accessible/qaccessible_win.cpp4
-rw-r--r--src/gui/dialogs/qfiledialog_win.cpp12
-rw-r--r--src/gui/dialogs/qwizard_win.cpp6
-rw-r--r--src/gui/kernel/qapplication_win.cpp38
-rw-r--r--src/gui/kernel/qdesktopwidget_win.cpp6
-rw-r--r--src/gui/kernel/qwidget_win.cpp6
-rw-r--r--src/gui/styles/qwindowsstyle.cpp8
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp3
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp4
-rw-r--r--src/gui/text/qfontdatabase_win.cpp10
-rw-r--r--src/gui/text/qfontengine_win.cpp4
-rw-r--r--src/gui/util/qdesktopservices_win.cpp6
-rw-r--r--src/gui/util/qsystemtrayicon_win.cpp8
-rw-r--r--src/network/kernel/qhostinfo_win.cpp14
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp3
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp15
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp36
-rw-r--r--src/qt3support/network/q3dns.cpp3
-rw-r--r--src/tools/bootstrap/bootstrap.pro3
28 files changed, 282 insertions, 100 deletions
diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32
index 48d84b7..c452c5a 100644
--- a/qmake/Makefile.win32
+++ b/qmake/Makefile.win32
@@ -102,6 +102,7 @@ QTOBJS= \
qtemporaryfile.obj \
qabstractfileengine.obj \
qfsfileengine_win.obj \
+ qsystemlibrary.obj \
qfsfileengine_iterator_win.obj \
qfileinfo.obj \
qglobal.obj \
@@ -155,6 +156,7 @@ clean::
-del qtemporaryfile.obj
-del qabstractfileengine.obj
-del qfsfileengine_win.obj
+ -del qsystemlibrary.obj
-del qfsfileengine_iterator_win.obj
-del qfileinfo.obj
-del qglobal.obj
@@ -313,6 +315,9 @@ qtemporaryfile.obj: $(SOURCE_PATH)\src\corelib\io\qtemporaryfile.cpp
qfsfileengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp
$(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp
+qsystemlibrary.obj: $(SOURCE_PATH)\src\corelib\plugin\qsystemlibrary.cpp
+ $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\plugin\qsystemlibrary.cpp
+
qfsfileengine_iterator_win.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine_iterator_win.cpp
$(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine_iterator_win.cpp
diff --git a/qmake/qmake.pri b/qmake/qmake.pri
index b82ab4d..8d3a559 100644
--- a/qmake/qmake.pri
+++ b/qmake/qmake.pri
@@ -128,7 +128,8 @@ bootstrap { #Qt code
LIBS += -framework ApplicationServices
}
} else:win32 {
- SOURCES += qfsfileengine_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp
+ SOURCES += qfsfileengine_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp \
+ qsystemlibrary.cpp
win32-msvc*:LIBS += ole32.lib advapi32.lib
win32-g++:LIBS += -lole32 -luuid
}
diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp
index 0cfc7eb..957733e 100644
--- a/src/activeqt/shared/qaxtypes.cpp
+++ b/src/activeqt/shared/qaxtypes.cpp
@@ -52,7 +52,7 @@
#include <qobject.h>
#ifdef QAX_SERVER
# include <qaxfactory.h>
-# include <qlibrary.h>
+# include <private/qsystemlibrary_p.h>
#else
# include <quuid.h>
# include <qaxobject.h>
@@ -666,7 +666,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
static bool resolved = false;
if (!resolved) {
resolved = true;
- pGetRecordInfoFromTypeInfo = (PGetRecordInfoFromTypeInfo)QLibrary::resolve(QLatin1String("oleaut32"),
+ pGetRecordInfoFromTypeInfo = (PGetRecordInfoFromTypeInfo)QSystemLibrary::resolve(QLatin1String("oleaut32"),
"GetRecordInfoFromTypeInfo");
}
if (!pGetRecordInfoFromTypeInfo)
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 139075f..44db59b 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -43,6 +43,7 @@
#include "qplatformdefs.h"
#include "qabstractfileengine.h"
#include "private/qfsfileengine_p.h"
+#include <private/qsystemlibrary_p.h>
#include <qdebug.h>
#include "qfile.h"
@@ -181,7 +182,7 @@ void QFSFileEnginePrivate::resolveLibs()
triedResolve = true;
#if !defined(Q_OS_WINCE)
- HINSTANCE advapiHnd = LoadLibraryW(L"advapi32");
+ HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
if (advapiHnd) {
ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW");
@@ -213,7 +214,7 @@ void QFSFileEnginePrivate::resolveLibs()
ptrFreeSid(pWorld);
}
}
- HINSTANCE userenvHnd = LoadLibraryW(L"userenv");
+ HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
if (userenvHnd)
ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
#endif
@@ -245,7 +246,7 @@ bool QFSFileEnginePrivate::resolveUNCLibs()
#endif
triedResolve = true;
#if !defined(Q_OS_WINCE)
- HINSTANCE hLib = LoadLibraryW(L"Netapi32");
+ HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
if (hLib) {
ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
if (ptrNetShareEnum)
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 64015ce..c3dece9 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -69,7 +69,7 @@
#ifdef Q_OS_WIN // for homedirpath reading from registry
#include "qt_windows.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#endif // Q_OS_WIN
#endif // QT_NO_QOBJECT
@@ -1046,9 +1046,9 @@ static QString windowsConfigPath(int type)
// We can't use QLibrary if there is QT_NO_QOBJECT is defined
// This only happens when bootstrapping qmake.
#ifndef Q_OS_WINCE
- QLibrary library(QLatin1String("shell32"));
+ QSystemLibrary library(QLatin1String("shell32"));
#else
- QLibrary library(QLatin1String("coredll"));
+ QSystemLibrary library(QLatin1String("coredll"));
#endif // Q_OS_WINCE
typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW");
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index f63fa1d..2da02f9 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -43,7 +43,7 @@
#include "qcoreapplication.h"
#include "qhash.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include "qpair.h"
#include "qset.h"
#include "qsocketnotifier.h"
@@ -324,11 +324,11 @@ static void resolveTimerAPI()
#endif
triedResolve = true;
#if !defined(Q_OS_WINCE)
- qtimeSetEvent = (ptimeSetEvent)QLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
+ qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
+ qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
#else
- qtimeSetEvent = (ptimeSetEvent)QLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
+ qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
+ qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
#endif
}
}
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index c05ff48..ba86353 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -7,7 +7,8 @@ HEADERS += \
plugin/qlibrary_p.h \
plugin/qplugin.h \
plugin/quuid.h \
- plugin/qfactoryloader_p.h
+ plugin/qfactoryloader_p.h \
+ plugin/qsystemlibrary_p.h
SOURCES += \
plugin/qpluginloader.cpp \
@@ -16,7 +17,9 @@ SOURCES += \
plugin/qlibrary.cpp
win32 {
- SOURCES += plugin/qlibrary_win.cpp
+ SOURCES += \
+ plugin/qlibrary_win.cpp \
+ plugin/qsystemlibrary.cpp
}
unix {
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
new file mode 100644
index 0000000..7e9fdde
--- /dev/null
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -0,0 +1,90 @@
+#include "qsystemlibrary_p.h"
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qfileinfo.h>
+
+/*!
+
+ \internal
+ \class QSystemLibrary
+
+ The purpose of this class is to load only libraries that are located in
+ well-known and trusted locations on the filesystem. It does not suffer from
+ the security problem that QLibrary has, therefore it will never search in
+ the current directory.
+
+ The search order is the same as the order in DLL Safe search mode Windows,
+ except that we don't search:
+ * The current directory
+ * The 16-bit system directory. (normally c:\windows\system)
+ * The Windows directory. (normally c:\windows)
+
+ This means that the effective search order is:
+ 1. Application path.
+ 2. System libraries path.
+ 3. Trying all paths inside the PATH environment variable.
+
+ Note, when onlySystemDirectory is true it will skip 1) and 3).
+
+ DLL Safe search mode is documented in the "Dynamic-Link Library Search
+ Order" document on MSDN.
+
+ Since library loading code is sometimes shared between Windows and WinCE,
+ this class can also be used on WinCE. However, its implementation just
+ calls the LoadLibrary() function. This is ok since it is documented as not
+ loading from the current directory on WinCE. This behaviour is documented
+ in the documentation for LoadLibrary for Windows CE at MSDN.
+ (http://msdn.microsoft.com/en-us/library/ms886736.aspx)
+*/
+#if !defined(QT_BOOTSTRAPPED)
+extern QString qAppFileName();
+#endif
+
+static QString qSystemDirectory()
+{
+ QVarLengthArray<wchar_t, MAX_PATH> fullPath;
+
+ UINT retLen = ::GetSystemDirectory(fullPath.data(), MAX_PATH);
+ if (retLen > MAX_PATH) {
+ fullPath.resize(retLen);
+ retLen = ::GetSystemDirectory(fullPath.data(), retLen);
+ }
+ // in some rare cases retLen might be 0
+ return QString::fromWCharArray(fullPath.constData(), int(retLen));
+}
+
+HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory/*= true*/)
+{
+#if defined(Q_OS_WINCE)
+ return ::LoadLibrary(lpFileName);
+#else
+ QStringList searchOrder;
+
+#if !defined(QT_BOOTSTRAPPED)
+ if (!onlySystemDirectory)
+ searchOrder << QFileInfo(qAppFileName()).path();
+#endif
+ searchOrder << qSystemDirectory();
+
+ if (!onlySystemDirectory) {
+ const QString PATH(QLatin1String(qgetenv("PATH").constData()));
+ searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts);
+ }
+ QString fileName = QString::fromWCharArray(libraryName);
+ fileName.append(QLatin1String(".dll"));
+
+ // Start looking in the order specified
+ for (int i = 0; i < searchOrder.count(); ++i) {
+ QString fullPathAttempt = searchOrder.at(i);
+ if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) {
+ fullPathAttempt.append(QLatin1Char('\\'));
+ }
+ fullPathAttempt.append(fileName);
+ HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16());
+ if (inst != 0)
+ return inst;
+ }
+ return 0;
+#endif
+}
+
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
new file mode 100644
index 0000000..60c59e2
--- /dev/null
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -0,0 +1,61 @@
+#ifndef QSYSTEMLIBRARY_P_H
+#define QSYSTEMLIBRARY_P_H
+
+#include <QtCore/qglobal.h>
+#ifdef Q_OS_WIN
+#include <qt_windows.h>
+#include <QtCore/qstring.h>
+
+class QSystemLibrary
+{
+public:
+ explicit QSystemLibrary(const QString &libraryName)
+ {
+ m_libraryName = libraryName;
+ m_handle = 0;
+ m_didLoad = false;
+ }
+
+ explicit QSystemLibrary(const wchar_t *libraryName)
+ {
+ m_libraryName = QString::fromWCharArray(libraryName);
+ m_handle = 0;
+ m_didLoad = false;
+ }
+
+ bool load(bool onlySystemDirectory = true)
+ {
+ m_handle = load((const wchar_t *)m_libraryName.utf16(), onlySystemDirectory);
+ m_didLoad = true;
+ return (m_handle != 0);
+ }
+
+ bool isLoaded()
+ {
+ return (m_handle != 0);
+ }
+
+ void *resolve(const char *symbol)
+ {
+ if (!m_didLoad)
+ load();
+ if (!m_handle)
+ return 0;
+ return (void*)GetProcAddress(m_handle, symbol);
+ }
+
+ static void *resolve(const QString &libraryName, const char *symbol)
+ {
+ return QSystemLibrary(libraryName).resolve(symbol);
+ }
+
+ static Q_CORE_EXPORT HINSTANCE load(const wchar_t *lpFileName, bool onlySystemDirectory = true);
+private:
+ HINSTANCE m_handle;
+ QString m_libraryName;
+ bool m_didLoad;
+};
+
+#endif //Q_OS_WIN
+
+#endif //QSYSTEMLIBRARY_P_H
diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp
index fc8575f..132d01f 100644
--- a/src/gui/accessible/qaccessible_win.cpp
+++ b/src/gui/accessible/qaccessible_win.cpp
@@ -42,7 +42,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include "qapplication.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include "qmessagebox.h" // ### dependency
#include "qt_windows.h"
#include "qwidget.h"
@@ -243,7 +243,7 @@ void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
static bool resolvedNWE = false;
if (!resolvedNWE) {
resolvedNWE = true;
- ptrNotifyWinEvent = (PtrNotifyWinEvent)QLibrary::resolve(QLatin1String("user32"), "NotifyWinEvent");
+ ptrNotifyWinEvent = (PtrNotifyWinEvent)QSystemLibrary::resolve(QLatin1String("user32"), "NotifyWinEvent");
}
if (!ptrNotifyWinEvent)
return;
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 5a7ace9..bd97527 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -52,7 +52,7 @@
#include <qbuffer.h>
#include <qdir.h>
#include <qstringlist.h>
-#include <qlibrary.h>
+#include <private/qsystemlibrary_p.h>
#ifndef QT_NO_THREAD
# include <private/qmutexpool_p.h>
@@ -126,10 +126,10 @@ static void qt_win_resolve_libs()
triedResolve = true;
#if !defined(Q_WS_WINCE)
- QLibrary lib(QLatin1String("shell32"));
- ptrSHBrowseForFolder = (PtrSHBrowseForFolder) lib.resolve("SHBrowseForFolderW");
- ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList) lib.resolve("SHGetPathFromIDListW");
- ptrSHGetMalloc = (PtrSHGetMalloc) lib.resolve("SHGetMalloc");
+ QSystemLibrary lib(L"shell32");
+ ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolderW");
+ ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)lib.resolve("SHGetPathFromIDListW");
+ ptrSHGetMalloc = (PtrSHGetMalloc)lib.resolve("SHGetMalloc");
#else
// CE stores them in a different lib and does not use unicode version
HINSTANCE handle = LoadLibraryW(L"Ceshell");
@@ -436,7 +436,7 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd,
{
if (!pSHCreateItemFromParsingName) {
// This function is available only in Vista & above.
- QLibrary shellLib(QLatin1String("Shell32"));
+ QSystemLibrary shellLib(QLatin1String("Shell32"));
pSHCreateItemFromParsingName = (PtrSHCreateItemFromParsingName)
shellLib.resolve("SHCreateItemFromParsingName");
if (!pSHCreateItemFromParsingName)
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp
index 1390b21..449ad62 100644
--- a/src/gui/dialogs/qwizard_win.cpp
+++ b/src/gui/dialogs/qwizard_win.cpp
@@ -43,7 +43,7 @@
#ifndef QT_NO_STYLE_WINDOWSVISTA
#include "qwizard_win_p.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include "qwizard.h"
#include "qpaintengine.h"
#include "qapplication.h"
@@ -691,7 +691,7 @@ bool QVistaHelper::resolveSymbols()
static bool tried = false;
if (!tried) {
tried = true;
- QLibrary dwmLib(QString::fromAscii("dwmapi"));
+ QSystemLibrary dwmLib(L"dwmapi");
pDwmIsCompositionEnabled =
(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
if (pDwmIsCompositionEnabled) {
@@ -699,7 +699,7 @@ bool QVistaHelper::resolveSymbols()
pDwmExtendFrameIntoClientArea =
(PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
}
- QLibrary themeLib(QString::fromAscii("uxtheme"));
+ QSystemLibrary themeLib(L"uxtheme");
pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
if (pIsAppThemed) {
pDrawThemeBackground = (PtrDrawThemeBackground)themeLib.resolve("DrawThemeBackground");
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index d6896c0..b6b49cc 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -66,7 +66,6 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#include "qdatetime.h"
#include "qpointer.h"
#include "qhash.h"
-#include "qlibrary.h"
#include "qmetaobject.h"
#include "qmime.h"
#include "qpainter.h"
@@ -91,6 +90,7 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#include "qdebug.h"
#include <private/qkeymapper_p.h>
#include <private/qlocale_p.h>
+#include <private/qsystemlibrary_p.h>
#include "qevent_p.h"
//#define ALIEN_DEBUG
@@ -204,7 +204,7 @@ static void resolveAygLibs()
{
if (!aygResolved) {
aygResolved = true;
- QLibrary ayglib(QLatin1String("aygshell"));
+ QSystemLibrary ayglib(QLatin1String("aygshell"));
if (!ayglib.load())
return;
ptrRecognizeGesture = (AygRecognizeGesture) ayglib.resolve("SHRecognizeGesture");
@@ -811,10 +811,10 @@ void qt_init(QApplicationPrivate *priv, int)
#ifndef Q_OS_WINCE
ptrUpdateLayeredWindowIndirect =
- (PtrUpdateLayeredWindowIndirect) QLibrary::resolve(QLatin1String("user32"),
+ (PtrUpdateLayeredWindowIndirect) QSystemLibrary::resolve(QLatin1String("user32"),
"UpdateLayeredWindowIndirect");
ptrUpdateLayeredWindow =
- (PtrUpdateLayeredWindow) QLibrary::resolve(QLatin1String("user32"),
+ (PtrUpdateLayeredWindow) QSystemLibrary::resolve(QLatin1String("user32"),
"UpdateLayeredWindow");
if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect)
@@ -822,7 +822,7 @@ void qt_init(QApplicationPrivate *priv, int)
// Notify Vista and Windows 7 that we support highter DPI settings
ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
- QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
+ QSystemLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
if (ptrSetProcessDPIAware)
ptrSetProcessDPIAware();
#endif
@@ -842,30 +842,28 @@ void qt_init(QApplicationPrivate *priv, int)
#elif !defined(Q_WS_WINCE)
#if !defined(QT_NO_NATIVE_GESTURES)
priv->GetGestureInfo =
- (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
+ (PtrGetGestureInfo)QSystemLibrary::resolve(QLatin1String("user32"),
"GetGestureInfo");
priv->GetGestureExtraArgs =
- (PtrGetGestureExtraArgs)QLibrary::resolve(QLatin1String("user32"),
+ (PtrGetGestureExtraArgs)QSystemLibrary::resolve(QLatin1String("user32"),
"GetGestureExtraArgs");
priv->CloseGestureInfoHandle =
- (PtrCloseGestureInfoHandle)QLibrary::resolve(QLatin1String("user32"),
+ (PtrCloseGestureInfoHandle)QSystemLibrary::resolve(QLatin1String("user32"),
"CloseGestureInfoHandle");
priv->SetGestureConfig =
- (PtrSetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
+ (PtrSetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"),
"SetGestureConfig");
priv->GetGestureConfig =
- (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
+ (PtrGetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"),
"GetGestureConfig");
#endif // QT_NO_NATIVE_GESTURES
+ QSystemLibrary libTheme(QLatin1String("uxtheme"));
priv->BeginPanningFeedback =
- (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
- "BeginPanningFeedback");
+ (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback");
priv->UpdatePanningFeedback =
- (PtrUpdatePanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
- "UpdatePanningFeedback");
+ (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback");
priv->EndPanningFeedback =
- (PtrEndPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
- "EndPanningFeedback");
+ (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback");
#endif
}
@@ -2294,7 +2292,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
if (!oleaccChecked) {
oleaccChecked = true;
#if !defined(Q_OS_WINCE)
- ptrLresultFromObject = (PtrLresultFromObject)QLibrary::resolve(QLatin1String("oleacc.dll"), "LresultFromObject");
+ ptrLresultFromObject = (PtrLresultFromObject)QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject");
#endif
}
if (ptrLresultFromObject) {
@@ -3080,7 +3078,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
static PtrTrackMouseEvent ptrTrackMouseEvent = 0;
if (!trackMouseEventLookup) {
trackMouseEventLookup = true;
- ptrTrackMouseEvent = (PtrTrackMouseEvent)QLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");
+ ptrTrackMouseEvent = (PtrTrackMouseEvent)QSystemLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");
}
if (ptrTrackMouseEvent && !qApp->d_func()->inPopupMode()) {
// We always have to set the tracking, since
@@ -3600,7 +3598,7 @@ static void initWinTabFunctions()
if (!qt_is_gui_used)
return;
- QLibrary library(QLatin1String("wintab32"));
+ QSystemLibrary library(QLatin1String("wintab32"));
if (library.load()) {
ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
@@ -4044,7 +4042,7 @@ void QApplicationPrivate::initializeMultitouch_sys()
iInkTablets->Release();
}
- QLibrary library(QLatin1String("user32"));
+ QSystemLibrary library(QLatin1String("user32"));
// MinGW (g++ 3.4.5) accepts only C casts.
RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
diff --git a/src/gui/kernel/qdesktopwidget_win.cpp b/src/gui/kernel/qdesktopwidget_win.cpp
index 1fea8d6..7d7caac 100644
--- a/src/gui/kernel/qdesktopwidget_win.cpp
+++ b/src/gui/kernel/qdesktopwidget_win.cpp
@@ -42,7 +42,7 @@
#include "qdesktopwidget.h"
#include "qt_windows.h"
#include "qapplication_p.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include <qvector.h>
#include <limits.h>
#ifdef Q_WS_WINCE
@@ -155,7 +155,7 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
screenCount = 0;
#ifndef Q_OS_WINCE
- QLibrary user32Lib(QLatin1String("user32"));
+ QSystemLibrary user32Lib(QLatin1String("user32"));
if (user32Lib.load()) {
enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");
@@ -173,7 +173,7 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
enumDisplayMonitors = 0;
getMonitorInfo = 0;
#else
- QLibrary coreLib(QLatin1String("coredll"));
+ QSystemLibrary coreLib(QLatin1String("coredll"));
if (coreLib.load()) {
// CE >= 4.0 case
enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors");
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 9acfb70..10d6345 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -47,7 +47,6 @@
#include "qevent.h"
#include "qimage.h"
#include "qlayout.h"
-#include "qlibrary.h"
#include "qpainter.h"
#include "qstack.h"
#include "qt_windows.h"
@@ -65,6 +64,7 @@
#include <private/qapplication_p.h>
#include <private/qwininputcontext_p.h>
#include <private/qpaintengine_raster_p.h>
+#include <private/qsystemlibrary_p.h>
#if defined(Q_WS_WINCE)
#include "qguifunctions_wince.h"
@@ -143,7 +143,7 @@ static void init_wintab_functions()
#else
if (!qt_is_gui_used)
return;
- QLibrary library(QLatin1String("wintab32"));
+ QSystemLibrary library(QLatin1String("wintab32"));
ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW");
ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
ptrWTClose = (PtrWTClose)library.resolve("WTClose");
@@ -1860,7 +1860,7 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
static bool function_resolved = false;
if (!function_resolved) {
ptrSetLayeredWindowAttributes =
- (PtrSetLayeredWindowAttributes) QLibrary::resolve(QLatin1String("user32"),
+ (PtrSetLayeredWindowAttributes) QSystemLibrary::resolve(QLatin1String("user32"),
"SetLayeredWindowAttributes");
function_resolved = true;
}
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 6c48590..53d32da 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -45,7 +45,7 @@
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include "qapplication.h"
#include "qbitmap.h"
#include "qdrawutil.h" // for now
@@ -126,7 +126,7 @@ QWindowsStylePrivate::QWindowsStylePrivate()
#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
- QLibrary shellLib(QLatin1String("shell32"));
+ QSystemLibrary shellLib(QLatin1String("shell32"));
pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
}
#endif
@@ -921,9 +921,9 @@ static const char *const question_xpm[] = {
static QPixmap loadIconFromShell32( int resourceId, int size )
{
#ifdef Q_OS_WINCE
- HMODULE hmod = LoadLibrary(L"ceshell.dll");
+ HMODULE hmod = LoadLibrary(L"ceshell");
#else
- HMODULE hmod = LoadLibrary(L"shell32.dll");
+ HMODULE hmod = QSystemLibrary::load(L"shell32");
#endif
if( hmod ) {
HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 67a7b85..92688c0 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -42,6 +42,7 @@
#include "qwindowsvistastyle.h"
#include "qwindowsvistastyle_p.h"
#include <private/qstylehelper_p.h>
+#include <private/qsystemlibrary_p.h>
#if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN)
@@ -2597,7 +2598,7 @@ bool QWindowsVistaStylePrivate::resolveSymbols()
static bool tried = false;
if (!tried) {
tried = true;
- QLibrary themeLib(QLatin1String("uxtheme"));
+ QSystemLibrary themeLib(QLatin1String("uxtheme"));
pSetWindowTheme = (PtrSetWindowTheme )themeLib.resolve("SetWindowTheme");
pIsThemePartDefined = (PtrIsThemePartDefined )themeLib.resolve("IsThemePartDefined");
pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index efb1224..a2538fe 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -48,7 +48,7 @@
#include <private/qapplication_p.h>
#include <private/qstylehelper_p.h>
#include <private/qwidget_p.h>
-#include <qlibrary.h>
+#include <private/qsystemlibrary_p.h>
#include <qpainter.h>
#include <qpaintengine.h>
#include <qwidget.h>
@@ -344,7 +344,7 @@ bool QWindowsXPStylePrivate::resolveSymbols()
static bool tried = false;
if (!tried) {
tried = true;
- QLibrary themeLib(QLatin1String("uxtheme"));
+ QSystemLibrary themeLib(QLatin1String("uxtheme"));
pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
if (pIsAppThemed) {
pIsThemeActive = (PtrIsThemeActive )themeLib.resolve("IsThemeActive");
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index a6ceee1..160b139 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -45,7 +45,7 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qpaintdevice.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include "qabstractfileengine.h"
#include "qendian.h"
@@ -1049,7 +1049,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
{
if(!fnt->data.isEmpty()) {
#ifndef Q_OS_WINCE
- PtrAddFontMemResourceEx ptrAddFontMemResourceEx = (PtrAddFontMemResourceEx)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrAddFontMemResourceEx ptrAddFontMemResourceEx = (PtrAddFontMemResourceEx)QSystemLibrary::resolve(QLatin1String("gdi32"),
"AddFontMemResourceEx");
if (!ptrAddFontMemResourceEx)
return;
@@ -1112,7 +1112,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
return;
#else
// supported from 2000 on, so no need to deal with the *A variant
- PtrAddFontResourceExW ptrAddFontResourceExW = (PtrAddFontResourceExW)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrAddFontResourceExW ptrAddFontResourceExW = (PtrAddFontResourceExW)QSystemLibrary::resolve(QLatin1String("gdi32"),
"AddFontResourceExW");
if (!ptrAddFontResourceExW
|| ptrAddFontResourceExW((wchar_t*)fnt->fileName.utf16(), FR_PRIVATE, 0) == 0)
@@ -1141,7 +1141,7 @@ bool QFontDatabase::removeApplicationFont(int handle)
if (!removeSucceeded)
return false;
#else
- PtrRemoveFontMemResourceEx ptrRemoveFontMemResourceEx = (PtrRemoveFontMemResourceEx)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrRemoveFontMemResourceEx ptrRemoveFontMemResourceEx = (PtrRemoveFontMemResourceEx)QSystemLibrary::resolve(QLatin1String("gdi32"),
"RemoveFontMemResourceEx");
if (!ptrRemoveFontMemResourceEx
|| !ptrRemoveFontMemResourceEx(font.handle))
@@ -1152,7 +1152,7 @@ bool QFontDatabase::removeApplicationFont(int handle)
if (!RemoveFontResource((LPCWSTR)font.fileName.utf16()))
return false;
#else
- PtrRemoveFontResourceExW ptrRemoveFontResourceExW = (PtrRemoveFontResourceExW)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrRemoveFontResourceExW ptrRemoveFontResourceExW = (PtrRemoveFontResourceExW)QSystemLibrary::resolve(QLatin1String("gdi32"),
"RemoveFontResourceExW");
if (!ptrRemoveFontResourceExW
|| !ptrRemoveFontResourceExW((LPCWSTR)font.fileName.utf16(), FR_PRIVATE, 0))
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index eea196e..be90f1c 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -50,7 +50,7 @@
#include "qt_windows.h"
#include <private/qapplication_p.h>
-#include <qlibrary.h>
+#include <private/qsystemlibrary_p.h>
#include <qpaintdevice.h>
#include <qpainter.h>
#include <limits.h>
@@ -140,7 +140,7 @@ static void resolveGetCharWidthI()
if (resolvedGetCharWidthI)
return;
resolvedGetCharWidthI = true;
- ptrGetCharWidthI = (PtrGetCharWidthI)QLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
+ ptrGetCharWidthI = (PtrGetCharWidthI)QSystemLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
}
#endif // !defined(Q_WS_WINCE)
diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp
index 9f3b6e1..359710f 100644
--- a/src/gui/util/qdesktopservices_win.cpp
+++ b/src/gui/util/qdesktopservices_win.cpp
@@ -41,7 +41,7 @@
#include <qsettings.h>
#include <qdir.h>
-#include <qlibrary.h>
+#include <private/qsystemlibrary_p.h>
#include <qurl.h>
#include <qstringlist.h>
#include <qprocess.h>
@@ -177,9 +177,9 @@ QString QDesktopServices::storageLocation(StandardLocation type)
QString result;
#ifndef Q_OS_WINCE
- QLibrary library(QLatin1String("shell32"));
+ QSystemLibrary library(QLatin1String("shell32"));
#else
- QLibrary library(QLatin1String("coredll"));
+ QSystemLibrary library(QLatin1String("coredll"));
#endif // Q_OS_WINCE
typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
static GetSpecialFolderPath SHGetSpecialFolderPath =
diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp
index 1571b94..6e78dfd 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/gui/util/qsystemtrayicon_win.cpp
@@ -55,7 +55,7 @@
#include <commctrl.h>
#include <shlwapi.h>
#include <QBitmap>
-#include <QLibrary>
+#include <private/qsystemlibrary_p.h>
#include <QApplication>
#include <QToolTip>
#include <QDesktopWidget>
@@ -134,14 +134,14 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object)
// Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher
static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx =
- (PtrChangeWindowMessageFilterEx)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
+ (PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
if (pChangeWindowMessageFilterEx) {
// Call the safer ChangeWindowMessageFilterEx API if available
pChangeWindowMessageFilterEx(winId(), MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0);
} else {
static PtrChangeWindowMessageFilter pChangeWindowMessageFilter =
- (PtrChangeWindowMessageFilter)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
+ (PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
if (pChangeWindowMessageFilter) {
// Call the deprecated ChangeWindowMessageFilter API otherwise
@@ -352,7 +352,7 @@ void QSystemTrayIconPrivate::install_sys()
QRect QSystemTrayIconSys::findIconGeometry(const int iconId)
{
static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
- (PtrShell_NotifyIconGetRect)QLibrary::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect");
+ (PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect");
if (Shell_NotifyIconGetRect) {
Q_NOTIFYICONIDENTIFIER nid;
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index b30204b..8241c84 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -49,7 +49,7 @@
#include "qhostinfo_p.h"
#include "private/qnativesocketengine_p.h"
#include <ws2tcpip.h>
-#include <qlibrary.h>
+#include <private/qsystemlibrary_p.h>
#include <qmutex.h>
#include <qurl.h>
#include <private/qmutexpool_p.h>
@@ -90,13 +90,13 @@ static void resolveLibrary()
// Attempt to resolve getaddrinfo(); without it we'll have to fall
// back to gethostbyname(), which has no IPv6 support.
#if !defined(Q_OS_WINCE)
- local_getaddrinfo = (getaddrinfoProto) QLibrary::resolve(QLatin1String("ws2_32.dll"), "getaddrinfo");
- local_freeaddrinfo = (freeaddrinfoProto) QLibrary::resolve(QLatin1String("ws2_32.dll"), "freeaddrinfo");
- local_getnameinfo = (getnameinfoProto) QLibrary::resolve(QLatin1String("ws2_32.dll"), "getnameinfo");
+ local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getaddrinfo");
+ local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "freeaddrinfo");
+ local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getnameinfo");
#else
- local_getaddrinfo = (getaddrinfoProto) QLibrary::resolve(QLatin1String("ws2.dll"), "getaddrinfo");
- local_freeaddrinfo = (freeaddrinfoProto) QLibrary::resolve(QLatin1String("ws2.dll"), "freeaddrinfo");
- local_getnameinfo = (getnameinfoProto) QLibrary::resolve(QLatin1String("ws2.dll"), "getnameinfo");
+ local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getaddrinfo");
+ local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "freeaddrinfo");
+ local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getnameinfo");
#endif
}
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index 056650d..a1d1df6 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -48,6 +48,7 @@
#include <qhostinfo.h>
#include <qhash.h>
#include <qurl.h>
+#include <private/qsystemlibrary_p.h>
QT_BEGIN_NAMESPACE
@@ -66,7 +67,7 @@ static void resolveLibs()
if (!done) {
done = true;
- HINSTANCE iphlpapiHnd = LoadLibrary(L"iphlpapi");
+ HINSTANCE iphlpapiHnd = QSystemLibrary::load(L"iphlpapi");
if (iphlpapiHnd == NULL)
return;
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index e801738..de7c245 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -51,6 +51,7 @@
#include <string.h>
#include <qt_windows.h>
#include <wininet.h>
+#include <private/qsystemlibrary_p.h>
/*
* Information on the WinHTTP DLL:
@@ -273,15 +274,15 @@ void QWindowsSystemProxy::init()
return;
#else
// load the winhttp.dll library
- HINSTANCE winhttpHnd = LoadLibrary(L"winhttp");
- if (!winhttpHnd)
+ QSystemLibrary lib(L"winhttp");
+ if (!lib.load())
return; // failed to load
- ptrWinHttpOpen = (PtrWinHttpOpen)GetProcAddress(winhttpHnd, "WinHttpOpen");
- ptrWinHttpCloseHandle = (PtrWinHttpCloseHandle)GetProcAddress(winhttpHnd, "WinHttpCloseHandle");
- ptrWinHttpGetProxyForUrl = (PtrWinHttpGetProxyForUrl)GetProcAddress(winhttpHnd, "WinHttpGetProxyForUrl");
- ptrWinHttpGetDefaultProxyConfiguration = (PtrWinHttpGetDefaultProxyConfiguration)GetProcAddress(winhttpHnd, "WinHttpGetDefaultProxyConfiguration");
- ptrWinHttpGetIEProxyConfigForCurrentUser = (PtrWinHttpGetIEProxyConfigForCurrentUser)GetProcAddress(winhttpHnd, "WinHttpGetIEProxyConfigForCurrentUser");
+ ptrWinHttpOpen = (PtrWinHttpOpen)lib.resolve("WinHttpOpen");
+ ptrWinHttpCloseHandle = (PtrWinHttpCloseHandle)lib.resolve("WinHttpCloseHandle");
+ ptrWinHttpGetProxyForUrl = (PtrWinHttpGetProxyForUrl)lib.resolve("WinHttpGetProxyForUrl");
+ ptrWinHttpGetDefaultProxyConfiguration = (PtrWinHttpGetDefaultProxyConfiguration)lib.resolve("WinHttpGetDefaultProxyConfiguration");
+ ptrWinHttpGetIEProxyConfigForCurrentUser = (PtrWinHttpGetIEProxyConfigForCurrentUser)lib.resolve("WinHttpGetIEProxyConfigForCurrentUser");
// Try to obtain the Internet Explorer configuration.
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxyConfig;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 8620e00..9e550ae 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -42,7 +42,11 @@
#include "qsslsocket_openssl_symbols_p.h"
-#include <QtCore/qlibrary.h>
+#ifdef Q_OS_WIN
+# include <private/qsystemlibrary_p.h>
+#else
+# include <QtCore/qlibrary.h>
+#endif
#include <QtCore/qmutex.h>
#include <private/qmutexpool_p.h>
#include <QtCore/qdatetime.h>
@@ -343,22 +347,22 @@ static QStringList findAllLibSsl()
}
# endif
-static QPair<QLibrary*, QLibrary*> loadOpenSsl()
+#ifdef Q_OS_WIN
+static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
{
- QPair<QLibrary*,QLibrary*> pair;
+ QPair<QSystemLibrary*,QSystemLibrary*> pair;
pair.first = 0;
pair.second = 0;
-# ifdef Q_OS_WIN
- QLibrary *ssleay32 = new QLibrary(QLatin1String("ssleay32"));
- if (!ssleay32->load()) {
+ QSystemLibrary *ssleay32 = new QSystemLibrary(QLatin1String("ssleay32"));
+ if (!ssleay32->load(false)) {
// Cannot find ssleay32.dll
delete ssleay32;
return pair;
}
- QLibrary *libeay32 = new QLibrary(QLatin1String("libeay32"));
- if (!libeay32->load()) {
+ QSystemLibrary *libeay32 = new QSystemLibrary(QLatin1String("libeay32"));
+ if (!libeay32->load(false)) {
delete ssleay32;
delete libeay32;
return pair;
@@ -367,7 +371,16 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
pair.first = ssleay32;
pair.second = libeay32;
return pair;
-# elif defined(Q_OS_SYMBIAN)
+}
+#else
+
+static QPair<QLibrary*, QLibrary*> loadOpenSsl()
+{
+ QPair<QLibrary*,QLibrary*> pair;
+ pair.first = 0;
+ pair.second = 0;
+
+# if defined(Q_OS_SYMBIAN)
QLibrary *libssl = new QLibrary(QLatin1String("libssl"));
if (!libssl->load()) {
// Cannot find ssleay32.dll
@@ -467,6 +480,7 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
return pair;
# endif
}
+#endif
bool q_resolveOpenSslSymbols()
{
@@ -481,7 +495,11 @@ bool q_resolveOpenSslSymbols()
return false;
triedToResolveSymbols = true;
+#ifdef Q_OS_WIN
+ QPair<QSystemLibrary *, QSystemLibrary *> libs = loadOpenSslWin32();
+#else
QPair<QLibrary *, QLibrary *> libs = loadOpenSsl();
+#endif
if (!libs.first || !libs.second)
// failed to load them
return false;
diff --git a/src/qt3support/network/q3dns.cpp b/src/qt3support/network/q3dns.cpp
index ab042c4..e0e9909 100644
--- a/src/qt3support/network/q3dns.cpp
+++ b/src/qt3support/network/q3dns.cpp
@@ -41,6 +41,7 @@
#include "qplatformdefs.h"
#include "qbytearray.h"
+#include <private/qsystemlibrary_p.h>
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_CYGWIN)
# include "qt_windows.h"
#else
@@ -2299,7 +2300,7 @@ void Q3Dns::doResInit()
bool gotNetworkParams = false;
// try the API call GetNetworkParams() first and use registry lookup only
// as a fallback
- HINSTANCE hinstLib = LoadLibrary( L"iphlpapi" );
+ HINSTANCE hinstLib = QSystemLibrary::load( L"iphlpapi" );
if ( hinstLib != 0 ) {
#ifdef Q_OS_WINCE
GNP getNetworkParams = (GNP) GetProcAddress( hinstLib, L"GetNetworkParams" );
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index 0dbb90f..21fd412 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -87,7 +87,8 @@ unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \
../../corelib/io/qfsfileengine_iterator_unix.cpp
win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \
- ../../corelib/io/qfsfileengine_iterator_win.cpp
+ ../../corelib/io/qfsfileengine_iterator_win.cpp \
+ ../../corelib/plugin/qsystemlibrary.cpp \
macx: {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)