2002-02-05 19:11:17 +01:00
|
|
|
/*
|
|
|
|
* OLE32 proxy/stub handler
|
|
|
|
*
|
|
|
|
* Copyright 2002 Marcus Meissner
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-02-05 19:11:17 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Documentation on MSDN:
|
2004-07-30 02:03:02 +02:00
|
|
|
*
|
|
|
|
* (Top level COM documentation)
|
|
|
|
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/componentdevelopmentank.asp
|
2002-02-05 19:11:17 +01:00
|
|
|
*
|
|
|
|
* (COM Proxy)
|
2004-07-30 02:03:02 +02:00
|
|
|
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/comext_1q0p.asp
|
2002-02-05 19:11:17 +01:00
|
|
|
*
|
|
|
|
* (COM Stub)
|
2004-07-30 02:03:02 +02:00
|
|
|
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/comext_1lia.asp
|
2002-02-05 19:11:17 +01:00
|
|
|
*
|
|
|
|
* (Marshal)
|
2004-07-30 02:03:02 +02:00
|
|
|
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/comext_1gfn.asp
|
2002-02-05 19:11:17 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-02-05 19:11:17 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "rpc.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
|
|
|
|
#include "compobj_private.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2002-12-19 23:16:35 +01:00
|
|
|
const CLSID CLSID_DfMarshal = { 0x0000030b, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} };
|
|
|
|
const CLSID CLSID_PSFactoryBuffer = { 0x00000320, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} };
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
/* From: http://msdn.microsoft.com/library/en-us/com/cmi_m_4lda.asp
|
|
|
|
*
|
|
|
|
* The first time a client requests a pointer to an interface on a
|
|
|
|
* particular object, COM loads an IClassFactory stub in the server
|
|
|
|
* process and uses it to marshal the first pointer back to the
|
|
|
|
* client. In the client process, COM loads the generic proxy for the
|
|
|
|
* class factory object and calls its implementation of IMarshal to
|
|
|
|
* unmarshal that first pointer. COM then creates the first interface
|
|
|
|
* proxy and hands it a pointer to the RPC channel. Finally, COM returns
|
|
|
|
* the IClassFactory pointer to the client, which uses it to call
|
|
|
|
* IClassFactory::CreateInstance, passing it a reference to the interface.
|
|
|
|
*
|
|
|
|
* Back in the server process, COM now creates a new instance of the
|
|
|
|
* object, along with a stub for the requested interface. This stub marshals
|
|
|
|
* the interface pointer back to the client process, where another object
|
|
|
|
* proxy is created, this time for the object itself. Also created is a
|
|
|
|
* proxy for the requested interface, a pointer to which is returned to
|
|
|
|
* the client. With subsequent calls to other interfaces on the object,
|
|
|
|
* COM will load the appropriate interface stubs and proxies as needed.
|
|
|
|
*/
|
|
|
|
typedef struct _CFStub {
|
2004-08-13 01:00:51 +02:00
|
|
|
IRpcStubBufferVtbl *lpvtbl;
|
2002-02-05 19:11:17 +01:00
|
|
|
DWORD ref;
|
|
|
|
|
|
|
|
LPUNKNOWN pUnkServer;
|
|
|
|
} CFStub;
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
CFStub_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv) {
|
|
|
|
if (IsEqualIID(&IID_IUnknown,riid)||IsEqualIID(&IID_IRpcStubBuffer,riid)) {
|
|
|
|
*ppv = (LPVOID)iface;
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("(%s), interface not supported.\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
CFStub_AddRef(LPRPCSTUBBUFFER iface) {
|
2004-09-09 23:03:58 +02:00
|
|
|
CFStub *This = (CFStub *)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
CFStub_Release(LPRPCSTUBBUFFER iface) {
|
2004-09-09 23:03:58 +02:00
|
|
|
CFStub *This = (CFStub *)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (!ref) HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
CFStub_Connect(LPRPCSTUBBUFFER iface, IUnknown *pUnkServer) {
|
2004-09-09 23:03:58 +02:00
|
|
|
CFStub *This = (CFStub *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
This->pUnkServer = pUnkServer;
|
|
|
|
IUnknown_AddRef(pUnkServer);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI
|
|
|
|
CFStub_Disconnect(LPRPCSTUBBUFFER iface) {
|
2004-09-09 23:03:58 +02:00
|
|
|
CFStub *This = (CFStub *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
IUnknown_Release(This->pUnkServer);
|
|
|
|
This->pUnkServer = NULL;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI
|
|
|
|
CFStub_Invoke(
|
|
|
|
LPRPCSTUBBUFFER iface,RPCOLEMESSAGE* msg,IRpcChannelBuffer* chanbuf
|
|
|
|
) {
|
2004-09-09 23:03:58 +02:00
|
|
|
CFStub *This = (CFStub *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (msg->iMethod == 3) { /* CreateInstance */
|
|
|
|
IID iid;
|
|
|
|
IClassFactory *classfac;
|
|
|
|
IUnknown *ppv;
|
|
|
|
IStream *pStm;
|
|
|
|
STATSTG ststg;
|
|
|
|
ULARGE_INTEGER newpos;
|
|
|
|
LARGE_INTEGER seekto;
|
|
|
|
ULONG res;
|
|
|
|
|
|
|
|
if (msg->cbBuffer < sizeof(IID)) {
|
|
|
|
FIXME("Not enough bytes in buffer (%ld instead of %d)?\n",msg->cbBuffer,sizeof(IID));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
memcpy(&iid,msg->Buffer,sizeof(iid));
|
|
|
|
TRACE("->CreateInstance(%s)\n",debugstr_guid(&iid));
|
2004-05-21 22:52:57 +02:00
|
|
|
hres = IUnknown_QueryInterface(This->pUnkServer,&IID_IClassFactory,(LPVOID*)&classfac);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
|
|
|
FIXME("Ole server does not provide a IClassFactory?\n");
|
|
|
|
return hres;
|
|
|
|
}
|
2004-05-21 22:52:57 +02:00
|
|
|
hres = IClassFactory_CreateInstance(classfac,NULL,&iid,(LPVOID*)&ppv);
|
2002-02-05 19:11:17 +01:00
|
|
|
IClassFactory_Release(classfac);
|
|
|
|
if (hres) {
|
|
|
|
msg->cbBuffer = 0;
|
|
|
|
FIXME("Failed to create an instance of %s\n",debugstr_guid(&iid));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("Failed to create stream on hglobal\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = CoMarshalInterface(pStm,&iid,ppv,0,NULL,0);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("CoMarshalInterface failed, %lx!\n",hres);
|
|
|
|
msg->cbBuffer = 0;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = IStream_Stat(pStm,&ststg,0);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("Stat failed.\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
msg->cbBuffer = ststg.cbSize.u.LowPart;
|
2003-10-14 07:24:20 +02:00
|
|
|
|
|
|
|
if (msg->Buffer)
|
2004-01-23 02:51:33 +01:00
|
|
|
msg->Buffer = HeapReAlloc(GetProcessHeap(),0,msg->Buffer,ststg.cbSize.u.LowPart);
|
2003-10-14 07:24:20 +02:00
|
|
|
else
|
2004-01-23 02:51:33 +01:00
|
|
|
msg->Buffer = HeapAlloc(GetProcessHeap(),0,ststg.cbSize.u.LowPart);
|
2003-10-14 07:24:20 +02:00
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
seekto.u.LowPart = 0;seekto.u.HighPart = 0;
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("IStream_Seek failed, %lx\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = IStream_Read(pStm,msg->Buffer,msg->cbBuffer,&res);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("Stream Read failed, %lx\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
IStream_Release(pStm);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("(%p,%p), stub!\n",msg,chanbuf);
|
|
|
|
FIXME("iMethod is %ld\n",msg->iMethod);
|
|
|
|
FIXME("cbBuffer is %ld\n",msg->cbBuffer);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPRPCSTUBBUFFER WINAPI
|
|
|
|
CFStub_IsIIDSupported(LPRPCSTUBBUFFER iface,REFIID riid) {
|
|
|
|
FIXME("(%s), stub!\n",debugstr_guid(riid));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
CFStub_CountRefs(LPRPCSTUBBUFFER iface) {
|
|
|
|
FIXME("(), stub!\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
CFStub_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,void** ppv) {
|
|
|
|
FIXME("(%p), stub!\n",ppv);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
static void WINAPI
|
|
|
|
CFStub_DebugServerRelease(LPRPCSTUBBUFFER iface,void *pv) {
|
|
|
|
FIXME("(%p), stub!\n",pv);
|
|
|
|
}
|
|
|
|
|
2004-08-13 01:00:51 +02:00
|
|
|
static IRpcStubBufferVtbl cfstubvt = {
|
2002-02-05 19:11:17 +01:00
|
|
|
CFStub_QueryInterface,
|
|
|
|
CFStub_AddRef,
|
|
|
|
CFStub_Release,
|
|
|
|
CFStub_Connect,
|
|
|
|
CFStub_Disconnect,
|
|
|
|
CFStub_Invoke,
|
|
|
|
CFStub_IsIIDSupported,
|
|
|
|
CFStub_CountRefs,
|
|
|
|
CFStub_DebugServerQueryInterface,
|
|
|
|
CFStub_DebugServerRelease
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
CFStub_Construct(LPRPCSTUBBUFFER *ppv) {
|
|
|
|
CFStub *cfstub;
|
|
|
|
cfstub = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CFStub));
|
|
|
|
if (!cfstub)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
*ppv = (LPRPCSTUBBUFFER)cfstub;
|
|
|
|
cfstub->lpvtbl = &cfstubvt;
|
|
|
|
cfstub->ref = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Since we create proxy buffers and classfactory in a pair, there is
|
2003-05-13 02:41:57 +02:00
|
|
|
* no need for 2 separate structs. Just put them in one, but remember
|
2002-02-05 19:11:17 +01:00
|
|
|
* the refcount.
|
|
|
|
*/
|
|
|
|
typedef struct _CFProxy {
|
2004-08-13 01:00:51 +02:00
|
|
|
IClassFactoryVtbl *lpvtbl_cf;
|
|
|
|
IRpcProxyBufferVtbl *lpvtbl_proxy;
|
2002-02-05 19:11:17 +01:00
|
|
|
DWORD ref;
|
|
|
|
|
|
|
|
IRpcChannelBuffer *chanbuf;
|
|
|
|
} CFProxy;
|
|
|
|
|
|
|
|
static HRESULT WINAPI IRpcProxyBufferImpl_QueryInterface(LPRPCPROXYBUFFER iface,REFIID riid,LPVOID *ppv) {
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid,&IID_IRpcProxyBuffer)||IsEqualIID(riid,&IID_IUnknown)) {
|
|
|
|
IRpcProxyBuffer_AddRef(iface);
|
|
|
|
*ppv = (LPVOID)iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("(%s), no interface.\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IRpcProxyBufferImpl_AddRef(LPRPCPROXYBUFFER iface) {
|
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IRpcProxyBufferImpl_Release(LPRPCPROXYBUFFER iface) {
|
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
if (!ref) {
|
2002-02-05 19:11:17 +01:00
|
|
|
IRpcChannelBuffer_Release(This->chanbuf);This->chanbuf = NULL;
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IRpcProxyBufferImpl_Connect(LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer) {
|
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface);
|
|
|
|
|
|
|
|
This->chanbuf = pRpcChannelBuffer;
|
|
|
|
IRpcChannelBuffer_AddRef(This->chanbuf);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
static void WINAPI IRpcProxyBufferImpl_Disconnect(LPRPCPROXYBUFFER iface) {
|
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface);
|
|
|
|
if (This->chanbuf) {
|
|
|
|
IRpcChannelBuffer_Release(This->chanbuf);
|
|
|
|
This->chanbuf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
CFProxy_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv) {
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(&IID_IClassFactory,riid) || IsEqualIID(&IID_IUnknown,riid)) {
|
|
|
|
*ppv = (LPVOID)iface;
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2003-05-13 02:41:57 +02:00
|
|
|
if (IsEqualIID(riid,&IID_IMarshal)) /* just to avoid debug output */
|
2002-02-05 19:11:17 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
FIXME("Unhandled interface: %s\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CFProxy_AddRef(LPCLASSFACTORY iface) {
|
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CFProxy_Release(LPCLASSFACTORY iface) {
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (!ref) HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CFProxy_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter,/* [in] */
|
|
|
|
REFIID riid, /* [in] */
|
|
|
|
LPVOID *ppv /* [out] */
|
|
|
|
) {
|
|
|
|
ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface);
|
|
|
|
HRESULT hres;
|
|
|
|
LPSTREAM pStream;
|
|
|
|
HGLOBAL hGlobal;
|
|
|
|
ULONG srstatus;
|
|
|
|
RPCOLEMESSAGE msg;
|
|
|
|
|
|
|
|
TRACE("(%p,%s,%p)\n",pUnkOuter,debugstr_guid(riid),ppv);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Send CreateInstance to the remote classfactory.
|
2002-02-05 19:11:17 +01:00
|
|
|
*
|
|
|
|
* Data: Only the 'IID'.
|
|
|
|
*/
|
|
|
|
msg.iMethod = 3;
|
|
|
|
msg.cbBuffer = sizeof(*riid);
|
|
|
|
msg.Buffer = NULL;
|
|
|
|
hres = IRpcChannelBuffer_GetBuffer(This->chanbuf,&msg,&IID_IClassFactory);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("IRpcChannelBuffer_GetBuffer failed with %lx?\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
memcpy(msg.Buffer,riid,sizeof(*riid));
|
|
|
|
hres = IRpcChannelBuffer_SendReceive(This->chanbuf,&msg,&srstatus);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("IRpcChannelBuffer_SendReceive failed with %lx?\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!msg.cbBuffer) /* interface not found on remote */
|
|
|
|
return srstatus;
|
|
|
|
|
2003-05-13 02:41:57 +02:00
|
|
|
/* We got back: [Marshalled Interface data] */
|
2002-02-05 19:11:17 +01:00
|
|
|
TRACE("got %ld bytes data.\n",msg.cbBuffer);
|
|
|
|
hGlobal = GlobalAlloc(GMEM_MOVEABLE|GMEM_NODISCARD|GMEM_SHARE,msg.cbBuffer);
|
|
|
|
memcpy(GlobalLock(hGlobal),msg.Buffer,msg.cbBuffer);
|
|
|
|
hres = CreateStreamOnHGlobal(hGlobal,TRUE,&pStream);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("CreateStreamOnHGlobal failed with %lx\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = CoUnmarshalInterface(
|
|
|
|
pStream,
|
|
|
|
riid,
|
|
|
|
ppv
|
|
|
|
);
|
|
|
|
IStream_Release(pStream); /* Does GlobalFree hGlobal too. */
|
|
|
|
if (hres) {
|
|
|
|
FIXME("CoMarshalInterface failed, %lx\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CFProxy_LockServer(LPCLASSFACTORY iface,BOOL fLock) {
|
|
|
|
/*ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface);*/
|
|
|
|
FIXME("(%d), stub!\n",fLock);
|
|
|
|
/* basically: write BOOL, read empty */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-08-13 01:00:51 +02:00
|
|
|
static IRpcProxyBufferVtbl pspbvtbl = {
|
2002-02-05 19:11:17 +01:00
|
|
|
IRpcProxyBufferImpl_QueryInterface,
|
|
|
|
IRpcProxyBufferImpl_AddRef,
|
|
|
|
IRpcProxyBufferImpl_Release,
|
|
|
|
IRpcProxyBufferImpl_Connect,
|
|
|
|
IRpcProxyBufferImpl_Disconnect
|
|
|
|
};
|
2004-08-13 01:00:51 +02:00
|
|
|
static IClassFactoryVtbl cfproxyvt = {
|
2002-02-05 19:11:17 +01:00
|
|
|
CFProxy_QueryInterface,
|
|
|
|
CFProxy_AddRef,
|
|
|
|
CFProxy_Release,
|
|
|
|
CFProxy_CreateInstance,
|
|
|
|
CFProxy_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
CFProxy_Construct(LPVOID *ppv,LPVOID *ppProxy) {
|
|
|
|
CFProxy *cf;
|
|
|
|
|
|
|
|
cf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CFProxy));
|
|
|
|
if (!cf)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
cf->lpvtbl_cf = &cfproxyvt;
|
|
|
|
cf->lpvtbl_proxy = &pspbvtbl;
|
2004-06-14 19:58:03 +02:00
|
|
|
/* 1 reference for the proxy and 1 for the object */
|
|
|
|
cf->ref = 2;
|
2002-02-05 19:11:17 +01:00
|
|
|
*ppv = &(cf->lpvtbl_cf);
|
|
|
|
*ppProxy = &(cf->lpvtbl_proxy);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************* OLE Proxy/Stub Factory ********************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PSFacBuf_QueryInterface(LPPSFACTORYBUFFER iface, REFIID iid, LPVOID *ppv) {
|
|
|
|
if (IsEqualIID(iid,&IID_IPSFactoryBuffer)||IsEqualIID(iid,&IID_IUnknown)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
*ppv = (LPVOID)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
/* No ref counting, static class */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("(%s) unknown IID?\n",debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PSFacBuf_AddRef(LPPSFACTORYBUFFER iface) { return 2; }
|
|
|
|
static ULONG WINAPI PSFacBuf_Release(LPPSFACTORYBUFFER iface) { return 1; }
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PSFacBuf_CreateProxy(
|
|
|
|
LPPSFACTORYBUFFER iface, IUnknown* pUnkOuter, REFIID riid,
|
|
|
|
IRpcProxyBuffer **ppProxy, LPVOID *ppv
|
|
|
|
) {
|
2002-06-05 00:14:06 +02:00
|
|
|
if (IsEqualIID(&IID_IClassFactory,riid) ||
|
|
|
|
IsEqualIID(&IID_IUnknown,riid)
|
|
|
|
)
|
2002-02-05 19:11:17 +01:00
|
|
|
return CFProxy_Construct(ppv,(LPVOID*)ppProxy);
|
|
|
|
FIXME("proxying not implemented for (%s) yet!\n",debugstr_guid(riid));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PSFacBuf_CreateStub(
|
|
|
|
LPPSFACTORYBUFFER iface, REFIID riid,IUnknown *pUnkServer,
|
|
|
|
IRpcStubBuffer** ppStub
|
|
|
|
) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_guid(riid),pUnkServer,ppStub);
|
|
|
|
|
2002-06-05 00:14:06 +02:00
|
|
|
if (IsEqualIID(&IID_IClassFactory,riid) ||
|
|
|
|
IsEqualIID(&IID_IUnknown,riid)
|
|
|
|
) {
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = CFStub_Construct(ppStub);
|
|
|
|
if (!hres)
|
|
|
|
IRpcStubBuffer_Connect((*ppStub),pUnkServer);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
FIXME("stubbing not implemented for (%s) yet!\n",debugstr_guid(riid));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2004-08-13 01:00:51 +02:00
|
|
|
static IPSFactoryBufferVtbl psfacbufvtbl = {
|
2002-02-05 19:11:17 +01:00
|
|
|
PSFacBuf_QueryInterface,
|
|
|
|
PSFacBuf_AddRef,
|
|
|
|
PSFacBuf_Release,
|
|
|
|
PSFacBuf_CreateProxy,
|
|
|
|
PSFacBuf_CreateStub
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is the whole PSFactoryBuffer object, just the vtableptr */
|
2004-08-13 01:00:51 +02:00
|
|
|
static IPSFactoryBufferVtbl *lppsfac = &psfacbufvtbl;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* DllGetClassObject [OLE32.@]
|
2002-02-05 19:11:17 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(rclsid,&CLSID_PSFactoryBuffer)) {
|
|
|
|
*ppv = &lppsfac;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-06-05 00:14:06 +02:00
|
|
|
if (IsEqualIID(rclsid,&CLSID_DfMarshal)&&(
|
|
|
|
IsEqualIID(iid,&IID_IClassFactory) ||
|
|
|
|
IsEqualIID(iid,&IID_IUnknown)
|
|
|
|
)
|
|
|
|
)
|
2002-02-05 19:11:17 +01:00
|
|
|
return MARSHAL_GetStandardMarshalCF(ppv);
|
2003-06-17 05:57:18 +02:00
|
|
|
if (IsEqualIID(rclsid,&CLSID_StdGlobalInterfaceTable) && (IsEqualIID(iid,&IID_IClassFactory) || IsEqualIID(iid,&IID_IUnknown)))
|
|
|
|
return StdGlobalInterfaceTable_GetFactory(ppv);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|