Make sure Windows doesn't load DLLs from the current working directory.

This commit is contained in:
Felix Geyer 2015-12-06 14:32:06 +01:00
parent 77b4bfb14e
commit 17ab438c5a
3 changed files with 12 additions and 1 deletions

View file

@ -30,7 +30,7 @@
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <windows.h> // for Sleep() #include <windows.h> // for Sleep(), SetDllDirectoryA() and SetSearchPathMode()
#endif #endif
#ifdef Q_OS_UNIX #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 } // namespace Tools

View file

@ -40,6 +40,7 @@ void sleep(int ms);
void wait(int ms); void wait(int ms);
QString platform(); QString platform();
void disableCoreDumps(); void disableCoreDumps();
void setupSearchPaths();
} // namespace Tools } // namespace Tools

View file

@ -32,6 +32,7 @@ int main(int argc, char** argv)
#ifdef QT_NO_DEBUG #ifdef QT_NO_DEBUG
Tools::disableCoreDumps(); Tools::disableCoreDumps();
#endif #endif
Tools::setupSearchPaths();
Application app(argc, argv); Application app(argc, argv);
Application::setApplicationName("keepassx"); Application::setApplicationName("keepassx");