diff options
author | George Hazan <george.hazan@gmail.com> | 2024-10-17 18:01:03 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-10-17 18:01:03 +0300 |
commit | 9ed8134e118a1b8e671252e37d2f247afa4ba5bf (patch) | |
tree | c65113f96001b3ca338ebf7ef5c28350082b48c7 | |
parent | 58a65dba133370082d973fd6d5150159fc2f044c (diff) |
fixes #4741 (Telegram: падение под Windows XP)
-rw-r--r-- | src/mir_app/src/CMPluginBase.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 11 | ||||
-rw-r--r-- | 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<CMPluginBase> g_arPlugins(10, Compare);
+LIST<CMPluginBase> 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<CMPluginBase> g_arPlugins;
\ No newline at end of file |