mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 21:25:05 +00:00
[RPCRT4]
partial rpcrt4 sync to wine 1.1.40 (fixes crashing cstub test) svn path=/trunk/; revision=46292
This commit is contained in:
parent
7356746408
commit
69ced963a6
|
@ -2,6 +2,7 @@
|
||||||
* COM proxy implementation
|
* COM proxy implementation
|
||||||
*
|
*
|
||||||
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
||||||
|
* Copyright 2009 Alexandre Julliard
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,6 +21,9 @@
|
||||||
* TODO: Handle non-i386 architectures
|
* TODO: Handle non-i386 architectures
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "wine/port.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
|
@ -37,21 +41,19 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||||
|
|
||||||
struct StublessThunk;
|
|
||||||
|
|
||||||
/* I don't know what MS's std proxy structure looks like,
|
/* I don't know what MS's std proxy structure looks like,
|
||||||
so this probably doesn't match, but that shouldn't matter */
|
so this probably doesn't match, but that shouldn't matter */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const IRpcProxyBufferVtbl *lpVtbl;
|
const IRpcProxyBufferVtbl *lpVtbl;
|
||||||
LPVOID *PVtbl;
|
LPVOID *PVtbl;
|
||||||
LONG RefCount;
|
LONG RefCount;
|
||||||
const MIDL_STUBLESS_PROXY_INFO *stubless;
|
|
||||||
const IID* piid;
|
const IID* piid;
|
||||||
LPUNKNOWN pUnkOuter;
|
LPUNKNOWN pUnkOuter;
|
||||||
|
IUnknown *base_object; /* must be at offset 0x10 from PVtbl */
|
||||||
|
IRpcProxyBuffer *base_proxy;
|
||||||
PCInterfaceName name;
|
PCInterfaceName name;
|
||||||
LPPSFACTORYBUFFER pPSFactory;
|
LPPSFACTORYBUFFER pPSFactory;
|
||||||
LPRPCCHANNELBUFFER pChannel;
|
LPRPCCHANNELBUFFER pChannel;
|
||||||
struct StublessThunk *thunks;
|
|
||||||
} StdProxyImpl;
|
} StdProxyImpl;
|
||||||
|
|
||||||
static const IRpcProxyBufferVtbl StdProxy_Vtbl;
|
static const IRpcProxyBufferVtbl StdProxy_Vtbl;
|
||||||
|
@ -62,66 +64,111 @@ static const IRpcProxyBufferVtbl StdProxy_Vtbl;
|
||||||
|
|
||||||
#include "pshpack1.h"
|
#include "pshpack1.h"
|
||||||
|
|
||||||
struct StublessThunk {
|
struct thunk {
|
||||||
BYTE push;
|
BYTE push;
|
||||||
DWORD index;
|
DWORD index;
|
||||||
BYTE call;
|
BYTE jmp;
|
||||||
LONG handler;
|
LONG handler;
|
||||||
BYTE ret;
|
|
||||||
WORD bytes;
|
|
||||||
BYTE pad[3];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "poppack.h"
|
#include "poppack.h"
|
||||||
|
|
||||||
/* adjust the stack size since we don't use Windows's method */
|
extern void call_stubless_func(void);
|
||||||
#define STACK_ADJUST sizeof(DWORD)
|
__ASM_GLOBAL_FUNC(call_stubless_func,
|
||||||
|
"pushl %esp\n\t" /* pointer to index */
|
||||||
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
||||||
|
"call " __ASM_NAME("ObjectStubless") __ASM_STDCALL(4) "\n\t"
|
||||||
|
"popl %edx\n\t" /* args size */
|
||||||
|
__ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
|
||||||
|
"movl (%esp),%ecx\n\t" /* return address */
|
||||||
|
"addl %edx,%esp\n\t"
|
||||||
|
"jmp *%ecx" );
|
||||||
|
|
||||||
#define FILL_STUBLESS(x,idx,stk) \
|
HRESULT WINAPI ObjectStubless(DWORD *args)
|
||||||
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);
|
DWORD index = args[0];
|
||||||
LPVOID iface = *(LPVOID*)args;
|
void **iface = (void **)args[2];
|
||||||
|
const void **vtbl = (const void **)*iface;
|
||||||
|
const MIDL_STUBLESS_PROXY_INFO *stubless = *(const MIDL_STUBLESS_PROXY_INFO **)(vtbl - 2);
|
||||||
|
const PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[index];
|
||||||
|
|
||||||
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
|
/* 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]);
|
||||||
|
|
||||||
PFORMAT_STRING fs = This->stubless->ProcFormatString + This->stubless->FormatStringOffset[index];
|
return NdrClientCall2(stubless->pStubDesc, fs, args + 2);
|
||||||
unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
|
}
|
||||||
TRACE("(%p)->(%d)([%d bytes]) ret=%08x\n", iface, index, bytes, *(DWORD*)(args+bytes));
|
|
||||||
|
|
||||||
return NdrClientCall2(This->stubless->pStubDesc, fs, args);
|
#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;
|
||||||
|
|
||||||
|
if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
|
||||||
|
{
|
||||||
|
FIXME( "%u methods not supported\n", num );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* __i386__ */
|
#else /* __i386__ */
|
||||||
|
|
||||||
/* can't do that on this arch */
|
static BOOL fill_stubless_table( IUnknownVtbl *vtbl, DWORD num )
|
||||||
struct StublessThunk { int dummy; };
|
{
|
||||||
#define FILL_STUBLESS(x,idx,stk) \
|
ERR("stubless proxies are not supported on this architecture\n");
|
||||||
ERR("stubless proxies are not supported on this architecture\n");
|
return FALSE;
|
||||||
#define STACK_ADJUST 0
|
}
|
||||||
|
|
||||||
#endif /* __i386__ */
|
#endif /* __i386__ */
|
||||||
|
|
||||||
HRESULT WINAPI StdProxy_Construct(REFIID riid,
|
HRESULT StdProxy_Construct(REFIID riid,
|
||||||
LPUNKNOWN pUnkOuter,
|
LPUNKNOWN pUnkOuter,
|
||||||
const ProxyFileInfo *ProxyInfo,
|
const ProxyFileInfo *ProxyInfo,
|
||||||
int Index,
|
int Index,
|
||||||
LPPSFACTORYBUFFER pPSFactory,
|
LPPSFACTORYBUFFER pPSFactory,
|
||||||
LPRPCPROXYBUFFER *ppProxy,
|
LPRPCPROXYBUFFER *ppProxy,
|
||||||
LPVOID *ppvObj)
|
LPVOID *ppvObj)
|
||||||
{
|
{
|
||||||
StdProxyImpl *This;
|
StdProxyImpl *This;
|
||||||
const MIDL_STUBLESS_PROXY_INFO *stubless = NULL;
|
|
||||||
PCInterfaceName name = ProxyInfo->pNamesArray[Index];
|
PCInterfaceName name = ProxyInfo->pNamesArray[Index];
|
||||||
CInterfaceProxyVtbl *vtbl = ProxyInfo->pProxyVtblList[Index];
|
CInterfaceProxyVtbl *vtbl = ProxyInfo->pProxyVtblList[Index];
|
||||||
|
|
||||||
|
@ -129,14 +176,12 @@ HRESULT WINAPI StdProxy_Construct(REFIID riid,
|
||||||
|
|
||||||
/* TableVersion = 2 means it is the stubless version of CInterfaceProxyVtbl */
|
/* TableVersion = 2 means it is the stubless version of CInterfaceProxyVtbl */
|
||||||
if (ProxyInfo->TableVersion > 1) {
|
if (ProxyInfo->TableVersion > 1) {
|
||||||
stubless = *(const void **)vtbl;
|
ULONG count = ProxyInfo->pStubVtblList[Index]->header.DispatchTableCount;
|
||||||
vtbl = (CInterfaceProxyVtbl *)((const void **)vtbl + 1);
|
vtbl = (CInterfaceProxyVtbl *)((const void **)vtbl + 1);
|
||||||
TRACE("stubless=%p\n", stubless);
|
TRACE("stubless vtbl %p: count=%d\n", vtbl->Vtbl, count );
|
||||||
|
fill_stubless_table( (IUnknownVtbl *)vtbl->Vtbl, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
|
|
||||||
TRACE("vtbl=%p\n", vtbl->Vtbl);
|
|
||||||
|
|
||||||
if (!IsEqualGUID(vtbl->header.piid, riid)) {
|
if (!IsEqualGUID(vtbl->header.piid, riid)) {
|
||||||
ERR("IID mismatch during proxy creation\n");
|
ERR("IID mismatch during proxy creation\n");
|
||||||
return RPC_E_UNEXPECTED;
|
return RPC_E_UNEXPECTED;
|
||||||
|
@ -145,51 +190,37 @@ HRESULT WINAPI StdProxy_Construct(REFIID riid,
|
||||||
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(StdProxyImpl));
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(StdProxyImpl));
|
||||||
if (!This) return E_OUTOFMEMORY;
|
if (!This) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
if (stubless) {
|
if (!pUnkOuter) pUnkOuter = (IUnknown *)This;
|
||||||
CInterfaceStubVtbl *svtbl = ProxyInfo->pStubVtblList[Index];
|
|
||||||
unsigned long i, count = svtbl->header.DispatchTableCount;
|
|
||||||
/* Maybe the original vtbl is just modified directly to point at
|
|
||||||
* ObjectStublessClientXXX thunks in real Windows, but I don't like it
|
|
||||||
*/
|
|
||||||
TRACE("stubless thunks: count=%ld\n", count);
|
|
||||||
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];
|
|
||||||
unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
|
|
||||||
TRACE("method %ld: stacksize=%d\n", i, bytes);
|
|
||||||
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;
|
This->lpVtbl = &StdProxy_Vtbl;
|
||||||
|
This->PVtbl = vtbl->Vtbl;
|
||||||
/* one reference for the proxy */
|
/* one reference for the proxy */
|
||||||
This->RefCount = 1;
|
This->RefCount = 1;
|
||||||
This->stubless = stubless;
|
|
||||||
This->piid = vtbl->header.piid;
|
This->piid = vtbl->header.piid;
|
||||||
|
This->base_object = NULL;
|
||||||
|
This->base_proxy = NULL;
|
||||||
This->pUnkOuter = pUnkOuter;
|
This->pUnkOuter = pUnkOuter;
|
||||||
This->name = name;
|
This->name = name;
|
||||||
This->pPSFactory = pPSFactory;
|
This->pPSFactory = pPSFactory;
|
||||||
This->pChannel = NULL;
|
This->pChannel = NULL;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*ppProxy = (LPRPCPROXYBUFFER)&This->lpVtbl;
|
*ppProxy = (LPRPCPROXYBUFFER)&This->lpVtbl;
|
||||||
*ppvObj = &This->PVtbl;
|
*ppvObj = &This->PVtbl;
|
||||||
/* if there is no outer unknown then the caller will control the lifetime
|
IUnknown_AddRef((IUnknown *)*ppvObj);
|
||||||
* 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);
|
|
||||||
IPSFactoryBuffer_AddRef(pPSFactory);
|
IPSFactoryBuffer_AddRef(pPSFactory);
|
||||||
|
|
||||||
|
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 );
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +231,10 @@ static void StdProxy_Destruct(LPRPCPROXYBUFFER iface)
|
||||||
if (This->pChannel)
|
if (This->pChannel)
|
||||||
IRpcProxyBuffer_Disconnect(iface);
|
IRpcProxyBuffer_Disconnect(iface);
|
||||||
|
|
||||||
|
if (This->base_object) IUnknown_Release( This->base_object );
|
||||||
|
if (This->base_proxy) IRpcProxyBuffer_Release( This->base_proxy );
|
||||||
|
|
||||||
IPSFactoryBuffer_Release(This->pPSFactory);
|
IPSFactoryBuffer_Release(This->pPSFactory);
|
||||||
if (This->thunks) {
|
|
||||||
HeapFree(GetProcessHeap(),0,This->PVtbl);
|
|
||||||
HeapFree(GetProcessHeap(),0,This->thunks);
|
|
||||||
}
|
|
||||||
HeapFree(GetProcessHeap(),0,This);
|
HeapFree(GetProcessHeap(),0,This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +289,7 @@ static HRESULT WINAPI StdProxy_Connect(LPRPCPROXYBUFFER iface,
|
||||||
|
|
||||||
This->pChannel = pChannel;
|
This->pChannel = pChannel;
|
||||||
IRpcChannelBuffer_AddRef(pChannel);
|
IRpcChannelBuffer_AddRef(pChannel);
|
||||||
|
if (This->base_proxy) IRpcProxyBuffer_Connect( This->base_proxy, pChannel );
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +298,8 @@ static VOID WINAPI StdProxy_Disconnect(LPRPCPROXYBUFFER iface)
|
||||||
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface);
|
||||||
TRACE("(%p)->Disconnect()\n",This);
|
TRACE("(%p)->Disconnect()\n",This);
|
||||||
|
|
||||||
|
if (This->base_proxy) IRpcProxyBuffer_Disconnect( This->base_proxy );
|
||||||
|
|
||||||
IRpcChannelBuffer_Release(This->pChannel);
|
IRpcChannelBuffer_Release(This->pChannel);
|
||||||
This->pChannel = NULL;
|
This->pChannel = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,41 @@ static const IPSFactoryBufferVtbl CStdPSFactory_Vtbl =
|
||||||
CStdPSFactory_CreateStub
|
CStdPSFactory_CreateStub
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void init_psfactory( CStdPSFactoryBuffer *psfac, const ProxyFileInfo **file_list )
|
||||||
|
{
|
||||||
|
DWORD i, j, k;
|
||||||
|
|
||||||
|
psfac->lpVtbl = &CStdPSFactory_Vtbl;
|
||||||
|
psfac->RefCount = 0;
|
||||||
|
psfac->pProxyFileList = file_list;
|
||||||
|
for (i = 0; file_list[i]; i++)
|
||||||
|
{
|
||||||
|
const PCInterfaceProxyVtblList *proxies = file_list[i]->pProxyVtblList;
|
||||||
|
const PCInterfaceStubVtblList *stubs = file_list[i]->pStubVtblList;
|
||||||
|
|
||||||
|
for (j = 0; j < file_list[i]->TableSize; j++)
|
||||||
|
{
|
||||||
|
/* FIXME: i think that different vtables should be copied for
|
||||||
|
* async interfaces */
|
||||||
|
void * const *pSrcRpcStubVtbl = (void * const *)&CStdStubBuffer_Vtbl;
|
||||||
|
void **pRpcStubVtbl = (void **)&stubs[j]->Vtbl;
|
||||||
|
|
||||||
|
if (file_list[i]->pDelegatedIIDs && file_list[i]->pDelegatedIIDs[j])
|
||||||
|
{
|
||||||
|
void **vtbl = proxies[j]->Vtbl;
|
||||||
|
if (file_list[i]->TableVersion > 1) vtbl++;
|
||||||
|
fill_delegated_proxy_table( (IUnknownVtbl *)vtbl, stubs[j]->header.DispatchTableCount );
|
||||||
|
pSrcRpcStubVtbl = (void * const *)&CStdStubBuffer_Delegating_Vtbl;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < sizeof(IRpcStubBufferVtbl)/sizeof(void *); k++)
|
||||||
|
if (!pRpcStubVtbl[k]) pRpcStubVtbl[k] = pSrcRpcStubVtbl[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* NdrDllGetClassObject [RPCRT4.@]
|
* NdrDllGetClassObject [RPCRT4.@]
|
||||||
*/
|
*/
|
||||||
|
@ -158,35 +193,8 @@ HRESULT WINAPI NdrDllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv,
|
||||||
pPSFactoryBuffer);
|
pPSFactoryBuffer);
|
||||||
|
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
if (!pPSFactoryBuffer->lpVtbl) {
|
if (!pPSFactoryBuffer->lpVtbl) init_psfactory( pPSFactoryBuffer, pProxyFileList );
|
||||||
const ProxyFileInfo **pProxyFileList2;
|
|
||||||
DWORD max_delegating_vtbl_size = 0;
|
|
||||||
pPSFactoryBuffer->lpVtbl = &CStdPSFactory_Vtbl;
|
|
||||||
pPSFactoryBuffer->RefCount = 0;
|
|
||||||
pPSFactoryBuffer->pProxyFileList = pProxyFileList;
|
|
||||||
for (pProxyFileList2 = pProxyFileList; *pProxyFileList2; pProxyFileList2++) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < (*pProxyFileList2)->TableSize; i++) {
|
|
||||||
/* FIXME: i think that different vtables should be copied for
|
|
||||||
* async interfaces */
|
|
||||||
void * const *pSrcRpcStubVtbl = (void * const *)&CStdStubBuffer_Vtbl;
|
|
||||||
void **pRpcStubVtbl = (void **)&(*pProxyFileList2)->pStubVtblList[i]->Vtbl;
|
|
||||||
unsigned int j;
|
|
||||||
|
|
||||||
if ((*pProxyFileList2)->pDelegatedIIDs && (*pProxyFileList2)->pDelegatedIIDs[i]) {
|
|
||||||
pSrcRpcStubVtbl = (void * const *)&CStdStubBuffer_Delegating_Vtbl;
|
|
||||||
if ((*pProxyFileList2)->pStubVtblList[i]->header.DispatchTableCount > max_delegating_vtbl_size)
|
|
||||||
max_delegating_vtbl_size = (*pProxyFileList2)->pStubVtblList[i]->header.DispatchTableCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < sizeof(IRpcStubBufferVtbl)/sizeof(void *); j++)
|
|
||||||
if (!pRpcStubVtbl[j])
|
|
||||||
pRpcStubVtbl[j] = pSrcRpcStubVtbl[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(max_delegating_vtbl_size > 0)
|
|
||||||
create_delegating_vtbl(max_delegating_vtbl_size);
|
|
||||||
}
|
|
||||||
if (pclsid && IsEqualGUID(rclsid, pclsid))
|
if (pclsid && IsEqualGUID(rclsid, pclsid))
|
||||||
return IPSFactoryBuffer_QueryInterface((LPPSFACTORYBUFFER)pPSFactoryBuffer, iid, ppv);
|
return IPSFactoryBuffer_QueryInterface((LPPSFACTORYBUFFER)pPSFactoryBuffer, iid, ppv);
|
||||||
else {
|
else {
|
||||||
|
@ -207,7 +215,7 @@ HRESULT WINAPI NdrDllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv,
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer)
|
HRESULT WINAPI NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer)
|
||||||
{
|
{
|
||||||
return !(pPSFactoryBuffer->RefCount);
|
return pPSFactoryBuffer->RefCount != 0 ? S_FALSE : S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,7 +274,7 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
|
||||||
if (len && len < sizeof(module)) {
|
if (len && len < sizeof(module)) {
|
||||||
TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module));
|
TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module));
|
||||||
if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {
|
if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {
|
||||||
RegSetValueExW(subkey, NULL, 0, REG_SZ, (const BYTE *)psfactoryW, sizeof(psfactoryW));
|
RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)psfactoryW, sizeof(psfactoryW));
|
||||||
if (RegCreateKeyW(key, inprocserverW, &subkey) == ERROR_SUCCESS) {
|
if (RegCreateKeyW(key, inprocserverW, &subkey) == ERROR_SUCCESS) {
|
||||||
RegSetValueExW(subkey, NULL, 0, REG_SZ, (LPBYTE)module, (strlenW(module)+1)*sizeof(WCHAR));
|
RegSetValueExW(subkey, NULL, 0, REG_SZ, (LPBYTE)module, (strlenW(module)+1)*sizeof(WCHAR));
|
||||||
RegSetValueExW(subkey, threadingmodelW, 0, REG_SZ, (const BYTE *)bothW, sizeof(bothW));
|
RegSetValueExW(subkey, threadingmodelW, 0, REG_SZ, (const BYTE *)bothW, sizeof(bothW));
|
||||||
|
|
|
@ -21,36 +21,25 @@
|
||||||
#ifndef __WINE_CPSF_H
|
#ifndef __WINE_CPSF_H
|
||||||
#define __WINE_CPSF_H
|
#define __WINE_CPSF_H
|
||||||
|
|
||||||
HRESULT WINAPI StdProxy_Construct(REFIID riid,
|
HRESULT StdProxy_Construct(REFIID riid, LPUNKNOWN pUnkOuter, const ProxyFileInfo *ProxyInfo,
|
||||||
LPUNKNOWN pUnkOuter,
|
int Index, LPPSFACTORYBUFFER pPSFactory, LPRPCPROXYBUFFER *ppProxy,
|
||||||
const ProxyFileInfo *ProxyInfo,
|
LPVOID *ppvObj);
|
||||||
int Index,
|
|
||||||
LPPSFACTORYBUFFER pPSFactory,
|
|
||||||
LPRPCPROXYBUFFER *ppProxy,
|
|
||||||
LPVOID *ppvObj);
|
|
||||||
|
|
||||||
HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
|
HRESULT CStdStubBuffer_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name,
|
||||||
LPUNKNOWN pUnkServer,
|
CInterfaceStubVtbl *vtbl, LPPSFACTORYBUFFER pPSFactory,
|
||||||
PCInterfaceName name,
|
LPRPCSTUBBUFFER *ppStub);
|
||||||
CInterfaceStubVtbl *vtbl,
|
|
||||||
LPPSFACTORYBUFFER pPSFactory,
|
|
||||||
LPRPCSTUBBUFFER *ppStub);
|
|
||||||
|
|
||||||
HRESULT WINAPI CStdStubBuffer_Delegating_Construct(REFIID riid,
|
HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name,
|
||||||
LPUNKNOWN pUnkServer,
|
CInterfaceStubVtbl *vtbl, REFIID delegating_iid,
|
||||||
PCInterfaceName name,
|
LPPSFACTORYBUFFER pPSFactory, LPRPCSTUBBUFFER *ppStub);
|
||||||
CInterfaceStubVtbl *vtbl,
|
|
||||||
REFIID delegating_iid,
|
|
||||||
LPPSFACTORYBUFFER pPSFactory,
|
|
||||||
LPRPCSTUBBUFFER *ppStub);
|
|
||||||
|
|
||||||
const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface);
|
const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface);
|
||||||
|
|
||||||
const IRpcStubBufferVtbl CStdStubBuffer_Vtbl;
|
const IRpcStubBufferVtbl CStdStubBuffer_Vtbl;
|
||||||
const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl;
|
const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl;
|
||||||
|
|
||||||
void create_delegating_vtbl(DWORD num_methods);
|
BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num);
|
||||||
|
HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, void **ppv);
|
||||||
HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub);
|
HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub);
|
||||||
|
|
||||||
#endif /* __WINE_CPSF_H */
|
#endif /* __WINE_CPSF_H */
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* COM stub (CStdStubBuffer) implementation
|
* COM stub (CStdStubBuffer) implementation
|
||||||
*
|
*
|
||||||
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
||||||
|
* Copyright 2009 Alexandre Julliard
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -61,12 +62,12 @@ static inline cstdstubbuffer_delegating_t *impl_from_delegating( IRpcStubBuffer
|
||||||
return (cstdstubbuffer_delegating_t*)((char *)iface - FIELD_OFFSET(cstdstubbuffer_delegating_t, stub_buffer));
|
return (cstdstubbuffer_delegating_t*)((char *)iface - FIELD_OFFSET(cstdstubbuffer_delegating_t, stub_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
|
HRESULT CStdStubBuffer_Construct(REFIID riid,
|
||||||
LPUNKNOWN pUnkServer,
|
LPUNKNOWN pUnkServer,
|
||||||
PCInterfaceName name,
|
PCInterfaceName name,
|
||||||
CInterfaceStubVtbl *vtbl,
|
CInterfaceStubVtbl *vtbl,
|
||||||
LPPSFACTORYBUFFER pPSFactory,
|
LPPSFACTORYBUFFER pPSFactory,
|
||||||
LPRPCSTUBBUFFER *ppStub)
|
LPRPCSTUBBUFFER *ppStub)
|
||||||
{
|
{
|
||||||
CStdStubBuffer *This;
|
CStdStubBuffer *This;
|
||||||
IUnknown *pvServer;
|
IUnknown *pvServer;
|
||||||
|
@ -113,20 +114,16 @@ typedef struct
|
||||||
{
|
{
|
||||||
DWORD ref;
|
DWORD ref;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
void **methods;
|
|
||||||
IUnknownVtbl vtbl;
|
IUnknownVtbl vtbl;
|
||||||
/* remaining entries in vtbl */
|
/* remaining entries in vtbl */
|
||||||
} ref_counted_vtbl;
|
} ref_counted_vtbl;
|
||||||
|
|
||||||
static struct
|
static ref_counted_vtbl *current_vtbl;
|
||||||
{
|
|
||||||
ref_counted_vtbl *table;
|
|
||||||
} current_vtbl;
|
|
||||||
|
|
||||||
|
|
||||||
static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv)
|
static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv)
|
||||||
{
|
{
|
||||||
*ppv = (void *)pUnk;
|
*ppv = pUnk;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,87 +158,137 @@ typedef struct {
|
||||||
} vtbl_method_t;
|
} vtbl_method_t;
|
||||||
#include "poppack.h"
|
#include "poppack.h"
|
||||||
|
|
||||||
static void fill_table(IUnknownVtbl *vtbl, void **methods, DWORD num)
|
#define BLOCK_SIZE 1024
|
||||||
{
|
#define MAX_BLOCKS 64 /* 64k methods should be enough for anybody */
|
||||||
vtbl_method_t *method;
|
|
||||||
void **entry;
|
|
||||||
DWORD i;
|
|
||||||
|
|
||||||
|
static const vtbl_method_t *method_blocks[MAX_BLOCKS];
|
||||||
|
|
||||||
|
static const vtbl_method_t *allocate_block( unsigned int num )
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
vtbl_method_t *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].mov1 = 0x0424448b;
|
||||||
|
block[i].mov2 = 0x408b;
|
||||||
|
block[i].sixteen = 0x10;
|
||||||
|
block[i].mov3 = 0x04244489;
|
||||||
|
block[i].mov4 = 0x008b;
|
||||||
|
block[i].mov5 = 0x808b;
|
||||||
|
block[i].offset = (BLOCK_SIZE * num + i + 3) << 2;
|
||||||
|
block[i].jmp = 0xe0ff;
|
||||||
|
block[i].pad[0] = 0x8d;
|
||||||
|
block[i].pad[1] = 0x76;
|
||||||
|
block[i].pad[2] = 0x00;
|
||||||
|
}
|
||||||
|
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_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
|
||||||
|
{
|
||||||
|
const void **entry = (const void **)(vtbl + 1);
|
||||||
|
DWORD i, j;
|
||||||
|
|
||||||
|
if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
|
||||||
|
{
|
||||||
|
FIXME( "%u methods not supported\n", num );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
vtbl->QueryInterface = delegating_QueryInterface;
|
vtbl->QueryInterface = delegating_QueryInterface;
|
||||||
vtbl->AddRef = delegating_AddRef;
|
vtbl->AddRef = delegating_AddRef;
|
||||||
vtbl->Release = delegating_Release;
|
vtbl->Release = delegating_Release;
|
||||||
|
for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
|
||||||
method = (vtbl_method_t*)methods;
|
|
||||||
entry = (void**)(vtbl + 1);
|
|
||||||
|
|
||||||
for(i = 3; i < num; i++)
|
|
||||||
{
|
{
|
||||||
*entry = method;
|
const vtbl_method_t *block = method_blocks[i];
|
||||||
method->mov1 = 0x0424448b;
|
if (!block && !(block = allocate_block( i ))) return FALSE;
|
||||||
method->mov2 = 0x408b;
|
for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++) *entry++ = &block[j];
|
||||||
method->sixteen = 0x10;
|
|
||||||
method->mov3 = 0x04244489;
|
|
||||||
method->mov4 = 0x008b;
|
|
||||||
method->mov5 = 0x808b;
|
|
||||||
method->offset = i << 2;
|
|
||||||
method->jmp = 0xe0ff;
|
|
||||||
method->pad[0] = 0x8d;
|
|
||||||
method->pad[1] = 0x76;
|
|
||||||
method->pad[2] = 0x00;
|
|
||||||
|
|
||||||
method++;
|
|
||||||
entry++;
|
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
|
||||||
|
{
|
||||||
|
const void **entry = (const void **)(vtbl + 1);
|
||||||
|
DWORD i, j;
|
||||||
|
|
||||||
|
if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
|
||||||
|
{
|
||||||
|
FIXME( "%u methods not supported\n", num );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
vtbl->QueryInterface = IUnknown_QueryInterface_Proxy;
|
||||||
|
vtbl->AddRef = IUnknown_AddRef_Proxy;
|
||||||
|
vtbl->Release = IUnknown_Release_Proxy;
|
||||||
|
for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
|
||||||
|
{
|
||||||
|
const vtbl_method_t *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) *entry = &block[j];
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* __i386__ */
|
#else /* __i386__ */
|
||||||
|
|
||||||
typedef struct {int dummy;} vtbl_method_t;
|
static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
|
||||||
static void fill_table(IUnknownVtbl *vtbl, void **methods, DWORD num)
|
|
||||||
{
|
{
|
||||||
ERR("delegated stubs are not supported on this architecture\n");
|
ERR("delegated stubs are not supported on this architecture\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
|
||||||
|
{
|
||||||
|
ERR("delegated proxies are not supported on this architecture\n");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __i386__ */
|
#endif /* __i386__ */
|
||||||
|
|
||||||
void create_delegating_vtbl(DWORD num_methods)
|
static IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
|
||||||
{
|
|
||||||
TRACE("%d\n", num_methods);
|
|
||||||
if(num_methods <= 3)
|
|
||||||
{
|
|
||||||
ERR("should have more than %d methods\n", num_methods);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnterCriticalSection(&delegating_vtbl_section);
|
|
||||||
if(!current_vtbl.table || num_methods > current_vtbl.table->size)
|
|
||||||
{
|
|
||||||
DWORD size;
|
|
||||||
DWORD old_protect;
|
|
||||||
if(current_vtbl.table && current_vtbl.table->ref == 0)
|
|
||||||
{
|
|
||||||
TRACE("freeing old table\n");
|
|
||||||
VirtualFree(current_vtbl.table->methods, 0, MEM_RELEASE);
|
|
||||||
HeapFree(GetProcessHeap(), 0, current_vtbl.table);
|
|
||||||
}
|
|
||||||
size = (num_methods - 3) * sizeof(vtbl_method_t);
|
|
||||||
current_vtbl.table = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
|
|
||||||
current_vtbl.table->ref = 0;
|
|
||||||
current_vtbl.table->size = num_methods;
|
|
||||||
current_vtbl.table->methods = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
|
||||||
fill_table(¤t_vtbl.table->vtbl, current_vtbl.table->methods, num_methods);
|
|
||||||
VirtualProtect(current_vtbl.table->methods, size, PAGE_EXECUTE_READ, &old_protect);
|
|
||||||
}
|
|
||||||
LeaveCriticalSection(&delegating_vtbl_section);
|
|
||||||
}
|
|
||||||
|
|
||||||
static IUnknownVtbl *get_delegating_vtbl(void)
|
|
||||||
{
|
{
|
||||||
IUnknownVtbl *ret;
|
IUnknownVtbl *ret;
|
||||||
|
|
||||||
|
if (num_methods < 256) num_methods = 256; /* avoid frequent reallocations */
|
||||||
|
|
||||||
EnterCriticalSection(&delegating_vtbl_section);
|
EnterCriticalSection(&delegating_vtbl_section);
|
||||||
current_vtbl.table->ref++;
|
|
||||||
ret = ¤t_vtbl.table->vtbl;
|
if(!current_vtbl || num_methods > current_vtbl->size)
|
||||||
|
{
|
||||||
|
ref_counted_vtbl *table = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
|
||||||
|
if (!table)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&delegating_vtbl_section);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
table->ref = 0;
|
||||||
|
table->size = num_methods;
|
||||||
|
fill_delegated_stub_table(&table->vtbl, num_methods);
|
||||||
|
|
||||||
|
if (current_vtbl && current_vtbl->ref == 0)
|
||||||
|
{
|
||||||
|
TRACE("freeing old table\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, current_vtbl);
|
||||||
|
}
|
||||||
|
current_vtbl = table;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_vtbl->ref++;
|
||||||
|
ret = ¤t_vtbl->vtbl;
|
||||||
LeaveCriticalSection(&delegating_vtbl_section);
|
LeaveCriticalSection(&delegating_vtbl_section);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -253,22 +300,21 @@ static void release_delegating_vtbl(IUnknownVtbl *vtbl)
|
||||||
EnterCriticalSection(&delegating_vtbl_section);
|
EnterCriticalSection(&delegating_vtbl_section);
|
||||||
table->ref--;
|
table->ref--;
|
||||||
TRACE("ref now %d\n", table->ref);
|
TRACE("ref now %d\n", table->ref);
|
||||||
if(table->ref == 0 && table != current_vtbl.table)
|
if(table->ref == 0 && table != current_vtbl)
|
||||||
{
|
{
|
||||||
TRACE("... and we're not current so free'ing\n");
|
TRACE("... and we're not current so free'ing\n");
|
||||||
VirtualFree(current_vtbl.table->methods, 0, MEM_RELEASE);
|
|
||||||
HeapFree(GetProcessHeap(), 0, table);
|
HeapFree(GetProcessHeap(), 0, table);
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&delegating_vtbl_section);
|
LeaveCriticalSection(&delegating_vtbl_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI CStdStubBuffer_Delegating_Construct(REFIID riid,
|
HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid,
|
||||||
LPUNKNOWN pUnkServer,
|
LPUNKNOWN pUnkServer,
|
||||||
PCInterfaceName name,
|
PCInterfaceName name,
|
||||||
CInterfaceStubVtbl *vtbl,
|
CInterfaceStubVtbl *vtbl,
|
||||||
REFIID delegating_iid,
|
REFIID delegating_iid,
|
||||||
LPPSFACTORYBUFFER pPSFactory,
|
LPPSFACTORYBUFFER pPSFactory,
|
||||||
LPRPCSTUBBUFFER *ppStub)
|
LPRPCSTUBBUFFER *ppStub)
|
||||||
{
|
{
|
||||||
cstdstubbuffer_delegating_t *This;
|
cstdstubbuffer_delegating_t *This;
|
||||||
IUnknown *pvServer;
|
IUnknown *pvServer;
|
||||||
|
@ -294,7 +340,7 @@ HRESULT WINAPI CStdStubBuffer_Delegating_Construct(REFIID riid,
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
This->base_obj = get_delegating_vtbl();
|
This->base_obj = get_delegating_vtbl( vtbl->header.DispatchTableCount );
|
||||||
r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
|
r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
|
||||||
if(FAILED(r))
|
if(FAILED(r))
|
||||||
{
|
{
|
||||||
|
|
|
@ -369,6 +369,30 @@ void WINAPI NdrOleFree(void *NodeToFree)
|
||||||
COM_MemFree(NodeToFree);
|
COM_MemFree(NodeToFree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Helper function to create a stub.
|
* Helper function to create a stub.
|
||||||
* This probably looks very much like NdrpCreateStub.
|
* This probably looks very much like NdrpCreateStub.
|
||||||
|
|
Loading…
Reference in a new issue