[PATCH 0/1] MR7868: combase: Find correct apartment in ClientRpcChannelBuffer_SendReceive().
From: Dmitry Timoshkov <dmitry(a)baikal.ru> When an application has both apartment-threaded and multi-threaded apartments then apartment_get_current_or_mta() may return wrong one, and later the oxid check will fail. Probably it's better try to find correct apartment from the start. Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru> --- dlls/combase/rpc.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/dlls/combase/rpc.c b/dlls/combase/rpc.c index c51b59de4bf..160c5c579b2 100644 --- a/dlls/combase/rpc.c +++ b/dlls/combase/rpc.c @@ -1344,15 +1344,6 @@ static DWORD WINAPI rpc_sendreceive_thread(LPVOID param) return 0; } -static inline HRESULT ClientRpcChannelBuffer_IsCorrectApartment(ClientRpcChannelBuffer *This, const struct apartment *apt) -{ - if (!apt) - return S_FALSE; - if (This->oxid != apartment_getoxid(apt)) - return S_FALSE; - return S_OK; -} - static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus) { ClientRpcChannelBuffer *This = (ClientRpcChannelBuffer *)iface; @@ -1365,17 +1356,15 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac ORPC_EXTENT_ARRAY orpc_ext_array; WIRE_ORPC_EXTENT *first_wire_orpc_extent = NULL; HRESULT hrFault = S_OK; - struct apartment *apt = apartment_get_current_or_mta(); + struct apartment *apt = apartment_findfromoxid(This->oxid); struct tlsdata *tlsdata; TRACE("%p, iMethod %ld\n", olemsg, olemsg->iMethod); - hr = ClientRpcChannelBuffer_IsCorrectApartment(This, apt); - if (hr != S_OK) + if (!apt) { ERR("called from wrong apartment, should have been 0x%s\n", wine_dbgstr_longlong(This->oxid)); - if (apt) apartment_release(apt); return RPC_E_WRONG_THREAD; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7868
Could we come up with a test for this? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7868#note_102045
On Mon Apr 28 17:42:29 2025 +0000, Huw Davies wrote:
Could we come up with a test for this? I tried, however I couldn't reproduce this in a test.
Observed behaviour is similar to what b4da14035741f287130002b512c7d0e9117da80a has fixed, and in that case creating a test also proved to be problematic. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7868#note_102060
This merge request was approved by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7868
On Mon Apr 28 17:42:29 2025 +0000, Dmitry Timoshkov wrote:
I tried, however I couldn't reproduce this in a test. Observed behaviour is similar to what b4da14035741f287130002b512c7d0e9117da80a has fixed, and in that case creating a test also proved to be problematic. Right, ok. Makes sense.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7868#note_102472
participants (3)
-
Dmitry Timoshkov -
Dmitry Timoshkov (@dmitry) -
Huw Davies (@huw)