2002-10-10 23:18:29 +02:00
|
|
|
|
/*
|
|
|
|
|
* COM proxy implementation
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2001 Ove K<EFBFBD>ven, TransGaming Technologies
|
|
|
|
|
*
|
|
|
|
|
* 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-10 23:18:29 +02:00
|
|
|
|
*
|
|
|
|
|
* TODO: Handle non-i386 architectures
|
|
|
|
|
*/
|
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
|
#include "windef.h"
|
|
|
|
|
#include "winbase.h"
|
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
2002-12-05 21:33:07 +01:00
|
|
|
|
#include "objbase.h"
|
2002-10-10 23:18:29 +02:00
|
|
|
|
#include "rpcproxy.h"
|
|
|
|
|
|
|
|
|
|
#include "cpsf.h"
|
|
|
|
|
#include "ndr_misc.h"
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
|
|
struct StublessThunk;
|
|
|
|
|
|
|
|
|
|
/* I don't know what MS's std proxy structure looks like,
|
|
|
|
|
so this probably doesn't match, but that shouldn't matter */
|
|
|
|
|
typedef struct {
|
2005-06-06 21:50:35 +02:00
|
|
|
|
const IRpcProxyBufferVtbl *lpVtbl;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
LPVOID *PVtbl;
|
2006-08-29 22:16:44 +02:00
|
|
|
|
LONG RefCount;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
const MIDL_STUBLESS_PROXY_INFO *stubless;
|
|
|
|
|
const IID* piid;
|
|
|
|
|
LPUNKNOWN pUnkOuter;
|
2003-05-20 06:13:44 +02:00
|
|
|
|
PCInterfaceName name;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
LPPSFACTORYBUFFER pPSFactory;
|
|
|
|
|
LPRPCCHANNELBUFFER pChannel;
|
|
|
|
|
struct StublessThunk *thunks;
|
|
|
|
|
} StdProxyImpl;
|
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
|
static const IRpcProxyBufferVtbl StdProxy_Vtbl;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
|
2004-08-13 02:44:22 +02:00
|
|
|
|
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
|
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
|
/* How the Windows stubless proxy thunks work is explained at
|
|
|
|
|
* http://msdn.microsoft.com/library/en-us/dnmsj99/html/com0199.asp,
|
|
|
|
|
* but I'll use a slightly different method, to make life easier */
|
|
|
|
|
|
|
|
|
|
#if defined(__i386__)
|
|
|
|
|
|
2004-01-09 23:18:49 +01:00
|
|
|
|
#include "pshpack1.h"
|
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
|
struct StublessThunk {
|
2004-01-09 23:18:49 +01:00
|
|
|
|
BYTE push;
|
|
|
|
|
DWORD index;
|
|
|
|
|
BYTE call;
|
|
|
|
|
LONG handler;
|
|
|
|
|
BYTE ret;
|
|
|
|
|
WORD bytes;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
BYTE pad[3];
|
|
|
|
|
};
|
|
|
|
|
|
2004-01-09 23:18:49 +01:00
|
|
|
|
#include "poppack.h"
|
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
|
/* adjust the stack size since we don't use Windows's method */
|
|
|
|
|
#define STACK_ADJUST sizeof(DWORD)
|
|
|
|
|
|
|
|
|
|
#define FILL_STUBLESS(x,idx,stk) \
|
|
|
|
|
x->push = 0x68; /* pushl [immediate] */ \
|
|
|
|
|
x->index = (idx); \
|
|
|
|
|
x->call = 0xe8; /* call [near] */ \
|
|
|
|
|
x->handler = (char*)ObjectStubless - (char*)&x->ret; \
|
|
|
|
|
x->ret = 0xc2; /* ret [immediate] */ \
|
|
|
|
|
x->bytes = stk; \
|
|
|
|
|
x->pad[0] = 0x8d; /* leal (%esi),%esi */ \
|
|
|
|
|
x->pad[1] = 0x76; \
|
|
|
|
|
x->pad[2] = 0x00;
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI ObjectStubless(DWORD index)
|
|
|
|
|
{
|
|
|
|
|
char *args = (char*)(&index + 2);
|
|
|
|
|
LPVOID iface = *(LPVOID*)args;
|
|
|
|
|
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
|
|
|
|
|
|
|
|
|
PFORMAT_STRING fs = This->stubless->ProcFormatString + This->stubless->FormatStringOffset[index];
|
2004-11-30 22:38:57 +01:00
|
|
|
|
unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
|
2006-11-09 23:04:48 +01:00
|
|
|
|
TRACE("(%p)->(%d)([%d bytes]) ret=%08x\n", iface, index, bytes, *(DWORD*)(args+bytes));
|
2002-10-10 23:18:29 +02:00
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
|
return NdrClientCall2(This->stubless->pStubDesc, fs, args);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-17 18:45:24 +02:00
|
|
|
|
#else /* __i386__ */
|
|
|
|
|
|
|
|
|
|
/* can't do that on this arch */
|
|
|
|
|
struct StublessThunk { int dummy; };
|
|
|
|
|
#define FILL_STUBLESS(x,idx,stk) \
|
|
|
|
|
ERR("stubless proxies are not supported on this architecture\n");
|
|
|
|
|
#define STACK_ADJUST 0
|
|
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
|
HRESULT WINAPI StdProxy_Construct(REFIID riid,
|
|
|
|
|
LPUNKNOWN pUnkOuter,
|
2006-01-20 16:15:25 +01:00
|
|
|
|
const ProxyFileInfo *ProxyInfo,
|
|
|
|
|
int Index,
|
2002-10-10 23:18:29 +02:00
|
|
|
|
LPPSFACTORYBUFFER pPSFactory,
|
|
|
|
|
LPRPCPROXYBUFFER *ppProxy,
|
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
|
{
|
|
|
|
|
StdProxyImpl *This;
|
|
|
|
|
const MIDL_STUBLESS_PROXY_INFO *stubless = NULL;
|
2006-01-20 16:15:25 +01:00
|
|
|
|
PCInterfaceName name = ProxyInfo->pNamesArray[Index];
|
|
|
|
|
CInterfaceProxyVtbl *vtbl = ProxyInfo->pProxyVtblList[Index];
|
2002-10-10 23:18:29 +02:00
|
|
|
|
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p,%p,%p,%p,%p) %s\n", pUnkOuter, vtbl, pPSFactory, ppProxy, ppvObj, name);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
|
2006-01-20 16:15:25 +01:00
|
|
|
|
/* TableVersion = 2 means it is the stubless version of CInterfaceProxyVtbl */
|
|
|
|
|
if (ProxyInfo->TableVersion > 1) {
|
2004-04-19 21:24:03 +02:00
|
|
|
|
stubless = *(const void **)vtbl;
|
|
|
|
|
vtbl = (CInterfaceProxyVtbl *)((const void **)vtbl + 1);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
TRACE("stubless=%p\n", stubless);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
|
|
|
|
|
TRACE("vtbl=%p\n", vtbl->Vtbl);
|
|
|
|
|
|
|
|
|
|
if (!IsEqualGUID(vtbl->header.piid, riid)) {
|
|
|
|
|
ERR("IID mismatch during proxy creation\n");
|
|
|
|
|
return RPC_E_UNEXPECTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(StdProxyImpl));
|
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
if (stubless) {
|
2006-01-20 16:15:25 +01:00
|
|
|
|
CInterfaceStubVtbl *svtbl = ProxyInfo->pStubVtblList[Index];
|
|
|
|
|
unsigned long i, count = svtbl->header.DispatchTableCount;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
/* Maybe the original vtbl is just modified directly to point at
|
|
|
|
|
* ObjectStublessClientXXX thunks in real Windows, but I don't like it
|
|
|
|
|
*/
|
2006-01-20 16:15:25 +01:00
|
|
|
|
TRACE("stubless thunks: count=%ld\n", count);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
This->thunks = HeapAlloc(GetProcessHeap(),0,sizeof(struct StublessThunk)*count);
|
|
|
|
|
This->PVtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPVOID)*count);
|
|
|
|
|
for (i=0; i<count; i++) {
|
|
|
|
|
struct StublessThunk *thunk = &This->thunks[i];
|
|
|
|
|
if (vtbl->Vtbl[i] == (LPVOID)-1) {
|
|
|
|
|
PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[i];
|
2004-11-30 22:38:57 +01:00
|
|
|
|
unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
|
2006-01-20 16:15:25 +01:00
|
|
|
|
TRACE("method %ld: stacksize=%d\n", i, bytes);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
FILL_STUBLESS(thunk, i, bytes)
|
|
|
|
|
This->PVtbl[i] = thunk;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
memset(thunk, 0, sizeof(struct StublessThunk));
|
|
|
|
|
This->PVtbl[i] = vtbl->Vtbl[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
This->PVtbl = vtbl->Vtbl;
|
|
|
|
|
|
|
|
|
|
This->lpVtbl = &StdProxy_Vtbl;
|
2005-09-18 13:10:37 +02:00
|
|
|
|
/* one reference for the proxy */
|
|
|
|
|
This->RefCount = 1;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
This->stubless = stubless;
|
|
|
|
|
This->piid = vtbl->header.piid;
|
|
|
|
|
This->pUnkOuter = pUnkOuter;
|
2003-05-20 06:13:44 +02:00
|
|
|
|
This->name = name;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
This->pPSFactory = pPSFactory;
|
|
|
|
|
This->pChannel = NULL;
|
|
|
|
|
*ppProxy = (LPRPCPROXYBUFFER)&This->lpVtbl;
|
|
|
|
|
*ppvObj = &This->PVtbl;
|
2006-02-07 16:24:33 +01:00
|
|
|
|
/* if there is no outer unknown then the caller will control the lifetime
|
|
|
|
|
* of the proxy object through the proxy buffer, so no need to increment the
|
|
|
|
|
* ref count of the proxy object */
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*ppvObj);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
IPSFactoryBuffer_AddRef(pPSFactory);
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void WINAPI StdProxy_Destruct(LPRPCPROXYBUFFER iface)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
|
2004-06-14 19:58:03 +02:00
|
|
|
|
if (This->pChannel)
|
|
|
|
|
IRpcProxyBuffer_Disconnect(iface);
|
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
|
IPSFactoryBuffer_Release(This->pPSFactory);
|
|
|
|
|
if (This->thunks) {
|
|
|
|
|
HeapFree(GetProcessHeap(),0,This->PVtbl);
|
|
|
|
|
HeapFree(GetProcessHeap(),0,This->thunks);
|
|
|
|
|
}
|
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI StdProxy_QueryInterface(LPRPCPROXYBUFFER iface,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *obj)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown,riid) ||
|
|
|
|
|
IsEqualGUID(This->piid,riid)) {
|
|
|
|
|
*obj = &This->PVtbl;
|
2006-08-29 22:16:44 +02:00
|
|
|
|
InterlockedIncrement(&This->RefCount);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IRpcProxyBuffer,riid)) {
|
|
|
|
|
*obj = &This->lpVtbl;
|
2006-08-29 22:16:44 +02:00
|
|
|
|
InterlockedIncrement(&This->RefCount);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG WINAPI StdProxy_AddRef(LPRPCPROXYBUFFER iface)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
TRACE("(%p)->AddRef()\n",This);
|
|
|
|
|
|
2006-08-29 22:16:44 +02:00
|
|
|
|
return InterlockedIncrement(&This->RefCount);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG WINAPI StdProxy_Release(LPRPCPROXYBUFFER iface)
|
|
|
|
|
{
|
2006-08-29 22:16:44 +02:00
|
|
|
|
ULONG refs;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
TRACE("(%p)->Release()\n",This);
|
|
|
|
|
|
2006-08-29 22:16:44 +02:00
|
|
|
|
refs = InterlockedDecrement(&This->RefCount);
|
|
|
|
|
if (!refs)
|
2002-10-10 23:18:29 +02:00
|
|
|
|
StdProxy_Destruct((LPRPCPROXYBUFFER)&This->lpVtbl);
|
2006-08-29 22:16:44 +02:00
|
|
|
|
return refs;
|
2002-10-10 23:18:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI StdProxy_Connect(LPRPCPROXYBUFFER iface,
|
|
|
|
|
LPRPCCHANNELBUFFER pChannel)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
TRACE("(%p)->Connect(%p)\n",This,pChannel);
|
|
|
|
|
|
|
|
|
|
This->pChannel = pChannel;
|
2004-06-14 19:58:03 +02:00
|
|
|
|
IRpcChannelBuffer_AddRef(pChannel);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static VOID WINAPI StdProxy_Disconnect(LPRPCPROXYBUFFER iface)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
TRACE("(%p)->Disconnect()\n",This);
|
|
|
|
|
|
2004-06-14 19:58:03 +02:00
|
|
|
|
IRpcChannelBuffer_Release(This->pChannel);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
This->pChannel = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
|
static const IRpcProxyBufferVtbl StdProxy_Vtbl =
|
2002-10-10 23:18:29 +02:00
|
|
|
|
{
|
|
|
|
|
StdProxy_QueryInterface,
|
|
|
|
|
StdProxy_AddRef,
|
|
|
|
|
StdProxy_Release,
|
|
|
|
|
StdProxy_Connect,
|
|
|
|
|
StdProxy_Disconnect
|
|
|
|
|
};
|
|
|
|
|
|
2006-08-31 18:14:34 +02:00
|
|
|
|
static void StdProxy_GetChannel(LPVOID iface,
|
2006-08-29 22:12:42 +02:00
|
|
|
|
LPRPCCHANNELBUFFER *ppChannel)
|
2002-10-10 23:18:29 +02:00
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p)->GetChannel(%p) %s\n",This,ppChannel,This->name);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
|
|
|
|
|
*ppChannel = This->pChannel;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-31 18:14:34 +02:00
|
|
|
|
static void StdProxy_GetIID(LPVOID iface,
|
2006-08-29 22:12:42 +02:00
|
|
|
|
const IID **ppiid)
|
2002-10-10 23:18:29 +02:00
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p)->GetIID(%p) %s\n",This,ppiid,This->name);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
|
|
|
|
|
*ppiid = This->piid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI IUnknown_QueryInterface_Proxy(LPUNKNOWN iface,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p)->QueryInterface(%s,%p) %s\n",This,debugstr_guid(riid),ppvObj,This->name);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
return IUnknown_QueryInterface(This->pUnkOuter,riid,ppvObj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ULONG WINAPI IUnknown_AddRef_Proxy(LPUNKNOWN iface)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p)->AddRef() %s\n",This,This->name);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
return IUnknown_AddRef(This->pUnkOuter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ULONG WINAPI IUnknown_Release_Proxy(LPUNKNOWN iface)
|
|
|
|
|
{
|
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p)->Release() %s\n",This,This->name);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
return IUnknown_Release(This->pUnkOuter);
|
|
|
|
|
}
|
2004-10-18 21:37:42 +02:00
|
|
|
|
|
2006-08-29 22:12:42 +02:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrProxyInitialize [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
void WINAPI NdrProxyInitialize(void *This,
|
|
|
|
|
PRPC_MESSAGE pRpcMsg,
|
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
|
PMIDL_STUB_DESC pStubDescriptor,
|
|
|
|
|
unsigned int ProcNum)
|
|
|
|
|
{
|
|
|
|
|
TRACE("(%p,%p,%p,%p,%d)\n", This, pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);
|
|
|
|
|
NdrClientInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);
|
2006-08-31 18:14:34 +02:00
|
|
|
|
StdProxy_GetChannel(This, &pStubMsg->pRpcChannelBuffer);
|
|
|
|
|
IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
|
|
|
|
|
&pStubMsg->dwDestContext,
|
|
|
|
|
&pStubMsg->pvDestContext);
|
2006-08-29 22:12:42 +02:00
|
|
|
|
TRACE("channel=%p\n", pStubMsg->pRpcChannelBuffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrProxyGetBuffer [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
void WINAPI NdrProxyGetBuffer(void *This,
|
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg)
|
|
|
|
|
{
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
const IID *riid = NULL;
|
|
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", This, pStubMsg);
|
|
|
|
|
pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
|
|
|
|
|
pStubMsg->dwStubPhase = PROXY_GETBUFFER;
|
2006-08-31 18:14:34 +02:00
|
|
|
|
StdProxy_GetIID(This, &riid);
|
2006-08-29 22:12:42 +02:00
|
|
|
|
hr = IRpcChannelBuffer_GetBuffer(pStubMsg->pRpcChannelBuffer,
|
|
|
|
|
(RPCOLEMESSAGE*)pStubMsg->RpcMsg,
|
|
|
|
|
riid);
|
2006-08-31 18:14:34 +02:00
|
|
|
|
if (FAILED(hr))
|
|
|
|
|
{
|
|
|
|
|
RpcRaiseException(hr);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-01-08 13:02:55 +01:00
|
|
|
|
pStubMsg->fBufferValid = TRUE;
|
2006-08-29 22:12:42 +02:00
|
|
|
|
pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
|
|
|
|
|
pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
|
|
|
|
|
pStubMsg->Buffer = pStubMsg->BufferStart;
|
|
|
|
|
pStubMsg->dwStubPhase = PROXY_MARSHAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrProxySendReceive [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
void WINAPI NdrProxySendReceive(void *This,
|
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg)
|
|
|
|
|
{
|
|
|
|
|
ULONG Status = 0;
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", This, pStubMsg);
|
|
|
|
|
|
|
|
|
|
if (!pStubMsg->pRpcChannelBuffer)
|
|
|
|
|
{
|
|
|
|
|
WARN("Trying to use disconnected proxy %p\n", This);
|
|
|
|
|
RpcRaiseException(RPC_E_DISCONNECTED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;
|
|
|
|
|
hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,
|
|
|
|
|
(RPCOLEMESSAGE*)pStubMsg->RpcMsg,
|
|
|
|
|
&Status);
|
|
|
|
|
pStubMsg->dwStubPhase = PROXY_UNMARSHAL;
|
|
|
|
|
pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
|
|
|
|
|
pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
|
|
|
|
|
pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
|
|
|
|
|
pStubMsg->Buffer = pStubMsg->BufferStart;
|
|
|
|
|
|
|
|
|
|
/* raise exception if call failed */
|
|
|
|
|
if (hr == RPC_S_CALL_FAILED) RpcRaiseException(*(DWORD*)pStubMsg->Buffer);
|
|
|
|
|
else if (FAILED(hr)) RpcRaiseException(hr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrProxyFreeBuffer [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
void WINAPI NdrProxyFreeBuffer(void *This,
|
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg)
|
|
|
|
|
{
|
|
|
|
|
TRACE("(%p,%p)\n", This, pStubMsg);
|
2008-01-08 13:02:55 +01:00
|
|
|
|
|
|
|
|
|
if (pStubMsg->fBufferValid)
|
|
|
|
|
{
|
|
|
|
|
IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer,
|
|
|
|
|
(RPCOLEMESSAGE*)pStubMsg->RpcMsg);
|
|
|
|
|
pStubMsg->fBufferValid = TRUE;
|
|
|
|
|
}
|
2006-08-29 22:12:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrProxyErrorHandler [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
HRESULT WINAPI NdrProxyErrorHandler(DWORD dwExceptionCode)
|
|
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
|
WARN("(0x%08x): a proxy call failed\n", dwExceptionCode);
|
2006-08-29 22:12:42 +02:00
|
|
|
|
|
|
|
|
|
if (FAILED(dwExceptionCode))
|
|
|
|
|
return dwExceptionCode;
|
|
|
|
|
else
|
|
|
|
|
return HRESULT_FROM_WIN32(dwExceptionCode);
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-18 21:37:42 +02:00
|
|
|
|
HRESULT WINAPI
|
|
|
|
|
CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo, LPUNKNOWN pUnkOuter, REFIID riid,
|
|
|
|
|
LPRPCPROXYBUFFER *ppProxy, LPVOID *ppv )
|
|
|
|
|
{
|
2006-07-17 21:19:38 +02:00
|
|
|
|
typedef INT (WINAPI *MessageBoxA)(HWND,LPCSTR,LPCSTR,UINT);
|
|
|
|
|
HMODULE hUser32 = LoadLibraryA("user32");
|
2007-05-24 16:41:17 +02:00
|
|
|
|
MessageBoxA pMessageBoxA = (void *)GetProcAddress(hUser32, "MessageBoxA");
|
2006-07-17 21:19:38 +02:00
|
|
|
|
|
2004-10-18 21:37:42 +02:00
|
|
|
|
FIXME("%p %p %s %p %p\n", pTypeInfo, pUnkOuter, debugstr_guid(riid), ppProxy, ppv);
|
2006-07-17 21:19:38 +02:00
|
|
|
|
if (pMessageBoxA)
|
|
|
|
|
{
|
|
|
|
|
pMessageBoxA(NULL,
|
|
|
|
|
"The native implementation of OLEAUT32.DLL cannot be used "
|
|
|
|
|
"with Wine's RPCRT4.DLL. Remove OLEAUT32.DLL and try again.\n",
|
|
|
|
|
"Wine: Unimplemented CreateProxyFromTypeInfo",
|
|
|
|
|
0x10);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
2004-10-18 21:37:42 +02:00
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
}
|