From 9835445c8bb9e1c7c6459f76226e33d42642ffb8 Mon Sep 17 00:00:00 2001 From: Don HO Date: Fri, 17 Jun 2016 01:10:32 +0200 Subject: [PATCH] Detect x32 and x64 compatibility between plugins and Notepad++ --- .../MISC/PluginsManager/PluginsManager.cpp | 45 ++++++++++++++----- PowerEditor/src/Parameters.h | 2 + 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 3adba1c1..db8dbe2d 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -87,20 +87,45 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vectorisx64()) + throw generic_string(TEXT("This plugin is in 32-bit, whereas your Notepad++ is in 64-bit.")); + } + break; + + case SCS_64BIT_BINARY: + { + if (not nppParams->isx64()) + throw generic_string(TEXT("This plugin is in 64-bit, whereas your Notepad++ is in 32-bit.")); + } + break; + + default: + throw generic_string(TEXT("It's not a windows standard dll.")); + } + } pi->_moduleName = PathFindFileName(pluginFilePath); - pi->_hLib = ::LoadLibrary(pluginFilePath); - if (!pi->_hLib) - { - const std::wstring& lastErrorMsg = GetLastErrorAsString(); - if (lastErrorMsg.empty()) - throw generic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem.")); - else - throw generic_string(lastErrorMsg.c_str()); - } + pi->_hLib = ::LoadLibrary(pluginFilePath); + if (!pi->_hLib) + { + const std::wstring& lastErrorMsg = GetLastErrorAsString(); + if (lastErrorMsg.empty()) + throw generic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem.")); + else + throw generic_string(lastErrorMsg.c_str()); + } pi->_pFuncIsUnicode = (PFUNCISUNICODE)GetProcAddress(pi->_hLib, "isUnicode"); if (!pi->_pFuncIsUnicode || !pi->_pFuncIsUnicode()) @@ -157,8 +182,6 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector