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
#ifdef Q_OS_WIN
#include <windows.h> // for Sleep()
#include <windows.h> // 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

View File

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

View File

@ -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");