diff --git a/src/core/Tools.cpp b/src/core/Tools.cpp index 8ed083361..db3baa8c6 100644 --- a/src/core/Tools.cpp +++ b/src/core/Tools.cpp @@ -30,7 +30,7 @@ #endif #ifdef Q_OS_WIN -#include // for Sleep() +#include // for Sleep(), SetDllDirectoryA() and SetSearchPathMode() #endif #ifdef Q_OS_UNIX @@ -259,4 +259,13 @@ void disableCoreDumps() } } +void setupSearchPaths() +{ +#ifdef Q_OS_WIN + // Make sure Windows doesn't load DLLs from the current working directory + SetDllDirectoryA(""); + SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE); +#endif +} + } // namespace Tools diff --git a/src/core/Tools.h b/src/core/Tools.h index 3854507b5..68e9dcd39 100644 --- a/src/core/Tools.h +++ b/src/core/Tools.h @@ -40,6 +40,7 @@ void sleep(int ms); void wait(int ms); QString platform(); void disableCoreDumps(); +void setupSearchPaths(); } // namespace Tools diff --git a/src/main.cpp b/src/main.cpp index df8493acf..bf558f118 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,7 @@ int main(int argc, char** argv) #ifdef QT_NO_DEBUG Tools::disableCoreDumps(); #endif + Tools::setupSearchPaths(); Application app(argc, argv); Application::setApplicationName("keepassx");