mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
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))
|
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);
|
||||||
if (!pi->_hLib)
|
if (!pi->_hLib)
|
||||||
{
|
{
|
||||||
const std::wstring& lastErrorMsg = GetLastErrorAsString();
|
const std::wstring& lastErrorMsg = GetLastErrorAsString();
|
||||||
if (lastErrorMsg.empty())
|
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."));
|
throw generic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem."));
|
||||||
else
|
else
|
||||||
throw generic_string(lastErrorMsg.c_str());
|
throw generic_string(lastErrorMsg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
pi->_pFuncIsUnicode = (PFUNCISUNICODE)GetProcAddress(pi->_hLib, "isUnicode");
|
pi->_pFuncIsUnicode = (PFUNCISUNICODE)GetProcAddress(pi->_hLib, "isUnicode");
|
||||||
if (!pi->_pFuncIsUnicode || !pi->_pFuncIsUnicode())
|
if (!pi->_pFuncIsUnicode || !pi->_pFuncIsUnicode())
|
||||||
@ -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();
|
||||||
|
@ -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; };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user