From 00f9dff02df4f27866908f28213a79b2c259d727 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 19 Aug 2020 11:29:13 +0300 Subject: [PATCH] combase: Move CoRegisterMessageFilter(). Signed-off-by: Nikolay Sivov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/combase/combase.c | 37 ++++++++++++++++++++++++ dlls/combase/combase.spec | 2 +- dlls/ole32/compobj.c | 59 --------------------------------------- dlls/ole32/ole32.spec | 2 +- 4 files changed, 39 insertions(+), 61 deletions(-) diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index 88dc7aa7b19..96c6a9bb817 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -1684,3 +1684,40 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD flags, DWORD timeout, ULONG handle return hr; } + +/****************************************************************************** + * CoRegisterMessageFilter (combase.@) + */ +HRESULT WINAPI CoRegisterMessageFilter(IMessageFilter *filter, IMessageFilter **ret_filter) +{ + IMessageFilter *old_filter; + struct apartment *apt; + + TRACE("%p, %p\n", filter, ret_filter); + + apt = com_get_current_apt(); + + /* Can't set a message filter in a multi-threaded apartment */ + if (!apt || apt->multi_threaded) + { + WARN("Can't set message filter in MTA or uninitialized apt\n"); + return CO_E_NOT_SUPPORTED; + } + + if (filter) + IMessageFilter_AddRef(filter); + + EnterCriticalSection(&apt->cs); + + old_filter = apt->filter; + apt->filter = filter; + + LeaveCriticalSection(&apt->cs); + + if (ret_filter) + *ret_filter = old_filter; + else if (old_filter) + IMessageFilter_Release(old_filter); + + return S_OK; +} diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 7fd1e964cd3..bb7eaf69f9d 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -142,7 +142,7 @@ @ stdcall CoRegisterClassObject(ptr ptr long long ptr) ole32.CoRegisterClassObject @ stdcall CoRegisterInitializeSpy(ptr ptr) @ stdcall CoRegisterMallocSpy(ptr) -@ stdcall CoRegisterMessageFilter(ptr ptr) ole32.CoRegisterMessageFilter +@ stdcall CoRegisterMessageFilter(ptr ptr) @ stdcall CoRegisterPSClsid(ptr ptr) ole32.CoRegisterPSClsid @ stdcall CoRegisterSurrogate(ptr) ole32.CoRegisterSurrogate @ stdcall CoRegisterSurrogateEx(ptr ptr) ole32.CoRegisterSurrogateEx diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 574a7b33055..f02cdb8b53f 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -3146,65 +3146,6 @@ HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *id) return S_OK; } -/****************************************************************************** - * CoRegisterMessageFilter [OLE32.@] - * - * Registers a message filter. - * - * PARAMS - * lpMessageFilter [I] Pointer to interface. - * lplpMessageFilter [O] Indirect pointer to prior instance if non-NULL. - * - * RETURNS - * Success: S_OK. - * Failure: HRESULT code. - * - * NOTES - * Both lpMessageFilter and lplpMessageFilter are optional. Passing in a NULL - * lpMessageFilter removes the message filter. - * - * If lplpMessageFilter is not NULL the previous message filter will be - * returned in the memory pointer to this parameter and the caller is - * responsible for releasing the object. - * - * The current thread be in an apartment otherwise the function will crash. - */ -HRESULT WINAPI CoRegisterMessageFilter( - LPMESSAGEFILTER lpMessageFilter, - LPMESSAGEFILTER *lplpMessageFilter) -{ - struct apartment *apt; - IMessageFilter *lpOldMessageFilter; - - TRACE("(%p, %p)\n", lpMessageFilter, lplpMessageFilter); - - apt = COM_CurrentApt(); - - /* can't set a message filter in a multi-threaded apartment */ - if (!apt || apt->multi_threaded) - { - WARN("can't set message filter in MTA or uninitialized apt\n"); - return CO_E_NOT_SUPPORTED; - } - - if (lpMessageFilter) - IMessageFilter_AddRef(lpMessageFilter); - - EnterCriticalSection(&apt->cs); - - lpOldMessageFilter = apt->filter; - apt->filter = lpMessageFilter; - - LeaveCriticalSection(&apt->cs); - - if (lplpMessageFilter) - *lplpMessageFilter = lpOldMessageFilter; - else if (lpOldMessageFilter) - IMessageFilter_Release(lpOldMessageFilter); - - return S_OK; -} - /*********************************************************************** * CoIsOle1Class [OLE32.@] * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index afb0e104075..ed5a958ce3c 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -68,7 +68,7 @@ @ stdcall CoRegisterClassObject(ptr ptr long long ptr) @ stdcall CoRegisterInitializeSpy(ptr ptr) combase.CoRegisterInitializeSpy @ stdcall CoRegisterMallocSpy(ptr) combase.CoRegisterMallocSpy -@ stdcall CoRegisterMessageFilter(ptr ptr) +@ stdcall CoRegisterMessageFilter(ptr ptr) combase.CoRegisterMessageFilter @ stdcall CoRegisterPSClsid(ptr ptr) @ stdcall CoRegisterSurrogate(ptr) @ stdcall CoRegisterSurrogateEx(ptr ptr)