Detect x32 and x64 compatibility between plugins and Notepad++
This commit is contained in:
parent
5a5582b972
commit
9835445c8b
@ -87,20 +87,45 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
||||
if (isInLoadedDlls(pluginFileName))
|
||||
return 0;
|
||||
|
||||
NppParameters * nppParams = NppParameters::getInstance();
|
||||
|
||||
PluginInfo *pi = new PluginInfo;
|
||||
try
|
||||
{
|
||||
DWORD detectionResult;
|
||||
if (GetBinaryType(pluginFilePath, &detectionResult))
|
||||
{
|
||||
switch (detectionResult)
|
||||
{
|
||||
case SCS_32BIT_BINARY:
|
||||
{
|
||||
if (nppParams->isx64())
|
||||
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<generic_strin
|
||||
|
||||
int numLexers = GetLexerCount();
|
||||
|
||||
NppParameters * nppParams = NppParameters::getInstance();
|
||||
|
||||
ExternalLangContainer *containers[30];
|
||||
|
||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||
|
@ -1544,6 +1544,7 @@ public:
|
||||
void setCloudChoice(const TCHAR *pathChoice);
|
||||
void removeCloudChoice();
|
||||
bool isCloudPathChanged() const;
|
||||
bool isx64() const { return _isx64; };
|
||||
|
||||
COLORREF getCurrentDefaultBgColor() const {
|
||||
return _currentDefaultBgColor;
|
||||
@ -1627,6 +1628,7 @@ private:
|
||||
WNDPROC _transparentFuncAddr;
|
||||
WNDPROC _enableThemeDialogTextureFuncAddr;
|
||||
bool _isLocal;
|
||||
bool _isx64 = false; // by default 32-bit
|
||||
|
||||
public:
|
||||
void setShortcutDirty() { _isAnyShortcutModified = true; };
|
||||
|
Loading…
Reference in New Issue
Block a user