diff options
author | George Hazan <ghazan@miranda.im> | 2017-08-08 12:18:11 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-08-08 12:18:11 +0300 |
commit | 54d93d2c1ae60d2205476cc08ad356fc7bbd13e0 (patch) | |
tree | d2511407730733583156eab9c7a840b1e4fb336e | |
parent | fc8c1d39c4955db131d423a9930f5da878d10f9e (diff) |
HookTemporaryEvent - new function that executes an event handler immediately if the event is missing
usable to hook events that disappear after being used
-rw-r--r-- | include/m_core.h | 4 | ||||
-rw-r--r-- | libs/win32/mir_core.lib | bin | 317222 -> 317458 bytes | |||
-rw-r--r-- | libs/win64/mir_core.lib | bin | 318184 -> 318400 bytes | |||
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/modules.cpp | 24 |
6 files changed, 30 insertions, 0 deletions
diff --git a/include/m_core.h b/include/m_core.h index 6d31fe17bb..eba11f2956 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -109,6 +109,10 @@ MIR_CORE_DLL(HANDLE) HookEventParam(const char *name, MIRANDAHOOKPARAM hookProc MIR_CORE_DLL(HANDLE) HookEventObj(const char *name, MIRANDAHOOKOBJ hookProc, void* object);
MIR_CORE_DLL(HANDLE) HookEventObjParam(const char *name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam);
MIR_CORE_DLL(HANDLE) HookEventMessage(const char *name, HWND hwnd, UINT message);
+ +// executes the event handler if event is missing +MIR_CORE_DLL(HANDLE) HookTemporaryEvent(const char *name, MIRANDAHOOK hookProc); +
MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook);
MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject);
MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE pModule);
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib Binary files differindex 4d146f0474..573e3e749a 100644 --- a/libs/win32/mir_core.lib +++ b/libs/win32/mir_core.lib diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib Binary files differindex 147ada0405..96c16192bd 100644 --- a/libs/win64/mir_core.lib +++ b/libs/win64/mir_core.lib diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index f5037de864..8a8e4df230 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1050,3 +1050,4 @@ CallFunctionSync @1170 ?Hide@CDlgBase@@QAEXXZ @1238 NONAME
?Resize@CDlgBase@@QAEXXZ @1239 NONAME
Utils_IsRtl @1240
+HookTemporaryEvent @1241
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 31edd2dbea..f188b5b51d 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1050,3 +1050,4 @@ CallFunctionSync @1170 ?Hide@CDlgBase@@QEAAXXZ @1238 NONAME
?Resize@CDlgBase@@QEAAXXZ @1239 NONAME
Utils_IsRtl @1240
+HookTemporaryEvent @1241
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index c6908e723d..ae7cd45f1e 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -332,6 +332,30 @@ MIR_CORE_DLL(HANDLE) HookEventObjParam(const char *name, MIRANDAHOOKOBJPARAM hoo return HookEventInt(4, name, (MIRANDAHOOK)hookProc, object, lParam); } +MIR_CORE_DLL(HANDLE) HookTemporaryEvent(const char *name, MIRANDAHOOK hookProc) +{ + mir_cslockfull lck(csHooks); + + int idx; + if ((idx = hooks.getIndex((THook*)name)) == -1) { + lck.unlock(); + hookProc(0, 0); + return NULL; + } + + THook *p = hooks[idx]; + p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount + 1)); + + THookSubscriber &s = p->subscriber[p->subscriberCount]; + memset(&s, 0, sizeof(THookSubscriber)); + s.type = 1; + s.pfnHook = hookProc; + s.hOwner = GetInstByAddress(hookProc); + + p->subscriberCount++; + return (HANDLE)((p->id << 16) | p->subscriberCount); +} + MIR_CORE_DLL(HANDLE) HookEventMessage(const char *name, HWND hwnd, UINT message) { mir_cslock lck(csHooks); |