From dee74a6ec940bfd15282ba54f682ea053fd4924b Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Tue, 4 Jan 2005 11:47:52 +0000 Subject: [PATCH] Make the ClassFactory proxy support aggregation. --- dlls/ole32/oleproxy.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/dlls/ole32/oleproxy.c b/dlls/ole32/oleproxy.c index b9f65348313..5255474a769 100644 --- a/dlls/ole32/oleproxy.c +++ b/dlls/ole32/oleproxy.c @@ -270,6 +270,7 @@ typedef struct _CFProxy { DWORD ref; IRpcChannelBuffer *chanbuf; + IUnknown *outer_unknown; } CFProxy; static HRESULT WINAPI IRpcProxyBufferImpl_QueryInterface(LPRPCPROXYBUFFER iface,REFIID riid,LPVOID *ppv) { @@ -316,6 +317,8 @@ static void WINAPI IRpcProxyBufferImpl_Disconnect(LPRPCPROXYBUFFER iface) { static HRESULT WINAPI CFProxy_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv) { + ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface); + if (This->outer_unknown) return IUnknown_QueryInterface(This->outer_unknown, riid, ppv); *ppv = NULL; if (IsEqualIID(&IID_IClassFactory,riid) || IsEqualIID(&IID_IUnknown,riid)) { *ppv = (LPVOID)iface; @@ -330,15 +333,22 @@ CFProxy_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv) { static ULONG WINAPI CFProxy_AddRef(LPCLASSFACTORY iface) { ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface); + if (This->outer_unknown) return IUnknown_AddRef(This->outer_unknown); return InterlockedIncrement(&This->ref); } static ULONG WINAPI CFProxy_Release(LPCLASSFACTORY iface) { ULONG ref; ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface); - - ref = InterlockedDecrement(&This->ref); - if (!ref) HeapFree(GetProcessHeap(),0,This); + if (This->outer_unknown) + ref = IUnknown_Release(This->outer_unknown); + else + ref = InterlockedDecrement(&This->ref); + + if (!ref) { + IRpcChannelBuffer_Release(This->chanbuf); + HeapFree(GetProcessHeap(),0,This); + } return ref; } @@ -424,7 +434,7 @@ static IClassFactoryVtbl cfproxyvt = { }; static HRESULT -CFProxy_Construct(LPVOID *ppv,LPVOID *ppProxy) { +CFProxy_Construct(IUnknown *pUnkOuter, LPVOID *ppv,LPVOID *ppProxy) { CFProxy *cf; cf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CFProxy)); @@ -433,10 +443,13 @@ CFProxy_Construct(LPVOID *ppv,LPVOID *ppProxy) { cf->lpvtbl_cf = &cfproxyvt; cf->lpvtbl_proxy = &pspbvtbl; - /* 1 reference for the proxy and 1 for the object */ - cf->ref = 2; + /* 1 reference for the proxy... */ + cf->ref = 1; + cf->outer_unknown = pUnkOuter; *ppv = &(cf->lpvtbl_cf); *ppProxy = &(cf->lpvtbl_proxy); + /* ...and 1 for the object */ + IUnknown_AddRef((IUnknown *)*ppv); return S_OK; } @@ -464,7 +477,7 @@ PSFacBuf_CreateProxy( if (IsEqualIID(&IID_IClassFactory,riid) || IsEqualIID(&IID_IUnknown,riid) ) - return CFProxy_Construct(ppv,(LPVOID*)ppProxy); + return CFProxy_Construct(pUnkOuter, ppv,(LPVOID*)ppProxy); FIXME("proxying not implemented for (%s) yet!\n",debugstr_guid(riid)); return E_FAIL; } -- 2.11.4.GIT