Commit b75db2d9 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ole: Join the MTA if necessary when executing an RPC call.

Join the MTA if necessary when executing an RPC call to ensure that it is executing with a valid apartment and won't fail for certain COM calls.
parent 1eda42cc
......@@ -422,6 +422,12 @@ static LRESULT CALLBACK apartment_wndproc(HWND hWnd, UINT msg, WPARAM wParam, LP
}
}
void apartment_joinmta(void)
{
apartment_addref(MTA);
COM_CurrentInfo()->apt = MTA;
}
/*****************************************************************************
* This section contains OpenDllList implemantation
*/
......
......@@ -228,6 +228,7 @@ static inline HRESULT apartment_getoxid(struct apartment *apt, OXID *oxid)
*oxid = apt->oxid;
return S_OK;
}
void apartment_joinmta(void);
/* DCOM messages used by the apartment window (not compatible with native) */
......
......@@ -503,7 +503,20 @@ static void __RPC_STUB dispatch_rpc(RPC_MESSAGE *msg)
CloseHandle(params->handle);
}
else
{
BOOL joined = FALSE;
if (!COM_CurrentInfo()->apt)
{
apartment_joinmta();
joined = TRUE;
}
RPC_ExecuteCall(params);
if (joined)
{
apartment_release(COM_CurrentInfo()->apt);
COM_CurrentInfo()->apt = NULL;
}
}
HeapFree(GetProcessHeap(), 0, params);
......
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