diff --git a/LunaHost/GUI/Plugin/CMakeLists.txt b/LunaHost/GUI/Plugin/CMakeLists.txt index 4de5c73..6cb1689 100644 --- a/LunaHost/GUI/Plugin/CMakeLists.txt +++ b/LunaHost/GUI/Plugin/CMakeLists.txt @@ -4,7 +4,7 @@ target_precompile_headers(ToClipboard REUSE_FROM pch) set_target_properties(ToClipboard PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugin${bitappendix}") endif() -if(0) #pluginmanager->QtLoadLibrarys + include(QtUtils.cmake) msvc_registry_search() if(Qt5_DIR) @@ -15,5 +15,4 @@ if(Qt5_DIR) #target_sources(QtLoader PRIVATE ${MOC_SOURCES}) target_link_libraries(QtLoader Qt5::Widgets Qt5::Core) set_target_properties(QtLoader PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugin${bitappendix}") -endif() endif() \ No newline at end of file diff --git a/LunaHost/GUI/pluginmanager.cpp b/LunaHost/GUI/pluginmanager.cpp index 6fe6cf9..63bab85 100644 --- a/LunaHost/GUI/pluginmanager.cpp +++ b/LunaHost/GUI/pluginmanager.cpp @@ -108,6 +108,14 @@ std::vector QtLoadLibrarys(std::vector&collectQtplugs) return modules; } +typedef HMODULE*(*QtLoadLibrary_t)(LPWSTR*,int); +QtLoadLibrary_t loadqtloader(const std::filesystem::path&pluginpath){ + auto QtLoaderPath=pluginpath/"QtLoader.dll"; + auto helper=LoadLibrary(QtLoaderPath.c_str()); + if(helper==0)return 0; + auto QtLoadLibrary = (QtLoadLibrary_t)GetProcAddress(helper, "QtLoadLibrary"); + return QtLoadLibrary; +} void Pluginmanager::loadqtdlls(std::vector&collectQtplugs){ if(collectQtplugs.size()==0)return; auto pluginpath=std::filesystem::current_path()/(x64?"plugin64":"plugin32"); @@ -120,9 +128,24 @@ void Pluginmanager::loadqtdlls(std::vector&collectQtplugs){ } SetEnvironmentVariableW(L"PATH",envs.c_str()); - auto modules=QtLoadLibrarys(collectQtplugs); - if(modules.empty())return; + // auto modules=QtLoadLibrarys(collectQtplugs); + // if(modules.empty())return; + + auto QtLoadLibrary = loadqtloader(pluginpath); + if(!QtLoadLibrary){ + MessageBoxW(host->winId,CantLoadQtLoader,L"Error",0); + return ; + } + std::vectorsaves; + for(auto&p:collectQtplugs){ + auto str=new wchar_t[p.size()+1]; + wcscpy(str,p.c_str()); + saves.emplace_back(str); + } + auto modules=QtLoadLibrary(saves.data(),collectQtplugs.size()); + for(auto str:saves)delete str; + for(int i=0;i