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.
This commit is contained in:
parent
1eda42ccac
commit
b75db2d9de
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue