From e767d690d104bf83b8efe28e338768aec3406bfc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 7 Dec 2023 12:22:10 +0300 Subject: EventExists: a helper to check the hookable event's presence --- include/m_core.h | 1 + libs/win32/mir_core.lib | Bin 493794 -> 493990 bytes libs/win64/mir_core.lib | Bin 499060 -> 499242 bytes src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + src/mir_core/src/modules.cpp | 9 +++++++++ 6 files changed, 12 insertions(+) diff --git a/include/m_core.h b/include/m_core.h index 6f2b88f631..d4fd0f197a 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -109,6 +109,7 @@ typedef INT_PTR (*MIRANDASERVICEOBJPARAM)(void*, WPARAM, LPARAM, LPARAM); MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name); MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent); +MIR_CORE_DLL(bool) EventExists(const char *name); MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook); MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, const char *pszEvent, WPARAM wParam = 0, LPARAM lParam = 0); MIR_CORE_DLL(int) CallObjectEventHook(void *pObject, HANDLE hEvent, WPARAM wParam = 0, LPARAM lParam = 0); diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib index f8e046d131..6adf3dddb9 100644 Binary files a/libs/win32/mir_core.lib and b/libs/win32/mir_core.lib differ diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib index 16cfc1e6f1..d0a67b237e 100644 Binary files a/libs/win64/mir_core.lib and b/libs/win64/mir_core.lib differ diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 1b934ef47f..0d7894a5c5 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1560,3 +1560,4 @@ db_event_updateId @1772 ?GetPlugin@CDlgBase@@QBEPBVCMPluginBase@@XZ @1784 NONAME _TranslateW_UUID@8 @1785 NONAME ?Langpack_GetDefaultLocaleName@@YGPADXZ @1786 NONAME +_EventExists@4 @1787 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 8007570bba..db7faf95a8 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1560,3 +1560,4 @@ db_event_updateId @1772 ?GetPlugin@CDlgBase@@QEBAPEBVCMPluginBase@@XZ @1784 NONAME TranslateW_UUID @1785 NONAME ?Langpack_GetDefaultLocaleName@@YAPEADXZ @1786 NONAME +EventExists @1787 NONAME diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index 0d471c8c6c..e62f72a4be 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -102,6 +102,15 @@ static int QueueMainThread(PAPCFUNC pFunc, void* pParam, HANDLE hDoneEvent) /////////////////////////////////////////////////////////////////////////////// // HOOKS +MIR_CORE_DLL(bool) EventExists(const char *name) +{ + if (name == nullptr) + return false; + + mir_cslock lck(csHooks); + return hooks.getIndex((THook *)name) != -1; +} + MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name) { if (name == nullptr) -- cgit v1.2.3