From 9ed8134e118a1b8e671252e37d2f247afa4ba5bf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 Oct 2024 18:01:03 +0300 Subject: =?UTF-8?q?fixes=20#4741=20(Telegram:=20=D0=BF=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B4=20Windows=20XP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_app/src/CMPluginBase.cpp | 8 +++++--- src/mir_app/src/newplugins.cpp | 11 +++++++---- src/mir_app/src/plugins.h | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index f6107c39b7..79bfcbc7ae 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -27,6 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "plugins.h" #include "IcoLib.h" +CMPluginBase *g_pLastPlugin; + static int sttFakeID = -100; static int Compare(const CMPluginBase *p1, const CMPluginBase *p2) @@ -34,11 +36,11 @@ static int Compare(const CMPluginBase *p1, const CMPluginBase *p2) return INT_PTR(p1->getInst()) - INT_PTR(p2->getInst()); } -static LIST g_arPlugins(10, Compare); +LIST g_arPlugins(10, Compare); void RegisterModule(CMPluginBase *pPlugin) { - g_arPlugins.insert(pPlugin); + g_pLastPlugin = pPlugin; } MIR_APP_DLL(HINSTANCE) GetInstByAddress(void *codePtr) @@ -144,7 +146,7 @@ CMPluginBase::CMPluginBase(const char *moduleName, const PLUGININFOEX &pInfo) : m_arIcons(10, CompareIcons) { if (m_hInst != nullptr) - g_arPlugins.insert(this); + g_pLastPlugin = this; } CMPluginBase::~CMPluginBase() diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index a24239edae..022570fb8b 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -32,6 +32,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PLUGINDISABLELIST "PluginDisable" +extern CMPluginBase *g_pLastPlugin; + bool g_bReadyToInitClist = false, g_bLoadStd = false; void LoadExtraIconsModule(); @@ -234,16 +236,17 @@ bool pluginEntry::checkAPI(wchar_t *plugin) return false; // dll must register itself during LoadLibrary - CMPluginBase &ppb = GetPluginByInstance(h); - if (ppb.getInst() != h) { + if (!g_pLastPlugin || g_pLastPlugin->getInst() != h) { LBL_Error: bFailed = true; clear(); FreeLibrary(h); + g_pLastPlugin = nullptr; return false; } - m_pPlugin = &ppb; + g_arPlugins.insert(g_pLastPlugin); + m_pPlugin = g_pLastPlugin; g_pLastPlugin = nullptr; pfnLoad = (Miranda_Plugin_Load)GetProcAddress(h, "Load"); pfnUnload = (Miranda_Plugin_Unload)GetProcAddress(h, "Unload"); @@ -260,7 +263,7 @@ LBL_Error: if (!validInterfaceList(m_pInterfaces)) goto LBL_Error; - const PLUGININFOEX &pInfo = ppb.getInfo(); + const PLUGININFOEX &pInfo = m_pPlugin->getInfo(); if (pInfo.cbSize != sizeof(PLUGININFOEX)) goto LBL_Error; diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h index 6f0afacb76..5130d2bbfc 100644 --- a/src/mir_app/src/plugins.h +++ b/src/mir_app/src/plugins.h @@ -83,3 +83,5 @@ struct MuuidReplacement }; MUUID* GetPluginInterfaces(const wchar_t *ptszFileName, bool &bIsPlugin); + +extern LIST g_arPlugins; \ No newline at end of file -- cgit v1.2.3