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 +++--- protocols/Dummy/src/dummy.h | 2 +- protocols/Dummy/src/dummy_options.cpp | 2 +- protocols/Dummy/src/main.cpp | 14 +++++--------- protocols/EmLanProto/src/amdproto.cpp | 6 ++++-- protocols/FacebookRM/src/main.cpp | 8 ++------ protocols/Gadu-Gadu/src/dialogs.cpp | 14 +++++++------- protocols/Gadu-Gadu/src/gg.cpp | 18 +++--------------- protocols/Gadu-Gadu/src/gg.h | 2 +- protocols/Gadu-Gadu/src/gg_proto.cpp | 2 +- protocols/Gadu-Gadu/src/gg_proto.h | 3 +++ protocols/Gadu-Gadu/src/groupchat.cpp | 2 +- protocols/Gadu-Gadu/src/icolib.cpp | 2 +- protocols/Gadu-Gadu/src/image.cpp | 10 +++++----- protocols/Gadu-Gadu/src/links.cpp | 2 +- protocols/Gadu-Gadu/src/services.cpp | 2 +- protocols/Gadu-Gadu/src/sessions.cpp | 4 ++-- protocols/Gadu-Gadu/src/token.cpp | 2 +- protocols/IRCG/src/main.cpp | 8 ++------ protocols/IRCG/src/options.cpp | 4 ++-- protocols/IRCG/src/stdafx.h | 2 +- protocols/IRCG/src/userinfo.cpp | 2 +- protocols/IcqOscarJ/src/dlgproc.cpp | 2 +- protocols/IcqOscarJ/src/editlist.cpp | 2 +- protocols/IcqOscarJ/src/editstring.cpp | 8 ++++---- protocols/IcqOscarJ/src/globals.h | 1 - protocols/IcqOscarJ/src/icq_firstrun.cpp | 2 +- protocols/IcqOscarJ/src/icq_opts.cpp | 2 +- protocols/IcqOscarJ/src/icq_proto.cpp | 4 ++-- protocols/IcqOscarJ/src/icq_uploadui.cpp | 2 +- protocols/IcqOscarJ/src/icq_xstatus.cpp | 4 ++-- protocols/IcqOscarJ/src/init.cpp | 11 +++-------- protocols/IcqOscarJ/src/loginpassword.cpp | 2 +- protocols/IcqOscarJ/src/userinfotab.cpp | 2 +- protocols/JabberG/src/jabber.cpp | 10 +++------- protocols/JabberG/src/jabber_adhoc.cpp | 10 +++++----- protocols/JabberG/src/jabber_bookmarks.cpp | 6 +++--- protocols/JabberG/src/jabber_captcha.cpp | 2 +- protocols/JabberG/src/jabber_chat.cpp | 2 +- protocols/JabberG/src/jabber_filterlist.cpp | 2 +- protocols/JabberG/src/jabber_form.cpp | 18 +++++++++--------- protocols/JabberG/src/jabber_frame.cpp | 8 ++++---- protocols/JabberG/src/jabber_icolib.cpp | 8 ++++---- protocols/JabberG/src/jabber_iqid_muc.cpp | 4 ++-- protocols/JabberG/src/jabber_opt.cpp | 6 +++--- protocols/JabberG/src/jabber_password.cpp | 2 +- protocols/JabberG/src/jabber_search.cpp | 8 ++++---- protocols/JabberG/src/jabber_thread.cpp | 2 +- protocols/JabberG/src/jabber_userinfo.cpp | 2 +- protocols/JabberG/src/jabber_vcard.cpp | 10 +++++----- protocols/JabberG/src/jabber_xstatus.cpp | 2 +- protocols/JabberG/src/stdafx.h | 2 +- protocols/MRA/src/Mra.cpp | 12 +----------- protocols/MSN/src/msn.cpp | 7 ++----- protocols/MSN/src/msn_auth.cpp | 6 +++--- protocols/MSN/src/msn_chat.cpp | 4 ++-- protocols/MSN/src/msn_links.cpp | 2 +- protocols/MSN/src/msn_lists.cpp | 2 +- protocols/MSN/src/msn_menu.cpp | 2 +- protocols/MSN/src/msn_opts.cpp | 6 +++--- protocols/MSN/src/msn_svcs.cpp | 4 ++-- protocols/MSN/src/stdafx.h | 2 +- protocols/Sametime/src/options.cpp | 2 +- protocols/Sametime/src/sametime.cpp | 13 ++++--------- protocols/Sametime/src/sametime.h | 2 +- protocols/Sametime/src/sametime_proto.cpp | 2 +- protocols/Sametime/src/sametime_session.cpp | 2 +- protocols/SkypeWeb/src/main.cpp | 7 +------ protocols/Steam/src/main.cpp | 7 +------ protocols/Tox/src/main.cpp | 7 +------ protocols/Twitter/src/main.cpp | 6 +----- protocols/VKontakte/src/main.cpp | 21 +++------------------ protocols/VKontakte/src/misc.cpp | 2 +- protocols/VKontakte/src/stdafx.h | 2 +- protocols/VKontakte/src/vk.h | 2 +- protocols/VKontakte/src/vk_proto.h | 11 ++++++++++- 78 files changed, 177 insertions(+), 254 deletions(-) (limited to 'protocols') 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); diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h index 67f7da5716..90b08dd243 100644 --- a/protocols/Dummy/src/dummy.h +++ b/protocols/Dummy/src/dummy.h @@ -19,7 +19,7 @@ along with this program. If not, see . struct CDummyProto; extern LIST dummy_Instances; -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; #define DUMMY_ID_TEMPLATE "Template" #define DUMMY_ID_TEXT "UniqueIdText" diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index c2a156bd4e..701d647589 100644 --- a/protocols/Dummy/src/dummy_options.cpp +++ b/protocols/Dummy/src/dummy_options.cpp @@ -116,5 +116,5 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM INT_PTR CDummyProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, DummyAccountProc, (LPARAM)this); + return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, DummyAccountProc, (LPARAM)this); } diff --git a/protocols/Dummy/src/main.cpp b/protocols/Dummy/src/main.cpp index 6a57644bf3..93492c1df6 100644 --- a/protocols/Dummy/src/main.cpp +++ b/protocols/Dummy/src/main.cpp @@ -18,7 +18,7 @@ along with this program. If not, see . #include "stdafx.h" #include "version.h" -HINSTANCE hInst; +HINSTANCE g_hInstance; int hLangpack; CLIST_INTERFACE *pcli; @@ -36,19 +36,13 @@ PLUGININFOEX pluginInfo = { 0x2a1081d1, 0xaee3, 0x4091, {0xb7, 0xd, 0xae, 0x46, 0xd0, 0x9f, 0x9a, 0x7f}} }; -///////////////////////////////////////////////////////////////////////////////////////// - -BOOL WINAPI DllMain(HINSTANCE hModule, DWORD, LPVOID) -{ - hInst = hModule; - return TRUE; -} - extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) { return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST}; ///////////////////////////////////////////////////////////////////////////////////////// @@ -94,3 +88,5 @@ struct CMPlugin : public ACCPROTOPLUGIN } } g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/protocols/EmLanProto/src/amdproto.cpp b/protocols/EmLanProto/src/amdproto.cpp index 8305850048..9efd5a1ac3 100644 --- a/protocols/EmLanProto/src/amdproto.cpp +++ b/protocols/EmLanProto/src/amdproto.cpp @@ -362,13 +362,15 @@ extern "C" int __declspec(dllexport) __cdecl Unload() ///////////////////////////////////////////////////////////////////////////////////////// -struct CMPlugin : public CMPluginBase +struct CMPlugin : public PLUGIN { CMPlugin() : - CMPluginBase(PROTONAME) + PLUGIN(PROTONAME) { RegisterProtocol(PROTOTYPE_PROTOCOL); SetUniqueId("Nick"); } } g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp index ee2810a5c7..a2d89766aa 100644 --- a/protocols/FacebookRM/src/main.cpp +++ b/protocols/FacebookRM/src/main.cpp @@ -44,12 +44,6 @@ PLUGININFOEX pluginInfo = { { 0x8432b009, 0xff32, 0x4727, { 0xaa, 0xe6, 0xa9, 0x3, 0x50, 0x38, 0xfd, 0x58 } } }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - return TRUE; -} - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { g_mirandaVersion = mirandaVersion; @@ -97,3 +91,5 @@ extern "C" int __declspec(dllexport) Unload(void) { return 0; } + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index 28a69f80c9..5ebdb40815 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -357,19 +357,19 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, dat.gg = gg; if (LOWORD(wParam) == IDC_CREATEACCOUNT) { dat.mode = GG_USERUTIL_CREATE; - ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } else if (LOWORD(wParam) == IDC_CHPASS) { dat.mode = GG_USERUTIL_PASS; - ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } else if (LOWORD(wParam) == IDC_CHEMAIL) { dat.mode = GG_USERUTIL_EMAIL; - ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } else { dat.mode = GG_USERUTIL_REMOVE; - ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } if (ret == IDOK) { @@ -759,7 +759,7 @@ int GaduProto::options_init(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_UNICODE; odp.position = 1003000; - odp.hInstance = hInstance; + odp.hInstance = g_hInstance; odp.szGroup.w = LPGENW("Network"); odp.szTitle.w = m_tszUserName; odp.dwInitParam = (LPARAM)this; @@ -809,7 +809,7 @@ int GaduProto::details_init(WPARAM wParam, LPARAM lParam) OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_DONTTRANSLATE | ODPF_UNICODE; - odp.hInstance = hInstance; + odp.hInstance = g_hInstance; odp.pfnDlgProc = gg_detailsdlgproc; odp.position = -1900000000; odp.pszTemplate = pszTemplate; @@ -867,7 +867,7 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP dat.email = email; dat.gg = gg; dat.mode = GG_USERUTIL_CREATE; - int ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + int ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); if (ret == IDOK) { DBVARIANT dbv; diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index 8aeffc1391..bec809277c 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -39,7 +39,7 @@ PLUGININFOEX pluginInfo = { // Other variables CMPlugin g_plugin; -HINSTANCE hInstance; +HINSTANCE g_hInstance; SSL_API sslApi; CLIST_INTERFACE *pcli; @@ -47,6 +47,8 @@ int hLangpack; static unsigned long crc_table[256]; +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; + ////////////////////////////////////////////////////////// // Extra winsock function for error description // @@ -407,17 +409,3 @@ void gg_debughandler(int level, const char *format, va_list ap) free(szFormat); } #endif - -////////////////////////////////////////////////////////// -// main DLL function -// -BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD, LPVOID) -{ - crc_gentable(); - hInstance = hInst; -#ifdef DEBUGMODE - gg_debug_level = GG_DEBUG_FUNCTION; - gg_debug_handler = gg_debughandler; -#endif - return TRUE; -} diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index da4cc74c01..f96f613fdd 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -258,7 +258,7 @@ struct GGGETAVATARDATA struct GaduProto; -extern HINSTANCE hInstance; +extern HINSTANCE g_hInstance; extern CLIST_INTERFACE *pcli; extern PLUGININFOEX pluginInfo; extern IconItem iconList[]; diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index a54e6100da..2b2c9eefc5 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -507,7 +507,7 @@ static INT_PTR CALLBACK gg_advancedsearchdlgproc(HWND hwndDlg, UINT message, WPA HWND GaduProto::CreateExtendedSearchUI(HWND owner) { - return CreateDialogParam(hInstance, + return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_GGADVANCEDSEARCH), owner, gg_advancedsearchdlgproc, (LPARAM)this); } diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h index ddeaa82cb9..87555b9d06 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.h +++ b/protocols/Gadu-Gadu/src/gg_proto.h @@ -303,11 +303,14 @@ inline void GaduProto::gg_sleep(DWORD miliseconds, BOOL alterable, char* calling #endif } +void crc_gentable(void); + struct CMPlugin : public ACCPROTOPLUGIN { CMPlugin() : ACCPROTOPLUGIN(GGDEF_PROTO) { + crc_gentable(); SetUniqueId(GG_KEY_UIN); } }; diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index e8db07c499..1ea195a83b 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -600,7 +600,7 @@ INT_PTR GaduProto::gc_openconf(WPARAM, LPARAM) return 0; } - CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_CONFERENCE), nullptr, gg_gc_openconfdlg, (LPARAM)this); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CONFERENCE), nullptr, gg_gc_openconfdlg, (LPARAM)this); return 1; } diff --git a/protocols/Gadu-Gadu/src/icolib.cpp b/protocols/Gadu-Gadu/src/icolib.cpp index 040583299c..7ee2a5e5fd 100644 --- a/protocols/Gadu-Gadu/src/icolib.cpp +++ b/protocols/Gadu-Gadu/src/icolib.cpp @@ -43,7 +43,7 @@ extern IconItem iconList[] = void gg_icolib_init() { - Icon_Register(hInstance, "Protocols/" GGDEF_PROTO, iconList, _countof(iconList), GGDEF_PROTO); + Icon_Register(g_hInstance, "Protocols/" GGDEF_PROTO, iconList, _countof(iconList), GGDEF_PROTO); } HICON LoadIconEx(const char* name, bool big) diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 8d86ada520..909ee5c078 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -256,7 +256,7 @@ int gg_img_saveimage(HWND hwnd, GGIMAGEENTRY *dat) OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwnd; - ofn.hInstance = hInstance; + ofn.hInstance = g_hInstance; ofn.lpstrFile = szFileName; ofn.lpstrFilter = szFilter; ofn.nMaxFile = MAX_PATH; @@ -439,7 +439,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case WM_SIZE: - Utils_ResizeDialog(hwndDlg, hInstance, dat->bReceiving ? MAKEINTRESOURCEA(IDD_IMAGE_RECV) : MAKEINTRESOURCEA(IDD_IMAGE_SEND), sttImageDlgResizer); + Utils_ResizeDialog(hwndDlg, g_hInstance, dat->bReceiving ? MAKEINTRESOURCEA(IDD_IMAGE_RECV) : MAKEINTRESOURCEA(IDD_IMAGE_SEND), sttImageDlgResizer); if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) InvalidateRect(hwndDlg, nullptr, FALSE); return 0; @@ -669,7 +669,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP *szFileName = 0; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; - ofn.hInstance = hInstance; + ofn.hInstance = g_hInstance; ofn.lpstrFilter = szFilter; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; @@ -708,7 +708,7 @@ void __cdecl GaduProto::img_dlgcallthread(void *param) HWND hMIWnd = nullptr; GGIMAGEDLGDATA *dat = (GGIMAGEDLGDATA *)param; - DialogBoxParam(hInstance, dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND), + DialogBoxParam(g_hInstance, dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND), hMIWnd, gg_img_dlgproc, (LPARAM)dat); #ifdef DEBUGMODE @@ -747,7 +747,7 @@ int gg_img_isexists(wchar_t *szPath, GGIMAGEENTRY *dat) if (_wstat(szPath, &st) != 0) return 0; - if ((long)st.st_size == dat->nSize) + if (st.st_size == (long)dat->nSize) { FILE *fp = _wfopen(szPath, L"rb"); if (!fp) return 0; diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp index 523be087a9..7ef2ec6cf6 100644 --- a/protocols/Gadu-Gadu/src/links.cpp +++ b/protocols/Gadu-Gadu/src/links.cpp @@ -108,7 +108,7 @@ void gg_links_init() { if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) { CreateServiceFunction(GGS_PARSELINK, gg_parselink); - AssocMgr_AddNewUrlTypeW("gg:", TranslateT("Gadu-Gadu Link Protocol"), hInstance, IDI_GG, GGS_PARSELINK, 0); + AssocMgr_AddNewUrlTypeW("gg:", TranslateT("Gadu-Gadu Link Protocol"), g_hInstance, IDI_GG, GGS_PARSELINK, 0); } } diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index b127f19852..425eb044a2 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -379,7 +379,7 @@ extern INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwnd, UINT msg, WPARAM wParam // INT_PTR GaduProto::get_acc_mgr_gui(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this); + return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this); } ////////////////////////////////////////////////////////// diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 2c4f80318c..63ba37d099 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -360,7 +360,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w return 0; case WM_SIZE: - Utils_ResizeDialog(hwndDlg, hInstance, MAKEINTRESOURCEA(IDD_SESSIONS), sttSessionsDlgResizer); + Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_SESSIONS), sttSessionsDlgResizer); return 0; case WM_SETCURSOR: @@ -397,7 +397,7 @@ INT_PTR GaduProto::sessions_view(WPARAM, LPARAM) SetFocus(hwndSessionsDlg); } else - CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SESSIONS), nullptr, gg_sessions_viewdlg, (LPARAM)this); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SESSIONS), nullptr, gg_sessions_viewdlg, (LPARAM)this); return 0; } diff --git a/protocols/Gadu-Gadu/src/token.cpp b/protocols/Gadu-Gadu/src/token.cpp index ebb9535726..9f7f80b87c 100644 --- a/protocols/Gadu-Gadu/src/token.cpp +++ b/protocols/Gadu-Gadu/src/token.cpp @@ -145,7 +145,7 @@ int GaduProto::gettoken(GGTOKEN *token) } // Load token dialog - if (DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_TOKEN), nullptr, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL) + if (DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_TOKEN), nullptr, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL) return FALSE; // Fillup patterns diff --git a/protocols/IRCG/src/main.cpp b/protocols/IRCG/src/main.cpp index 1dd78c6e77..8b4c3597ad 100644 --- a/protocols/IRCG/src/main.cpp +++ b/protocols/IRCG/src/main.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CMPlugin g_plugin; CHAT_MANAGER *pci; CLIST_INTERFACE *pcli; -HINSTANCE hInst = nullptr; +HINSTANCE g_hInstance; int hLangpack; @@ -52,11 +52,7 @@ PLUGININFOEX pluginInfo = {0x92382b4d, 0x5572, 0x48a0, {0xb0, 0xb9, 0x13, 0x36, 0xa6, 0x1, 0xd6, 0x89}} // {92382B4D-5572-48a0-B0B9-1336A601D689} }; -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 33a1bc7030..344999e511 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -204,7 +204,7 @@ static IconItem iconList[] = void InitIcons(void) { - Icon_Register(hInst, "Protocols/IRC", iconList, _countof(iconList), "IRC"); + Icon_Register(g_hInstance, "Protocols/IRC", iconList, _countof(iconList), "IRC"); } HICON LoadIconEx(int iconId, bool big) @@ -1848,7 +1848,7 @@ void InitServers() wchar_t *szIniFile = Utils_ReplaceVarsW(L"%temp%\\default_servers.ini"); FILE *serverFile = _wfopen(szIniFile, L"a"); if (serverFile) { - char* pszSvrs = (char*)LockResource(LoadResource(hInst, FindResource(hInst, MAKEINTRESOURCE(IDR_SERVERS), L"TEXT"))); + char* pszSvrs = (char*)LockResource(LoadResource(g_hInstance, FindResource(g_hInstance, MAKEINTRESOURCE(IDR_SERVERS), L"TEXT"))); if (pszSvrs) fwrite(pszSvrs, 1, mir_strlen(pszSvrs) + 1, serverFile); fclose(serverFile); diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index 61e086bb1e..896d6a6097 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -200,7 +200,7 @@ using namespace irc; // Functions // main.cpp -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; extern OBJLIST g_servers; diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp index faa5809241..c04c7036a9 100644 --- a/protocols/IRCG/src/userinfo.cpp +++ b/protocols/IRCG/src/userinfo.cpp @@ -212,7 +212,7 @@ int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam) odp.flags = ODPF_DONTTRANSLATE; odp.szTitle.a = m_szModuleName; odp.dwInitParam = (LPARAM)this; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.position = -1900000000; odp.pfnDlgProc = UserDetailsDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO); diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index 992cbe8ad7..d7c91e5e8c 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -440,7 +440,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (IsIconic(hwndDlg)) break; - Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO), ChangeInfoDlg_Resize); + Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO), ChangeInfoDlg_Resize); { RECT rc; // update listview column widths GetClientRect(dat->hwndList, &rc); diff --git a/protocols/IcqOscarJ/src/editlist.cpp b/protocols/IcqOscarJ/src/editlist.cpp index bcbccb281d..f0d88461dd 100644 --- a/protocols/IcqOscarJ/src/editlist.cpp +++ b/protocols/IcqOscarJ/src/editlist.cpp @@ -80,7 +80,7 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey dataListEdit = this; hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, L"LISTBOX", L"", WS_POPUP | WS_BORDER | WS_VSCROLL, - rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, hInst, nullptr); + rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, g_hInstance, nullptr); SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0); int itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0); diff --git a/protocols/IcqOscarJ/src/editstring.cpp b/protocols/IcqOscarJ/src/editstring.cpp index 8e190aad47..feb334b34b 100644 --- a/protocols/IcqOscarJ/src/editstring.cpp +++ b/protocols/IcqOscarJ/src/editstring.cpp @@ -188,7 +188,7 @@ static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wPa SendMessage(hwndEdit, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd); DestroyWindow(hwndEdit); EscapesToMultiline(text, &selStart, &selEnd); - hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, nullptr, nullptr, hInst, nullptr); + hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, nullptr, nullptr, g_hInstance, nullptr); SetWindowTextUcs(hwndEdit, text); mir_subclassWindow(hwndEdit, StringEditSubclassProc); SendMessage(hwndEdit, WM_SETFONT, (WPARAM)dataStringEdit->hListFont, 0); @@ -251,13 +251,13 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) if ((si.displayType & LIM_TYPE) == LI_LONGSTRING) { rc->right -= rc->bottom - rc->top; - hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, nullptr, hInst, nullptr); + hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, nullptr, g_hInstance, nullptr); SendMessage(hwndExpandButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib)); mir_subclassWindow(hwndExpandButton, ExpandButtonSubclassProc); } dataStringEdit = this; - hwndEdit = CreateWindow(L"EDIT", L"", WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, nullptr, hInst, nullptr); + hwndEdit = CreateWindow(L"EDIT", L"", WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, nullptr, g_hInstance, nullptr); SetWindowTextUtf(hwndEdit, szValue); if (alloced) SAFE_FREE(&szValue); mir_subclassWindow(hwndEdit, StringEditSubclassProc); @@ -265,7 +265,7 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) if ((si.displayType & LIM_TYPE) == LI_NUMBER) { int *range = (int*)si.pList; RECT rcUpDown; - hwndUpDown = CreateWindow(UPDOWN_CLASS, L"", WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, nullptr, hInst, nullptr); + hwndUpDown = CreateWindow(UPDOWN_CLASS, L"", WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, nullptr, g_hInstance, nullptr); SendMessage(hwndUpDown, UDM_SETRANGE32, range[0], range[1]); SendMessage(hwndUpDown, UDM_SETPOS32, 0, sid.value); if (!(si.displayType & LIF_ZEROISVALID) && sid.value == 0) diff --git a/protocols/IcqOscarJ/src/globals.h b/protocols/IcqOscarJ/src/globals.h index 0af42b4c6c..16870b1657 100644 --- a/protocols/IcqOscarJ/src/globals.h +++ b/protocols/IcqOscarJ/src/globals.h @@ -36,7 +36,6 @@ typedef char uid_str[MAX_PATH]; // from init.cpp -extern HINSTANCE hInst; extern DWORD MIRANDA_VERSION; extern HANDLE hExtraXStatus; diff --git a/protocols/IcqOscarJ/src/icq_firstrun.cpp b/protocols/IcqOscarJ/src/icq_firstrun.cpp index c0ed75645f..ea5254cf05 100644 --- a/protocols/IcqOscarJ/src/icq_firstrun.cpp +++ b/protocols/IcqOscarJ/src/icq_firstrun.cpp @@ -104,5 +104,5 @@ INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR INT_PTR CIcqProto::OnCreateAccMgrUI(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQACCOUNT), (HWND)lParam, icq_FirstRunDlgProc, LPARAM(this)); + return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ICQACCOUNT), (HWND)lParam, icq_FirstRunDlgProc, LPARAM(this)); } diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index 6c27c46de4..f19dcaef7a 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -506,7 +506,7 @@ int CIcqProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.position = -800000000; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.szGroup.w = LPGENW("Network"); odp.dwInitParam = LPARAM(this); odp.szTitle.w = m_tszUserName; diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 6cc998712c..a3ec27ff40 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -808,8 +808,8 @@ HANDLE __cdecl CIcqProto::SearchByName(const wchar_t *nick, const wchar_t *first HWND __cdecl CIcqProto::CreateExtendedSearchUI(HWND parent) { - if (parent && hInst) - return CreateDialog(hInst, MAKEINTRESOURCE(IDD_ICQADVANCEDSEARCH), parent, AdvancedSearchDlgProc); + if (parent && g_hInstance) + return CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_ICQADVANCEDSEARCH), parent, AdvancedSearchDlgProc); return nullptr; // Failure } diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index 7fbdeca635..a7eb3bf6cd 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -866,7 +866,7 @@ void CIcqProto::ShowUploadContactsDialog(void) { if (hwndUploadContacts == nullptr) { hItemAll = nullptr; - hwndUploadContacts = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQUPLOADLIST), nullptr, DlgProcUploadList, LPARAM(this)); + hwndUploadContacts = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ICQUPLOADLIST), nullptr, DlgProcUploadList, LPARAM(this)); } SetForegroundWindow(hwndUploadContacts); diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index 95f584be87..0505ca7d43 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -807,7 +807,7 @@ void CIcqProto::setXStatusEx(BYTE bXStatus, BYTE bQuiet) init.bXStatus = bXStatus; init.szXStatusName = szName; init.szXStatusMsg = szMsg; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init); } else { setByte(DBSETTING_XSTATUS_ID, bXStatus); @@ -916,7 +916,7 @@ INT_PTR CIcqProto::ShowXStatusDetails(WPARAM hContact, LPARAM) init.ppro = this; init.bAction = 1; // retrieve init.hContact = hContact; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init); return 0; } diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index 4f6cd06873..55d8c21fe8 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -29,7 +29,7 @@ #include "m_icolib.h" CMPlugin g_plugin; -HINSTANCE hInst; +HINSTANCE g_hInstance; int hLangpack; bool g_bTerminated; @@ -56,11 +56,7 @@ extern "C" PLUGININFOEX __declspec(dllexport) *MirandaPluginInfoEx(DWORD) extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; ///////////////////////////////////////////////////////////////////////////////////////// @@ -105,7 +101,7 @@ extern "C" int __declspec(dllexport) Load(void) hExtraXStatus = ExtraIcon_RegisterIcolib("xstatus", LPGEN("ICQ xStatus"), "icq_xstatus13"); - Icon_Register(hInst, "ICQ", iconList, _countof(iconList)); + Icon_Register(g_hInstance, "ICQ", iconList, _countof(iconList)); g_MenuInit(); return 0; @@ -159,4 +155,3 @@ void CIcqProto::UpdateGlobalSettings() m_bXStatusEnabled = getByte("XStatusEnabled", DEFAULT_XSTATUS_ENABLED); m_bMoodsEnabled = getByte("MoodsEnabled", DEFAULT_MOODS_ENABLED); } - diff --git a/protocols/IcqOscarJ/src/loginpassword.cpp b/protocols/IcqOscarJ/src/loginpassword.cpp index 5fbb2bc601..1a6d8c1e51 100644 --- a/protocols/IcqOscarJ/src/loginpassword.cpp +++ b/protocols/IcqOscarJ/src/loginpassword.cpp @@ -84,5 +84,5 @@ INT_PTR CALLBACK LoginPasswdDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA void CIcqProto::RequestPassword() { - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_LOGINPW), nullptr, LoginPasswdDlgProc, LPARAM(this)); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_LOGINPW), nullptr, LoginPasswdDlgProc, LPARAM(this)); } diff --git a/protocols/IcqOscarJ/src/userinfotab.cpp b/protocols/IcqOscarJ/src/userinfotab.cpp index bbeb69ef07..8bd0911293 100644 --- a/protocols/IcqOscarJ/src/userinfotab.cpp +++ b/protocols/IcqOscarJ/src/userinfotab.cpp @@ -270,7 +270,7 @@ int CIcqProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_UNICODE | ODPF_DONTTRANSLATE; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.dwInitParam = LPARAM(this); odp.pfnDlgProc = IcqDlgProc; odp.position = -1900000000; diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index d82b7a50fd..9e8c7e3204 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma comment(lib, "Dnsapi.lib") #pragma comment(lib, "Secur32.lib") -HINSTANCE hInst; +HINSTANCE g_hInstance; HMODULE hMsftedit; CMPlugin g_plugin; @@ -73,11 +73,7 @@ bool bSecureIM, bMirOTR, bNewGPG, bPlatform; ///////////////////////////////////////////////////////////////////////////// -BOOL WINAPI DllMain(HINSTANCE hModule, DWORD, LPVOID) -{ - hInst = hModule; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { @@ -112,7 +108,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) // file associations manager plugin support if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) { CreateServiceFunction("JABBER/*" JS_PARSE_XMPP_URI, g_SvcParseXmppUri); - AssocMgr_AddNewUrlTypeW("xmpp:", TranslateT("Jabber Link Protocol"), hInst, IDI_JABBER, "JABBER/*" JS_PARSE_XMPP_URI, 0); + AssocMgr_AddNewUrlTypeW("xmpp:", TranslateT("Jabber Link Protocol"), g_hInstance, IDI_JABBER, "JABBER/*" JS_PARSE_XMPP_URI, 0); } // init fontservice for info frame diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index 9a5e8a84e4..fccbbcdbd0 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -339,7 +339,7 @@ int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id, ctrlWidth = min(ctrlWidth, strRect.right - strRect.left + 20); ReleaseDC(hFrame, hdc); - HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, hInst, nullptr); + HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, g_hInstance, nullptr); SendMessage(hCtrl, WM_SETFONT, (WPARAM)SendMessage(GetParent(hFrame), WM_GETFONT, 0, 0), 0); SendMessage(hCtrl, BM_SETCHECK, value, 0); return (ypos + labelHeight + verticalStep); @@ -527,7 +527,7 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) HMENU hMenu = CreatePopupMenu(); for (int i = 0; i < item->arResources.getCount(); i++) AppendMenu(hMenu, MF_STRING, i + 1, item->arResources[i]->m_tszResourceName); - HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, nullptr, nullptr, hInst, nullptr); + HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, nullptr, nullptr, g_hInstance, nullptr); SetForegroundWindow(hwndTemp); RECT rc; POINT pt; @@ -551,11 +551,11 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) if (item == nullptr || selected) { CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, nullptr); - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)pStartupParams); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)pStartupParams); } } else if (lParam != 0) - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, lParam); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, lParam); } return res; } @@ -563,5 +563,5 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) void CJabberProto::ContactMenuAdhocCommands(CJabberAdhocStartupParams* param) { if (param) - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)param); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)param); } diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp index 56f1faa408..829d3dbfbe 100644 --- a/protocols/JabberG/src/jabber_bookmarks.cpp +++ b/protocols/JabberG/src/jabber_bookmarks.cpp @@ -197,7 +197,7 @@ private: JabberAddBookmarkDlgParam param; param.ppro = m_proto; param.m_item = nullptr; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m); } void btnEdit_OnClick(CCtrlFilterListView *) @@ -216,7 +216,7 @@ private: JabberAddBookmarkDlgParam param; param.ppro = m_proto; param.m_item = item; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m); } void btnRemove_OnClick(CCtrlFilterListView *) @@ -443,7 +443,7 @@ int CJabberProto::AddEditBookmark(JABBER_LIST_ITEM *item) JabberAddBookmarkDlgParam param; param.ppro = this; param.m_item = item;//(JABBER_LIST_ITEM*)lParam; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), nullptr, JabberAddBookmarkDlgProc, (LPARAM)¶m); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), nullptr, JabberAddBookmarkDlgProc, (LPARAM)¶m); } return 0; } diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp index f4ea12630f..d9127e822c 100644 --- a/protocols/JabberG/src/jabber_captcha.cpp +++ b/protocols/JabberG/src/jabber_captcha.cpp @@ -152,7 +152,7 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info) GetObject(param.bmp, sizeof(bmp), &bmp); param.w = bmp.bmWidth; param.h = bmp.bmHeight; - int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, JabberCaptchaFormDlgProc, (LPARAM)¶m); + int res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, JabberCaptchaFormDlgProc, (LPARAM)¶m); if (mir_wstrcmp(param.Result, L"") == 0 || !res) sendCaptchaError(info, param.from, param.to, param.challenge); else diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index ce0f6ba36e..3f7c381a15 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1036,7 +1036,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* dat->him = him; dat->item = item; dat->ppro = ppro; - HWND hwndInfo = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_GROUPCHAT_INFO), nullptr, sttUserInfoDlgProc, (LPARAM)dat); + HWND hwndInfo = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_GROUPCHAT_INFO), nullptr, sttUserInfoDlgProc, (LPARAM)dat); ShowWindow(hwndInfo, SW_SHOW); } break; diff --git a/protocols/JabberG/src/jabber_filterlist.cpp b/protocols/JabberG/src/jabber_filterlist.cpp index 6759596178..269468958e 100644 --- a/protocols/JabberG/src/jabber_filterlist.cpp +++ b/protocols/JabberG/src/jabber_filterlist.cpp @@ -183,7 +183,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara fdat->m_hwndEditBox = CreateWindow(L"edit", fdat->m_filterText, WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL, 0, 0, 0, 0, - ::GetParent(m_hwnd), (HMENU)-1, hInst, nullptr); + ::GetParent(m_hwnd), (HMENU)-1, g_hInstance, nullptr); SendMessage(fdat->m_hwndEditBox, WM_SETFONT, (WPARAM)fdat->m_hfntNormal, 0); diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp index 1b4219d5b7..e7763d10da 100644 --- a/protocols/JabberG/src/jabber_form.cpp +++ b/protocols/JabberG/src/jabber_form.cpp @@ -282,7 +282,7 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo #define JabberFormCreateLabel() \ CreateWindow(L"static", labelStr, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \ - 0, 0, 0, 0, hwndStatic, (HMENU)-1, hInst, nullptr) + 0, 0, 0, 0, hwndStatic, (HMENU)-1, g_hInstance, nullptr) TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, TJabberFormControlType type, const wchar_t *labelStr, const wchar_t *valueStr) { @@ -302,7 +302,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, nullptr); + hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr); ++layout_info->id; break; @@ -311,7 +311,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, nullptr); + hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr); mir_subclassWindow(item->hCtrl, JabberFormMultiLineWndProc); ++layout_info->id; break; @@ -320,7 +320,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, nullptr); + hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr); if (valueStr && !mir_wstrcmp(valueStr, L"1")) SendMessage(item->hCtrl, BM_SETCHECK, 1, 0); ++layout_info->id; @@ -331,7 +331,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "combobox", nullptr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, nullptr); + hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr); ++layout_info->id; break; @@ -340,7 +340,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "listbox", nullptr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | LBS_MULTIPLESEL, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, nullptr); + hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr); ++layout_info->id; break; @@ -348,7 +348,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindow(L"edit", valueStr, WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL, 0, 0, 0, 0, - hwndStatic, (HMENU)-1, hInst, nullptr); + hwndStatic, (HMENU)-1, g_hInstance, nullptr); break; case JFORM_CTYPE_HIDDEN: @@ -359,7 +359,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL, 0, 0, 0, 0, - hwndStatic, (HMENU)layout_info->id, hInst, nullptr); + hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr); ++layout_info->id; break; } @@ -849,7 +849,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, static VOID CALLBACK JabberFormCreateDialogApcProc(void* param) { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberFormDlgProc, (LPARAM)param); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberFormDlgProc, (LPARAM)param); } void CJabberProto::FormCreateDialog(HXML xNode, wchar_t* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata) diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp index 6f15bf4780..10a0a4218a 100644 --- a/protocols/JabberG/src/jabber_frame.cpp +++ b/protocols/JabberG/src/jabber_frame.cpp @@ -79,7 +79,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): CLISTFrame frame = { sizeof(frame) }; HWND hwndClist = pcli->hwndContactList; - frame.hWnd = CreateWindowEx(0, L"JabberInfoFrameClass", nullptr, WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, hwndClist, nullptr, hInst, this); + frame.hWnd = CreateWindowEx(0, L"JabberInfoFrameClass", nullptr, WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, hwndClist, nullptr, g_hInstance, this); frame.align = alBottom; frame.height = 2 * SZ_FRAMEPADDING + GetSystemMetrics(SM_CYSMICON) + SZ_LINEPADDING; // compact height by default frame.Flags = F_VISIBLE|F_LOCKED|F_NOBORDER|F_UNICODE; @@ -98,7 +98,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): m_hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - m_hwnd, nullptr, hInst, nullptr); + m_hwnd, nullptr, g_hInstance, nullptr); SetWindowPos(m_hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); CreateInfoItem("$", true); @@ -136,7 +136,7 @@ void CJabberInfoFrame::InitClass() wcx.cbSize = sizeof(wcx); wcx.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wcx.lpfnWndProc = GlobalWndProc; - wcx.hInstance = hInst; + wcx.hInstance = g_hInstance; wcx.lpszClassName = L"JabberInfoFrameClass"; wcx.hCursor = LoadCursor(nullptr, IDC_ARROW); RegisterClassEx(&wcx); @@ -297,7 +297,7 @@ void CJabberInfoFrame::SetToolTip(int id, RECT *rc, wchar_t *pszText) ti.uFlags = TTF_SUBCLASS; ti.hwnd = m_hwnd; ti.uId = id; - ti.hinst = hInst; + ti.hinst = g_hInstance; ti.lpszText = pszText; ti.rect = *rc; SendMessage(m_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 082aa5af29..4c105cb6ae 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -522,10 +522,10 @@ static IconItem sharedIconList4[] = void g_IconsInit() { - Icon_Register(hInst, LPGEN("Protocols") "/" LPGEN("Jabber"), sharedIconList1, _countof(sharedIconList1), GLOBAL_SETTING_PREFIX); - Icon_Register(hInst, LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs"), sharedIconList2, _countof(sharedIconList2), GLOBAL_SETTING_PREFIX); - Icon_Register(hInst, LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Discovery"), sharedIconList3, _countof(sharedIconList3), GLOBAL_SETTING_PREFIX); - Icon_Register(hInst, LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Privacy"), sharedIconList4, _countof(sharedIconList4), GLOBAL_SETTING_PREFIX); + Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Jabber"), sharedIconList1, _countof(sharedIconList1), GLOBAL_SETTING_PREFIX); + Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs"), sharedIconList2, _countof(sharedIconList2), GLOBAL_SETTING_PREFIX); + Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Discovery"), sharedIconList3, _countof(sharedIconList3), GLOBAL_SETTING_PREFIX); + Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Privacy"), sharedIconList4, _countof(sharedIconList4), GLOBAL_SETTING_PREFIX); } HANDLE g_GetIconHandle(int iconId) diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index c678f54387..98a2dadf9f 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.cpp @@ -212,7 +212,7 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w return TRUE; case WM_SIZE: - Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_JIDLIST), sttJidListResizer); + Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_JIDLIST), sttJidListResizer); RECT listrc; LVCOLUMN lvc; @@ -472,7 +472,7 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param) SetForegroundWindow(*pHwndJidList); SendMessage(*pHwndJidList, WM_JABBER_REFRESH, 0, (LPARAM)jidListInfo); } - else *pHwndJidList = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_JIDLIST), GetForegroundWindow(), JabberMucJidListDlgProc, (LPARAM)jidListInfo); + else *pHwndJidList = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_JIDLIST), GetForegroundWindow(), JabberMucJidListDlgProc, (LPARAM)jidListInfo); } void CJabberProto::OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType) diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 049e11a2c2..ba8d77b14c 100755 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1357,7 +1357,7 @@ static LRESULT CALLBACK _RosterNewListProc(HWND hList, UINT msg, WPARAM wParam, wchar_t buff[260]; ListView_GetSubItemRect(hList, lvhti.iItem, lvhti.iSubItem, LVIR_BOUNDS, &rc); ListView_GetItemText(hList, lvhti.iItem, lvhti.iSubItem, buff, _countof(buff)); - HWND hEditor = CreateWindow(TEXT("EDIT"), buff, WS_CHILD | ES_AUTOHSCROLL, rc.left + 3, rc.top + 2, rc.right - rc.left - 3, rc.bottom - rc.top - 3, hList, nullptr, hInst, nullptr); + HWND hEditor = CreateWindow(TEXT("EDIT"), buff, WS_CHILD | ES_AUTOHSCROLL, rc.left + 3, rc.top + 2, rc.right - rc.left - 3, rc.bottom - rc.top - 3, hList, nullptr, g_hInstance, nullptr); SendMessage(hEditor, WM_SETFONT, (WPARAM)SendMessage(hList, WM_GETFONT, 0, 0), 0); ShowWindow(hEditor, SW_SHOW); SetWindowText(hEditor, buff); @@ -1448,7 +1448,7 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wP } case WM_SIZE: - Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_OPT_JABBER3), sttRosterEditorResizer); + Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_OPT_JABBER3), sttRosterEditorResizer); break; case WM_COMMAND: @@ -1486,7 +1486,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl(WPARAM, LPARAM) if (rrud.hwndDlg && IsWindow(rrud.hwndDlg)) SetForegroundWindow(rrud.hwndDlg); else - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_JABBER3), nullptr, JabberRosterOptDlgProc, (LPARAM)this); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_OPT_JABBER3), nullptr, JabberRosterOptDlgProc, (LPARAM)this); return 0; } diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp index 674a480c57..018446a3ab 100644 --- a/protocols/JabberG/src/jabber_password.cpp +++ b/protocols/JabberG/src/jabber_password.cpp @@ -33,7 +33,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleChangePassword(WPARAM, LPARAM) if (IsWindow(m_hwndJabberChangePassword)) SetForegroundWindow(m_hwndJabberChangePassword); else - m_hwndJabberChangePassword = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANGEPASSWORD), nullptr, JabberChangePasswordDlgProc, (LPARAM)this); + m_hwndJabberChangePassword = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CHANGEPASSWORD), nullptr, JabberChangePasswordDlgProc, (LPARAM)this); return 0; } diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index d0dfcfcbe3..204876b73a 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -105,8 +105,8 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat) int Order = (FieldDat->bHidden) ? -1 : FieldDat->Order; - HWND hwndLabel = CreateWindowEx(0, L"STATIC", (const wchar_t *)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, nullptr, hInst, nullptr); - HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (const wchar_t *)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, hInst, nullptr); + HWND hwndLabel = CreateWindowEx(0, L"STATIC", (const wchar_t *)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, nullptr, g_hInstance, nullptr); + HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (const wchar_t *)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, g_hInstance, nullptr); SendMessage(hwndLabel, WM_SETFONT, (WPARAM)hFont, 0); SendMessage(hwndVar, WM_SETFONT, (WPARAM)hFont, 0); if (!FieldDat->bHidden) { @@ -707,10 +707,10 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR HWND __cdecl CJabberProto::CreateExtendedSearchUI(HWND parent) { - if (parent && hInst) { + if (parent && g_hInstance) { ptrW szServer(getWStringA("LoginServer")); if (szServer == nullptr || mir_wstrcmpi(szServer, L"S.ms")) - return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this); + return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this); } return nullptr; // Failure diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 653e8af1bb..fdf951ad47 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -116,7 +116,7 @@ static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa static VOID CALLBACK JabberPasswordCreateDialogApcProc(void* param) { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), nullptr, JabberPasswordDlgProc, (LPARAM)param); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_PASSWORD), nullptr, JabberPasswordDlgProc, (LPARAM)param); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 203c1022e2..35da917865 100755 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -822,7 +822,7 @@ int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) char *szProto = GetContactProto(hContact); if (szProto != nullptr && !mir_strcmp(szProto, m_szModuleName)) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.dwInitParam = (LPARAM)this; odp.pfnDlgProc = JabberUserInfoDlgProc; diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 5fd5cd0521..f82b2e8c70 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -842,9 +842,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP EditDlgParam param = { -1, ppro }; int res; if (nm->hdr.idFrom == IDC_PHONES) - res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m); + res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m); else - res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m); + res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m); if (res != IDOK) break; SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); @@ -882,9 +882,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP EditDlgParam param = { (int)lvi.lParam, ppro }; int res; if (nm->hdr.idFrom == IDC_PHONES) - res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m); + res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m); else - res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m); + res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m); if (res != IDOK) break; SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); @@ -1178,7 +1178,7 @@ void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM) m_szPhotoFileName[0] = 0; OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.dwInitParam = (LPARAM)this; odp.flags = ODPF_UNICODE | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE; odp.szTitle.w = m_tszUserName; diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index f71bc05754..df48a3d90c 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -1496,7 +1496,7 @@ wchar_t* CJabberProto::ReadAdvStatusT(MCONTACT hContact, const char *pszSlot, co void g_XstatusIconsInit() { wchar_t szFile[MAX_PATH]; - GetModuleFileName(hInst, szFile, _countof(szFile)); + GetModuleFileName(g_hInstance, szFile, _countof(szFile)); if (wchar_t *p = wcsrchr(szFile, '\\')) mir_wstrcpy(p + 1, L"..\\Icons\\xstatus_jabber.dll"); diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 464d3e8259..37dacc2085 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -577,7 +577,7 @@ private: /******************************************************************* * Global variables *******************************************************************/ -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; extern HANDLE hExtraMood; extern HANDLE hExtraActivity; diff --git a/protocols/MRA/src/Mra.cpp b/protocols/MRA/src/Mra.cpp index 79dfebf977..68373ab59b 100644 --- a/protocols/MRA/src/Mra.cpp +++ b/protocols/MRA/src/Mra.cpp @@ -29,17 +29,7 @@ WCHAR g_szMirWorkDirPath[MAX_FILEPATH]; void IconsLoad(); -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) -{ - switch (dwReason) { - case DLL_PROCESS_ATTACH: - g_hInstance = hInstance; - DisableThreadLibraryCalls(hInstance); - break; - } - - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; diff --git a/protocols/MSN/src/msn.cpp b/protocols/MSN/src/msn.cpp index bc2d78b797..fe24b511e2 100644 --- a/protocols/MSN/src/msn.cpp +++ b/protocols/MSN/src/msn.cpp @@ -26,7 +26,7 @@ along with this program. If not, see . CMPlugin g_plugin; CLIST_INTERFACE *pcli; -HINSTANCE g_hInst, g_hOpenssl = nullptr; +HINSTANCE g_hInstance; int hLangpack; ///////////////////////////////////////////////////////////////////////////////////////// @@ -65,7 +65,7 @@ static int sttCompareProtocols(const CMsnProto *p1, const CMsnProto *p2) extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) { if (fdwReason == DLL_PROCESS_ATTACH) { - g_hInst = hinstDLL; + g_hInstance = hinstDLL; DisableThreadLibraryCalls(hinstDLL); } return TRUE; @@ -97,9 +97,6 @@ extern "C" int __declspec(dllexport) Load(void) // Unload a plugin extern "C" int __declspec(dllexport) Unload(void) { - if (g_hOpenssl) - FreeLibrary(g_hOpenssl); - MSN_RemoveContactMenus(); MsnLinks_Destroy(); return 0; diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index f9420029cd..db67f3cbb1 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -886,14 +886,14 @@ void __cdecl CMsnProto::msn_IEAuthThread(void *pParam) wc.cbSize = sizeof(WNDCLASSEX); wc.cbWndExtra = sizeof(void*); - wc.hInstance = g_hInst; + wc.hInstance = g_hInstance; wc.lpfnWndProc = AuthWindowProc; wc.lpszClassName = ClassName; RegisterClassEx(&wc); if ((hWnd = CreateWindowEx(0, ClassName, L"MSN Login", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, - HWND_DESKTOP, nullptr, g_hInst, pParam))) { + HWND_DESKTOP, nullptr, g_hInstance, pParam))) { ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); @@ -903,7 +903,7 @@ void __cdecl CMsnProto::msn_IEAuthThread(void *pParam) } } - UnregisterClass(ClassName, g_hInst); + UnregisterClass(ClassName, g_hInstance); CoUninitialize(); } diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index 45f37fb39f..a10a43a2d6 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -495,7 +495,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) break; case GC_USER_CHANMGR: - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(gch->ptszID, NULL, this))); break; @@ -506,7 +506,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) case GC_USER_LOGMENU: switch (gch->dwData) { case 10: - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(gch->ptszID, NULL, this))); break; diff --git a/protocols/MSN/src/msn_links.cpp b/protocols/MSN/src/msn_links.cpp index 884c9275ce..16345a3b49 100644 --- a/protocols/MSN/src/msn_links.cpp +++ b/protocols/MSN/src/msn_links.cpp @@ -135,7 +135,7 @@ void MsnLinks_Init(void) static const char szService[] = "MSN/ParseMsnimLink"; CreateServiceFunction(szService, ServiceParseMsnimLink); - AssocMgr_AddNewUrlTypeW("msnim:", TranslateT("MSN Link Protocol"), g_hInst, IDI_MSN, szService, 0); + AssocMgr_AddNewUrlTypeW("msnim:", TranslateT("MSN Link Protocol"), g_hInstance, IDI_MSN, szService, 0); } void MsnLinks_Destroy(void) diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index 393e1d085d..6823338996 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -397,7 +397,7 @@ static void SaveListItem(MCONTACT hContact, const char* szEmail, int list, int i if (iNewValue == 0) { if (list & LIST_FL) { DeleteParam param = { proto, hContact }; - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m); return; } diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index 397fabc8ec..161258a4b7 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -100,7 +100,7 @@ INT_PTR CMsnProto::MsnEditProfile(WPARAM, LPARAM) // MsnInviteCommand - invite command callback function INT_PTR CMsnProto::MsnInviteCommand(WPARAM, LPARAM) { - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(nullptr, NULL, this))); return 0; } diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index 8549350c1d..77b042b0c4 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -47,7 +47,7 @@ static IconItem iconList[] = void MsnInitIcons(void) { - Icon_Register(g_hInst, "Protocols/MSN", iconList, _countof(iconList), "MSN"); + Icon_Register(g_hInstance, "Protocols/MSN", iconList, _countof(iconList), "MSN"); } HICON LoadIconEx(const char* name, bool big) @@ -593,7 +593,7 @@ int CMsnProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.position = -790000000; - odp.hInstance = g_hInst; + odp.hInstance = g_hInstance; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSN); odp.szTitle.w = m_tszUserName; odp.szGroup.w = LPGENW("Network"); @@ -623,7 +623,7 @@ int CMsnProto::OnOptionsInit(WPARAM wParam, LPARAM) INT_PTR CMsnProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_ACCMGRUI), + return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, DlgProcAccMgrUI, (LPARAM)this); } diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 4c2aa72335..2e50f2548f 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -267,7 +267,7 @@ int CMsnProto::OnContactDeleted(WPARAM hContact, LPARAM) if (Lists_IsInList(LIST_FL, szEmail)) { DeleteParam param = { this, MCONTACT(hContact) }; - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m); MsnContact *msc = Lists_Get(szEmail); if (msc) @@ -406,7 +406,7 @@ int CMsnProto::OnWindowPopup(WPARAM, LPARAM lParam) case MSG_WINDOWPOPUP_SELECTED: if (mwpd->selection == 13465) - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(nullptr, mwpd->hContact, this))); + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(nullptr, mwpd->hContact, this))); break; } diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index 84fc8292b3..48fd351dfc 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -919,7 +919,7 @@ const char msnStoreAppId[] = "Skype"; const char msnProductVer[] = "0/6.16.0.105/259/"; const char msnProtID[] = "MSNP24"; -extern HINSTANCE g_hInst; +extern HINSTANCE g_hInstance; extern bool g_bTerminated; /////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Sametime/src/options.cpp b/protocols/Sametime/src/options.cpp index 188f0afd79..4c140e9f38 100644 --- a/protocols/Sametime/src/options.cpp +++ b/protocols/Sametime/src/options.cpp @@ -343,7 +343,7 @@ int CSametimeProto::OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTNET); odp.szTitle.w = m_tszUserName; odp.szGroup.w = LPGENW("Network"); diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index e02d755a40..7e842b1501 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -17,16 +17,11 @@ PLUGININFOEX pluginInfo = }; CMPlugin g_plugin; -HINSTANCE hInst; +HINSTANCE g_hInstance; LIST g_Instances(1, PtrKeySortT); int hLangpack; -// sametime.cpp: Defines the entry point for the DLL application. -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { @@ -65,7 +60,7 @@ INT_PTR CSametimeProto::SametimeLoadIcon(WPARAM wParam, LPARAM lParam) return NULL; } - return (INT_PTR) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, + return (INT_PTR) LoadImage(g_hInstance, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON), GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0); } @@ -84,7 +79,7 @@ static IconItem iconList[] = void SametimeInitIcons(void) { - Icon_Register(hInst, "Protocols/Sametime", iconList, _countof(iconList), "SAMETIME"); + Icon_Register(g_hInstance, "Protocols/Sametime", iconList, _countof(iconList), "SAMETIME"); } HANDLE GetIconHandle(int iconId) diff --git a/protocols/Sametime/src/sametime.h b/protocols/Sametime/src/sametime.h index f5da14c480..9afa3230ad 100644 --- a/protocols/Sametime/src/sametime.h +++ b/protocols/Sametime/src/sametime.h @@ -105,7 +105,7 @@ typedef struct FileTransferClientData_tag { // Global variables struct CSametimeProto; -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; extern PLUGININFOEX pluginInfo; #include "sametime_proto.h" diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index 382c941c51..d1c5a0dcfe 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -174,7 +174,7 @@ HWND CSametimeProto::SearchAdvanced(HWND owner) HWND CSametimeProto::CreateExtendedSearchUI(HWND owner) { debugLogW(L"CSametimeProto::CreateExtendedSearchUI() start"); - return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_USERSEARCH), owner, SearchDialogFunc, (LPARAM)this); + return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_USERSEARCH), owner, SearchDialogFunc, (LPARAM)this); } diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp index 3646cc2f34..7f87cd8456 100644 --- a/protocols/Sametime/src/sametime_session.cpp +++ b/protocols/Sametime/src/sametime_session.cpp @@ -563,7 +563,7 @@ INT_PTR CSametimeProto::SessionAnnounce(WPARAM wParam, LPARAM lParam) SessionAnnounceDialogProc_arg* sadpArg = (SessionAnnounceDialogProc_arg*)mir_calloc(sizeof(SessionAnnounceDialogProc_arg)); sadpArg->proto = this; sadpArg->sendAnnouncementFunc = SendAnnouncement; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SESSIONANNOUNCE), GetDesktopWindow(), SessionAnnounceDialogProc, (LPARAM)sadpArg); + CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SESSIONANNOUNCE), GetDesktopWindow(), SessionAnnounceDialogProc, (LPARAM)sadpArg); return 0; } diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index a748c396e4..bc5ebf60f3 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -39,12 +39,7 @@ PLUGININFOEX pluginInfo = { 0x57e90ac6, 0x1067, 0x423b, { 0x8c, 0xa3, 0x70, 0xa3, 0x9d, 0x20, 0xd, 0x4f } } }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp index 7464db16e2..f674bc4a09 100644 --- a/protocols/Steam/src/main.cpp +++ b/protocols/Steam/src/main.cpp @@ -20,12 +20,7 @@ PLUGININFOEX pluginInfo = { 0x68f5a030, 0xba32, 0x48ec, { 0x95, 0x7, 0x5c, 0x2f, 0xbd, 0xea, 0x52, 0x17 }} }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp index 88a13bc13b..ec6ae99f82 100644 --- a/protocols/Tox/src/main.cpp +++ b/protocols/Tox/src/main.cpp @@ -21,12 +21,7 @@ PLUGININFOEX pluginInfo = {0x272a3e, 0xf5fa, 0x4090, {0x8b, 0x67, 0x3e, 0x62, 0xac, 0x1e, 0xe0, 0xb4}} }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { diff --git a/protocols/Twitter/src/main.cpp b/protocols/Twitter/src/main.cpp index 14e91dc39e..de7559e55e 100644 --- a/protocols/Twitter/src/main.cpp +++ b/protocols/Twitter/src/main.cpp @@ -41,11 +41,7 @@ PLUGININFOEX pluginInfo = { { 0xbc09a71b, 0xb86e, 0x4d33, { 0xb1, 0x8d, 0x82, 0xd3, 0x4, 0x51, 0xdd, 0x3c } } }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index 71e8ddd3cd..01a6dfb66d 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -18,7 +18,8 @@ along with this program. If not, see . #include "stdafx.h" #include "version.h" -HINSTANCE hInst; +CMPlugin g_plugin; +HINSTANCE g_hInstance; int hLangpack; CLIST_INTERFACE *pcli; @@ -38,11 +39,7 @@ PLUGININFOEX pluginInfo = ///////////////////////////////////////////////////////////////////////////////////////// -BOOL WINAPI DllMain(HINSTANCE hModule, DWORD, LPVOID) -{ - hInst = hModule; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { @@ -70,15 +67,3 @@ extern "C" int __declspec(dllexport) Unload(void) { return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// - -struct CMPlugin : public ACCPROTOPLUGIN -{ - CMPlugin() : - ACCPROTOPLUGIN("VKontakte") - { - SetUniqueId("ID"); - } -} - g_plugin; diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 2f3aeca9c7..1b18bc382b 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -79,7 +79,7 @@ static IconItem iconList[] = void InitIcons() { - Icon_Register(hInst, LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte"); + Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte"); } HANDLE GetIconHandle(int iCommand) diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index da91ad030d..e60368369e 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -57,7 +57,7 @@ along with this program. If not, see . #include "win2k.h" -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; #include "resource.h" #include "vk.h" diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 4fd3060912..b40f8980ba 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -103,7 +103,7 @@ along with this program. If not, see . struct CVkProto; extern LIST vk_Instances; extern mir_cs csInstances; -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField); bool wlstrstr(wchar_t *_s1, wchar_t *_s2); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 8b7abdbb8a..5c050cf2a4 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -399,4 +399,13 @@ private: void SetChatStatus(MCONTACT hContact, int iStatus); CVkChatInfo* GetChatById(LPCWSTR pwszId); INT_PTR __cdecl SvcCreateChat(WPARAM, LPARAM); -}; \ No newline at end of file +}; + +struct CMPlugin : public ACCPROTOPLUGIN +{ + CMPlugin() : + ACCPROTOPLUGIN("VKontakte") + { + SetUniqueId("ID"); + } +}; -- cgit v1.2.3