2002-10-11 20:45:02 +02:00
|
|
|
/*
|
|
|
|
* OLE32 callouts, COM interface marshalling
|
|
|
|
*
|
2008-10-18 19:20:44 +02:00
|
|
|
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
2002-10-11 20:45:02 +02: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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-11 20:45:02 +02:00
|
|
|
*
|
|
|
|
* TODO:
|
2006-05-19 12:03:06 +02:00
|
|
|
* - fix the wire-protocol to match MS/RPC
|
2002-10-11 20:45:02 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-10-11 20:45:02 +02: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
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2002-10-11 20:45:02 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "objbase.h"
|
2002-10-11 20:45:02 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
#include "ndr_misc.h"
|
2002-10-11 20:45:02 +02:00
|
|
|
#include "rpcndr.h"
|
2018-06-13 04:19:10 +02:00
|
|
|
#include "ndrtypes.h"
|
2006-08-28 20:05:36 +02:00
|
|
|
#include "rpcproxy.h"
|
|
|
|
#include "cpsf.h"
|
2002-10-11 20:45:02 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
static HMODULE hOLE;
|
|
|
|
|
2003-05-20 04:17:15 +02:00
|
|
|
static HRESULT (WINAPI *COM_GetMarshalSizeMax)(ULONG *,REFIID,LPUNKNOWN,DWORD,LPVOID,DWORD);
|
|
|
|
static HRESULT (WINAPI *COM_MarshalInterface)(LPSTREAM,REFIID,LPUNKNOWN,DWORD,LPVOID,DWORD);
|
|
|
|
static HRESULT (WINAPI *COM_UnmarshalInterface)(LPSTREAM,REFIID,LPVOID*);
|
|
|
|
static HRESULT (WINAPI *COM_ReleaseMarshalData)(LPSTREAM);
|
|
|
|
static HRESULT (WINAPI *COM_GetClassObject)(REFCLSID,DWORD,COSERVERINFO *,REFIID,LPVOID *);
|
|
|
|
static HRESULT (WINAPI *COM_GetPSClsid)(REFIID,CLSID *);
|
|
|
|
static LPVOID (WINAPI *COM_MemAlloc)(ULONG);
|
|
|
|
static void (WINAPI *COM_MemFree)(LPVOID);
|
2002-10-11 20:45:02 +02:00
|
|
|
|
|
|
|
static HMODULE LoadCOM(void)
|
|
|
|
{
|
|
|
|
if (hOLE) return hOLE;
|
|
|
|
hOLE = LoadLibraryA("OLE32.DLL");
|
|
|
|
if (!hOLE) return 0;
|
|
|
|
COM_GetMarshalSizeMax = (LPVOID)GetProcAddress(hOLE, "CoGetMarshalSizeMax");
|
|
|
|
COM_MarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoMarshalInterface");
|
|
|
|
COM_UnmarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoUnmarshalInterface");
|
|
|
|
COM_ReleaseMarshalData = (LPVOID)GetProcAddress(hOLE, "CoReleaseMarshalData");
|
|
|
|
COM_GetClassObject = (LPVOID)GetProcAddress(hOLE, "CoGetClassObject");
|
|
|
|
COM_GetPSClsid = (LPVOID)GetProcAddress(hOLE, "CoGetPSClsid");
|
|
|
|
COM_MemAlloc = (LPVOID)GetProcAddress(hOLE, "CoTaskMemAlloc");
|
|
|
|
COM_MemFree = (LPVOID)GetProcAddress(hOLE, "CoTaskMemFree");
|
|
|
|
return hOLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CoMarshalInterface/CoUnmarshalInterface works on streams,
|
|
|
|
* so implement a simple stream on top of the RPC buffer
|
|
|
|
* (which also implements the MInterfacePointer structure) */
|
|
|
|
typedef struct RpcStreamImpl
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
IStream IStream_iface;
|
2008-07-07 12:09:45 +02:00
|
|
|
LONG RefCount;
|
2002-10-11 20:45:02 +02:00
|
|
|
PMIDL_STUB_MESSAGE pMsg;
|
|
|
|
LPDWORD size;
|
2007-12-19 15:53:40 +01:00
|
|
|
unsigned char *data;
|
2002-10-11 20:45:02 +02:00
|
|
|
DWORD pos;
|
|
|
|
} RpcStreamImpl;
|
|
|
|
|
2010-12-08 22:59:42 +01:00
|
|
|
static inline RpcStreamImpl *impl_from_IStream(IStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, RpcStreamImpl, IStream_iface);
|
|
|
|
}
|
|
|
|
|
2002-10-11 20:45:02 +02:00
|
|
|
static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *obj)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualGUID(&IID_ISequentialStream, riid) ||
|
|
|
|
IsEqualGUID(&IID_IStream, riid)) {
|
2015-03-06 18:16:40 +01:00
|
|
|
*obj = iface;
|
|
|
|
IStream_AddRef(iface);
|
2002-10-11 20:45:02 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2015-03-06 18:16:40 +01:00
|
|
|
|
|
|
|
*obj = NULL;
|
2002-10-11 20:45:02 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI RpcStream_AddRef(LPSTREAM iface)
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
2008-07-07 12:09:45 +02:00
|
|
|
return InterlockedIncrement( &This->RefCount );
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
2008-07-07 12:09:45 +02:00
|
|
|
ULONG ref = InterlockedDecrement( &This->RefCount );
|
|
|
|
if (!ref) {
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("size=%d\n", *This->size);
|
2008-01-16 22:57:31 +01:00
|
|
|
This->pMsg->Buffer = This->data + *This->size;
|
2002-10-11 20:45:02 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
2008-07-07 12:09:45 +02:00
|
|
|
return ref;
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Read(LPSTREAM iface,
|
|
|
|
void *pv,
|
|
|
|
ULONG cb,
|
|
|
|
ULONG *pcbRead)
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
2005-06-07 22:07:06 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
if (This->pos + cb > *This->size)
|
|
|
|
{
|
|
|
|
cb = *This->size - This->pos;
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
2002-10-11 20:45:02 +02:00
|
|
|
if (cb) {
|
|
|
|
memcpy(pv, This->data + This->pos, cb);
|
|
|
|
This->pos += cb;
|
|
|
|
}
|
|
|
|
if (pcbRead) *pcbRead = cb;
|
2005-06-07 22:07:06 +02:00
|
|
|
return hr;
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Write(LPSTREAM iface,
|
|
|
|
const void *pv,
|
|
|
|
ULONG cb,
|
|
|
|
ULONG *pcbWritten)
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
2007-12-19 15:53:40 +01:00
|
|
|
if (This->data + cb > (unsigned char *)This->pMsg->RpcMsg->Buffer + This->pMsg->BufferLength)
|
2005-06-07 22:07:06 +02:00
|
|
|
return STG_E_MEDIUMFULL;
|
2002-10-11 20:45:02 +02:00
|
|
|
memcpy(This->data + This->pos, pv, cb);
|
|
|
|
This->pos += cb;
|
|
|
|
if (This->pos > *This->size) *This->size = This->pos;
|
|
|
|
if (pcbWritten) *pcbWritten = cb;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Seek(LPSTREAM iface,
|
|
|
|
LARGE_INTEGER move,
|
|
|
|
DWORD origin,
|
|
|
|
ULARGE_INTEGER *newPos)
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
2002-10-11 20:45:02 +02:00
|
|
|
switch (origin) {
|
|
|
|
case STREAM_SEEK_SET:
|
2004-01-23 02:51:33 +01:00
|
|
|
This->pos = move.u.LowPart;
|
2002-10-11 20:45:02 +02:00
|
|
|
break;
|
|
|
|
case STREAM_SEEK_CUR:
|
2004-01-23 02:51:33 +01:00
|
|
|
This->pos = This->pos + move.u.LowPart;
|
2002-10-11 20:45:02 +02:00
|
|
|
break;
|
|
|
|
case STREAM_SEEK_END:
|
2004-01-23 02:51:33 +01:00
|
|
|
This->pos = *This->size + move.u.LowPart;
|
2002-10-11 20:45:02 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
|
|
|
}
|
|
|
|
if (newPos) {
|
2004-01-23 02:51:33 +01:00
|
|
|
newPos->u.LowPart = This->pos;
|
|
|
|
newPos->u.HighPart = 0;
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_SetSize(LPSTREAM iface,
|
|
|
|
ULARGE_INTEGER newSize)
|
|
|
|
{
|
2010-12-08 22:59:42 +01:00
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
2004-01-23 02:51:33 +01:00
|
|
|
*This->size = newSize.u.LowPart;
|
2002-10-11 20:45:02 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-06 19:07:39 +01:00
|
|
|
static HRESULT WINAPI RpcStream_CopyTo(IStream *iface, IStream *dest,
|
|
|
|
ULARGE_INTEGER len, ULARGE_INTEGER *read, ULARGE_INTEGER *written)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Commit(IStream *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p)->(0x%08x): stub\n", This, flags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Revert(IStream *iface)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_LockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_UnlockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Stat(IStream *iface, STATSTG *stat, DWORD flag)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI RpcStream_Clone(IStream *iface, IStream **cloned)
|
|
|
|
{
|
|
|
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IStreamVtbl RpcStream_Vtbl =
|
2002-10-11 20:45:02 +02:00
|
|
|
{
|
|
|
|
RpcStream_QueryInterface,
|
|
|
|
RpcStream_AddRef,
|
|
|
|
RpcStream_Release,
|
|
|
|
RpcStream_Read,
|
|
|
|
RpcStream_Write,
|
|
|
|
RpcStream_Seek,
|
|
|
|
RpcStream_SetSize,
|
2015-03-06 19:07:39 +01:00
|
|
|
RpcStream_CopyTo,
|
|
|
|
RpcStream_Commit,
|
|
|
|
RpcStream_Revert,
|
|
|
|
RpcStream_LockRegion,
|
|
|
|
RpcStream_UnlockRegion,
|
|
|
|
RpcStream_Stat,
|
|
|
|
RpcStream_Clone
|
2002-10-11 20:45:02 +02:00
|
|
|
};
|
|
|
|
|
2015-03-06 18:28:24 +01:00
|
|
|
static HRESULT RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *size, IStream **stream)
|
2002-10-11 20:45:02 +02:00
|
|
|
{
|
|
|
|
RpcStreamImpl *This;
|
2015-03-06 18:16:40 +01:00
|
|
|
|
|
|
|
*stream = NULL;
|
2015-03-06 18:28:24 +01:00
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcStreamImpl));
|
2015-03-06 18:16:40 +01:00
|
|
|
if (!This) return E_OUTOFMEMORY;
|
2010-12-08 22:59:42 +01:00
|
|
|
This->IStream_iface.lpVtbl = &RpcStream_Vtbl;
|
2002-10-11 20:45:02 +02:00
|
|
|
This->RefCount = 1;
|
|
|
|
This->pMsg = pStubMsg;
|
|
|
|
This->size = (LPDWORD)pStubMsg->Buffer;
|
2015-03-06 18:28:24 +01:00
|
|
|
This->data = pStubMsg->Buffer + sizeof(DWORD);
|
2002-10-11 20:45:02 +02:00
|
|
|
This->pos = 0;
|
|
|
|
if (init) *This->size = 0;
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("init size=%d\n", *This->size);
|
2015-03-06 18:28:24 +01:00
|
|
|
|
|
|
|
if (size) *size = *This->size;
|
2015-03-06 18:16:40 +01:00
|
|
|
*stream = &This->IStream_iface;
|
|
|
|
return S_OK;
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
|
2005-07-05 14:49:14 +02:00
|
|
|
static const IID* get_ip_iid(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
|
|
|
const IID *riid;
|
|
|
|
if (!pFormat) return &IID_IUnknown;
|
|
|
|
TRACE("format=%02x %02x\n", pFormat[0], pFormat[1]);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_IP) FIXME("format=%d\n", pFormat[0]);
|
|
|
|
if (pFormat[1] == FC_CONSTANT_IID) {
|
2003-05-20 04:17:15 +02:00
|
|
|
riid = (const IID *)&pFormat[2];
|
|
|
|
} else {
|
|
|
|
ComputeConformance(pStubMsg, pMemory, pFormat+2, 0);
|
|
|
|
riid = (const IID *)pStubMsg->MaxCount;
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
if (!riid) riid = &IID_IUnknown;
|
2003-05-20 04:17:15 +02:00
|
|
|
TRACE("got %s\n", debugstr_guid(riid));
|
2003-02-01 01:44:51 +01:00
|
|
|
return riid;
|
|
|
|
}
|
|
|
|
|
2002-10-11 20:45:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrInterfacePointerMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrInterfacePointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2003-02-01 01:44:51 +01:00
|
|
|
const IID *riid = get_ip_iid(pStubMsg, pMemory, pFormat);
|
2002-10-11 20:45:02 +02:00
|
|
|
LPSTREAM stream;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pStubMsg->MaxCount = 0;
|
|
|
|
if (!LoadCOM()) return NULL;
|
2006-05-18 04:40:29 +02:00
|
|
|
if (pStubMsg->Buffer + sizeof(DWORD) <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) {
|
2015-03-06 18:28:24 +01:00
|
|
|
hr = RpcStream_Create(pStubMsg, TRUE, NULL, &stream);
|
2015-03-06 18:16:40 +01:00
|
|
|
if (hr == S_OK) {
|
2006-01-31 12:21:13 +01:00
|
|
|
if (pMemory)
|
|
|
|
hr = COM_MarshalInterface(stream, riid, (LPUNKNOWN)pMemory,
|
|
|
|
pStubMsg->dwDestContext, pStubMsg->pvDestContext,
|
|
|
|
MSHLFLAGS_NORMAL);
|
2005-06-07 22:07:06 +02:00
|
|
|
IStream_Release(stream);
|
|
|
|
}
|
2015-03-06 18:16:40 +01:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
RpcRaiseException(hr);
|
2005-06-07 22:07:06 +02:00
|
|
|
}
|
2002-10-11 20:45:02 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrInterfacePointerUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2018-11-02 05:53:45 +01:00
|
|
|
IUnknown **unk = (IUnknown **)ppMemory;
|
2002-10-11 20:45:02 +02:00
|
|
|
LPSTREAM stream;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
if (!LoadCOM()) return NULL;
|
2018-11-02 05:53:45 +01:00
|
|
|
|
|
|
|
/* Avoid reference leaks for [in, out] pointers. */
|
|
|
|
if (pStubMsg->IsClient && *unk)
|
|
|
|
IUnknown_Release(*unk);
|
|
|
|
|
|
|
|
*unk = NULL;
|
2005-11-29 10:41:34 +01:00
|
|
|
if (pStubMsg->Buffer + sizeof(DWORD) < (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) {
|
2015-03-06 18:28:24 +01:00
|
|
|
ULONG size;
|
|
|
|
|
|
|
|
hr = RpcStream_Create(pStubMsg, FALSE, &size, &stream);
|
2015-03-06 18:16:40 +01:00
|
|
|
if (hr == S_OK) {
|
2015-03-06 18:28:24 +01:00
|
|
|
if (size != 0)
|
2018-11-02 05:53:45 +01:00
|
|
|
hr = COM_UnmarshalInterface(stream, &IID_NULL, (void **)unk);
|
2015-03-06 18:16:40 +01:00
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
}
|
|
|
|
|
2007-03-14 16:46:16 +01:00
|
|
|
if (FAILED(hr))
|
2005-11-29 10:41:34 +01:00
|
|
|
RpcRaiseException(hr);
|
2005-06-07 22:07:06 +02:00
|
|
|
}
|
2002-10-11 20:45:02 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrInterfacePointerBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrInterfacePointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2003-02-01 01:44:51 +01:00
|
|
|
const IID *riid = get_ip_iid(pStubMsg, pMemory, pFormat);
|
2002-10-11 20:45:02 +02:00
|
|
|
ULONG size = 0;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
if (!LoadCOM()) return;
|
2010-05-14 22:06:47 +02:00
|
|
|
COM_GetMarshalSizeMax(&size, riid, (LPUNKNOWN)pMemory,
|
|
|
|
pStubMsg->dwDestContext, pStubMsg->pvDestContext,
|
|
|
|
MSHLFLAGS_NORMAL);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("size=%d\n", size);
|
2005-11-29 10:41:34 +01:00
|
|
|
pStubMsg->BufferLength += sizeof(DWORD) + size;
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrInterfacePointerMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:02:09 +01:00
|
|
|
ULONG WINAPI NdrInterfacePointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2002-10-11 20:45:02 +02:00
|
|
|
{
|
2006-05-17 15:46:06 +02:00
|
|
|
ULONG size;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
|
|
|
|
|
|
|
size = *(ULONG *)pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer += 4;
|
|
|
|
pStubMsg->MemorySize += 4;
|
|
|
|
|
|
|
|
pStubMsg->Buffer += size;
|
|
|
|
|
|
|
|
return pStubMsg->MemorySize;
|
2002-10-11 20:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrInterfacePointerFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrInterfacePointerFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
LPUNKNOWN pUnk = (LPUNKNOWN)pMemory;
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
if (pUnk) IUnknown_Release(pUnk);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrOleAllocate [RPCRT4.@]
|
|
|
|
*/
|
2009-01-30 14:46:17 +01:00
|
|
|
void * WINAPI NdrOleAllocate(SIZE_T Size)
|
2002-10-11 20:45:02 +02:00
|
|
|
{
|
|
|
|
if (!LoadCOM()) return NULL;
|
|
|
|
return COM_MemAlloc(Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrOleFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrOleFree(void *NodeToFree)
|
|
|
|
{
|
|
|
|
if (!LoadCOM()) return;
|
|
|
|
COM_MemFree(NodeToFree);
|
|
|
|
}
|
2006-08-28 20:05:36 +02:00
|
|
|
|
2009-06-03 16:42:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Helper function to create a proxy.
|
|
|
|
* Probably similar to NdrpCreateProxy.
|
|
|
|
*/
|
|
|
|
HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, void **ppv)
|
|
|
|
{
|
|
|
|
CLSID clsid;
|
|
|
|
IPSFactoryBuffer *psfac;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
if(!LoadCOM()) return E_FAIL;
|
|
|
|
|
|
|
|
r = COM_GetPSClsid( iid, &clsid );
|
|
|
|
if(FAILED(r)) return r;
|
|
|
|
|
|
|
|
r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac );
|
|
|
|
if(FAILED(r)) return r;
|
|
|
|
|
|
|
|
r = IPSFactoryBuffer_CreateProxy(psfac, pUnkOuter, iid, pproxy, ppv);
|
|
|
|
|
|
|
|
IPSFactoryBuffer_Release(psfac);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-08-28 20:05:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Helper function to create a stub.
|
|
|
|
* This probably looks very much like NdrpCreateStub.
|
|
|
|
*/
|
|
|
|
HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub)
|
|
|
|
{
|
|
|
|
CLSID clsid;
|
|
|
|
IPSFactoryBuffer *psfac;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
if(!LoadCOM()) return E_FAIL;
|
|
|
|
|
|
|
|
r = COM_GetPSClsid( iid, &clsid );
|
|
|
|
if(FAILED(r)) return r;
|
|
|
|
|
|
|
|
r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac );
|
|
|
|
if(FAILED(r)) return r;
|
|
|
|
|
|
|
|
r = IPSFactoryBuffer_CreateStub(psfac, iid, pUnk, ppstub);
|
|
|
|
|
|
|
|
IPSFactoryBuffer_Release(psfac);
|
|
|
|
return r;
|
|
|
|
}
|