2002-08-03 02:17:10 +02:00
|
|
|
/*
|
2003-05-13 02:41:57 +02:00
|
|
|
* free threaded marshaller
|
2002-08-03 02:17:10 +02:00
|
|
|
*
|
|
|
|
* Copyright 2002 Juergen Schmied
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-08-03 02:17:10 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-08-03 02:17:10 +02:00
|
|
|
#include "winbase.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "objbase.h"
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2006-05-25 00:01:41 +02:00
|
|
|
#include "compobj_private.h"
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
typedef struct _FTMarshalImpl {
|
2016-07-05 09:54:38 +02:00
|
|
|
IUnknown IUnknown_inner;
|
2010-12-15 00:35:52 +01:00
|
|
|
IMarshal IMarshal_iface;
|
2016-07-05 09:54:38 +02:00
|
|
|
IUnknown *outer_unk;
|
|
|
|
LONG ref;
|
2002-08-03 02:17:10 +02:00
|
|
|
} FTMarshalImpl;
|
|
|
|
|
2010-12-15 00:35:52 +01:00
|
|
|
static inline FTMarshalImpl *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
2016-07-05 09:54:38 +02:00
|
|
|
return CONTAINING_RECORD(iface, FTMarshalImpl, IUnknown_inner);
|
2010-12-15 00:35:52 +01:00
|
|
|
}
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
static inline FTMarshalImpl *impl_from_IMarshal( IMarshal *iface )
|
|
|
|
{
|
2010-12-15 00:35:52 +01:00
|
|
|
return CONTAINING_RECORD(iface, FTMarshalImpl, IMarshal_iface);
|
2005-07-27 13:10:52 +02:00
|
|
|
}
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
/* inner IUnknown to handle aggregation */
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
2010-12-15 00:35:52 +01:00
|
|
|
FTMarshalImpl *This = impl_from_IUnknown(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID (&IID_IUnknown, riid))
|
2016-07-05 09:54:38 +02:00
|
|
|
*ppv = &This->IUnknown_inner;
|
2002-08-03 02:17:10 +02:00
|
|
|
else if (IsEqualIID (&IID_IMarshal, riid))
|
2010-12-15 00:35:52 +01:00
|
|
|
*ppv = &This->IMarshal_iface;
|
2002-08-03 02:17:10 +02:00
|
|
|
else {
|
|
|
|
FIXME ("No interface for %s.\n", debugstr_guid (riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
IUnknown_AddRef ((IUnknown *) * ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
2010-12-15 00:35:52 +01:00
|
|
|
FTMarshalImpl *This = impl_from_IUnknown(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
|
|
|
return InterlockedIncrement (&This->ref);
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static ULONG WINAPI IiFTMUnknown_fnRelease (IUnknown * iface)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
2010-12-15 00:35:52 +01:00
|
|
|
FTMarshalImpl *This = impl_from_IUnknown(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
|
|
|
if (InterlockedDecrement (&This->ref))
|
|
|
|
return This->ref;
|
|
|
|
HeapFree (GetProcessHeap (), 0, This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IUnknownVtbl iunkvt =
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
IiFTMUnknown_fnQueryInterface,
|
|
|
|
IiFTMUnknown_fnAddRef,
|
|
|
|
IiFTMUnknown_fnRelease
|
|
|
|
};
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
FTMarshalImpl_QueryInterface (LPMARSHAL iface, REFIID riid, LPVOID * ppv)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
FTMarshalImpl *This = impl_from_IMarshal(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppv);
|
2016-07-05 09:54:38 +02:00
|
|
|
return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
FTMarshalImpl_AddRef (LPMARSHAL iface)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
FTMarshalImpl *This = impl_from_IMarshal(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
2016-07-05 09:54:38 +02:00
|
|
|
return IUnknown_AddRef(This->outer_unk);
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
FTMarshalImpl_Release (LPMARSHAL iface)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
FTMarshalImpl *This = impl_from_IMarshal(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
2016-07-05 09:54:38 +02:00
|
|
|
return IUnknown_Release(This->outer_unk);
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
FTMarshalImpl_GetUnmarshalClass (LPMARSHAL iface, REFIID riid, void *pv, DWORD dwDestContext,
|
2002-08-03 02:17:10 +02:00
|
|
|
void *pvDestContext, DWORD mshlflags, CLSID * pCid)
|
|
|
|
{
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%s, %p, 0x%x, %p, 0x%x, %p)\n", debugstr_guid(riid), pv,
|
2006-05-25 00:02:26 +02:00
|
|
|
dwDestContext, pvDestContext, mshlflags, pCid);
|
|
|
|
if (dwDestContext == MSHCTX_INPROC || dwDestContext == MSHCTX_CROSSCTX)
|
2008-03-10 22:58:43 +01:00
|
|
|
*pCid = CLSID_InProcFreeMarshaler;
|
2006-05-25 00:02:26 +02:00
|
|
|
else
|
2018-10-11 19:11:30 +02:00
|
|
|
*pCid = CLSID_StdMarshal;
|
2002-08-03 02:17:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
FTMarshalImpl_GetMarshalSizeMax (LPMARSHAL iface, REFIID riid, void *pv, DWORD dwDestContext,
|
2002-08-03 02:17:10 +02:00
|
|
|
void *pvDestContext, DWORD mshlflags, DWORD * pSize)
|
|
|
|
{
|
|
|
|
|
|
|
|
IMarshal *pMarshal = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%s, %p, 0x%x, %p, 0x%x, %p)\n", debugstr_guid(riid), pv,
|
2006-06-09 18:24:32 +02:00
|
|
|
dwDestContext, pvDestContext, mshlflags, pSize);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2003-05-13 02:41:57 +02:00
|
|
|
/* if the marshalling happens inside the same process the interface pointer is
|
|
|
|
copied between the apartments */
|
2002-08-03 02:17:10 +02:00
|
|
|
if (dwDestContext == MSHCTX_INPROC || dwDestContext == MSHCTX_CROSSCTX) {
|
2006-06-09 18:24:32 +02:00
|
|
|
*pSize = sizeof (mshlflags) + sizeof (pv) + sizeof (DWORD) + sizeof (GUID);
|
|
|
|
return S_OK;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2003-05-13 02:41:57 +02:00
|
|
|
/* use the standard marshaller to handle all other cases */
|
2002-08-03 02:17:10 +02:00
|
|
|
CoGetStandardMarshal (riid, pv, dwDestContext, pvDestContext, mshlflags, &pMarshal);
|
|
|
|
hres = IMarshal_GetMarshalSizeMax (pMarshal, riid, pv, dwDestContext, pvDestContext, mshlflags, pSize);
|
|
|
|
IMarshal_Release (pMarshal);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
FTMarshalImpl_MarshalInterface (LPMARSHAL iface, IStream * pStm, REFIID riid, void *pv,
|
|
|
|
DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
IMarshal *pMarshal = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p, %s, %p, 0x%x, %p, 0x%x)\n", pStm, debugstr_guid(riid), pv,
|
2006-05-25 00:01:41 +02:00
|
|
|
dwDestContext, pvDestContext, mshlflags);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2003-05-13 02:41:57 +02:00
|
|
|
/* if the marshalling happens inside the same process the interface pointer is
|
|
|
|
copied between the apartments */
|
2002-08-03 02:17:10 +02:00
|
|
|
if (dwDestContext == MSHCTX_INPROC || dwDestContext == MSHCTX_CROSSCTX) {
|
2006-05-25 00:01:41 +02:00
|
|
|
void *object;
|
|
|
|
DWORD constant = 0;
|
|
|
|
GUID unknown_guid = { 0 };
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface((IUnknown *)pv, riid, &object);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2006-05-25 00:01:53 +02:00
|
|
|
/* don't hold a reference to table-weak marshaled interfaces */
|
|
|
|
if (mshlflags & MSHLFLAGS_TABLEWEAK)
|
|
|
|
IUnknown_Release((IUnknown *)object);
|
|
|
|
|
2006-05-25 00:01:41 +02:00
|
|
|
hres = IStream_Write (pStm, &mshlflags, sizeof (mshlflags), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_MEDIUMFULL;
|
|
|
|
|
|
|
|
hres = IStream_Write (pStm, &object, sizeof (object), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_MEDIUMFULL;
|
|
|
|
|
2010-04-06 21:45:38 +02:00
|
|
|
if (sizeof(object) == sizeof(DWORD))
|
|
|
|
{
|
|
|
|
hres = IStream_Write (pStm, &constant, sizeof (constant), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_MEDIUMFULL;
|
|
|
|
}
|
2006-05-25 00:01:41 +02:00
|
|
|
|
|
|
|
hres = IStream_Write (pStm, &unknown_guid, sizeof (unknown_guid), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_MEDIUMFULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* use the standard marshaler to handle all other cases */
|
|
|
|
CoGetStandardMarshal (riid, pv, dwDestContext, pvDestContext, mshlflags, &pMarshal);
|
|
|
|
hres = IMarshal_MarshalInterface (pMarshal, pStm, riid, pv, dwDestContext, pvDestContext, mshlflags);
|
|
|
|
IMarshal_Release (pMarshal);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
FTMarshalImpl_UnmarshalInterface (LPMARSHAL iface, IStream * pStm, REFIID riid, void **ppv)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2006-05-25 00:01:41 +02:00
|
|
|
DWORD mshlflags;
|
2006-05-25 00:02:26 +02:00
|
|
|
IUnknown *object;
|
|
|
|
DWORD constant;
|
|
|
|
GUID unknown_guid;
|
2006-05-25 00:01:41 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE ("(%p, %s, %p)\n", pStm, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
hres = IStream_Read (pStm, &mshlflags, sizeof (mshlflags), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
|
|
|
|
2006-05-25 00:02:26 +02:00
|
|
|
hres = IStream_Read (pStm, &object, sizeof (object), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
2006-05-25 00:01:41 +02:00
|
|
|
|
2010-04-06 21:45:38 +02:00
|
|
|
if (sizeof(object) == sizeof(DWORD))
|
|
|
|
{
|
|
|
|
hres = IStream_Read (pStm, &constant, sizeof (constant), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
|
|
|
if (constant != 0)
|
|
|
|
FIXME("constant is 0x%x instead of 0\n", constant);
|
|
|
|
}
|
2006-05-25 00:01:41 +02:00
|
|
|
|
2006-05-25 00:02:26 +02:00
|
|
|
hres = IStream_Read (pStm, &unknown_guid, sizeof (unknown_guid), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
2006-05-25 00:01:41 +02:00
|
|
|
|
2006-05-25 00:02:26 +02:00
|
|
|
hres = IUnknown_QueryInterface(object, riid, ppv);
|
|
|
|
if (!(mshlflags & (MSHLFLAGS_TABLEWEAK|MSHLFLAGS_TABLESTRONG)))
|
|
|
|
IUnknown_Release(object);
|
|
|
|
return hres;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI FTMarshalImpl_ReleaseMarshalData (LPMARSHAL iface, IStream * pStm)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2006-05-25 00:02:14 +02:00
|
|
|
DWORD mshlflags;
|
2006-05-25 00:02:26 +02:00
|
|
|
IUnknown *object;
|
|
|
|
DWORD constant;
|
|
|
|
GUID unknown_guid;
|
2006-05-25 00:02:14 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE ("(%p)\n", pStm);
|
|
|
|
|
|
|
|
hres = IStream_Read (pStm, &mshlflags, sizeof (mshlflags), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
|
|
|
|
2006-05-25 00:02:26 +02:00
|
|
|
hres = IStream_Read (pStm, &object, sizeof (object), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
2006-05-25 00:02:14 +02:00
|
|
|
|
2010-04-06 21:45:38 +02:00
|
|
|
if (sizeof(object) == sizeof(DWORD))
|
|
|
|
{
|
|
|
|
hres = IStream_Read (pStm, &constant, sizeof (constant), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
|
|
|
if (constant != 0)
|
|
|
|
FIXME("constant is 0x%x instead of 0\n", constant);
|
|
|
|
}
|
2006-05-25 00:02:14 +02:00
|
|
|
|
2006-05-25 00:02:26 +02:00
|
|
|
hres = IStream_Read (pStm, &unknown_guid, sizeof (unknown_guid), NULL);
|
|
|
|
if (hres != S_OK) return STG_E_READFAULT;
|
2006-05-25 00:02:14 +02:00
|
|
|
|
2006-05-25 00:02:26 +02:00
|
|
|
IUnknown_Release(object);
|
|
|
|
return S_OK;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2005-05-16 10:47:26 +02:00
|
|
|
static HRESULT WINAPI FTMarshalImpl_DisconnectObject (LPMARSHAL iface, DWORD dwReserved)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2006-05-25 00:02:14 +02:00
|
|
|
TRACE ("()\n");
|
|
|
|
/* nothing to do */
|
2002-08-03 02:17:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IMarshalVtbl ftmvtbl =
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
FTMarshalImpl_QueryInterface,
|
|
|
|
FTMarshalImpl_AddRef,
|
|
|
|
FTMarshalImpl_Release,
|
|
|
|
FTMarshalImpl_GetUnmarshalClass,
|
|
|
|
FTMarshalImpl_GetMarshalSizeMax,
|
|
|
|
FTMarshalImpl_MarshalInterface,
|
|
|
|
FTMarshalImpl_UnmarshalInterface,
|
|
|
|
FTMarshalImpl_ReleaseMarshalData,
|
|
|
|
FTMarshalImpl_DisconnectObject
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* CoCreateFreeThreadedMarshaler [OLE32.@]
|
2002-08-03 02:17:10 +02:00
|
|
|
*
|
2006-06-17 13:31:54 +02:00
|
|
|
* Creates a free-threaded marshaler.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* punkOuter [I] Optional. Outer unknown.
|
|
|
|
* ppunkMarshal [O] On return, the inner unknown of the created free-threaded marshaler.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: E_OUTOFMEMORY if no memory available to create object.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Objects that ensure their state is maintained consistent when used by
|
|
|
|
* multiple threads and reference no single-threaded objects are known as
|
|
|
|
* free-threaded. The free-threaded marshaler enables these objects to be
|
|
|
|
* efficiently marshaled within the same process, by not creating proxies
|
|
|
|
* (as they aren't needed for the object to be safely used), whilst still
|
|
|
|
* allowing the object to be used in inter-process and inter-machine contexts.
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoCreateFreeThreadedMarshaler (LPUNKNOWN punkOuter, LPUNKNOWN * ppunkMarshal)
|
|
|
|
{
|
|
|
|
|
|
|
|
FTMarshalImpl *ftm;
|
|
|
|
|
|
|
|
TRACE ("(%p %p)\n", punkOuter, ppunkMarshal);
|
|
|
|
|
2005-03-21 12:25:13 +01:00
|
|
|
ftm = HeapAlloc (GetProcessHeap (), 0, sizeof (FTMarshalImpl));
|
2002-08-03 02:17:10 +02:00
|
|
|
if (!ftm)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2016-07-05 09:54:38 +02:00
|
|
|
ftm->IUnknown_inner.lpVtbl = &iunkvt;
|
2010-12-15 00:35:52 +01:00
|
|
|
ftm->IMarshal_iface.lpVtbl = &ftmvtbl;
|
2002-08-03 02:17:10 +02:00
|
|
|
ftm->ref = 1;
|
2016-07-05 09:54:38 +02:00
|
|
|
ftm->outer_unk = punkOuter ? punkOuter : &ftm->IUnknown_inner;
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2016-07-05 09:54:38 +02:00
|
|
|
*ppunkMarshal = &ftm->IUnknown_inner;
|
2002-08-03 02:17:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2006-05-25 00:02:35 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI FTMarshalCF_QueryInterface(LPCLASSFACTORY iface,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
2012-08-13 11:40:33 +02:00
|
|
|
IClassFactory_AddRef(iface);
|
2006-05-25 00:02:35 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FTMarshalCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 2; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FTMarshalCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 1; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FTMarshalCF_CreateInstance(LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
IUnknown *pUnknown;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
hr = CoCreateFreeThreadedMarshaler(pUnk, &pUnknown);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(pUnknown, riid, ppv);
|
|
|
|
IUnknown_Release(pUnknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FTMarshalCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
|
|
|
|
{
|
|
|
|
FIXME("(%d), stub!\n",fLock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl FTMarshalCFVtbl =
|
|
|
|
{
|
|
|
|
FTMarshalCF_QueryInterface,
|
|
|
|
FTMarshalCF_AddRef,
|
|
|
|
FTMarshalCF_Release,
|
|
|
|
FTMarshalCF_CreateInstance,
|
|
|
|
FTMarshalCF_LockServer
|
|
|
|
};
|
|
|
|
static const IClassFactoryVtbl *FTMarshalCF = &FTMarshalCFVtbl;
|
|
|
|
|
|
|
|
HRESULT FTMarshalCF_Create(REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
return IClassFactory_QueryInterface((IClassFactory *)&FTMarshalCF, riid, ppv);
|
|
|
|
}
|