summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-23 16:11:59 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-23 16:11:59 +0300
commita7d5cce8e2cea97d52a35a1769d0e87e84e5502a (patch)
tree328aa85baa74ea929faa4c09b5e4c49b0cada896 /src
parent7249e4f451c89d778ce0f211eb0730e6fa3adc04 (diff)
we don't need MirandaPluginInfoEx() anymore. farewell, my lovely
Diffstat (limited to 'src')
-rw-r--r--src/core/stdautoaway/src/main.cpp5
-rw-r--r--src/core/stdaway/src/main.cpp5
-rw-r--r--src/core/stdclist/src/init.cpp5
-rw-r--r--src/core/stdcrypt/src/main.cpp5
-rw-r--r--src/core/stdemail/src/main.cpp5
-rw-r--r--src/core/stdfile/src/main.cpp5
-rw-r--r--src/core/stdidle/src/main.cpp5
-rw-r--r--src/core/stdmsg/src/srmm.cpp5
-rw-r--r--src/core/stdssl/src/main.cpp5
-rw-r--r--src/core/stduihist/src/main.cpp5
-rw-r--r--src/core/stduserinfo/src/main.cpp5
-rw-r--r--src/core/stduseronline/src/main.cpp5
-rw-r--r--src/mir_app/src/database.cpp4
-rw-r--r--src/mir_app/src/dll_sniffer.cpp9
-rw-r--r--src/mir_app/src/newplugins.cpp37
-rw-r--r--src/mir_app/src/pluginopts.cpp2
-rw-r--r--src/mir_app/src/plugins.h12
17 files changed, 28 insertions, 96 deletions
diff --git a/src/core/stdautoaway/src/main.cpp b/src/core/stdautoaway/src/main.cpp
index b520ce7890..51ce693ead 100644
--- a/src/core/stdautoaway/src/main.cpp
+++ b/src/core/stdautoaway/src/main.cpp
@@ -44,11 +44,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_AUTOAWAY, MIID_LAST };
diff --git a/src/core/stdaway/src/main.cpp b/src/core/stdaway/src/main.cpp
index 90c43ec8a8..f67eefefe2 100644
--- a/src/core/stdaway/src/main.cpp
+++ b/src/core/stdaway/src/main.cpp
@@ -44,11 +44,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST };
diff --git a/src/core/stdclist/src/init.cpp b/src/core/stdclist/src/init.cpp
index 548677eb42..94d4517491 100644
--- a/src/core/stdclist/src/init.cpp
+++ b/src/core/stdclist/src/init.cpp
@@ -59,11 +59,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>("CList", pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// returns plugin's interfaces information
diff --git a/src/core/stdcrypt/src/main.cpp b/src/core/stdcrypt/src/main.cpp
index 4e69e3da7f..59c390c3f3 100644
--- a/src/core/stdcrypt/src/main.cpp
+++ b/src/core/stdcrypt/src/main.cpp
@@ -43,11 +43,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_CRYPTO, MIID_LAST };
diff --git a/src/core/stdemail/src/main.cpp b/src/core/stdemail/src/main.cpp
index 12e62d1b3d..dd9c3ae081 100644
--- a/src/core/stdemail/src/main.cpp
+++ b/src/core/stdemail/src/main.cpp
@@ -44,11 +44,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SREMAIL, MIID_LAST };
diff --git a/src/core/stdfile/src/main.cpp b/src/core/stdfile/src/main.cpp
index 864f95e58a..27a00db40a 100644
--- a/src/core/stdfile/src/main.cpp
+++ b/src/core/stdfile/src/main.cpp
@@ -48,11 +48,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRFILE, MIID_LAST };
diff --git a/src/core/stdidle/src/main.cpp b/src/core/stdidle/src/main.cpp
index 85084c8d18..89268caadf 100644
--- a/src/core/stdidle/src/main.cpp
+++ b/src/core/stdidle/src/main.cpp
@@ -46,11 +46,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_IDLE, MIID_LAST };
diff --git a/src/core/stdmsg/src/srmm.cpp b/src/core/stdmsg/src/srmm.cpp
index d32aebd342..2cdff71f91 100644
--- a/src/core/stdmsg/src/srmm.cpp
+++ b/src/core/stdmsg/src/srmm.cpp
@@ -46,11 +46,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(SRMMMOD, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRMM, MIID_LAST };
diff --git a/src/core/stdssl/src/main.cpp b/src/core/stdssl/src/main.cpp
index c50ad8fb21..d80db3e488 100644
--- a/src/core/stdssl/src/main.cpp
+++ b/src/core/stdssl/src/main.cpp
@@ -43,11 +43,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SSL, MIID_LAST };
extern "C" int __declspec(dllexport) Load(void)
diff --git a/src/core/stduihist/src/main.cpp b/src/core/stduihist/src/main.cpp
index d9f99ca941..1f5eeae95f 100644
--- a/src/core/stduihist/src/main.cpp
+++ b/src/core/stduihist/src/main.cpp
@@ -44,11 +44,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_UIHISTORY, MIID_LAST };
diff --git a/src/core/stduserinfo/src/main.cpp b/src/core/stduserinfo/src/main.cpp
index 1a3c0c3d51..cefc32e91d 100644
--- a/src/core/stduserinfo/src/main.cpp
+++ b/src/core/stduserinfo/src/main.cpp
@@ -44,11 +44,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_UIUSERINFO, MIID_LAST };
diff --git a/src/core/stduseronline/src/main.cpp b/src/core/stduseronline/src/main.cpp
index 2f0869a6dc..248bf8077e 100644
--- a/src/core/stduseronline/src/main.cpp
+++ b/src/core/stduseronline/src/main.cpp
@@ -45,11 +45,6 @@ CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_USERONLINE, MIID_LAST };
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp
index 12de009718..e7f5483e59 100644
--- a/src/mir_app/src/database.cpp
+++ b/src/mir_app/src/database.cpp
@@ -373,7 +373,7 @@ int touchDatabase(const wchar_t *tszProfile, DATABASELINK **dblink)
return EGROKPRF_CANTREAD;
}
-// enumerate all plugins that had valid DatabasePluginInfo()
+// enumerate all database plugins
int tryOpenDatabase(const wchar_t *tszProfile)
{
for (auto &it : arDbPlugins) {
@@ -408,7 +408,7 @@ int tryOpenDatabase(const wchar_t *tszProfile)
return -1; // no suitable driver found
}
-// enumerate all plugins that had valid DatabasePluginInfo()
+// enumerate all database plugins
static int tryCreateDatabase(const wchar_t *ptszProfile)
{
wchar_t *tszProfile = NEWWSTR_ALLOCA(ptszProfile);
diff --git a/src/mir_app/src/dll_sniffer.cpp b/src/mir_app/src/dll_sniffer.cpp
index c341c9e87c..c4e64b31ed 100644
--- a/src/mir_app/src/dll_sniffer.cpp
+++ b/src/mir_app/src/dll_sniffer.cpp
@@ -112,26 +112,21 @@ MUUID* GetPluginInterfaces(const wchar_t* ptszFileName, bool& bIsPlugin)
DWORD *ptrFuncList = (DWORD*)&pSecStart[pED->AddressOfFunctions];
MUUID* pIds = nullptr;
- bool bHasLoad = false, bHasUnload = false, bHasInfo = false, bHasMuuids = false;
+ bool bHasLoad = false, bHasUnload = false, bHasMuuids = false;
for (size_t i=0; i < pED->NumberOfNames; i++, ptrRVA++, ptrOrdRVA++) {
char *szName = (char*)&pSecStart[*ptrRVA];
if (!mir_strcmp(szName, "Load"))
bHasLoad = true;
- if (!mir_strcmp(szName, "MirandaPluginInfoEx"))
- bHasInfo = true;
else if (!mir_strcmp(szName, "Unload"))
bHasUnload = true;
else if (!mir_strcmp(szName, "MirandaInterfaces")) {
bHasMuuids = true;
pIds = (MUUID*)&pSecStart[ptrFuncList[*ptrOrdRVA]];
}
- // old plugin, skip it
- else if (!mir_strcmp(szName, "MirandaPluginInterfaces"))
- __leave;
}
// a plugin might have no interfaces
- if (bHasLoad && bHasUnload && bHasInfo)
+ if (bHasLoad && bHasUnload)
bIsPlugin = true;
if (!bHasLoad || !bHasMuuids || !bHasUnload)
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 6ed202455e..9bf1835e75 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -55,7 +55,6 @@ MUUID miid_last = MIID_LAST;
static BOOL bModuleInitialized = FALSE;
wchar_t mirandabootini[MAX_PATH];
-static DWORD mirandaVersion;
static int askAboutIgnoredPlugins;
pluginEntry *plugin_crshdmp, *plugin_service, *plugin_ssl, *plugin_clist;
@@ -185,12 +184,12 @@ static bool validInterfaceList(MUUID *piface)
return true;
}
-static int checkPI(BASIC_PLUGIN_INFO *bpi, PLUGININFOEX *pi)
+static int checkPI(BASIC_PLUGIN_INFO *bpi, const PLUGININFOEX *pi)
{
if (pi == nullptr)
return FALSE;
- if (bpi->InfoEx == nullptr || pi->cbSize != sizeof(PLUGININFOEX))
+ if (pi->cbSize != sizeof(PLUGININFOEX))
return FALSE;
if (!validInterfaceList(bpi->Interfaces) || isPluginBanned(pi->uuid))
@@ -203,7 +202,7 @@ static int checkPI(BASIC_PLUGIN_INFO *bpi, PLUGININFOEX *pi)
return TRUE;
}
-int checkAPI(wchar_t* plugin, BASIC_PLUGIN_INFO* bpi, DWORD dwMirVer, int checkTypeAPI)
+int checkAPI(wchar_t* plugin, BASIC_PLUGIN_INFO* bpi, int checkTypeAPI)
{
SetErrorMode(SEM_FAILCRITICALERRORS); // disable error messages
HINSTANCE h = LoadLibrary(plugin);
@@ -212,12 +211,12 @@ int checkAPI(wchar_t* plugin, BASIC_PLUGIN_INFO* bpi, DWORD dwMirVer, int checkT
return 0;
// loaded, check for exports
+ CMPluginBase &pPlugin = GetPluginByInstance(h);
bpi->Load = (Miranda_Plugin_Load)GetProcAddress(h, "Load");
bpi->Unload = (Miranda_Plugin_Unload)GetProcAddress(h, "Unload");
- bpi->InfoEx = (Miranda_Plugin_InfoEx)GetProcAddress(h, "MirandaPluginInfoEx");
- // if they were present
- if (!bpi->Load || !bpi->Unload || !bpi->InfoEx) {
+ // Load & Unload shall be defined anyway, and a dll must register itself during LoadLibrary
+ if (!bpi->Load || !bpi->Unload || pPlugin.getInst() != h) {
LBL_Error:
FreeLibrary(h);
return 0;
@@ -225,17 +224,19 @@ LBL_Error:
bpi->Interfaces = (MUUID*)GetProcAddress(h, "MirandaInterfaces");
if (bpi->Interfaces == nullptr) {
- typedef MUUID * (__cdecl * Miranda_Plugin_Interfaces) (void);
+ // MirandaPluginInterfaces function is actual only for the only plugin, HistoryPlusPlus
+ // plugins written in C++ shall export data directly
+ typedef MUUID* (__cdecl * Miranda_Plugin_Interfaces)(void);
Miranda_Plugin_Interfaces pFunc = (Miranda_Plugin_Interfaces)GetProcAddress(h, "MirandaPluginInterfaces");
if (pFunc)
bpi->Interfaces = pFunc();
}
- PLUGININFOEX* pi = bpi->InfoEx(dwMirVer);
- if (!checkPI(bpi, pi))
+ const PLUGININFOEX &pi = pPlugin.getInfo();
+ if (!checkPI(bpi, &pi))
goto LBL_Error;
- bpi->pluginInfo = pi;
+ bpi->pluginInfo = &pi;
// basic API is present
if (checkTypeAPI == CHECKAPI_NONE) {
LBL_Ok:
@@ -245,7 +246,7 @@ LBL_Ok:
// check clist ?
if (checkTypeAPI == CHECKAPI_CLIST) {
bpi->clistlink = (CList_Initialise)GetProcAddress(h, "CListInitialise");
- if ((pi->flags & UNICODE_AWARE) && bpi->clistlink)
+ if ((pi.flags & UNICODE_AWARE) && bpi->clistlink)
goto LBL_Ok;
}
goto LBL_Error;
@@ -379,7 +380,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
bool bIsDb = hasMuuid(pIds, MIID_DATABASE);
if (bIsDb || hasMuuid(pIds, MIID_CRYPTO)) {
BASIC_PLUGIN_INFO bpi;
- if (checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
+ if (checkAPI(tszFullPath, &bpi, CHECKAPI_NONE)) {
// plugin is valid
p->bHasBasicApi = p->bIsLast = true;
if (bIsDb)
@@ -412,7 +413,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
// load it for a profile manager's window
else if (hasMuuid(pIds, MIID_SERVICEMODE)) {
BASIC_PLUGIN_INFO bpi;
- if (checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
+ if (checkAPI(tszFullPath, &bpi, CHECKAPI_NONE)) {
p->bOk = p->bHasBasicApi = true;
p->bpi = bpi;
if (hasMuuid(bpi, MIID_SERVICEMODE)) {
@@ -465,7 +466,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
BASIC_PLUGIN_INFO bpi;
mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, (p->bIsCore) ? L"Core" : L"Plugins", p->pluginname);
- if (!checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
+ if (!checkAPI(tszFullPath, &bpi, CHECKAPI_NONE)) {
p->bFailed = true;
return false;
}
@@ -557,7 +558,7 @@ static bool loadClistModule(wchar_t* exe, pluginEntry *p)
g_bReadyToInitClist = true;
BASIC_PLUGIN_INFO bpi;
- if (checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_CLIST)) {
+ if (checkAPI(exe, &bpi, CHECKAPI_CLIST)) {
p->bpi = bpi;
p->bIsLast = p->bOk = p->bHasBasicApi = true;
@@ -711,7 +712,7 @@ int LoadProtocolPlugins(void)
mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, L"Plugins", p->pluginname);
BASIC_PLUGIN_INFO bpi;
- if (checkAPI(tszFullPath, &bpi, 0, CHECKAPI_NONE)) {
+ if (checkAPI(tszFullPath, &bpi, CHECKAPI_NONE)) {
p->bOk = p->bHasBasicApi = true;
p->bpi = bpi;
}
@@ -798,8 +799,6 @@ int LoadNewPluginsModuleInfos(void)
LoadPluginOptions();
- mirandaVersion = Miranda_GetVersion();
-
// remember where the mirandaboot.ini goes
PathToAbsoluteW(L"mirandaboot.ini", mirandabootini);
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp
index ee7bc7d146..db0390e517 100644
--- a/src/mir_app/src/pluginopts.cpp
+++ b/src/mir_app/src/pluginopts.cpp
@@ -65,7 +65,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM
HINSTANCE hInst = GetModuleHandle(buf);
BASIC_PLUGIN_INFO pi;
- if (checkAPI(buf, &pi, MIRANDA_VERSION_CORE, CHECKAPI_NONE) == 0)
+ if (checkAPI(buf, &pi, CHECKAPI_NONE) == 0)
return TRUE;
PluginListItemData *dat = (PluginListItemData*)mir_alloc(sizeof(PluginListItemData));
diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h
index 08b5c63eda..68f8b3024e 100644
--- a/src/mir_app/src/plugins.h
+++ b/src/mir_app/src/plugins.h
@@ -11,8 +11,7 @@
// basic export prototypes
typedef int (__cdecl * Miranda_Plugin_Load) (void);
typedef int (__cdecl * Miranda_Plugin_Unload) (void);
-// version control
-typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_InfoEx) (DWORD mirandaVersion);
+
// prototype for clists
typedef int (__cdecl * CList_Initialise) (void);
@@ -22,10 +21,9 @@ struct BASIC_PLUGIN_INFO
HINSTANCE hInst;
Miranda_Plugin_Load Load;
Miranda_Plugin_Unload Unload;
- Miranda_Plugin_InfoEx InfoEx;
CList_Initialise clistlink;
- PLUGININFOEX *pluginInfo; // must be freed if hInst = = nullptr then its a copy
- MUUID *Interfaces; // array of supported interfaces
+ const PLUGININFOEX *pluginInfo; // must be freed if hInst == nullptr then its a copy
+ MUUID *Interfaces; // array of supported interfaces
};
struct pluginEntry
@@ -43,7 +41,7 @@ struct pluginEntry
bool bHasBasicApi : 1; // has Load, Unload, MirandaPluginInfo() -> PLUGININFO seems valid, this dll is in memory.
bool bIsProtocol : 1; // protocol module
- bool bIsDatabase : 1; // has DatabasePluginInfo() and is valid as can be, and PCLASS_BASICAPI has to be set too
+ bool bIsDatabase : 1; // has MUUID_DATABASE in its interfaces, and PCLASS_BASICAPI has to be set too
bool bIsClist : 1; // a CList implementation
bool bIsCrypto : 1; // crypto provider
};
@@ -64,7 +62,7 @@ void SetPluginOnWhiteList(const wchar_t* pluginname, int allow);
int getDefaultPluginIdx(const MUUID& muuid);
bool hasMuuid(const BASIC_PLUGIN_INFO&, const MUUID&);
bool hasMuuid(const MUUID* pFirst, const MUUID&);
-int checkAPI(wchar_t* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI);
+int checkAPI(wchar_t* plugin, BASIC_PLUGIN_INFO* bpi, int checkTypeAPI);
pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path);