2002-10-11 00:46:08 +02:00
|
|
|
|
/*
|
|
|
|
|
* COM stub (CStdStubBuffer) 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-11 00:46:08 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
2002-10-11 00:46:08 +02:00
|
|
|
|
#include "windef.h"
|
|
|
|
|
#include "winbase.h"
|
|
|
|
|
#include "winerror.h"
|
2006-06-10 13:33:40 +02:00
|
|
|
|
#include "excpt.h"
|
2002-10-11 00:46:08 +02:00
|
|
|
|
|
2002-12-05 21:33:07 +01:00
|
|
|
|
#include "objbase.h"
|
2002-10-11 00:46:08 +02:00
|
|
|
|
#include "rpcproxy.h"
|
|
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2006-06-10 13:33:40 +02:00
|
|
|
|
#include "wine/exception.h"
|
2002-10-11 00:46:08 +02:00
|
|
|
|
|
|
|
|
|
#include "cpsf.h"
|
|
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
|
|
#define STUB_HEADER(This) (((CInterfaceStubHeader*)((This)->lpVtbl))[-1])
|
|
|
|
|
|
2006-06-10 13:33:40 +02:00
|
|
|
|
static WINE_EXCEPTION_FILTER(stub_filter)
|
|
|
|
|
{
|
|
|
|
|
if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
|
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-11 00:46:08 +02:00
|
|
|
|
HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
|
|
|
|
|
LPUNKNOWN pUnkServer,
|
2003-05-20 06:13:44 +02:00
|
|
|
|
PCInterfaceName name,
|
2002-10-11 00:46:08 +02:00
|
|
|
|
CInterfaceStubVtbl *vtbl,
|
|
|
|
|
LPPSFACTORYBUFFER pPSFactory,
|
|
|
|
|
LPRPCSTUBBUFFER *ppStub)
|
|
|
|
|
{
|
|
|
|
|
CStdStubBuffer *This;
|
|
|
|
|
|
2003-05-20 06:13:44 +02:00
|
|
|
|
TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
|
2002-10-11 00:46:08 +02:00
|
|
|
|
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 stub creation\n");
|
|
|
|
|
return RPC_E_UNEXPECTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
|
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
This->lpVtbl = &vtbl->Vtbl;
|
|
|
|
|
This->RefCount = 1;
|
|
|
|
|
This->pvServerObject = pUnkServer;
|
|
|
|
|
This->pPSFactory = pPSFactory;
|
|
|
|
|
*ppStub = (LPRPCSTUBBUFFER)This;
|
|
|
|
|
|
2003-04-19 04:49:15 +02:00
|
|
|
|
IUnknown_AddRef(This->pvServerObject);
|
2002-10-11 00:46:08 +02:00
|
|
|
|
IPSFactoryBuffer_AddRef(pPSFactory);
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *obj)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown,riid) ||
|
|
|
|
|
IsEqualGUID(&IID_IRpcStubBuffer,riid)) {
|
|
|
|
|
*obj = This;
|
|
|
|
|
This->RefCount++;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->AddRef()\n",This);
|
|
|
|
|
return ++(This->RefCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
|
|
|
|
|
LPPSFACTORYBUFFER pPSF)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->Release()\n",This);
|
|
|
|
|
|
|
|
|
|
if (!--(This->RefCount)) {
|
2005-07-19 21:12:54 +02:00
|
|
|
|
IRpcStubBuffer_Disconnect(iface);
|
2002-11-08 19:52:34 +01:00
|
|
|
|
if(This->pPSFactory)
|
|
|
|
|
IPSFactoryBuffer_Release(This->pPSFactory);
|
2002-10-11 00:46:08 +02:00
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return This->RefCount;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-26 15:56:00 +02:00
|
|
|
|
ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface,
|
|
|
|
|
LPPSFACTORYBUFFER pPSF)
|
|
|
|
|
{
|
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-11 00:46:08 +02:00
|
|
|
|
HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface,
|
|
|
|
|
LPUNKNOWN lpUnkServer)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
|
|
|
|
|
This->pvServerObject = lpUnkServer;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->Disconnect()\n",This);
|
2005-07-19 21:12:54 +02:00
|
|
|
|
if (This->pvServerObject)
|
|
|
|
|
{
|
|
|
|
|
IUnknown_Release(This->pvServerObject);
|
|
|
|
|
This->pvServerObject = NULL;
|
|
|
|
|
}
|
2002-10-11 00:46:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface,
|
|
|
|
|
PRPCOLEMESSAGE pMsg,
|
|
|
|
|
LPRPCCHANNELBUFFER pChannel)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
DWORD dwPhase = STUB_UNMARSHAL;
|
2006-06-10 13:33:40 +02:00
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
|
|
|
|
|
|
2006-06-10 13:33:40 +02:00
|
|
|
|
__TRY
|
|
|
|
|
{
|
|
|
|
|
if (STUB_HEADER(This).pDispatchTable)
|
|
|
|
|
STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
|
|
|
|
|
else /* pure interpreted */
|
|
|
|
|
NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
|
|
|
|
|
}
|
|
|
|
|
__EXCEPT(stub_filter)
|
|
|
|
|
{
|
|
|
|
|
DWORD dwExceptionCode = GetExceptionCode();
|
|
|
|
|
WARN("a stub call failed with exception 0x%08lx (%ld)\n", dwExceptionCode, dwExceptionCode);
|
|
|
|
|
if (FAILED(dwExceptionCode))
|
|
|
|
|
hr = dwExceptionCode;
|
|
|
|
|
else
|
|
|
|
|
hr = HRESULT_FROM_WIN32(dwExceptionCode);
|
|
|
|
|
}
|
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
|
|
return hr;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface,
|
|
|
|
|
REFIID riid)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
|
|
|
|
|
return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->CountRefs()\n",This);
|
|
|
|
|
return This->RefCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,
|
|
|
|
|
LPVOID *ppv)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface,
|
|
|
|
|
LPVOID pv)
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
2002-10-11 00:46:08 +02:00
|
|
|
|
TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
|
|
|
|
|
}
|
2005-11-29 10:42:04 +01:00
|
|
|
|
|
2006-01-30 14:56:07 +01:00
|
|
|
|
const IRpcStubBufferVtbl CStdStubBuffer_Vtbl =
|
|
|
|
|
{
|
|
|
|
|
CStdStubBuffer_QueryInterface,
|
|
|
|
|
CStdStubBuffer_AddRef,
|
|
|
|
|
NULL,
|
|
|
|
|
CStdStubBuffer_Connect,
|
|
|
|
|
CStdStubBuffer_Disconnect,
|
|
|
|
|
CStdStubBuffer_Invoke,
|
|
|
|
|
CStdStubBuffer_IsIIDSupported,
|
|
|
|
|
CStdStubBuffer_CountRefs,
|
|
|
|
|
CStdStubBuffer_DebugServerQueryInterface,
|
|
|
|
|
CStdStubBuffer_DebugServerRelease
|
|
|
|
|
};
|
|
|
|
|
|
2005-11-29 10:42:04 +01:00
|
|
|
|
const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface)
|
|
|
|
|
{
|
|
|
|
|
CStdStubBuffer *This = (CStdStubBuffer *)iface;
|
|
|
|
|
return STUB_HEADER(This).pServerInfo;
|
|
|
|
|
}
|