Detect x32 and x64 compatibility between plugins and Notepad++

This commit is contained in:
Don HO 2016-06-17 01:10:32 +02:00
parent 5a5582b972
commit 9835445c8b
2 changed files with 36 additions and 11 deletions

View File

@ -87,9 +87,34 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
if (isInLoadedDlls(pluginFileName)) if (isInLoadedDlls(pluginFileName))
return 0; return 0;
NppParameters * nppParams = NppParameters::getInstance();
PluginInfo *pi = new PluginInfo; PluginInfo *pi = new PluginInfo;
try 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->_moduleName = PathFindFileName(pluginFilePath);
pi->_hLib = ::LoadLibrary(pluginFilePath); pi->_hLib = ::LoadLibrary(pluginFilePath);
@ -157,8 +182,6 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
int numLexers = GetLexerCount(); int numLexers = GetLexerCount();
NppParameters * nppParams = NppParameters::getInstance();
ExternalLangContainer *containers[30]; ExternalLangContainer *containers[30];
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();

View File

@ -1544,6 +1544,7 @@ public:
void setCloudChoice(const TCHAR *pathChoice); void setCloudChoice(const TCHAR *pathChoice);
void removeCloudChoice(); void removeCloudChoice();
bool isCloudPathChanged() const; bool isCloudPathChanged() const;
bool isx64() const { return _isx64; };
COLORREF getCurrentDefaultBgColor() const { COLORREF getCurrentDefaultBgColor() const {
return _currentDefaultBgColor; return _currentDefaultBgColor;
@ -1627,6 +1628,7 @@ private:
WNDPROC _transparentFuncAddr; WNDPROC _transparentFuncAddr;
WNDPROC _enableThemeDialogTextureFuncAddr; WNDPROC _enableThemeDialogTextureFuncAddr;
bool _isLocal; bool _isLocal;
bool _isx64 = false; // by default 32-bit
public: public:
void setShortcutDirty() { _isAnyShortcutModified = true; }; void setShortcutDirty() { _isAnyShortcutModified = true; };