summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mir_app/src/newplugins.cpp44
-rw-r--r--src/mir_app/src/pluginopts.cpp2
-rw-r--r--src/mir_app/src/plugins.h2
3 files changed, 24 insertions, 24 deletions
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 9bf1835e75..6c442e3bd5 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -279,11 +279,14 @@ void Plugin_Uninit(pluginEntry *p)
mir_free(p);
}
-int Plugin_UnloadDyn(pluginEntry *p)
+bool Plugin_UnloadDyn(pluginEntry *p)
{
+ if (p == nullptr)
+ return true;
+
if (p->bpi.hInst) {
if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
- return FALSE;
+ return false;
KillModuleAccounts(p->bpi.hInst);
KillModuleSubclassing(p->bpi.hInst);
@@ -319,7 +322,7 @@ int Plugin_UnloadDyn(pluginEntry *p)
it.pImpl = nullptr;
Plugin_Uninit(p);
- return TRUE;
+ return true;
}
// returns true if the given file is <anything>.dll exactly
@@ -359,22 +362,20 @@ void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam)
pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
{
- pluginEntry *p = (pluginEntry*)mir_calloc(sizeof(pluginEntry));
- wcsncpy_s(p->pluginname, tszFileName, _TRUNCATE);
-
- // add it to the list anyway
- pluginList.insert(p);
-
wchar_t tszFullPath[MAX_PATH];
mir_snwprintf(tszFullPath, L"%s\\%s\\%s", path, dir, tszFileName);
// map dll into the memory and check its exports
bool bIsPlugin = false;
mir_ptr<MUUID> pIds(GetPluginInterfaces(tszFullPath, bIsPlugin));
- if (!bIsPlugin) {
- p->bFailed = true; // piece of shit
- return p;
- }
+ if (!bIsPlugin)
+ return nullptr;
+
+ pluginEntry *p = (pluginEntry*)mir_calloc(sizeof(pluginEntry));
+ wcsncpy_s(p->pluginname, tszFileName, _TRUNCATE);
+
+ // add it to the list anyway
+ pluginList.insert(p);
// plugin declared that it's a database or a cryptor. load it asap!
bool bIsDb = hasMuuid(pIds, MIID_DATABASE);
@@ -427,6 +428,12 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
}
else if (hasMuuid(pIds, MIID_PROTOCOL) || !mir_wstrcmpi(tszFileName, L"mradio.dll") || !mir_wstrcmpi(tszFileName, L"watrack.dll"))
p->bIsProtocol = true;
+
+ if (plugin_crshdmp == nullptr && !mir_wstrcmpi(tszFileName, L"crashdumper.dll")) {
+ plugin_crshdmp = p;
+ p->bIsLast = true;
+ }
+
return p;
}
@@ -526,7 +533,7 @@ bool LoadCorePlugin(MuuidReplacement &mr)
mir_snwprintf(tszPlugName, L"%s.dll", mr.stdplugname);
pluginEntry* pPlug = OpenPlugin(tszPlugName, L"Core", exe);
- if (pPlug->bFailed) {
+ if (pPlug == nullptr) {
LBL_Error:
MessageBox(nullptr, CMStringW(FORMAT, TranslateW(tszCoreErr), mr.stdplugname), TranslateT("Fatal error"), MB_OK | MB_ICONSTOP);
@@ -781,14 +788,7 @@ int LoadNewPluginsModule(void)
static BOOL scanPluginsDir(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM)
{
- pluginEntry *p = OpenPlugin(fd->cFileName, L"Plugins", path);
- if (!p->bFailed) {
- if (plugin_crshdmp == nullptr && mir_wstrcmpi(fd->cFileName, L"crashdumper.dll") == 0) {
- plugin_crshdmp = p;
- p->bIsLast = true;
- }
- }
-
+ OpenPlugin(fd->cFileName, L"Plugins", path);
return TRUE;
}
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp
index db0390e517..8005898105 100644
--- a/src/mir_app/src/pluginopts.cpp
+++ b/src/mir_app/src/pluginopts.cpp
@@ -170,7 +170,7 @@ static bool LoadPluginDynamically(PluginListItemData *dat)
wchar_t *p = wcsrchr(exe, '\\'); if (p) *p = 0;
pluginEntry* pPlug = OpenPlugin(dat->fileName, L"Plugins", exe);
- if (pPlug->bFailed) {
+ if (pPlug == nullptr) {
LBL_Error:
Plugin_UnloadDyn(pPlug);
return false;
diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h
index 68f8b3024e..5852865f8d 100644
--- a/src/mir_app/src/plugins.h
+++ b/src/mir_app/src/plugins.h
@@ -68,7 +68,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path);
bool TryLoadPlugin(pluginEntry *p, bool bDynamic);
void Plugin_Uninit(pluginEntry *p);
-int Plugin_UnloadDyn(pluginEntry *p);
+bool Plugin_UnloadDyn(pluginEntry *p);
typedef BOOL (*SCAN_PLUGINS_CALLBACK) (WIN32_FIND_DATA * fd, wchar_t *path, WPARAM wParam, LPARAM lParam);
void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam);