mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Add ARM64 support for auto-update feature
This commit is contained in:
parent
f6856626e0
commit
d0afc51621
@ -28,24 +28,6 @@ const TCHAR * USERMSG = TEXT(" is not compatible with the current version of Not
|
||||
Do you want to remove this plugin from the plugins directory to prevent this message from the next launch?");
|
||||
|
||||
|
||||
#ifdef _WIN64
|
||||
|
||||
#ifdef _M_ARM64
|
||||
#define ARCH_TYPE IMAGE_FILE_MACHINE_ARM64
|
||||
const TCHAR *ARCH_ERR_MSG = TEXT("Cannot load 32-bit or non-ARM64 plugin.");
|
||||
#else
|
||||
#define ARCH_TYPE IMAGE_FILE_MACHINE_AMD64
|
||||
const TCHAR *ARCH_ERR_MSG = TEXT("Cannot load 32-bit plugin.");
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define ARCH_TYPE IMAGE_FILE_MACHINE_I386
|
||||
const TCHAR *ARCH_ERR_MSG = TEXT("Cannot load 64-bit plugin.");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
|
||||
{
|
||||
SCNotification scnN;
|
||||
@ -128,9 +110,17 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
|
||||
try
|
||||
{
|
||||
pi->_moduleName = pluginFileName;
|
||||
int archType = nppParams.archType();
|
||||
if (getBinaryArchitectureType(pluginFilePath) != archType)
|
||||
{
|
||||
const TCHAR *archErrMsg = TEXT("Cannot load 64-bit plugin."); // IMAGE_FILE_MACHINE_I386 by default
|
||||
if (archType == IMAGE_FILE_MACHINE_ARM64)
|
||||
archErrMsg = TEXT("Cannot load 32-bit or non-ARM64 plugin.");
|
||||
else if(archType == IMAGE_FILE_MACHINE_AMD64)
|
||||
archErrMsg = TEXT("Cannot load 32-bit plugin.");
|
||||
|
||||
if (getBinaryArchitectureType(pluginFilePath) != ARCH_TYPE)
|
||||
throw generic_string(ARCH_ERR_MSG);
|
||||
throw generic_string(archErrMsg);
|
||||
}
|
||||
|
||||
const DWORD dwFlags = GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "AddDllDirectory") != NULL ? LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0;
|
||||
pi->_hLib = ::LoadLibraryEx(pluginFilePath, NULL, dwFlags);
|
||||
|
@ -3153,11 +3153,15 @@ void Notepad_plus::command(int id)
|
||||
{
|
||||
param = TEXT("-verbose -v");
|
||||
param += VERSION_VALUE;
|
||||
|
||||
if (NppParameters::getInstance().isx64())
|
||||
int archType = NppParameters::getInstance().archType();
|
||||
if (archType == IMAGE_FILE_MACHINE_AMD64)
|
||||
{
|
||||
param += TEXT(" -px64");
|
||||
}
|
||||
else if (archType == IMAGE_FILE_MACHINE_ARM64)
|
||||
{
|
||||
param += TEXT(" -parm64");
|
||||
}
|
||||
}
|
||||
Process updater(updaterFullPath.c_str(), param.c_str(), updaterDir.c_str());
|
||||
|
||||
|
@ -29,6 +29,19 @@
|
||||
#include <assert.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#ifdef _WIN64
|
||||
|
||||
#ifdef _M_ARM64
|
||||
#define ARCH_TYPE IMAGE_FILE_MACHINE_ARM64
|
||||
#else
|
||||
#define ARCH_TYPE IMAGE_FILE_MACHINE_AMD64
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define ARCH_TYPE IMAGE_FILE_MACHINE_I386
|
||||
|
||||
#endif
|
||||
|
||||
class NativeLangSpeaker;
|
||||
|
||||
const bool POS_VERTICAL = true;
|
||||
@ -1670,8 +1683,7 @@ public:
|
||||
void setCloudChoice(const TCHAR *pathChoice);
|
||||
void removeCloudChoice();
|
||||
bool isCloudPathChanged() const;
|
||||
bool isx64() const { return _isx64; };
|
||||
|
||||
int archType() const { return ARCH_TYPE; };
|
||||
COLORREF getCurrentDefaultBgColor() const {
|
||||
return _currentDefaultBgColor;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ INT_PTR CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara
|
||||
buildTime += wmc.char2wchar(__TIME__, CP_ACP);
|
||||
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
LPCTSTR bitness = nppParam.isx64() ? TEXT("(64-bit)") : TEXT("(32-bit)");
|
||||
LPCTSTR bitness = nppParam.archType() == IMAGE_FILE_MACHINE_I386 ? TEXT("(32-bit)") : (nppParam.archType() == IMAGE_FILE_MACHINE_AMD64 ? TEXT("(64-bit)") : TEXT("(ARM 64-bit)"));
|
||||
::SetDlgItemText(_hSelf, IDC_VERSION_BIT, bitness);
|
||||
|
||||
::SendMessage(compileDateHandle, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(buildTime.c_str()));
|
||||
@ -123,7 +123,7 @@ INT_PTR CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM /
|
||||
|
||||
// Notepad++ version
|
||||
_debugInfoStr = NOTEPAD_PLUS_VERSION;
|
||||
_debugInfoStr += nppParam.isx64() ? TEXT(" (64-bit)") : TEXT(" (32-bit)");
|
||||
_debugInfoStr += nppParam.archType() == IMAGE_FILE_MACHINE_I386 ? TEXT(" (32-bit)") : (nppParam.archType() == IMAGE_FILE_MACHINE_AMD64 ? TEXT(" (64-bit)") : TEXT(" (ARM 64-bit)"));
|
||||
_debugInfoStr += TEXT("\r\n");
|
||||
|
||||
// Build time
|
||||
|
@ -625,10 +625,14 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
|
||||
|
||||
if (TheFirstOne && isUpExist && isGtXP && isSignatureOK)
|
||||
{
|
||||
if (nppParameters.isx64())
|
||||
if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64)
|
||||
{
|
||||
updaterParams += TEXT(" -px64");
|
||||
}
|
||||
else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64)
|
||||
{
|
||||
updaterParams += TEXT(" -parm64");
|
||||
}
|
||||
|
||||
if (doUpdateNpp)
|
||||
{
|
||||
@ -650,10 +654,14 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
|
||||
generic_string upPlParams = TEXT("-v");
|
||||
upPlParams += notepad_plus_plus.getPluginListVerStr();
|
||||
|
||||
if (nppParameters.isx64())
|
||||
if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64)
|
||||
{
|
||||
upPlParams += TEXT(" -px64");
|
||||
}
|
||||
else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64)
|
||||
{
|
||||
upPlParams += TEXT(" -parm64");
|
||||
}
|
||||
|
||||
upPlParams += TEXT(" -upZip");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user