* when the proxy disconnects or is destroyed */
#define SORFP_NOLIFETIMEMGMT SORF_OXRES2
+/* imported object / proxy manager */
+struct proxy_manager
+{
+ const IMultiQIVtbl *lpVtbl;
+ const IMarshalVtbl *lpVtblMarshal;
+ const IClientSecurityVtbl *lpVtblCliSec;
+ struct apartment *parent; /* owning apartment (RO) */
+ struct list entry; /* entry in apartment (CS parent->cs) */
+ OXID oxid; /* object exported ID (RO) */
+ OXID_INFO oxid_info; /* string binding, ipid of rem unknown and other information (RO) */
+ OID oid; /* object ID (RO) */
+ struct list interfaces; /* imported interfaces (CS cs) */
+ LONG refs; /* proxy reference count (LOCK) */
+ CRITICAL_SECTION cs; /* thread safety for this object and children */
+ ULONG sorflags; /* STDOBJREF flags (RO) */
+ IRemUnknown *remunk; /* proxy to IRemUnknown used for lifecycle management (CS cs) */
+ HANDLE remoting_mutex; /* mutex used for synchronizing access to IRemUnknown */
+ MSHCTX dest_context; /* context used for activating optimisations (LOCK) */
+ void *dest_context_data; /* reserved context value (LOCK) */
+};
+
+static inline struct proxy_manager *impl_from_IMarshal( IMarshal *iface )
+{
+ return (struct proxy_manager *)((char*)iface - FIELD_OFFSET(struct proxy_manager, lpVtblMarshal));
+}
+
+static inline struct proxy_manager *impl_from_IClientSecurity( IClientSecurity *iface )
+{
+ return (struct proxy_manager *)((char*)iface - FIELD_OFFSET(struct proxy_manager, lpVtblCliSec));
+}
+
static HRESULT unmarshal_object(const STDOBJREF *stdobjref, APARTMENT *apt,
MSHCTX dest_context, void *dest_context_data,
REFIID riid, const OXID_INFO *oxid_info,
static HRESULT WINAPI Proxy_QueryInterface(IMarshal *iface, REFIID riid, void **ppvObject)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ struct proxy_manager *This = impl_from_IMarshal( iface );
return IMultiQI_QueryInterface((IMultiQI *)&This->lpVtbl, riid, ppvObject);
}
static ULONG WINAPI Proxy_AddRef(IMarshal *iface)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ struct proxy_manager *This = impl_from_IMarshal( iface );
return IMultiQI_AddRef((IMultiQI *)&This->lpVtbl);
}
static ULONG WINAPI Proxy_Release(IMarshal *iface)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ struct proxy_manager *This = impl_from_IMarshal( iface );
return IMultiQI_Release((IMultiQI *)&This->lpVtbl);
}
LPMARSHAL iface, IStream *pStm, REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ struct proxy_manager *This = impl_from_IMarshal( iface );
HRESULT hr;
struct ifproxy *ifproxy;
static HRESULT WINAPI ProxyCliSec_QueryInterface(IClientSecurity *iface, REFIID riid, void **ppvObject)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblCliSec, iface);
+ struct proxy_manager *This = impl_from_IClientSecurity( iface );
return IMultiQI_QueryInterface((IMultiQI *)&This->lpVtbl, riid, ppvObject);
}
static ULONG WINAPI ProxyCliSec_AddRef(IClientSecurity *iface)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblCliSec, iface);
+ struct proxy_manager *This = impl_from_IClientSecurity( iface );
return IMultiQI_AddRef((IMultiQI *)&This->lpVtbl);
}
static ULONG WINAPI ProxyCliSec_Release(IClientSecurity *iface)
{
- ICOM_THIS_MULTI(struct proxy_manager, lpVtblCliSec, iface);
+ struct proxy_manager *This = impl_from_IClientSecurity( iface );
return IMultiQI_Release((IMultiQI *)&This->lpVtbl);
}
RPC_StartRemoting(apt);
hres = marshal_object(apt, &stdobjref, riid, pv, mshlflags);
- if (hres)
+ if (hres != S_OK)
{
ERR("Failed to create ifstub, hres=0x%x\n", hres);
return hres;
}
- hres = IStream_Write(pStm, &stdobjref, sizeof(stdobjref), &res);
- if (hres) return hres;
-
- return S_OK;
+ return IStream_Write(pStm, &stdobjref, sizeof(stdobjref), &res);
}
/* helper for StdMarshalImpl_UnmarshalInterface - does the unmarshaling with
/* read STDOBJREF from wire */
hres = IStream_Read(pStm, &stdobjref, sizeof(stdobjref), &res);
- if (hres) return STG_E_READFAULT;
+ if (hres != S_OK) return STG_E_READFAULT;
hres = apartment_getoxid(apt, &oxid);
- if (hres) return hres;
+ if (hres != S_OK) return hres;
/* check if we're marshalling back to ourselves */
if ((oxid == stdobjref.oxid) && (stubmgr = get_stub_manager(apt, stdobjref.oid)))
/* unref the ifstub. FIXME: only do this on success? */
if (!stub_manager_is_table_marshaled(stubmgr, &stdobjref.ipid))
- stub_manager_ext_release(stubmgr, stdobjref.cPublicRefs, stdobjref.flags & SORFP_TABLEWEAK, TRUE);
+ stub_manager_ext_release(stubmgr, stdobjref.cPublicRefs, stdobjref.flags & SORFP_TABLEWEAK, FALSE);
stub_manager_int_release(stubmgr);
return hres;
if (stubmgr) stub_manager_int_release(stubmgr);
if (stub_apt) apartment_release(stub_apt);
- if (hres) WARN("Failed with error 0x%08x\n", hres);
+ if (hres != S_OK) WARN("Failed with error 0x%08x\n", hres);
else TRACE("Successfully created proxy %p\n", *ppv);
return hres;
TRACE("iface=%p, pStm=%p\n", iface, pStm);
hres = IStream_Read(pStm, &stdobjref, sizeof(stdobjref), &res);
- if (hres) return STG_E_READFAULT;
+ if (hres != S_OK) return STG_E_READFAULT;
TRACE("oxid = %s, oid = %s, ipid = %s\n",
wine_dbgstr_longlong(stdobjref.oxid),
if (!pUnk)
return E_POINTER;
hr = IUnknown_QueryInterface(pUnk, &IID_IMarshal, (LPVOID*)pMarshal);
- if (hr)
+ if (hr != S_OK)
hr = CoGetStandardMarshal(riid, pUnk, dwDestContext, pvDestContext,
mshlFlags, pMarshal);
return hr;
/* read common OBJREF header */
hr = IStream_Read(stream, &objref, FIELD_OFFSET(OBJREF, u_objref), &res);
- if (hr || (res != FIELD_OFFSET(OBJREF, u_objref)))
+ if (hr != S_OK || (res != FIELD_OFFSET(OBJREF, u_objref)))
{
ERR("Failed to read common OBJREF header, 0x%08x\n", hr);
return STG_E_READFAULT;
/* read constant sized OR_CUSTOM data from stream */
hr = IStream_Read(stream, &objref.u_objref.u_custom,
custom_header_size, &res);
- if (hr || (res != custom_header_size))
+ if (hr != S_OK || (res != custom_header_size))
{
ERR("Failed to read OR_CUSTOM header, 0x%08x\n", hr);
return STG_E_READFAULT;
return RPC_E_INVALID_OBJREF;
}
- if (hr)
+ if (hr != S_OK)
ERR("Failed to create marshal, 0x%08x\n", hr);
return hr;
CLSID marshaler_clsid;
hr = get_marshaler(riid, pUnk, dwDestContext, pvDestContext, mshlFlags, &pMarshal);
- if (hr)
+ if (hr != S_OK)
return hr;
hr = IMarshal_GetUnmarshalClass(pMarshal, riid, pUnk, dwDestContext,
pvDestContext, mshlFlags, &marshaler_clsid);
- if (hr)
+ if (hr != S_OK)
{
ERR("IMarshal::GetUnmarshalClass failed, 0x%08x\n", hr);
IMarshal_Release(pMarshal);
/* get the marshaler for the specified interface */
hr = get_marshaler(riid, pUnk, dwDestContext, pvDestContext, mshlFlags, &pMarshal);
- if (hr)
+ if (hr != S_OK)
{
ERR("Failed to get marshaller, 0x%08x\n", hr);
return hr;
hr = IMarshal_GetUnmarshalClass(pMarshal, riid, pUnk, dwDestContext,
pvDestContext, mshlFlags, &marshaler_clsid);
- if (hr)
+ if (hr != S_OK)
{
ERR("IMarshal::GetUnmarshalClass failed, 0x%08x\n", hr);
goto cleanup;
/* write the common OBJREF header to the stream */
hr = IStream_Write(pStream, &objref, FIELD_OFFSET(OBJREF, u_objref), NULL);
- if (hr)
+ if (hr != S_OK)
{
ERR("Failed to write OBJREF header to stream, 0x%08x\n", hr);
goto cleanup;
hr = IMarshal_GetMarshalSizeMax(pMarshal, riid, pUnk, dwDestContext,
pvDestContext, mshlFlags,
&objref.u_objref.u_custom.size);
- if (hr)
+ if (hr != S_OK)
{
ERR("Failed to get max size of marshal data, error 0x%08x\n", hr);
goto cleanup;
/* write constant sized common header and OR_CUSTOM data into stream */
hr = IStream_Write(pStream, &objref,
FIELD_OFFSET(OBJREF, u_objref.u_custom.pData), NULL);
- if (hr)
+ if (hr != S_OK)
{
ERR("Failed to write OR_CUSTOM header to stream with 0x%08x\n", hr);
goto cleanup;
hr = IMarshal_MarshalInterface(pMarshal, pStream, riid, pUnk, dwDestContext,
pvDestContext, mshlFlags);
- if (hr)
+ if (hr != S_OK)
{
ERR("Failed to marshal the interface %s, %x\n", debugstr_guid(riid), hr);
goto cleanup;
/* call the helper object to do the actual unmarshaling */
hr = IMarshal_UnmarshalInterface(pMarshal, pStream, &iid, (LPVOID*)&object);
- if (hr)
+ if (hr != S_OK)
ERR("IMarshal::UnmarshalInterface failed, 0x%08x\n", hr);
if (hr == S_OK)
{
TRACE("requested interface != marshalled interface, additional QI needed\n");
hr = IUnknown_QueryInterface(object, riid, ppv);
- if (hr)
+ if (hr != S_OK)
ERR("Couldn't query for interface %s, hr = 0x%08x\n",
debugstr_guid(riid), hr);
IUnknown_Release(object);
/* call the helper object to do the releasing of marshal data */
hr = IMarshal_ReleaseMarshalData(pMarshal, pStream);
- if (hr)
+ if (hr != S_OK)
ERR("IMarshal::ReleaseMarshalData failed with error 0x%08x\n", hr);
IMarshal_Release(pMarshal);