From b172c4bbc75cdad0e8ccd22292aa671ba43cac45 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Apr 2018 18:14:33 +0300 Subject: PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside --- protocols/Discord/src/main.cpp | 24 ++++-------------------- protocols/Discord/src/proto.h | 11 +++++++++++ protocols/Discord/src/stdafx.h | 6 +++--- 3 files changed, 18 insertions(+), 23 deletions(-) (limited to 'protocols/Discord/src') diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp index 4437ee1864..3b50bc946b 100644 --- a/protocols/Discord/src/main.cpp +++ b/protocols/Discord/src/main.cpp @@ -17,11 +17,14 @@ along with this program. If not, see . #include "stdafx.h" +CMPlugin g_plugin; CHAT_MANAGER *pci; HINSTANCE g_hInstance; int hLangpack = 0; HWND g_hwndHeartbeat; +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; + IconItem g_iconList[] = { { LPGEN("Main icon"), "main", IDI_MAIN }, @@ -41,13 +44,7 @@ PLUGININFOEX pluginInfo = { { 0x88928401, 0x2ce8, 0x4568, { 0xaa, 0xa7, 0x22, 0x61, 0x41, 0x87, 0x0c, 0xbf } } }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } @@ -79,16 +76,3 @@ extern "C" int __declspec(dllexport) Unload(void) DestroyWindow(g_hwndHeartbeat); return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// - -struct CMPlugin : public ACCPROTOPLUGIN -{ - CMPlugin() : - ACCPROTOPLUGIN("Discord") - { - SetUniqueId(DB_KEY_ID); - } -} - g_plugin; - diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 99fb50ecf6..a33511d3bd 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -350,3 +350,14 @@ public: static void CALLBACK HeartbeatTimerProc(HWND hwnd, UINT msg, UINT_PTR id, DWORD); static void CALLBACK MarkReadTimerProc(HWND hwnd, UINT msg, UINT_PTR id, DWORD); }; + +///////////////////////////////////////////////////////////////////////////////////////// + +struct CMPlugin : public ACCPROTOPLUGIN +{ + CMPlugin() : + ACCPROTOPLUGIN("Discord") + { + SetUniqueId(DB_KEY_ID); + } +}; diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h index d09c1a7499..5c83a50ef0 100644 --- a/protocols/Discord/src/stdafx.h +++ b/protocols/Discord/src/stdafx.h @@ -47,9 +47,6 @@ extern IconItem g_iconList[]; extern HINSTANCE g_hInstance; extern HWND g_hwndHeartbeat; -#include "version.h" -#include "proto.h" - #define DB_KEY_ID "id" #define DB_KEY_EMAIL "Email" #define DB_KEY_PASSWORD "Password" @@ -65,6 +62,9 @@ extern HWND g_hwndHeartbeat; #define DB_KEY_GROUP "GroupName" #define DB_KEYVAL_GROUP L"Discord" +#include "version.h" +#include "proto.h" + SnowFlake getId(const JSONNode &pNode); CMStringW PrepareMessageText(const JSONNode &pRoot); int StrToStatus(const CMStringW &str); -- cgit v1.2.3