2002-10-10 23:18:29 +02:00
|
|
|
/*
|
|
|
|
* COM proxy implementation
|
|
|
|
*
|
2008-10-18 19:20:44 +02:00
|
|
|
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
2009-06-03 16:42:50 +02:00
|
|
|
* Copyright 2009 Alexandre Julliard
|
2002-10-10 23:18:29 +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-10 23:18:29 +02:00
|
|
|
*
|
|
|
|
* TODO: Handle non-i386 architectures
|
|
|
|
*/
|
|
|
|
|
2009-06-01 20:52:40 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* 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 IID* piid;
|
|
|
|
LPUNKNOWN pUnkOuter;
|
2009-06-03 16:42:50 +02:00
|
|
|
IUnknown *base_object; /* must be at offset 0x10 from PVtbl */
|
|
|
|
IRpcProxyBuffer *base_proxy;
|
2003-05-20 06:13:44 +02:00
|
|
|
PCInterfaceName name;
|
2002-10-10 23:18:29 +02:00
|
|
|
LPPSFACTORYBUFFER pPSFactory;
|
|
|
|
LPRPCCHANNELBUFFER pChannel;
|
|
|
|
} 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
|
|
|
#if defined(__i386__)
|
|
|
|
|
2004-01-09 23:18:49 +01:00
|
|
|
#include "pshpack1.h"
|
|
|
|
|
2009-06-01 21:19:56 +02:00
|
|
|
struct thunk {
|
2004-01-09 23:18:49 +01:00
|
|
|
BYTE push;
|
|
|
|
DWORD index;
|
2009-06-01 20:52:40 +02:00
|
|
|
BYTE jmp;
|
2004-01-09 23:18:49 +01:00
|
|
|
LONG handler;
|
2002-10-10 23:18:29 +02:00
|
|
|
};
|
|
|
|
|
2004-01-09 23:18:49 +01:00
|
|
|
#include "poppack.h"
|
|
|
|
|
2009-06-01 20:52:40 +02:00
|
|
|
extern void call_stubless_func(void);
|
|
|
|
__ASM_GLOBAL_FUNC(call_stubless_func,
|
|
|
|
"pushl %esp\n\t" /* pointer to index */
|
2009-06-14 15:34:24 +02:00
|
|
|
"call " __ASM_NAME("ObjectStubless") __ASM_STDCALL(4) "\n\t"
|
2009-06-01 20:52:40 +02:00
|
|
|
"popl %edx\n\t" /* args size */
|
|
|
|
"movl (%esp),%ecx\n\t" /* return address */
|
|
|
|
"addl %edx,%esp\n\t"
|
|
|
|
"jmp *%ecx" );
|
|
|
|
|
|
|
|
HRESULT WINAPI ObjectStubless(DWORD *args)
|
2002-10-10 23:18:29 +02:00
|
|
|
{
|
2009-06-01 20:52:40 +02:00
|
|
|
DWORD index = args[0];
|
2009-06-01 21:32:56 +02:00
|
|
|
void **iface = (void **)args[2];
|
|
|
|
const void **vtbl = (const void **)*iface;
|
|
|
|
const MIDL_STUBLESS_PROXY_INFO *stubless = *(const MIDL_STUBLESS_PROXY_INFO **)(vtbl - 2);
|
2009-06-01 20:52:40 +02:00
|
|
|
const PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[index];
|
2002-10-10 23:18:29 +02:00
|
|
|
|
2009-06-01 20:52:40 +02:00
|
|
|
/* store bytes to remove from stack */
|
|
|
|
args[0] = *(const WORD*)(fs + 8);
|
|
|
|
TRACE("(%p)->(%d)([%d bytes]) ret=%08x\n", iface, index, args[0], args[1]);
|
2002-10-10 23:18:29 +02:00
|
|
|
|
2009-06-01 20:52:40 +02:00
|
|
|
return NdrClientCall2(stubless->pStubDesc, fs, args + 2);
|
2002-10-10 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
2009-06-01 21:19:56 +02:00
|
|
|
#define BLOCK_SIZE 1024
|
|
|
|
#define MAX_BLOCKS 64 /* 64k methods should be enough for anybody */
|
|
|
|
|
|
|
|
static const struct thunk *method_blocks[MAX_BLOCKS];
|
|
|
|
|
|
|
|
static const struct thunk *allocate_block( unsigned int num )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct thunk *prev, *block;
|
|
|
|
|
|
|
|
block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
|
|
|
|
MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
|
|
|
|
if (!block) return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < BLOCK_SIZE; i++)
|
|
|
|
{
|
|
|
|
block[i].push = 0x68; /* pushl */
|
|
|
|
block[i].index = BLOCK_SIZE * num + i + 3;
|
|
|
|
block[i].jmp = 0xe9; /* jmp */
|
|
|
|
block[i].handler = (char *)call_stubless_func - (char *)(&block[i].handler + 1);
|
|
|
|
}
|
|
|
|
VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, NULL );
|
|
|
|
prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL );
|
|
|
|
if (prev) /* someone beat us to it */
|
|
|
|
{
|
|
|
|
VirtualFree( block, 0, MEM_RELEASE );
|
|
|
|
block = prev;
|
|
|
|
}
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL fill_stubless_table( IUnknownVtbl *vtbl, DWORD num )
|
|
|
|
{
|
|
|
|
const void **entry = (const void **)(vtbl + 1);
|
|
|
|
DWORD i, j;
|
|
|
|
|
2009-06-03 16:52:06 +02:00
|
|
|
if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
|
|
|
|
{
|
|
|
|
FIXME( "%u methods not supported\n", num );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-06-01 21:19:56 +02:00
|
|
|
for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
|
|
|
|
{
|
|
|
|
const struct thunk *block = method_blocks[i];
|
|
|
|
if (!block && !(block = allocate_block( i ))) return FALSE;
|
|
|
|
for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++)
|
|
|
|
if (*entry == (LPVOID)-1) *entry = &block[j];
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-10-17 18:45:24 +02:00
|
|
|
#else /* __i386__ */
|
|
|
|
|
2009-06-01 21:19:56 +02:00
|
|
|
static BOOL fill_stubless_table( IUnknownVtbl *vtbl, DWORD num )
|
|
|
|
{
|
|
|
|
ERR("stubless proxies are not supported on this architecture\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-10-17 18:45:24 +02:00
|
|
|
|
|
|
|
#endif /* __i386__ */
|
|
|
|
|
2009-05-27 13:04:33 +02:00
|
|
|
HRESULT StdProxy_Construct(REFIID riid,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
const ProxyFileInfo *ProxyInfo,
|
|
|
|
int Index,
|
|
|
|
LPPSFACTORYBUFFER pPSFactory,
|
|
|
|
LPRPCPROXYBUFFER *ppProxy,
|
|
|
|
LPVOID *ppvObj)
|
2002-10-10 23:18:29 +02:00
|
|
|
{
|
|
|
|
StdProxyImpl *This;
|
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) {
|
2009-06-01 21:19:56 +02:00
|
|
|
ULONG count = ProxyInfo->pStubVtblList[Index]->header.DispatchTableCount;
|
2004-04-19 21:24:03 +02:00
|
|
|
vtbl = (CInterfaceProxyVtbl *)((const void **)vtbl + 1);
|
2009-06-01 21:32:56 +02:00
|
|
|
TRACE("stubless vtbl %p: count=%d\n", vtbl->Vtbl, count );
|
2009-06-01 21:19:56 +02:00
|
|
|
fill_stubless_table( (IUnknownVtbl *)vtbl->Vtbl, count );
|
2002-10-10 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2009-05-27 21:25:10 +02:00
|
|
|
if (!pUnkOuter) pUnkOuter = (IUnknown *)This;
|
2002-10-10 23:18:29 +02:00
|
|
|
This->lpVtbl = &StdProxy_Vtbl;
|
2009-06-01 21:19:56 +02:00
|
|
|
This->PVtbl = vtbl->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->piid = vtbl->header.piid;
|
2009-06-03 16:42:50 +02:00
|
|
|
This->base_object = NULL;
|
|
|
|
This->base_proxy = NULL;
|
2002-10-10 23:18:29 +02:00
|
|
|
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;
|
2009-06-03 16:42:50 +02:00
|
|
|
|
|
|
|
if(ProxyInfo->pDelegatedIIDs && ProxyInfo->pDelegatedIIDs[Index])
|
|
|
|
{
|
|
|
|
HRESULT r = create_proxy( ProxyInfo->pDelegatedIIDs[Index], NULL,
|
|
|
|
&This->base_proxy, (void **)&This->base_object );
|
|
|
|
if (FAILED(r))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
*ppProxy = (LPRPCPROXYBUFFER)&This->lpVtbl;
|
|
|
|
*ppvObj = &This->PVtbl;
|
2009-05-27 21:25:10 +02:00
|
|
|
IUnknown_AddRef((IUnknown *)*ppvObj);
|
2002-10-10 23:18:29 +02:00
|
|
|
IPSFactoryBuffer_AddRef(pPSFactory);
|
|
|
|
|
2009-06-03 16:42:50 +02:00
|
|
|
TRACE( "iid=%s this %p proxy %p obj %p vtbl %p base proxy %p base obj %p\n",
|
|
|
|
debugstr_guid(riid), This, *ppProxy, *ppvObj, This->PVtbl, This->base_proxy, This->base_object );
|
2002-10-10 23:18:29 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:43:14 +01:00
|
|
|
static void StdProxy_Destruct(LPRPCPROXYBUFFER iface)
|
2002-10-10 23:18:29 +02:00
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
|
|
|
|
2004-06-14 19:58:03 +02:00
|
|
|
if (This->pChannel)
|
|
|
|
IRpcProxyBuffer_Disconnect(iface);
|
|
|
|
|
2009-06-03 16:42:50 +02:00
|
|
|
if (This->base_object) IUnknown_Release( This->base_object );
|
|
|
|
if (This->base_proxy) IRpcProxyBuffer_Release( This->base_proxy );
|
|
|
|
|
2002-10-10 23:18:29 +02:00
|
|
|
IPSFactoryBuffer_Release(This->pPSFactory);
|
|
|
|
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);
|
2009-06-03 16:42:50 +02:00
|
|
|
if (This->base_proxy) IRpcProxyBuffer_Connect( This->base_proxy, 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);
|
|
|
|
|
2009-06-03 16:42:50 +02:00
|
|
|
if (This->base_proxy) IRpcProxyBuffer_Disconnect( This->base_proxy );
|
|
|
|
|
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;
|
2008-07-02 00:34:12 +02:00
|
|
|
/* avoid sending uninitialised parts of the buffer on the wire */
|
|
|
|
pStubMsg->RpcMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
|
2006-08-29 22:12:42 +02:00
|
|
|
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;
|
|
|
|
}
|