mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00

* Fix calls to depreciated wxPen constructor * Fix use of wxTimerEvent * Fix unrecognized character escape sequence * Fix signed/unsigned mismatch At least as much as possible without significantly altering parts of the application * Clean unreferenced variables * fix mistyped namespace selector * Update deprecated calls * Fix preprocessor statement * Remove empty switch statements * Change int vector used as bool to bool vector * Remove empty control statements and related unused code * Change multi character constant to string constant * Fix discarded return value json::parse was being called on the object, rather than statically like it should be. Also, the value was not being captured. * Rename ICON_SIZE def used by MultiMachine By having the definition in the header, it causes issues when other files define ICON_SIZE. By renaming it to MM_ICON_SIZE, this lessens the issue. It would probably be ideal to have the definitions in the respective .cpp that use them, but it would make it less convenient to update the values if needed in the future. * Remove unused includes * Fix linux/macOS compilation * Hide unused-function errors on non-Windows systems * Disable signed/unsigned comparison mismatch error * Remove/Disable more unused variables Still TODO: check double for loop in Print.cpp * Remove unused variable that was missed * Remove unused variables in libraries in the src folder * Apply temporary fix for subobject linkage error * Remove/Disable last set of unused variables reported by GCC * remove redundant for loop * fix misspelled ifdef check * Update message on dialog * Fix hard-coded platform specific modifier keys * Remove duplicate for loop * Disable -Wmisleading-indentation warning * disable -Wswitch warning * Remove unused local typedefs * Fix -Wunused-value * Fix pragma error on Windows from subobject linkage fix * Fix -Waddress * Fix null conversions (-Wconversion-null) --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
83 lines
2.7 KiB
C++
83 lines
2.7 KiB
C++
#include "BlacklistedLibraryCheck.hpp"
|
|
|
|
#include <boost/nowide/convert.hpp>
|
|
|
|
#ifdef WIN32
|
|
#include <psapi.h>
|
|
# endif //WIN32
|
|
|
|
namespace Slic3r {
|
|
|
|
#ifdef WIN32
|
|
|
|
//only dll name with .dll suffix - currently case sensitive
|
|
const std::vector<std::wstring> BlacklistedLibraryCheck::blacklist({ L"NahimicOSD.dll", L"SS2OSD.dll", L"amhook.dll", L"AMHook.dll" });
|
|
|
|
bool BlacklistedLibraryCheck::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 BlacklistedLibraryCheck::get_blacklisted_string()
|
|
{
|
|
std::wstring ret;
|
|
for (const auto& lib : m_found)
|
|
ret += lib + L"\n";
|
|
return ret;
|
|
}
|
|
|
|
bool BlacklistedLibraryCheck::perform_check()
|
|
{
|
|
// Get the pseudo-handle for the current process.
|
|
HANDLE hCurrentProcess = GetCurrentProcess();
|
|
|
|
// Get a list of all the modules in this process.
|
|
HMODULE hMods[1024];
|
|
DWORD cbNeeded;
|
|
if (EnumProcessModulesEx(hCurrentProcess, hMods, sizeof(hMods), &cbNeeded, LIST_MODULES_ALL))
|
|
{
|
|
//printf("Total Dlls: %d\n", cbNeeded / sizeof(HMODULE));
|
|
for (unsigned int i = 0; i < cbNeeded / sizeof(HMODULE); ++ i)
|
|
{
|
|
wchar_t szModName[MAX_PATH];
|
|
// Get the full path to the module's file.
|
|
if (GetModuleFileNameExW(hCurrentProcess, hMods[i], szModName, MAX_PATH))
|
|
{
|
|
// Add to list if blacklisted
|
|
if (BlacklistedLibraryCheck::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);
|
|
}
|
|
}
|
|
}
|
|
|
|
//printf("\n");
|
|
return !m_found.empty();
|
|
}
|
|
|
|
bool BlacklistedLibraryCheck::is_blacklisted(const 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(BlacklistedLibraryCheck::blacklist.begin(), BlacklistedLibraryCheck::blacklist.end(), dllname) != BlacklistedLibraryCheck::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 BlacklistedLibraryCheck::is_blacklisted(const std::string &dllpath)
|
|
{
|
|
return BlacklistedLibraryCheck::is_blacklisted(boost::nowide::widen(dllpath));
|
|
}
|
|
|
|
#endif //WIN32
|
|
|
|
} // namespace Slic3r
|