diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Mir_core/mir_core.def | 1 | ||||
-rw-r--r-- | plugins/Mir_core/modules.cpp | 31 | ||||
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 9 |
3 files changed, 20 insertions, 21 deletions
diff --git a/plugins/Mir_core/mir_core.def b/plugins/Mir_core/mir_core.def index e0cefde13b..6411108a72 100644 --- a/plugins/Mir_core/mir_core.def +++ b/plugins/Mir_core/mir_core.def @@ -6,7 +6,6 @@ CallProtoService @2 LangPackLookupUuid @3 NONAME
LangPackMarkPluginLoaded @4 NONAME
CallFunctionAsync @5
-CallHookSubscribers @6
CallPluginEventHook @7
CallService @8
CallServiceSync @9
diff --git a/plugins/Mir_core/modules.cpp b/plugins/Mir_core/modules.cpp index 6c023891a8..85e505684b 100644 --- a/plugins/Mir_core/modules.cpp +++ b/plugins/Mir_core/modules.cpp @@ -193,13 +193,12 @@ MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wPa return returnVal;
}
-MIR_CORE_DLL(int) CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lParam)
+static int CallHookSubscribers(THook* p, WPARAM wParam, LPARAM lParam)
{
- int returnVal = 0;
- THook* p = (THook*)hEvent;
if (p == NULL)
return -1;
+ int returnVal = 0;
EnterCriticalSection(&p->csHook);
// NOTE: We've got the critical section while all this lot are called. That's mostly safe, though.
@@ -227,25 +226,26 @@ MIR_CORE_DLL(int) CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lPara return returnVal;
}
-__forceinline bool checkHook(HANDLE hHook, bool& bIsValid)
+enum { hookOk, hookEmpty, hookInvalid };
+
+__forceinline int checkHook(THook* p)
{
- THook* p = (THook*)hHook;
if (p == NULL)
- return false;
+ return hookInvalid;
- bool ret;
+ int ret;
__try
{
if (p->secretSignature != HOOK_SECRET_SIGNATURE)
- bIsValid = ret = false;
+ ret = hookInvalid;
else if (p->subscriberCount == 0 && p->pfnHook == NULL)
- bIsValid = true, ret = false;
+ ret = hookEmpty;
else
- ret = true;
+ ret = hookOk;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
- bIsValid = ret = false;
+ ret = hookInvalid;
}
return ret;
@@ -260,12 +260,13 @@ static void CALLBACK HookToMainAPCFunc(ULONG_PTR dwParam) MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam)
{
- bool bIsValid;
- if ( !checkHook(hEvent, bIsValid))
- return (bIsValid) ? 0 : -1;
+ switch ( checkHook((THook*)hEvent)) {
+ case hookInvalid: return -1;
+ case hookEmpty: return 0;
+ }
if ( GetCurrentThreadId() == mainThreadId)
- return CallHookSubscribers(hEvent, wParam, lParam);
+ return CallHookSubscribers((THook*)hEvent, wParam, lParam);
mir_ptr<THookToMainThreadItem> item;
item->hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index 8d236072ab..f6c1b8936a 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -1068,11 +1068,10 @@ BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) extern "C" __declspec(dllexport) int Load(void)
{
-
mir_getLP(&pluginInfo);
- hEventDbPluginsLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit);
- hEventDbOkToExit=HookEvent(ME_SYSTEM_OKTOEXIT,OkToExit);
- hEventDbPreShutdown=HookEvent(ME_SYSTEM_PRESHUTDOWN,SessionPreShutdown);
+ hEventDbPluginsLoaded = HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit);
+ hEventDbOkToExit = HookEvent(ME_SYSTEM_OKTOEXIT,OkToExit);
+ hEventDbPreShutdown= HookEvent(ME_SYSTEM_PRESHUTDOWN,SessionPreShutdown);
return 0;
-}
\ No newline at end of file +}
|