Commit 1b7d346d authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ole: Verify that the proxy is being used in the correct thread.

parent 8c55c6f0
...@@ -98,6 +98,7 @@ typedef struct ...@@ -98,6 +98,7 @@ typedef struct
RpcChannelBuffer super; /* superclass */ RpcChannelBuffer super; /* superclass */
RPC_BINDING_HANDLE bind; /* handle to the remote server */ RPC_BINDING_HANDLE bind; /* handle to the remote server */
OXID oxid; /* apartment in which the channel is valid */
} ClientRpcChannelBuffer; } ClientRpcChannelBuffer;
struct dispatch_params struct dispatch_params
...@@ -206,6 +207,12 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface, ...@@ -206,6 +207,12 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
return HRESULT_FROM_WIN32(status); return HRESULT_FROM_WIN32(status);
} }
static HRESULT WINAPI ServerRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
{
FIXME("stub\n");
return E_NOTIMPL;
}
/* this thread runs an outgoing RPC */ /* this thread runs an outgoing RPC */
static DWORD WINAPI rpc_sendreceive_thread(LPVOID param) static DWORD WINAPI rpc_sendreceive_thread(LPVOID param)
{ {
...@@ -219,9 +226,22 @@ static DWORD WINAPI rpc_sendreceive_thread(LPVOID param) ...@@ -219,9 +226,22 @@ static DWORD WINAPI rpc_sendreceive_thread(LPVOID param)
return 0; return 0;
} }
static HRESULT WINAPI RpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus) static inline HRESULT ClientRpcChannelBuffer_IsCorrectApartment(ClientRpcChannelBuffer *This, APARTMENT *apt)
{ {
HRESULT hr = S_OK; OXID oxid;
if (!apt)
return S_FALSE;
if (apartment_getoxid(apt, &oxid) != S_OK)
return S_FALSE;
if (This->oxid != oxid)
return S_FALSE;
return S_OK;
}
static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
{
ClientRpcChannelBuffer *This = (ClientRpcChannelBuffer *)iface;
HRESULT hr;
RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg; RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg;
RPC_STATUS status; RPC_STATUS status;
DWORD index; DWORD index;
...@@ -232,6 +252,14 @@ static HRESULT WINAPI RpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPC ...@@ -232,6 +252,14 @@ static HRESULT WINAPI RpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER iface, RPC
TRACE("(%p) iMethod=%ld\n", olemsg, olemsg->iMethod); TRACE("(%p) iMethod=%ld\n", olemsg, olemsg->iMethod);
hr = ClientRpcChannelBuffer_IsCorrectApartment(This, COM_CurrentApt());
if (hr != S_OK)
{
ERR("called from wrong apartment, should have been 0x%s\n",
wine_dbgstr_longlong(This->oxid));
return RPC_E_WRONG_THREAD;
}
params = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*params)); params = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*params));
if (!params) return E_OUTOFMEMORY; if (!params) return E_OUTOFMEMORY;
...@@ -369,7 +397,7 @@ static const IRpcChannelBufferVtbl ClientRpcChannelBufferVtbl = ...@@ -369,7 +397,7 @@ static const IRpcChannelBufferVtbl ClientRpcChannelBufferVtbl =
RpcChannelBuffer_AddRef, RpcChannelBuffer_AddRef,
ClientRpcChannelBuffer_Release, ClientRpcChannelBuffer_Release,
ClientRpcChannelBuffer_GetBuffer, ClientRpcChannelBuffer_GetBuffer,
RpcChannelBuffer_SendReceive, ClientRpcChannelBuffer_SendReceive,
ClientRpcChannelBuffer_FreeBuffer, ClientRpcChannelBuffer_FreeBuffer,
RpcChannelBuffer_GetDestCtx, RpcChannelBuffer_GetDestCtx,
RpcChannelBuffer_IsConnected RpcChannelBuffer_IsConnected
...@@ -381,7 +409,7 @@ static const IRpcChannelBufferVtbl ServerRpcChannelBufferVtbl = ...@@ -381,7 +409,7 @@ static const IRpcChannelBufferVtbl ServerRpcChannelBufferVtbl =
RpcChannelBuffer_AddRef, RpcChannelBuffer_AddRef,
ServerRpcChannelBuffer_Release, ServerRpcChannelBuffer_Release,
ServerRpcChannelBuffer_GetBuffer, ServerRpcChannelBuffer_GetBuffer,
RpcChannelBuffer_SendReceive, ServerRpcChannelBuffer_SendReceive,
ServerRpcChannelBuffer_FreeBuffer, ServerRpcChannelBuffer_FreeBuffer,
RpcChannelBuffer_GetDestCtx, RpcChannelBuffer_GetDestCtx,
RpcChannelBuffer_IsConnected RpcChannelBuffer_IsConnected
...@@ -440,6 +468,7 @@ HRESULT RPC_CreateClientChannel(const OXID *oxid, const IPID *ipid, IRpcChannelB ...@@ -440,6 +468,7 @@ HRESULT RPC_CreateClientChannel(const OXID *oxid, const IPID *ipid, IRpcChannelB
This->super.lpVtbl = &ClientRpcChannelBufferVtbl; This->super.lpVtbl = &ClientRpcChannelBufferVtbl;
This->super.refs = 1; This->super.refs = 1;
This->bind = bind; This->bind = bind;
apartment_getoxid(COM_CurrentApt(), &This->oxid);
*chan = (IRpcChannelBuffer*)This; *chan = (IRpcChannelBuffer*)This;
......
...@@ -1024,11 +1024,9 @@ static DWORD CALLBACK bad_thread_proc(LPVOID p) ...@@ -1024,11 +1024,9 @@ static DWORD CALLBACK bad_thread_proc(LPVOID p)
hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy); hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (LPVOID*)&proxy);
if (proxy) IUnknown_Release(proxy); if (proxy) IUnknown_Release(proxy);
todo_wine {
ok(hr == RPC_E_WRONG_THREAD, ok(hr == RPC_E_WRONG_THREAD,
"COM should have failed with RPC_E_WRONG_THREAD on using proxy from wrong apartment, but instead returned 0x%08lx\n", "COM should have failed with RPC_E_WRONG_THREAD on using proxy from wrong apartment, but instead returned 0x%08lx\n",
hr); hr);
}
CoUninitialize(); CoUninitialize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment