Check loading of blacklisted dlls and show warning dialog at startup. Also show these dlls in sysinfo dialog.
This commit is contained in:
parent
4f161607c7
commit
fa2568a5e3
11 changed files with 172 additions and 5 deletions
|
@ -140,6 +140,11 @@ target_link_libraries(PrusaSlicer libslic3r_gui)
|
||||||
else ()
|
else ()
|
||||||
target_link_libraries(PrusaSlicer -ldl)
|
target_link_libraries(PrusaSlicer -ldl)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (WIN32)
|
||||||
|
include_directories(detours)
|
||||||
|
find_library(PSAPI_LIB NAMES Psapi)
|
||||||
|
target_link_libraries(PrusaSlicer ${PSAPI_LIB})
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# On Windows, a shim application is required to produce a console / non console version of the Slic3r application.
|
# On Windows, a shim application is required to produce a console / non console version of the Slic3r application.
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "libslic3r/Format/SL1.hpp"
|
#include "libslic3r/Format/SL1.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "libslic3r/Thread.hpp"
|
#include "libslic3r/Thread.hpp"
|
||||||
|
#include "libslic3r/LibraryCheck.hpp"
|
||||||
|
|
||||||
#include "PrusaSlicer.hpp"
|
#include "PrusaSlicer.hpp"
|
||||||
|
|
||||||
|
@ -566,6 +567,7 @@ int CLI::run(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (start_gui) {
|
if (start_gui) {
|
||||||
#ifdef SLIC3R_GUI
|
#ifdef SLIC3R_GUI
|
||||||
Slic3r::GUI::GUI_InitParams params;
|
Slic3r::GUI::GUI_InitParams params;
|
||||||
|
@ -600,6 +602,18 @@ bool CLI::setup(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// Notify user if blacklisted library is already loaded (Nahimic)
|
||||||
|
// If there are cases of no reports with blacklisted lib - this check should be performed later.
|
||||||
|
// Some libraries are loaded when we load libraries during startup.
|
||||||
|
if (LibraryCheck::get_instance().perform_check()) {
|
||||||
|
std::wstring text = L"Following libraries has been detected inside of the PrusaSlicer process."
|
||||||
|
L" We suggest stopping or uninstalling these services if you experience crashes or unexpected behaviour while using PrusaSlicer.\n\n";
|
||||||
|
text += LibraryCheck::get_instance().get_blacklisted_string();
|
||||||
|
MessageBoxW(NULL, text.c_str(), L"Warning"/*L"Incopatible library found"*/, MB_OK);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// See Invoking prusa-slicer from $PATH environment variable crashes #5542
|
// See Invoking prusa-slicer from $PATH environment variable crashes #5542
|
||||||
// boost::filesystem::path path_to_binary = boost::filesystem::system_complete(argv[0]);
|
// boost::filesystem::path path_to_binary = boost::filesystem::system_complete(argv[0]);
|
||||||
boost::filesystem::path path_to_binary = boost::dll::program_location();
|
boost::filesystem::path path_to_binary = boost::dll::program_location();
|
||||||
|
|
|
@ -208,7 +208,6 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#ifdef SLIC3R_WRAPPER_NOCONSOLE
|
#ifdef SLIC3R_WRAPPER_NOCONSOLE
|
||||||
int APIENTRY wWinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, PWSTR /* lpCmdLine */, int /* nCmdShow */)
|
int APIENTRY wWinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, PWSTR /* lpCmdLine */, int /* nCmdShow */)
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,6 +200,7 @@ static void register_error(hid_device *dev, const char *op)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HIDAPI_USE_DDK
|
#ifndef HIDAPI_USE_DDK
|
||||||
|
|
||||||
static int lookup_functions()
|
static int lookup_functions()
|
||||||
{
|
{
|
||||||
lib_handle = LoadLibraryA("hid.dll");
|
lib_handle = LoadLibraryA("hid.dll");
|
||||||
|
|
|
@ -120,6 +120,8 @@ add_library(libslic3r STATIC
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h"
|
||||||
Line.cpp
|
Line.cpp
|
||||||
Line.hpp
|
Line.hpp
|
||||||
|
LibraryCheck.cpp
|
||||||
|
LibraryCheck.hpp
|
||||||
Model.cpp
|
Model.cpp
|
||||||
Model.hpp
|
Model.hpp
|
||||||
ModelArrange.hpp
|
ModelArrange.hpp
|
||||||
|
|
100
src/libslic3r/LibraryCheck.cpp
Normal file
100
src/libslic3r/LibraryCheck.cpp
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
#include "LibraryCheck.hpp"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <boost/nowide/convert.hpp>
|
||||||
|
#include <psapi.h>
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
//only dll name with .dll suffix - currently case sensitive
|
||||||
|
const std::vector<std::wstring> LibraryCheck::blacklist({ L"NahimicOSD.dll" });
|
||||||
|
|
||||||
|
bool LibraryCheck::get_blacklisted(std::vector<std::wstring>& names)
|
||||||
|
{
|
||||||
|
if (m_found.empty())
|
||||||
|
return false;
|
||||||
|
for (const auto& lib : m_found)
|
||||||
|
names.emplace_back(lib);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring LibraryCheck::get_blacklisted_string()
|
||||||
|
{
|
||||||
|
std::wstring ret;
|
||||||
|
if (m_found.empty())
|
||||||
|
return ret;
|
||||||
|
//ret = L"These libraries has been detected inside of the PrusaSlicer process.\n"
|
||||||
|
// L"We suggest stopping or uninstalling these services if you experience crashes while using PrusaSlicer.\n\n";
|
||||||
|
for (const auto& lib : m_found)
|
||||||
|
{
|
||||||
|
ret += lib;
|
||||||
|
ret += L"\n";
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LibraryCheck::perform_check()
|
||||||
|
{
|
||||||
|
|
||||||
|
DWORD processID = GetCurrentProcessId();
|
||||||
|
HMODULE hMods[1024];
|
||||||
|
HANDLE hProcess;
|
||||||
|
DWORD cbNeeded;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
// Get a handle to the process.
|
||||||
|
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
|
||||||
|
PROCESS_VM_READ,
|
||||||
|
FALSE, processID);
|
||||||
|
if (NULL == hProcess)
|
||||||
|
return false;
|
||||||
|
// Get a list of all the modules in this process.
|
||||||
|
if (EnumProcessModulesEx(hProcess, hMods, sizeof(hMods), &cbNeeded, LIST_MODULES_ALL))
|
||||||
|
{
|
||||||
|
//printf("Total Dlls: %d\n", cbNeeded / sizeof(HMODULE));
|
||||||
|
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
|
||||||
|
{
|
||||||
|
TCHAR szModName[MAX_PATH];
|
||||||
|
// Get the full path to the module's file.
|
||||||
|
if (GetModuleFileNameEx(hProcess, hMods[i], szModName,
|
||||||
|
sizeof(szModName) / sizeof(TCHAR)))
|
||||||
|
{
|
||||||
|
// Add to list if blacklisted
|
||||||
|
if(LibraryCheck::is_blacklisted(szModName)) {
|
||||||
|
//wprintf(L"Contains library: %s\n", szModName);
|
||||||
|
if (std::find(m_found.begin(), m_found.end(), szModName) == m_found.end())
|
||||||
|
m_found.emplace_back(szModName);
|
||||||
|
}
|
||||||
|
//wprintf(L"%s\n", szModName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
//printf("\n");
|
||||||
|
return !m_found.empty();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LibraryCheck::is_blacklisted(std::wstring dllpath)
|
||||||
|
{
|
||||||
|
std::wstring dllname = boost::filesystem::path(dllpath).filename().wstring();
|
||||||
|
//std::transform(dllname.begin(), dllname.end(), dllname.begin(), std::tolower);
|
||||||
|
if (std::find(LibraryCheck::blacklist.begin(), LibraryCheck::blacklist.end(), dllname) != LibraryCheck::blacklist.end()) {
|
||||||
|
//std::wprintf(L"%s is blacklisted\n", dllname.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//std::wprintf(L"%s is NOT blacklisted\n", dllname.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool LibraryCheck::is_blacklisted(std::string dllpath)
|
||||||
|
{
|
||||||
|
return LibraryCheck::is_blacklisted(boost::nowide::widen(dllpath));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //WIN32
|
||||||
|
|
||||||
|
} // namespace Slic3r
|
45
src/libslic3r/LibraryCheck.hpp
Normal file
45
src/libslic3r/LibraryCheck.hpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef slic3r_LibraryCheck_hpp_
|
||||||
|
#define slic3r_LibraryCheck_hpp_
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#endif //WIN32
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
class LibraryCheck
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static LibraryCheck& get_instance()
|
||||||
|
{
|
||||||
|
static LibraryCheck instance;
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
LibraryCheck() {}
|
||||||
|
|
||||||
|
std::vector<std::wstring> m_found;
|
||||||
|
public:
|
||||||
|
LibraryCheck(LibraryCheck const&) = delete;
|
||||||
|
void operator=(LibraryCheck const&) = delete;
|
||||||
|
// returns all found blacklisted dlls
|
||||||
|
bool get_blacklisted(std::vector<std::wstring>& names);
|
||||||
|
std::wstring get_blacklisted_string();
|
||||||
|
// returns true if enumerating found blacklisted dll
|
||||||
|
bool perform_check();
|
||||||
|
|
||||||
|
static bool is_blacklisted(std::string dllpath);
|
||||||
|
static bool is_blacklisted(std::wstring dllpath);
|
||||||
|
private:
|
||||||
|
static const std::vector<std::wstring> blacklist;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //WIN32
|
||||||
|
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
#endif //slic3r_LibraryCheck_hpp_
|
|
@ -775,6 +775,7 @@ bool GUI_App::on_init_inner()
|
||||||
|
|
||||||
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
|
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
|
||||||
|
|
||||||
|
|
||||||
if (is_editor()) {
|
if (is_editor()) {
|
||||||
std::string msg = Http::tls_global_init();
|
std::string msg = Http::tls_global_init();
|
||||||
std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location");
|
std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location");
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "libslic3r/Config.hpp"
|
#include "libslic3r/Config.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "MainFrame.hpp"
|
#include "MainFrame.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
#include "../libslic3r/LibraryCheck.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// The standard Windows includes.
|
// The standard Windows includes.
|
||||||
|
@ -149,7 +150,8 @@ SysInfoDialog::SysInfoDialog()
|
||||||
"</font>"
|
"</font>"
|
||||||
"</body>"
|
"</body>"
|
||||||
"</html>", bgr_clr_str, text_clr_str, text_clr_str,
|
"</html>", bgr_clr_str, text_clr_str, text_clr_str,
|
||||||
get_mem_info(true) + "<br>" + wxGetApp().get_gl_info(true, true) + "<br>Eigen vectorization supported: " + Eigen::SimdInstructionSetsInUse());
|
get_mem_info(true) + "<br>" + wxGetApp().get_gl_info(true, true) + "<br>Eigen vectorization supported: " + Eigen::SimdInstructionSetsInUse()
|
||||||
|
+ "<br><br><b>Blacklisted loaded libraries:</b><br>" + LibraryCheck::get_instance().get_blacklisted_string().c_str());
|
||||||
m_opengl_info_html->SetPage(text);
|
m_opengl_info_html->SetPage(text);
|
||||||
main_sizer->Add(m_opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15);
|
main_sizer->Add(m_opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ private:
|
||||||
void onCopyToClipboard(wxEvent &);
|
void onCopyToClipboard(wxEvent &);
|
||||||
void onCloseDialog(wxEvent &);
|
void onCloseDialog(wxEvent &);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue