Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.c | 2 +- dlls/combase/combase.spec | 14 ++--- dlls/combase/combase_private.h | 2 +- dlls/combase/irpcss.idl | 1 + dlls/combase/rpc.c | 108 +++++++++++++++++++++++++++------ 5 files changed, 98 insertions(+), 29 deletions(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index df97799fe08..80d6ece266e 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -2245,7 +2245,7 @@ DWORD WINAPI CoGetCurrentProcess(void) return 0;
if (!tlsdata->thread_seqid) - tlsdata->thread_seqid = rpcss_get_next_seqid(); + rpcss_get_next_seqid(&tlsdata->thread_seqid);
return tlsdata->thread_seqid; } diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index a88c5d66fe1..9038d5fa8bf 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -255,13 +255,13 @@ @ stub InternalFillLocalOXIDInfo @ stub InternalFreeObjRef @ stub InternalGetWindowPropInterface -@ stub InternalIrotEnumRunning -@ stub InternalIrotGetObject -@ stub InternalIrotGetTimeOfLastChange -@ stub InternalIrotIsRunning -@ stub InternalIrotNoteChangeTime -@ stub InternalIrotRegister -@ stub InternalIrotRevoke +@ stdcall InternalIrotEnumRunning(ptr) +@ stdcall InternalIrotGetObject(ptr ptr ptr) +@ stdcall InternalIrotGetTimeOfLastChange(ptr ptr) +@ stdcall InternalIrotIsRunning(ptr) +@ stdcall InternalIrotNoteChangeTime(long ptr) +@ stdcall InternalIrotRegister(ptr ptr ptr ptr long ptr ptr) +@ stdcall InternalIrotRevoke(long ptr ptr ptr) @ stub InternalIsApartmentInitialized @ stub InternalIsProcessInitialized @ stub InternalMarshalObjRef diff --git a/dlls/combase/combase_private.h b/dlls/combase/combase_private.h index e910166fff2..7d7583282e1 100644 --- a/dlls/combase/combase_private.h +++ b/dlls/combase/combase_private.h @@ -90,4 +90,4 @@ static inline struct apartment* com_get_current_apt(void) }
/* RpcSs interface */ -DWORD rpcss_get_next_seqid(void) DECLSPEC_HIDDEN; +HRESULT rpcss_get_next_seqid(DWORD *id) DECLSPEC_HIDDEN; diff --git a/dlls/combase/irpcss.idl b/dlls/combase/irpcss.idl index 65078167de2..fab69f7310c 100644 --- a/dlls/combase/irpcss.idl +++ b/dlls/combase/irpcss.idl @@ -18,4 +18,5 @@
#pragma makedep client
+#include "wine/irot.idl" #include "wine/irpcss.idl" diff --git a/dlls/combase/rpc.c b/dlls/combase/rpc.c index 2fbccfd740d..3b531661726 100644 --- a/dlls/combase/rpc.c +++ b/dlls/combase/rpc.c @@ -127,29 +127,97 @@ static RPC_BINDING_HANDLE get_irpcss_handle(void) return irpcss_handle; }
-DWORD rpcss_get_next_seqid(void) +static RPC_BINDING_HANDLE get_irot_handle(void) { - DWORD id = 0; - HRESULT hr; + static RPC_BINDING_HANDLE irot_handle;
- for (;;) + if (!irot_handle) { - __TRY - { - hr = irpcss_get_thread_seq_id(get_irpcss_handle(), &id); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; + unsigned short protseq[] = IROT_PROTSEQ; + unsigned short endpoint[] = IROT_ENDPOINT; + + RPC_BINDING_HANDLE new_handle = get_rpc_handle(protseq, endpoint); + if (InterlockedCompareExchangePointer(&irot_handle, new_handle, NULL)) + /* another thread beat us to it */ + RpcBindingFree(&new_handle); } + return irot_handle; +} + +#define RPCSS_CALL_START \ + HRESULT hr; \ + for (;;) { \ + __TRY { + +#define RPCSS_CALL_END \ + } __EXCEPT(rpc_filter) { \ + hr = HRESULT_FROM_WIN32(GetExceptionCode()); \ + } \ + __ENDTRY \ + if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) { \ + if (start_rpcss()) \ + continue; \ + } \ + break; \ + } \ + return hr; + +HRESULT rpcss_get_next_seqid(DWORD *id) +{ + RPCSS_CALL_START + hr = irpcss_get_thread_seq_id(get_irpcss_handle(), id); + RPCSS_CALL_END +} + +HRESULT WINAPI InternalIrotRegister(const MonikerComparisonData *moniker_data, + const InterfaceData *object, const InterfaceData *moniker, + const FILETIME *time, DWORD flags, IrotCookie *cookie, IrotContextHandle *ctxt_handle) +{ + RPCSS_CALL_START + hr = IrotRegister(get_irot_handle(), moniker_data, object, moniker, time, flags, cookie, ctxt_handle); + RPCSS_CALL_END +} + +HRESULT WINAPI InternalIrotIsRunning(const MonikerComparisonData *moniker_data) +{ + RPCSS_CALL_START + hr = IrotIsRunning(get_irot_handle(), moniker_data); + RPCSS_CALL_END +} + +HRESULT WINAPI InternalIrotGetObject(const MonikerComparisonData *moniker_data, PInterfaceData *obj, + IrotCookie *cookie) +{ + RPCSS_CALL_START + hr = IrotGetObject(get_irot_handle(), moniker_data, obj, cookie); + RPCSS_CALL_END +} + +HRESULT WINAPI InternalIrotNoteChangeTime(IrotCookie cookie, const FILETIME *time) +{ + RPCSS_CALL_START + hr = IrotNoteChangeTime(get_irot_handle(), cookie, time); + RPCSS_CALL_END +}
- return id; +HRESULT WINAPI InternalIrotGetTimeOfLastChange(const MonikerComparisonData *moniker_data, FILETIME *time) +{ + RPCSS_CALL_START + hr = IrotGetTimeOfLastChange(get_irot_handle(), moniker_data, time); + RPCSS_CALL_END +} + +HRESULT WINAPI InternalIrotEnumRunning(PInterfaceList *list) +{ + RPCSS_CALL_START + hr = IrotEnumRunning(get_irot_handle(), list); + RPCSS_CALL_END +} + +HRESULT WINAPI InternalIrotRevoke(IrotCookie cookie, IrotContextHandle *ctxt_handle, PInterfaceData *object, + PInterfaceData *moniker) +{ + RPCSS_CALL_START + hr = IrotRevoke(get_irot_handle(), cookie, ctxt_handle, object, moniker); + RPCSS_CALL_END }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/irot.idl | 2 +- dlls/ole32/moniker.c | 254 +++++-------------------------------------- 2 files changed, 28 insertions(+), 228 deletions(-)
diff --git a/dlls/ole32/irot.idl b/dlls/ole32/irot.idl index ca730fdd3dc..e5ef1df9009 100644 --- a/dlls/ole32/irot.idl +++ b/dlls/ole32/irot.idl @@ -16,6 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#pragma makedep client +#pragma makedep header
#include "wine/irot.idl" diff --git a/dlls/ole32/moniker.c b/dlls/ole32/moniker.c index 4421219ac1b..b143b1bc6c6 100644 --- a/dlls/ole32/moniker.c +++ b/dlls/ole32/moniker.c @@ -26,17 +26,8 @@
#define COBJMACROS
-#include "winerror.h" -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "winsvc.h" -#include "wtypes.h" -#include "ole2.h" - #include "wine/list.h" #include "wine/debug.h" -#include "wine/exception.h"
#include "compobj_private.h" #include "moniker.h" @@ -44,10 +35,18 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
-static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *eptr) -{ - return I_RpcExceptionFilter(eptr->ExceptionRecord->ExceptionCode); -} + +HRESULT WINAPI InternalIrotRegister(const MonikerComparisonData *moniker_data, + const InterfaceData *object, const InterfaceData *moniker, + const FILETIME *time, DWORD flags, IrotCookie *cookie, IrotContextHandle *ctxt_handle); +HRESULT WINAPI InternalIrotIsRunning(const MonikerComparisonData *moniker_data); +HRESULT WINAPI InternalIrotGetObject(const MonikerComparisonData *moniker_data, PInterfaceData *obj, + IrotCookie *cookie); +HRESULT WINAPI InternalIrotNoteChangeTime(IrotCookie cookie, const FILETIME *time); +HRESULT WINAPI InternalIrotGetTimeOfLastChange(const MonikerComparisonData *moniker_data, FILETIME *time); +HRESULT WINAPI InternalIrotEnumRunning(PInterfaceList *list); +HRESULT WINAPI InternalIrotRevoke(IrotCookie cookie, IrotContextHandle *ctxt_handle, PInterfaceData *object, + PInterfaceData *moniker);
/* define the structure of the running object table elements */ struct rot_entry @@ -97,87 +96,6 @@ static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface) static HRESULT EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list, ULONG pos, IEnumMoniker **ppenumMoniker);
-static RPC_BINDING_HANDLE get_rpc_handle(unsigned short *protseq, unsigned short *endpoint) -{ - RPC_BINDING_HANDLE handle = NULL; - RPC_STATUS status; - RPC_WSTR binding; - - status = RpcStringBindingComposeW(NULL, protseq, NULL, endpoint, NULL, &binding); - if (status == RPC_S_OK) - { - status = RpcBindingFromStringBindingW(binding, &handle); - RpcStringFreeW(&binding); - } - - return handle; -} - -static IrotHandle get_irot_handle(void) -{ - if (!irot_handle) - { - unsigned short protseq[] = IROT_PROTSEQ; - unsigned short endpoint[] = IROT_ENDPOINT; - - IrotHandle new_handle = get_rpc_handle(protseq, endpoint); - if (InterlockedCompareExchangePointer(&irot_handle, new_handle, NULL)) - /* another thread beat us to it */ - RpcBindingFree(&new_handle); - } - return irot_handle; -} - -static BOOL start_rpcss(void) -{ - static const WCHAR rpcssW[] = {'R','p','c','S','s',0}; - SC_HANDLE scm, service; - SERVICE_STATUS_PROCESS status; - BOOL ret = FALSE; - - TRACE("\n"); - - if (!(scm = OpenSCManagerW( NULL, NULL, 0 ))) - { - ERR( "failed to open service manager\n" ); - return FALSE; - } - if (!(service = OpenServiceW( scm, rpcssW, SERVICE_START | SERVICE_QUERY_STATUS ))) - { - ERR( "failed to open RpcSs service\n" ); - CloseServiceHandle( scm ); - return FALSE; - } - if (StartServiceW( service, 0, NULL ) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING) - { - ULONGLONG start_time = GetTickCount64(); - do - { - DWORD dummy; - - if (!QueryServiceStatusEx( service, SC_STATUS_PROCESS_INFO, - (BYTE *)&status, sizeof(status), &dummy )) - break; - if (status.dwCurrentState == SERVICE_RUNNING) - { - ret = TRUE; - break; - } - if (GetTickCount64() - start_time > 30000) break; - Sleep( 100 ); - - } while (status.dwCurrentState == SERVICE_START_PENDING); - - if (status.dwCurrentState != SERVICE_RUNNING) - WARN( "RpcSs failed to start %u\n", status.dwCurrentState ); - } - else ERR( "failed to start RpcSs service\n" ); - - CloseServiceHandle( service ); - CloseServiceHandle( scm ); - return ret; -} - static HRESULT create_stream_on_mip_ro(const InterfaceData *mip, IStream **stream) { HGLOBAL hglobal = GlobalAlloc(0, mip->ulCntData); @@ -193,15 +111,8 @@ static void rot_entry_delete(struct rot_entry *rot_entry) { InterfaceData *object = NULL; InterfaceData *moniker = NULL; - __TRY - { - IrotRevoke(get_irot_handle(), rot_entry->cookie, - &rot_entry->ctxt_handle, &object, &moniker); - } - __EXCEPT(rpc_filter) - { - } - __ENDTRY + + InternalIrotRevoke(rot_entry->cookie, &rot_entry->ctxt_handle, &object, &moniker); MIDL_user_free(object); if (moniker) { @@ -436,7 +347,7 @@ RunningObjectTableImpl_Release(IRunningObjectTable* iface) * pdwRegister [out] the value identifying the registration */ static HRESULT WINAPI -RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags, +RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD flags, IUnknown *punkObject, IMoniker *pmkObjectName, DWORD *pdwRegister) { RunningObjectTableImpl *This = impl_from_IRunningObjectTable(iface); @@ -447,11 +358,11 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags, IBindCtx *pbc; InterfaceData *moniker = NULL;
- TRACE("(%p,%d,%p,%p,%p)\n",This,grfFlags,punkObject,pmkObjectName,pdwRegister); + TRACE("%p, %#x, %p, %p, %p\n", This, flags, punkObject, pmkObjectName, pdwRegister);
- if (grfFlags & ~(ROTFLAGS_REGISTRATIONKEEPSALIVE|ROTFLAGS_ALLOWANYCLIENT)) + if (flags & ~(ROTFLAGS_REGISTRATIONKEEPSALIVE|ROTFLAGS_ALLOWANYCLIENT)) { - ERR("Invalid grfFlags: 0x%08x\n", grfFlags & ~(ROTFLAGS_REGISTRATIONKEEPSALIVE|ROTFLAGS_ALLOWANYCLIENT)); + ERR("Invalid flags: 0x%08x\n", flags & ~(ROTFLAGS_REGISTRATIONKEEPSALIVE|ROTFLAGS_ALLOWANYCLIENT)); return E_INVALIDARG; }
@@ -469,7 +380,7 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags, rot_entry_delete(rot_entry); return hr; } - mshlflags = (grfFlags & ROTFLAGS_REGISTRATIONKEEPSALIVE) ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_TABLEWEAK; + mshlflags = flags & ROTFLAGS_REGISTRATIONKEEPSALIVE ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_TABLEWEAK; hr = CoMarshalInterface(pStream, &IID_IUnknown, punkObject, MSHCTX_LOCAL | MSHCTX_NOSHAREDMEM, NULL, mshlflags); /* FIXME: a cleaner way would be to create an IStream class that writes * directly to an MInterfacePointer */ @@ -562,28 +473,9 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags, return hr; }
+ hr = InternalIrotRegister(rot_entry->moniker_data, rot_entry->object, moniker, + &rot_entry->last_modified, flags, &rot_entry->cookie, &rot_entry->ctxt_handle);
- while (TRUE) - { - __TRY - { - hr = IrotRegister(get_irot_handle(), rot_entry->moniker_data, - rot_entry->object, moniker, - &rot_entry->last_modified, grfFlags, - &rot_entry->cookie, &rot_entry->ctxt_handle); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; - } HeapFree(GetProcessHeap(), 0, moniker); if (FAILED(hr)) { @@ -670,26 +562,7 @@ RunningObjectTableImpl_IsRunning( IRunningObjectTable* iface, IMoniker *pmkObjec LeaveCriticalSection(&This->lock);
if (hr == S_FALSE) - { - while (TRUE) - { - __TRY - { - hr = IrotIsRunning(get_irot_handle(), moniker_data); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; - } - } + hr = InternalIrotIsRunning(moniker_data);
HeapFree(GetProcessHeap(), 0, moniker_data);
@@ -753,25 +626,7 @@ RunningObjectTableImpl_GetObject( IRunningObjectTable* iface,
TRACE("moniker unavailable locally, calling SCM\n");
- while (TRUE) - { - __TRY - { - hr = IrotGetObject(get_irot_handle(), moniker_data, &object, &cookie); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; - } - + hr = InternalIrotGetObject(moniker_data, &object, &cookie); if (SUCCEEDED(hr)) { IStream *pStream; @@ -815,24 +670,7 @@ RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable* iface, rot_entry->last_modified = *pfiletime; LeaveCriticalSection(&This->lock);
- while (TRUE) - { - __TRY - { - hr = IrotNoteChangeTime(get_irot_handle(), dwRegister, pfiletime); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; - } + hr = InternalIrotNoteChangeTime(dwRegister, pfiletime);
goto done; } @@ -889,26 +727,7 @@ RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable* iface, LeaveCriticalSection(&This->lock);
if (hr != S_OK) - { - while (TRUE) - { - __TRY - { - hr = IrotGetTimeOfLastChange(get_irot_handle(), moniker_data, pfiletime); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; - } - } + hr = InternalIrotGetTimeOfLastChange(moniker_data, pfiletime);
HeapFree(GetProcessHeap(), 0, moniker_data);
@@ -934,28 +753,9 @@ RunningObjectTableImpl_EnumRunning(IRunningObjectTable* iface,
*ppenumMoniker = NULL;
- while (TRUE) - { - __TRY - { - hr = IrotEnumRunning(get_irot_handle(), &interface_list); - } - __EXCEPT(rpc_filter) - { - hr = HRESULT_FROM_WIN32(GetExceptionCode()); - } - __ENDTRY - if (hr == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) - { - if (start_rpcss()) - continue; - } - break; - } - + hr = InternalIrotEnumRunning(&interface_list); if (SUCCEEDED(hr)) - hr = EnumMonikerImpl_CreateEnumROTMoniker(interface_list, - 0, ppenumMoniker); + hr = EnumMonikerImpl_CreateEnumROTMoniker(interface_list, 0, ppenumMoniker);
return hr; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=77503
Your paranoid android.
=== debiant (64 bit WoW report) ===
ole32: clipboard.c:1404: Test failed: got 800401d0 clipboard.c:1405: Test failed: got 0 clipboard.c:1410: Test failed: got 800401d0 clipboard.c:1411: Test failed: got 0 clipboard.c:1416: Test failed: got 800401d0 clipboard.c:1417: Test failed: got 0 clipboard.c:1424: Test failed: got 800401d0 clipboard.c:1454: Test failed: got 800401d0 clipboard.c:1464: Test failed: got 800401d0 clipboard.c:1470: Test failed: got 800401d0 clipboard.c:1471: Test failed: got 0 clipboard.c:1483: Test failed: got 800401d0 clipboard.c:1484: Test failed: got 0 clipboard.c:1489: Test failed: got 800401d0 clipboard.c:1490: Test failed: got 0 clipboard.c:1529: Test failed: gle 5 clipboard.c:1531: Test failed: gle 1418 clipboard.c:1533: Test failed: gle 1418 clipboard.c:1544: Test failed: got 00000000 clipboard.c:1585: Test failed: tymed 1 clipboard.c:1589: Test failed: cf c020 clipboard.c:1593: Test failed: tymed 4 clipboard.c:1597: Test failed: cf c021 clipboard.c:1601: Test failed: tymed 8 clipboard.c:1605: Test failed: cf c046 clipboard.c:1609: Test failed: tymed d clipboard.c:1614: Test failed: cf c045 clipboard.c:1623: Test failed: cf c046 clipboard.c:1627: Test failed: tymed 1 clipboard.c:1631: Test failed: cf c046 clipboard.c:1635: Test failed: tymed fffff clipboard.c:1639: Test failed: cf c046 clipboard.c:1641: Test failed: aspect 4 clipboard.c:1643: Test failed: tymed fffff clipboard.c:1646: Test failed: got 00000000
Signed-off-by: Huw Davies huw@codeweavers.com