From 4c2e41b6497ff15452b630e38cd1e1eef53c663d Mon Sep 17 00:00:00 2001 From: Don HO Date: Mon, 10 Jul 2017 19:26:22 +0200 Subject: [PATCH] Plugin name should match to plugin folder name Load plugin only when plugin name match to plugin folder name. For example: "NppPluginDemo.dll" can be loaded only when it in the folder named "NppPluginDemo". --- .../MISC/PluginsManager/PluginsManager.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index b6c1eb2a..4e5fc3d6 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -359,38 +359,42 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir) WIN32_FIND_DATA foundData; HANDLE hFindFolder = ::FindFirstFile(pluginsFolderFilter.c_str(), &foundData); HANDLE hFindDll = INVALID_HANDLE_VALUE; + + // get plugin folder if (hFindFolder != INVALID_HANDLE_VALUE && (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { generic_string pluginsFullPathFilter = dir; PathAppend(pluginsFullPathFilter, foundData.cFileName); generic_string pluginsFolderPath = pluginsFullPathFilter; - PathAppend(pluginsFullPathFilter, TEXT("*.dll")); + generic_string dllName = foundData.cFileName; + dllName += TEXT(".dll"); + PathAppend(pluginsFullPathFilter, dllName); + // get plugin hFindDll = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData); if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - generic_string pluginsFullPath = pluginsFolderPath; - PathAppend(pluginsFullPath, foundData.cFileName); - dllNames.push_back(pluginsFullPath); + dllNames.push_back(pluginsFullPathFilter); PluginList & pl = nppParams->getPluginList(); pl.add(foundData.cFileName, false); } + // get plugin folder while (::FindNextFile(hFindFolder, &foundData)) { - generic_string pluginsFullPathFilter2 = dir; PathAppend(pluginsFullPathFilter2, foundData.cFileName); generic_string pluginsFolderPath2 = pluginsFullPathFilter2; - PathAppend(pluginsFullPathFilter2, TEXT("*.dll")); + generic_string dllName2 = foundData.cFileName; + dllName2 += TEXT(".dll"); + PathAppend(pluginsFullPathFilter2, dllName2); + // get plugin hFindDll = ::FindFirstFile(pluginsFullPathFilter2.c_str(), &foundData); if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - generic_string pluginsFullPath2 = pluginsFolderPath2; - PathAppend(pluginsFullPath2, foundData.cFileName); - dllNames.push_back(pluginsFullPath2); + dllNames.push_back(pluginsFullPathFilter2); PluginList & pl = nppParams->getPluginList(); pl.add(foundData.cFileName, false);