2002-02-05 19:11:17 +01:00
|
|
|
/*
|
|
|
|
* TYPELIB Marshaler
|
|
|
|
*
|
2005-03-29 15:06:44 +02:00
|
|
|
* Copyright 2002,2005 Marcus Meissner
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
2004-06-18 01:03:26 +02:00
|
|
|
* The olerelay debug channel allows you to see calls marshalled by
|
|
|
|
* the typelib marshaller. It is not a generic COM relaying system.
|
|
|
|
*
|
2002-03-10 00:29:33 +01: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-02-05 19:11:17 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2008-04-29 20:18:49 +02:00
|
|
|
#include "wine/port.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-02-05 19:11:17 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2003-08-20 20:22:31 +02:00
|
|
|
#include "winbase.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
|
|
|
|
#include "ole2.h"
|
2006-05-10 13:11:22 +02:00
|
|
|
#include "propidl.h" /* for LPSAFEARRAY_User* functions */
|
2002-02-05 19:11:17 +01:00
|
|
|
#include "typelib.h"
|
2006-01-27 12:54:03 +01:00
|
|
|
#include "variant.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2006-07-17 21:19:27 +02:00
|
|
|
#include "wine/exception.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2005-03-27 19:51:59 +02:00
|
|
|
static const WCHAR IDispatchW[] = { 'I','D','i','s','p','a','t','c','h',0};
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(olerelay);
|
2002-02-05 19:11:17 +01: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))
|
|
|
|
|
2007-02-06 20:19:56 +01:00
|
|
|
static HRESULT TMarshalDispatchChannel_Create(
|
|
|
|
IRpcChannelBuffer *pDelegateChannel, REFIID tmarshal_riid,
|
|
|
|
IRpcChannelBuffer **ppChannel);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
typedef struct _marshal_state {
|
|
|
|
LPBYTE base;
|
|
|
|
int size;
|
|
|
|
int curoff;
|
|
|
|
} marshal_state;
|
|
|
|
|
2004-06-18 01:03:26 +02:00
|
|
|
/* used in the olerelay code to avoid having the L"" stuff added by debugstr_w */
|
|
|
|
static char *relaystr(WCHAR *in) {
|
|
|
|
char *tmp = (char *)debugstr_w(in);
|
|
|
|
tmp += 2;
|
|
|
|
tmp[strlen(tmp)-1] = '\0';
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
static HRESULT
|
2006-05-10 12:55:37 +02:00
|
|
|
xbuf_resize(marshal_state *buf, DWORD newsize)
|
|
|
|
{
|
|
|
|
if(buf->size >= newsize)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
if(buf->base)
|
|
|
|
{
|
|
|
|
buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize);
|
|
|
|
if(!buf->base)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf->base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newsize);
|
|
|
|
if(!buf->base)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2006-05-15 11:02:48 +02:00
|
|
|
buf->size = newsize;
|
2006-05-10 12:55:37 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
2007-07-25 22:37:23 +02:00
|
|
|
xbuf_add(marshal_state *buf, const BYTE *stuff, DWORD size)
|
2006-05-10 12:55:37 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(buf->size - buf->curoff < size)
|
|
|
|
{
|
|
|
|
hr = xbuf_resize(buf, buf->size + size + 100);
|
|
|
|
if(FAILED(hr)) return hr;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
memcpy(buf->base+buf->curoff,stuff,size);
|
|
|
|
buf->curoff += size;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
xbuf_get(marshal_state *buf, LPBYTE stuff, DWORD size) {
|
|
|
|
if (buf->size < buf->curoff+size) return E_FAIL;
|
|
|
|
memcpy(stuff,buf->base+buf->curoff,size);
|
|
|
|
buf->curoff += size;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
xbuf_skip(marshal_state *buf, DWORD size) {
|
|
|
|
if (buf->size < buf->curoff+size) return E_FAIL;
|
|
|
|
buf->curoff += size;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
_unmarshal_interface(marshal_state *buf, REFIID riid, LPUNKNOWN *pUnk) {
|
|
|
|
IStream *pStm;
|
|
|
|
ULARGE_INTEGER newpos;
|
|
|
|
LARGE_INTEGER seekto;
|
|
|
|
ULONG res;
|
|
|
|
HRESULT hres;
|
|
|
|
DWORD xsize;
|
|
|
|
|
|
|
|
TRACE("...%s...\n",debugstr_guid(riid));
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
*pUnk = NULL;
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&xsize,sizeof(xsize));
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) {
|
|
|
|
ERR("xbuf_get failed\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
if (xsize == 0) return S_OK;
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Stream create failed %x\n",hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = IStream_Write(pStm,buf->base+buf->curoff,xsize,&res);
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("stream write %x\n",hres);
|
2005-01-27 12:11:32 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
memset(&seekto,0,sizeof(seekto));
|
|
|
|
hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed Seek %x\n",hres);
|
2005-01-27 12:11:32 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = CoUnmarshalInterface(pStm,riid,(LPVOID*)pUnk);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Unmarshalling interface %s failed with %x\n",debugstr_guid(riid),hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
IStream_Release(pStm);
|
|
|
|
return xbuf_skip(buf,xsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
_marshal_interface(marshal_state *buf, REFIID riid, LPUNKNOWN pUnk) {
|
2005-01-27 12:11:32 +01:00
|
|
|
LPBYTE tempbuf = NULL;
|
|
|
|
IStream *pStm = NULL;
|
2002-02-05 19:11:17 +01:00
|
|
|
STATSTG ststg;
|
|
|
|
ULARGE_INTEGER newpos;
|
|
|
|
LARGE_INTEGER seekto;
|
|
|
|
ULONG res;
|
|
|
|
DWORD xsize;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2005-01-27 12:11:32 +01:00
|
|
|
if (!pUnk) {
|
2005-03-29 15:06:44 +02:00
|
|
|
/* this is valid, if for instance we serialize
|
|
|
|
* a VT_DISPATCH with NULL ptr which apparently
|
|
|
|
* can happen. S_OK to make sure we continue
|
|
|
|
* serializing.
|
|
|
|
*/
|
2006-01-18 11:29:01 +01:00
|
|
|
WARN("pUnk is NULL\n");
|
2005-03-29 15:06:44 +02:00
|
|
|
xsize = 0;
|
|
|
|
return xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
|
2005-01-27 12:11:32 +01:00
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2005-03-29 15:06:44 +02:00
|
|
|
hres = E_FAIL;
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
TRACE("...%s...\n",debugstr_guid(riid));
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Stream create failed %x\n",hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2005-08-24 11:44:41 +02:00
|
|
|
hres = CoMarshalInterface(pStm,riid,pUnk,0,NULL,0);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Marshalling interface %s failed with %x\n", debugstr_guid(riid), hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2009-04-28 13:41:01 +02:00
|
|
|
hres = IStream_Stat(pStm,&ststg,STATFLAG_NONAME);
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) {
|
|
|
|
ERR("Stream stat failed\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
tempbuf = HeapAlloc(GetProcessHeap(), 0, ststg.cbSize.u.LowPart);
|
2002-02-05 19:11:17 +01:00
|
|
|
memset(&seekto,0,sizeof(seekto));
|
|
|
|
hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed Seek %x\n",hres);
|
2005-01-27 12:11:32 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
hres = IStream_Read(pStm,tempbuf,ststg.cbSize.u.LowPart,&res);
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed Read %x\n",hres);
|
2005-01-27 12:11:32 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
xsize = ststg.cbSize.u.LowPart;
|
2002-02-05 19:11:17 +01:00
|
|
|
xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
|
2004-01-23 02:51:33 +01:00
|
|
|
hres = xbuf_add(buf,tempbuf,ststg.cbSize.u.LowPart);
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,tempbuf);
|
2005-01-27 12:11:32 +01:00
|
|
|
IStream_Release(pStm);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
fail:
|
|
|
|
xsize = 0;
|
|
|
|
xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
|
2005-01-27 12:11:32 +01:00
|
|
|
if (pStm) IUnknown_Release(pStm);
|
|
|
|
HeapFree(GetProcessHeap(), 0, tempbuf);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************* OLE Proxy/Stub Factory ********************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PSFacBuf_QueryInterface(LPPSFACTORYBUFFER iface, REFIID iid, LPVOID *ppv) {
|
|
|
|
if (IsEqualIID(iid,&IID_IPSFactoryBuffer)||IsEqualIID(iid,&IID_IUnknown)) {
|
2009-02-09 09:45:52 +01:00
|
|
|
*ppv = iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
/* No ref counting, static class */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("(%s) unknown IID?\n",debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PSFacBuf_AddRef(LPPSFACTORYBUFFER iface) { return 2; }
|
|
|
|
static ULONG WINAPI PSFacBuf_Release(LPPSFACTORYBUFFER iface) { return 1; }
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
_get_typeinfo_for_iid(REFIID riid, ITypeInfo**ti) {
|
|
|
|
HRESULT hres;
|
|
|
|
HKEY ikey;
|
|
|
|
char tlguid[200],typelibkey[300],interfacekey[300],ver[100];
|
|
|
|
char tlfn[260];
|
|
|
|
OLECHAR tlfnW[260];
|
2005-07-06 21:08:05 +02:00
|
|
|
DWORD tlguidlen, verlen, type;
|
|
|
|
LONG tlfnlen;
|
2002-02-05 19:11:17 +01:00
|
|
|
ITypeLib *tl;
|
|
|
|
|
2006-10-15 12:27:34 +02:00
|
|
|
sprintf( interfacekey, "Interface\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
|
2002-02-05 19:11:17 +01:00
|
|
|
riid->Data1, riid->Data2, riid->Data3,
|
|
|
|
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
|
|
|
|
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (RegOpenKeyA(HKEY_CLASSES_ROOT,interfacekey,&ikey)) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("No %s key found.\n",interfacekey);
|
2002-02-05 19:11:17 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
tlguidlen = sizeof(tlguid);
|
2005-07-06 21:08:05 +02:00
|
|
|
if (RegQueryValueExA(ikey,NULL,NULL,&type,(LPBYTE)tlguid,&tlguidlen)) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Getting typelib guid failed.\n");
|
2002-02-05 19:11:17 +01:00
|
|
|
RegCloseKey(ikey);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
verlen = sizeof(ver);
|
2005-07-06 21:08:05 +02:00
|
|
|
if (RegQueryValueExA(ikey,"Version",NULL,&type,(LPBYTE)ver,&verlen)) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get version value?\n");
|
2002-02-05 19:11:17 +01:00
|
|
|
RegCloseKey(ikey);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
RegCloseKey(ikey);
|
2009-05-21 15:19:16 +02:00
|
|
|
sprintf(typelibkey,"Typelib\\%s\\%s\\0\\win%u",tlguid,ver,(sizeof(void*) == 8) ? 64 : 32);
|
2002-02-05 19:11:17 +01:00
|
|
|
tlfnlen = sizeof(tlfn);
|
|
|
|
if (RegQueryValueA(HKEY_CLASSES_ROOT,typelibkey,tlfn,&tlfnlen)) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get typelib fn?\n");
|
2002-02-05 19:11:17 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2006-05-12 00:07:59 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, tlfn, -1, tlfnW, sizeof(tlfnW) / sizeof(tlfnW[0]));
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = LoadTypeLib(tlfnW,&tl);
|
|
|
|
if (hres) {
|
|
|
|
ERR("Failed to load typelib for %s, but it should be there.\n",debugstr_guid(riid));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(tl,riid,ti);
|
|
|
|
if (hres) {
|
|
|
|
ERR("typelib does not contain info for %s?\n",debugstr_guid(riid));
|
|
|
|
ITypeLib_Release(tl);
|
|
|
|
return hres;
|
|
|
|
}
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeLib_Release(tl);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2007-05-17 16:29:41 +02:00
|
|
|
/*
|
|
|
|
* Determine the number of functions including all inherited functions.
|
|
|
|
* Note for non-dual dispinterfaces we simply return the size of IDispatch.
|
2002-02-05 19:11:17 +01:00
|
|
|
*/
|
2007-05-17 16:29:41 +02:00
|
|
|
static HRESULT num_of_funcs(ITypeInfo *tinfo, unsigned int *num)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
2007-01-02 16:39:48 +01:00
|
|
|
TYPEATTR *attr;
|
|
|
|
ITypeInfo *tinfo2;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2007-05-17 16:29:41 +02:00
|
|
|
*num = 0;
|
2007-01-02 16:39:48 +01:00
|
|
|
hres = ITypeInfo_GetTypeAttr(tinfo, &attr);
|
|
|
|
if (hres) {
|
|
|
|
ERR("GetTypeAttr failed with %x\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
2007-05-17 16:29:41 +02:00
|
|
|
|
|
|
|
if(attr->typekind == TKIND_DISPATCH && (attr->wTypeFlags & TYPEFLAG_FDUAL))
|
|
|
|
{
|
2007-01-02 16:39:48 +01:00
|
|
|
HREFTYPE href;
|
2007-05-17 16:29:41 +02:00
|
|
|
hres = ITypeInfo_GetRefTypeOfImplType(tinfo, -1, &href);
|
|
|
|
if(FAILED(hres))
|
|
|
|
{
|
|
|
|
ERR("Unable to get interface href from dual dispinterface\n");
|
|
|
|
goto end;
|
2007-01-02 16:39:48 +01:00
|
|
|
}
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
|
2007-05-17 16:29:41 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
{
|
|
|
|
ERR("Unable to get interface from dual dispinterface\n");
|
|
|
|
goto end;
|
2007-01-02 16:39:48 +01:00
|
|
|
}
|
2007-05-17 16:29:41 +02:00
|
|
|
hres = num_of_funcs(tinfo2, num);
|
2007-01-02 16:39:48 +01:00
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
}
|
2007-05-17 16:29:41 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*num = attr->cbSizeVft / 4;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2007-05-17 16:29:41 +02:00
|
|
|
|
|
|
|
end:
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
|
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
|
2004-01-09 23:18:49 +01:00
|
|
|
#include "pshpack1.h"
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
typedef struct _TMAsmProxy {
|
|
|
|
BYTE popleax;
|
|
|
|
BYTE pushlval;
|
2007-11-12 13:18:38 +01:00
|
|
|
DWORD nr;
|
2002-02-05 19:11:17 +01:00
|
|
|
BYTE pushleax;
|
|
|
|
BYTE lcall;
|
|
|
|
DWORD xcall;
|
|
|
|
BYTE lret;
|
|
|
|
WORD bytestopop;
|
2007-11-12 13:18:38 +01:00
|
|
|
BYTE nop;
|
2004-01-09 23:18:49 +01:00
|
|
|
} TMAsmProxy;
|
|
|
|
|
|
|
|
#include "poppack.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
#else /* __i386__ */
|
2005-10-19 21:06:49 +02:00
|
|
|
# warning You need to implement stubless proxies for your architecture
|
|
|
|
typedef struct _TMAsmProxy {
|
|
|
|
} TMAsmProxy;
|
2004-09-07 22:42:26 +02:00
|
|
|
#endif
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
typedef struct _TMProxyImpl {
|
2005-06-06 21:50:35 +02:00
|
|
|
LPVOID *lpvtbl;
|
|
|
|
const IRpcProxyBufferVtbl *lpvtbl2;
|
2005-07-11 12:25:19 +02:00
|
|
|
LONG ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
TMAsmProxy *asmstubs;
|
|
|
|
ITypeInfo* tinfo;
|
|
|
|
IRpcChannelBuffer* chanbuf;
|
|
|
|
IID iid;
|
2004-09-07 22:42:26 +02:00
|
|
|
CRITICAL_SECTION crit;
|
2005-03-11 11:18:31 +01:00
|
|
|
IUnknown *outerunknown;
|
2005-10-26 12:12:30 +02:00
|
|
|
IDispatch *dispatch;
|
2006-02-07 16:26:23 +01:00
|
|
|
IRpcProxyBuffer *dispatch_proxy;
|
2002-02-05 19:11:17 +01:00
|
|
|
} TMProxyImpl;
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
TRACE("()\n");
|
|
|
|
if (IsEqualIID(riid,&IID_IUnknown)||IsEqualIID(riid,&IID_IRpcProxyBuffer)) {
|
2009-02-09 09:45:52 +01:00
|
|
|
*ppv = iface;
|
2004-09-07 22:42:26 +02:00
|
|
|
IRpcProxyBuffer_AddRef(iface);
|
|
|
|
return S_OK;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
FIXME("no interface for %s\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface)
|
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
|
2004-09-07 22:42:26 +02:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMProxyImpl_Release(LPRPCPROXYBUFFER iface)
|
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
|
2004-09-07 22:42:26 +02:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
if (!refCount)
|
2004-09-07 22:42:26 +02:00
|
|
|
{
|
2006-02-07 16:26:23 +01:00
|
|
|
if (This->dispatch_proxy) IRpcProxyBuffer_Release(This->dispatch_proxy);
|
2007-03-10 22:09:58 +01:00
|
|
|
This->crit.DebugInfo->Spare[0] = 0;
|
2004-09-07 22:42:26 +02:00
|
|
|
DeleteCriticalSection(&This->crit);
|
|
|
|
if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf);
|
|
|
|
VirtualFree(This->asmstubs, 0, MEM_RELEASE);
|
2006-09-27 16:51:26 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->lpvtbl);
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo_Release(This->tinfo);
|
2004-09-07 22:42:26 +02:00
|
|
|
CoTaskMemFree(This);
|
|
|
|
}
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
TMProxyImpl_Connect(
|
2004-09-07 22:42:26 +02:00
|
|
|
LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(TMProxyImpl, lpvtbl2, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pRpcChannelBuffer);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->crit);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
IRpcChannelBuffer_AddRef(pRpcChannelBuffer);
|
2002-02-05 19:11:17 +01:00
|
|
|
This->chanbuf = pRpcChannelBuffer;
|
2004-09-07 22:42:26 +02:00
|
|
|
|
|
|
|
LeaveCriticalSection(&This->crit);
|
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
if (This->dispatch_proxy)
|
2007-02-06 20:19:56 +01:00
|
|
|
{
|
|
|
|
IRpcChannelBuffer *pDelegateChannel;
|
|
|
|
HRESULT hr = TMarshalDispatchChannel_Create(pRpcChannelBuffer, &This->iid, &pDelegateChannel);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2007-12-06 15:06:11 +01:00
|
|
|
hr = IRpcProxyBuffer_Connect(This->dispatch_proxy, pDelegateChannel);
|
|
|
|
IRpcChannelBuffer_Release(pDelegateChannel);
|
|
|
|
return hr;
|
2007-02-06 20:19:56 +01:00
|
|
|
}
|
2006-02-07 16:26:23 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(TMProxyImpl, lpvtbl2, iface);
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->crit);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
IRpcChannelBuffer_Release(This->chanbuf);
|
|
|
|
This->chanbuf = NULL;
|
2004-09-07 22:42:26 +02:00
|
|
|
|
|
|
|
LeaveCriticalSection(&This->crit);
|
2006-02-07 16:26:23 +01:00
|
|
|
|
|
|
|
if (This->dispatch_proxy)
|
|
|
|
IRpcProxyBuffer_Disconnect(This->dispatch_proxy);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IRpcProxyBufferVtbl tmproxyvtable = {
|
2002-02-05 19:11:17 +01:00
|
|
|
TMProxyImpl_QueryInterface,
|
|
|
|
TMProxyImpl_AddRef,
|
|
|
|
TMProxyImpl_Release,
|
|
|
|
TMProxyImpl_Connect,
|
|
|
|
TMProxyImpl_Disconnect
|
|
|
|
};
|
|
|
|
|
2002-06-10 04:30:20 +02:00
|
|
|
/* how much space do we use on stack in DWORD steps. */
|
2008-09-12 22:04:00 +02:00
|
|
|
static int
|
|
|
|
_argsize(TYPEDESC *tdesc, ITypeInfo *tinfo) {
|
|
|
|
switch (tdesc->vt) {
|
2008-09-12 22:04:00 +02:00
|
|
|
case VT_I8:
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_UI8:
|
|
|
|
return 8/sizeof(DWORD);
|
2005-06-09 11:43:38 +02:00
|
|
|
case VT_R8:
|
|
|
|
return sizeof(double)/sizeof(DWORD);
|
|
|
|
case VT_CY:
|
|
|
|
return sizeof(CY)/sizeof(DWORD);
|
2002-06-14 02:36:42 +02:00
|
|
|
case VT_DATE:
|
|
|
|
return sizeof(DATE)/sizeof(DWORD);
|
2008-09-12 22:04:00 +02:00
|
|
|
case VT_DECIMAL:
|
|
|
|
return (sizeof(DECIMAL)+3)/sizeof(DWORD);
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_VARIANT:
|
|
|
|
return (sizeof(VARIANT)+3)/sizeof(DWORD);
|
2008-09-15 21:22:25 +02:00
|
|
|
case VT_USERDEFINED:
|
|
|
|
{
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TYPEATTR *tattr;
|
|
|
|
HRESULT hres;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return 0; /* should fail critically in serialize_param */
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
ret = (tattr->cbSizeInstance+3)/sizeof(DWORD);
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
return ret;
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-12 22:04:00 +02:00
|
|
|
/* how much space do we use on the heap (in bytes) */
|
2002-06-10 04:30:20 +02:00
|
|
|
static int
|
2008-09-12 22:04:00 +02:00
|
|
|
_xsize(const TYPEDESC *td, ITypeInfo *tinfo) {
|
2002-06-10 04:30:20 +02:00
|
|
|
switch (td->vt) {
|
2002-06-14 02:36:42 +02:00
|
|
|
case VT_DATE:
|
|
|
|
return sizeof(DATE);
|
2008-09-12 22:04:00 +02:00
|
|
|
case VT_CY:
|
|
|
|
return sizeof(CY);
|
|
|
|
/* FIXME: VT_BOOL should return 2? */
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_VARIANT:
|
2008-09-12 22:04:00 +02:00
|
|
|
return sizeof(VARIANT)+3; /* FIXME: why the +3? */
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_CARRAY: {
|
|
|
|
int i, arrsize = 1;
|
2007-07-25 22:37:23 +02:00
|
|
|
const ARRAYDESC *adesc = td->u.lpadesc;
|
2002-06-10 04:30:20 +02:00
|
|
|
|
|
|
|
for (i=0;i<adesc->cDims;i++)
|
|
|
|
arrsize *= adesc->rgbounds[i].cElements;
|
2008-09-12 22:04:00 +02:00
|
|
|
return arrsize*_xsize(&adesc->tdescElem, tinfo);
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_UI8:
|
|
|
|
case VT_I8:
|
2008-09-12 22:04:00 +02:00
|
|
|
case VT_R8:
|
2005-11-04 12:13:55 +01:00
|
|
|
return 8;
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_UI2:
|
|
|
|
case VT_I2:
|
|
|
|
return 2;
|
|
|
|
case VT_UI1:
|
|
|
|
case VT_I1:
|
|
|
|
return 1;
|
2008-09-15 21:22:25 +02:00
|
|
|
case VT_USERDEFINED:
|
|
|
|
{
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TYPEATTR *tattr;
|
|
|
|
HRESULT hres;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,td->u.hreftype,&tinfo2);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return 0;
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
ret = tattr->cbSizeInstance;
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
return ret;
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
default:
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
static HRESULT
|
2002-06-10 04:30:20 +02:00
|
|
|
serialize_param(
|
|
|
|
ITypeInfo *tinfo,
|
|
|
|
BOOL writeit,
|
|
|
|
BOOL debugout,
|
|
|
|
BOOL dealloc,
|
|
|
|
TYPEDESC *tdesc,
|
|
|
|
DWORD *arg,
|
2004-09-07 22:42:26 +02:00
|
|
|
marshal_state *buf)
|
|
|
|
{
|
2002-06-10 04:30:20 +02:00
|
|
|
HRESULT hres = S_OK;
|
2009-01-29 16:52:29 +01:00
|
|
|
VARTYPE vartype;
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2006-01-27 12:54:03 +01:00
|
|
|
TRACE("(tdesc.vt %s)\n",debugstr_vt(tdesc->vt));
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2009-01-29 16:52:29 +01:00
|
|
|
vartype = tdesc->vt;
|
|
|
|
if ((vartype & 0xf000) == VT_ARRAY)
|
|
|
|
vartype = VT_SAFEARRAY;
|
|
|
|
|
|
|
|
switch (vartype) {
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_I8:
|
|
|
|
case VT_UI8:
|
2007-12-29 05:55:48 +01:00
|
|
|
case VT_R8:
|
2006-01-14 17:47:25 +01:00
|
|
|
case VT_CY:
|
2005-11-04 12:13:55 +01:00
|
|
|
hres = S_OK;
|
2006-10-18 21:21:57 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%x%x\n",arg[0],arg[1]);
|
2005-11-04 12:13:55 +01:00
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,8);
|
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
case VT_BOOL:
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_ERROR:
|
2006-02-07 16:26:02 +01:00
|
|
|
case VT_INT:
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_UINT:
|
2002-02-05 19:11:17 +01:00
|
|
|
case VT_I4:
|
2002-12-05 20:12:50 +01:00
|
|
|
case VT_R4:
|
2005-03-14 11:09:11 +01:00
|
|
|
case VT_UI4:
|
2005-03-27 20:17:19 +02:00
|
|
|
hres = S_OK;
|
2006-10-18 21:21:57 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%x\n",*arg);
|
2005-03-27 20:17:19 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
return hres;
|
|
|
|
case VT_I2:
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_UI2:
|
2005-03-27 20:17:19 +02:00
|
|
|
hres = S_OK;
|
2006-10-18 21:21:57 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%04x\n",*arg & 0xffff);
|
2005-03-27 20:17:19 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
return hres;
|
|
|
|
case VT_I1:
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_UI1:
|
|
|
|
hres = S_OK;
|
2006-10-18 21:21:57 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%02x\n",*arg & 0xff);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
case VT_VARIANT: {
|
2009-11-15 18:13:21 +01:00
|
|
|
if (debugout) TRACE_(olerelay)("Vt(%s%s)(",debugstr_vt(V_VT((VARIANT *)arg)),debugstr_vf(V_VT((VARIANT *)arg)));
|
|
|
|
if (writeit)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
ULONG size = VARIANT_UserSize(&flags, buf->curoff, (VARIANT *)arg);
|
|
|
|
xbuf_resize(buf, size);
|
|
|
|
VARIANT_UserMarshal(&flags, buf->base + buf->curoff, (VARIANT *)arg);
|
|
|
|
buf->curoff = size;
|
2005-03-14 11:09:11 +01:00
|
|
|
}
|
2009-11-15 18:13:21 +01:00
|
|
|
if (dealloc)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
VARIANT_UserFree(&flags, (VARIANT *)arg);
|
2005-03-14 11:09:11 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_BSTR: {
|
|
|
|
if (debugout) {
|
2005-03-27 20:20:10 +02:00
|
|
|
if (*arg)
|
|
|
|
TRACE_(olerelay)("%s",relaystr((WCHAR*)*arg));
|
2002-06-10 04:30:20 +02:00
|
|
|
else
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("<bstr NULL>");
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2009-11-15 18:13:21 +01:00
|
|
|
if (writeit)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
ULONG size = BSTR_UserSize(&flags, buf->curoff, (BSTR *)arg);
|
|
|
|
xbuf_resize(buf, size);
|
|
|
|
BSTR_UserMarshal(&flags, buf->base + buf->curoff, (BSTR *)arg);
|
|
|
|
buf->curoff = size;
|
|
|
|
}
|
|
|
|
if (dealloc)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
BSTR_UserFree(&flags, (BSTR *)arg);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
case VT_PTR: {
|
|
|
|
DWORD cookie;
|
2005-09-07 11:23:04 +02:00
|
|
|
BOOL derefhere = TRUE;
|
2005-06-09 11:43:38 +02:00
|
|
|
|
2005-09-07 11:23:04 +02:00
|
|
|
if (tdesc->u.lptdesc->vt == VT_USERDEFINED) {
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TYPEATTR *tattr;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.lptdesc->u.hreftype,&tinfo2);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc->u.lptdesc->u.hreftype);
|
2005-09-07 11:23:04 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
switch (tattr->typekind) {
|
2008-03-03 23:27:03 +01:00
|
|
|
case TKIND_ALIAS:
|
|
|
|
if (tattr->tdescAlias.vt == VT_USERDEFINED)
|
|
|
|
{
|
|
|
|
DWORD href = tattr->tdescAlias.u.hreftype;
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, tattr);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,href,&tinfo2);
|
|
|
|
if (hres) {
|
|
|
|
ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc->u.lptdesc->u.hreftype);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
derefhere = (tattr->typekind != TKIND_DISPATCH && tattr->typekind != TKIND_INTERFACE);
|
|
|
|
}
|
|
|
|
break;
|
2005-09-07 11:23:04 +02:00
|
|
|
case TKIND_ENUM: /* confirmed */
|
|
|
|
case TKIND_RECORD: /* FIXME: mostly untested */
|
|
|
|
break;
|
|
|
|
case TKIND_DISPATCH: /* will be done in VT_USERDEFINED case */
|
|
|
|
case TKIND_INTERFACE: /* will be done in VT_USERDEFINED case */
|
|
|
|
derefhere=FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled switch cases tattr->typekind %d\n", tattr->typekind);
|
|
|
|
derefhere=FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, tattr);
|
2005-09-07 11:23:04 +02:00
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("*");
|
2005-03-27 19:51:59 +02:00
|
|
|
/* Write always, so the other side knows when it gets a NULL pointer.
|
|
|
|
*/
|
|
|
|
cookie = *arg ? 0x42424242 : 0;
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)&cookie,sizeof(cookie));
|
|
|
|
if (hres)
|
|
|
|
return hres;
|
2002-06-10 04:30:20 +02:00
|
|
|
if (!*arg) {
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("NULL");
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
hres = serialize_param(tinfo,writeit,debugout,dealloc,tdesc->u.lptdesc,(DWORD*)*arg,buf);
|
2005-06-09 11:43:38 +02:00
|
|
|
if (derefhere && dealloc) HeapFree(GetProcessHeap(),0,(LPVOID)*arg);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
case VT_UNKNOWN:
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("unk(0x%x)",*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = _marshal_interface(buf,&IID_IUnknown,(LPUNKNOWN)*arg);
|
2006-02-14 11:33:03 +01:00
|
|
|
if (dealloc && *(IUnknown **)arg)
|
2006-02-07 16:25:42 +01:00
|
|
|
IUnknown_Release((LPUNKNOWN)*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
case VT_DISPATCH:
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("idisp(0x%x)",*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = _marshal_interface(buf,&IID_IDispatch,(LPUNKNOWN)*arg);
|
2006-02-14 11:33:03 +01:00
|
|
|
if (dealloc && *(IUnknown **)arg)
|
2006-02-07 16:25:42 +01:00
|
|
|
IUnknown_Release((LPUNKNOWN)*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
case VT_VOID:
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("<void>");
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
2002-02-05 19:11:17 +01:00
|
|
|
case VT_USERDEFINED: {
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TYPEATTR *tattr;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc->u.hreftype);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
switch (tattr->typekind) {
|
2002-12-12 23:25:07 +01:00
|
|
|
case TKIND_DISPATCH:
|
2002-02-05 19:11:17 +01:00
|
|
|
case TKIND_INTERFACE:
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres=_marshal_interface(buf,&(tattr->guid),(LPUNKNOWN)arg);
|
2005-08-24 11:44:41 +02:00
|
|
|
if (dealloc)
|
|
|
|
IUnknown_Release((LPUNKNOWN)arg);
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
2002-06-10 04:30:20 +02:00
|
|
|
case TKIND_RECORD: {
|
|
|
|
int i;
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("{");
|
2002-06-10 04:30:20 +02:00
|
|
|
for (i=0;i<tattr->cVars;i++) {
|
|
|
|
VARDESC *vdesc;
|
|
|
|
ELEMDESC *elem2;
|
|
|
|
TYPEDESC *tdesc2;
|
|
|
|
|
|
|
|
hres = ITypeInfo2_GetVarDesc(tinfo2, i, &vdesc);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get vardesc of %d\n",i);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
elem2 = &vdesc->elemdescVar;
|
|
|
|
tdesc2 = &elem2->tdesc;
|
|
|
|
hres = serialize_param(
|
|
|
|
tinfo2,
|
|
|
|
writeit,
|
|
|
|
debugout,
|
|
|
|
dealloc,
|
|
|
|
tdesc2,
|
|
|
|
(DWORD*)(((LPBYTE)arg)+vdesc->u.oInst),
|
|
|
|
buf
|
|
|
|
);
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo_ReleaseVarDesc(tinfo2, vdesc);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (hres!=S_OK)
|
|
|
|
return hres;
|
|
|
|
if (debugout && (i<(tattr->cVars-1)))
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)(",");
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("}");
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2005-07-19 21:13:23 +02:00
|
|
|
case TKIND_ALIAS:
|
2006-10-23 12:38:20 +02:00
|
|
|
hres = serialize_param(tinfo2,writeit,debugout,dealloc,&tattr->tdescAlias,arg,buf);
|
|
|
|
break;
|
2005-07-19 21:13:23 +02:00
|
|
|
case TKIND_ENUM:
|
|
|
|
hres = S_OK;
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%x",*arg);
|
2005-07-19 21:13:23 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
|
2006-10-23 12:38:20 +02:00
|
|
|
break;
|
2002-12-12 23:25:07 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled typekind %d\n",tattr->typekind);
|
|
|
|
hres = E_FAIL;
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
|
2002-02-05 19:11:17 +01:00
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
return hres;
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_CARRAY: {
|
|
|
|
ARRAYDESC *adesc = tdesc->u.lpadesc;
|
|
|
|
int i, arrsize = 1;
|
|
|
|
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("carr");
|
2002-06-10 04:30:20 +02:00
|
|
|
for (i=0;i<adesc->cDims;i++) {
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("[%d]",adesc->rgbounds[i].cElements);
|
2002-06-10 04:30:20 +02:00
|
|
|
arrsize *= adesc->rgbounds[i].cElements;
|
|
|
|
}
|
2006-01-27 12:54:03 +01:00
|
|
|
if (debugout) TRACE_(olerelay)("(vt %s)",debugstr_vt(adesc->tdescElem.vt));
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("[");
|
2002-06-10 04:30:20 +02:00
|
|
|
for (i=0;i<arrsize;i++) {
|
2009-10-25 00:29:02 +02:00
|
|
|
hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)(*arg)+i*_xsize(&adesc->tdescElem, tinfo)), buf);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (hres)
|
|
|
|
return hres;
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout && (i<arrsize-1)) TRACE_(olerelay)(",");
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("]");
|
2009-11-15 18:12:50 +01:00
|
|
|
if (dealloc)
|
|
|
|
HeapFree(GetProcessHeap(), 0, *(void **)arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2006-05-10 13:11:22 +02:00
|
|
|
case VT_SAFEARRAY: {
|
|
|
|
if (writeit)
|
|
|
|
{
|
2006-11-08 23:46:13 +01:00
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
ULONG size = LPSAFEARRAY_UserSize(&flags, buf->curoff, (LPSAFEARRAY *)arg);
|
2006-05-10 13:11:22 +02:00
|
|
|
xbuf_resize(buf, size);
|
|
|
|
LPSAFEARRAY_UserMarshal(&flags, buf->base + buf->curoff, (LPSAFEARRAY *)arg);
|
|
|
|
buf->curoff = size;
|
|
|
|
}
|
2009-11-15 18:12:50 +01:00
|
|
|
if (dealloc)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
LPSAFEARRAY_UserFree(&flags, (LPSAFEARRAY *)arg);
|
|
|
|
}
|
2006-05-10 13:11:22 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
default:
|
2002-06-10 04:30:20 +02:00
|
|
|
ERR("Unhandled marshal type %d.\n",tdesc->vt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
|
|
|
deserialize_param(
|
|
|
|
ITypeInfo *tinfo,
|
|
|
|
BOOL readit,
|
|
|
|
BOOL debugout,
|
|
|
|
BOOL alloc,
|
|
|
|
TYPEDESC *tdesc,
|
|
|
|
DWORD *arg,
|
2004-09-07 22:42:26 +02:00
|
|
|
marshal_state *buf)
|
|
|
|
{
|
2002-06-10 04:30:20 +02:00
|
|
|
HRESULT hres = S_OK;
|
2009-01-29 16:52:29 +01:00
|
|
|
VARTYPE vartype;
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2006-01-27 12:54:03 +01:00
|
|
|
TRACE("vt %s at %p\n",debugstr_vt(tdesc->vt),arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2009-01-29 16:52:29 +01:00
|
|
|
vartype = tdesc->vt;
|
|
|
|
if ((vartype & 0xf000) == VT_ARRAY)
|
|
|
|
vartype = VT_SAFEARRAY;
|
|
|
|
|
2002-06-10 04:30:20 +02:00
|
|
|
while (1) {
|
2009-01-29 16:52:29 +01:00
|
|
|
switch (vartype) {
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_VARIANT: {
|
2009-11-15 18:13:21 +01:00
|
|
|
if (readit)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
unsigned char *buffer;
|
|
|
|
buffer = VARIANT_UserUnmarshal(&flags, buf->base + buf->curoff, (VARIANT *)arg);
|
|
|
|
buf->curoff = buffer - buf->base;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2009-11-15 18:13:21 +01:00
|
|
|
return S_OK;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_I8:
|
|
|
|
case VT_UI8:
|
2007-12-29 05:55:48 +01:00
|
|
|
case VT_R8:
|
2006-01-14 17:47:25 +01:00
|
|
|
case VT_CY:
|
2005-11-04 12:13:55 +01:00
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)arg,8);
|
|
|
|
if (hres) ERR("Failed to read integer 8 byte\n");
|
|
|
|
}
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%x%x",arg[0],arg[1]);
|
2005-11-04 12:13:55 +01:00
|
|
|
return hres;
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_ERROR:
|
2005-03-14 11:09:11 +01:00
|
|
|
case VT_BOOL:
|
|
|
|
case VT_I4:
|
2006-02-07 16:26:02 +01:00
|
|
|
case VT_INT:
|
2005-03-14 11:09:11 +01:00
|
|
|
case VT_UINT:
|
|
|
|
case VT_R4:
|
|
|
|
case VT_UI4:
|
2002-06-10 04:30:20 +02:00
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)arg,sizeof(DWORD));
|
2005-01-27 12:11:32 +01:00
|
|
|
if (hres) ERR("Failed to read integer 4 byte\n");
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%x",*arg);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
2005-03-27 20:17:19 +02:00
|
|
|
case VT_I2:
|
|
|
|
case VT_UI2:
|
|
|
|
if (readit) {
|
|
|
|
DWORD x;
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&x,sizeof(DWORD));
|
|
|
|
if (hres) ERR("Failed to read integer 4 byte\n");
|
|
|
|
memcpy(arg,&x,2);
|
|
|
|
}
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%04x",*arg & 0xffff);
|
2005-03-27 20:17:19 +02:00
|
|
|
return hres;
|
|
|
|
case VT_I1:
|
|
|
|
case VT_UI1:
|
|
|
|
if (readit) {
|
|
|
|
DWORD x;
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&x,sizeof(DWORD));
|
|
|
|
if (hres) ERR("Failed to read integer 4 byte\n");
|
|
|
|
memcpy(arg,&x,1);
|
|
|
|
}
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%02x",*arg & 0xff);
|
2005-03-27 20:17:19 +02:00
|
|
|
return hres;
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_BSTR: {
|
2009-11-15 18:13:21 +01:00
|
|
|
if (readit)
|
|
|
|
{
|
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
unsigned char *buffer;
|
|
|
|
buffer = BSTR_UserUnmarshal(&flags, buf->base + buf->curoff, (BSTR *)arg);
|
|
|
|
buf->curoff = buffer - buf->base;
|
|
|
|
if (debugout) TRACE_(olerelay)("%s",relaystr(*(BSTR *)arg));
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_PTR: {
|
|
|
|
DWORD cookie;
|
2005-09-07 11:23:04 +02:00
|
|
|
BOOL derefhere = TRUE;
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2005-09-07 11:23:04 +02:00
|
|
|
if (tdesc->u.lptdesc->vt == VT_USERDEFINED) {
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TYPEATTR *tattr;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.lptdesc->u.hreftype,&tinfo2);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc->u.lptdesc->u.hreftype);
|
2005-09-07 11:23:04 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
switch (tattr->typekind) {
|
2008-03-03 23:27:03 +01:00
|
|
|
case TKIND_ALIAS:
|
|
|
|
if (tattr->tdescAlias.vt == VT_USERDEFINED)
|
|
|
|
{
|
|
|
|
DWORD href = tattr->tdescAlias.u.hreftype;
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, tattr);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,href,&tinfo2);
|
|
|
|
if (hres) {
|
|
|
|
ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc->u.lptdesc->u.hreftype);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
derefhere = (tattr->typekind != TKIND_DISPATCH && tattr->typekind != TKIND_INTERFACE);
|
|
|
|
}
|
|
|
|
break;
|
2005-09-07 11:23:04 +02:00
|
|
|
case TKIND_ENUM: /* confirmed */
|
|
|
|
case TKIND_RECORD: /* FIXME: mostly untested */
|
|
|
|
break;
|
|
|
|
case TKIND_DISPATCH: /* will be done in VT_USERDEFINED case */
|
|
|
|
case TKIND_INTERFACE: /* will be done in VT_USERDEFINED case */
|
|
|
|
derefhere=FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled switch cases tattr->typekind %d\n", tattr->typekind);
|
|
|
|
derefhere=FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
|
2005-09-07 11:23:04 +02:00
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
/* read it in all cases, we need to know if we have
|
|
|
|
* NULL pointer or not.
|
|
|
|
*/
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&cookie,sizeof(cookie));
|
|
|
|
if (hres) {
|
|
|
|
ERR("Failed to load pointer cookie.\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
if (cookie != 0x42424242) {
|
|
|
|
/* we read a NULL ptr from the remote side */
|
|
|
|
if (debugout) TRACE_(olerelay)("NULL");
|
|
|
|
*arg = 0;
|
|
|
|
return S_OK;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("*");
|
2002-06-10 04:30:20 +02:00
|
|
|
if (alloc) {
|
2005-03-27 19:51:59 +02:00
|
|
|
/* Allocate space for the referenced struct */
|
2002-06-10 04:30:20 +02:00
|
|
|
if (derefhere)
|
2008-09-12 22:04:00 +02:00
|
|
|
*arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc, tinfo));
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
if (derefhere)
|
|
|
|
return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, (LPDWORD)*arg, buf);
|
|
|
|
else
|
|
|
|
return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, arg, buf);
|
|
|
|
}
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
/* FIXME: UNKNOWN is unknown ..., but allocate 4 byte for it */
|
|
|
|
if (alloc)
|
|
|
|
*arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DWORD));
|
|
|
|
hres = S_OK;
|
|
|
|
if (readit)
|
|
|
|
hres = _unmarshal_interface(buf,&IID_IUnknown,(LPUNKNOWN*)arg);
|
|
|
|
if (debugout)
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("unk(%p)",arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
case VT_DISPATCH:
|
|
|
|
hres = S_OK;
|
|
|
|
if (readit)
|
|
|
|
hres = _unmarshal_interface(buf,&IID_IDispatch,(LPUNKNOWN*)arg);
|
|
|
|
if (debugout)
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("idisp(%p)",arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
case VT_VOID:
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("<void>");
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
|
|
|
case VT_USERDEFINED: {
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TYPEATTR *tattr;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc->u.hreftype);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get typeattr in VT_USERDEFINED.\n");
|
2002-06-10 04:30:20 +02:00
|
|
|
} else {
|
|
|
|
switch (tattr->typekind) {
|
2002-12-12 23:25:07 +01:00
|
|
|
case TKIND_DISPATCH:
|
2002-06-10 04:30:20 +02:00
|
|
|
case TKIND_INTERFACE:
|
|
|
|
if (readit)
|
|
|
|
hres = _unmarshal_interface(buf,&(tattr->guid),(LPUNKNOWN*)arg);
|
|
|
|
break;
|
|
|
|
case TKIND_RECORD: {
|
|
|
|
int i;
|
|
|
|
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("{");
|
2002-06-10 04:30:20 +02:00
|
|
|
for (i=0;i<tattr->cVars;i++) {
|
|
|
|
VARDESC *vdesc;
|
|
|
|
|
|
|
|
hres = ITypeInfo2_GetVarDesc(tinfo2, i, &vdesc);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get vardesc of %d\n",i);
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = deserialize_param(
|
|
|
|
tinfo2,
|
|
|
|
readit,
|
|
|
|
debugout,
|
|
|
|
alloc,
|
|
|
|
&vdesc->elemdescVar.tdesc,
|
2008-09-15 21:22:25 +02:00
|
|
|
(DWORD*)(((LPBYTE)arg)+vdesc->u.oInst),
|
2002-06-10 04:30:20 +02:00
|
|
|
buf
|
|
|
|
);
|
2005-12-06 21:24:19 +01:00
|
|
|
ITypeInfo2_ReleaseVarDesc(tinfo2, vdesc);
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout && (i<tattr->cVars-1)) TRACE_(olerelay)(",");
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("}");
|
2002-06-10 04:30:20 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-07-19 21:13:23 +02:00
|
|
|
case TKIND_ALIAS:
|
2006-10-23 12:38:20 +02:00
|
|
|
hres = deserialize_param(tinfo2,readit,debugout,alloc,&tattr->tdescAlias,arg,buf);
|
|
|
|
break;
|
2005-07-19 21:13:23 +02:00
|
|
|
case TKIND_ENUM:
|
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
if (hres) ERR("Failed to read enum (4 byte)\n");
|
|
|
|
}
|
2006-10-12 20:57:10 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%x",*arg);
|
2006-10-23 12:38:20 +02:00
|
|
|
break;
|
2002-12-12 23:25:07 +01:00
|
|
|
default:
|
|
|
|
ERR("Unhandled typekind %d\n",tattr->typekind);
|
|
|
|
hres = E_FAIL;
|
2002-06-10 04:30:20 +02:00
|
|
|
break;
|
|
|
|
}
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
if (hres)
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("failed to stuballoc in TKIND_RECORD.\n");
|
2002-06-10 04:30:20 +02:00
|
|
|
ITypeInfo_Release(tinfo2);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_CARRAY: {
|
|
|
|
/* arg is pointing to the start of the array. */
|
|
|
|
ARRAYDESC *adesc = tdesc->u.lpadesc;
|
|
|
|
int arrsize,i;
|
|
|
|
arrsize = 1;
|
|
|
|
if (adesc->cDims > 1) FIXME("cDims > 1 in VT_CARRAY. Does it work?\n");
|
|
|
|
for (i=0;i<adesc->cDims;i++)
|
|
|
|
arrsize *= adesc->rgbounds[i].cElements;
|
2009-10-25 00:29:02 +02:00
|
|
|
*arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc, tinfo) * arrsize);
|
2002-06-10 04:30:20 +02:00
|
|
|
for (i=0;i<arrsize;i++)
|
|
|
|
deserialize_param(
|
|
|
|
tinfo,
|
|
|
|
readit,
|
|
|
|
debugout,
|
|
|
|
alloc,
|
|
|
|
&adesc->tdescElem,
|
2009-10-25 00:29:02 +02:00
|
|
|
(DWORD*)((LPBYTE)(*arg)+i*_xsize(&adesc->tdescElem, tinfo)),
|
2002-06-10 04:30:20 +02:00
|
|
|
buf
|
|
|
|
);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-05-10 13:11:22 +02:00
|
|
|
case VT_SAFEARRAY: {
|
|
|
|
if (readit)
|
|
|
|
{
|
2006-11-08 23:46:13 +01:00
|
|
|
ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
2006-05-10 13:11:22 +02:00
|
|
|
unsigned char *buffer;
|
|
|
|
buffer = LPSAFEARRAY_UserUnmarshal(&flags, buf->base + buf->curoff, (LPSAFEARRAY *)arg);
|
|
|
|
buf->curoff = buffer - buf->base;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
default:
|
2002-06-10 04:30:20 +02:00
|
|
|
ERR("No handler for VT type %d!\n",tdesc->vt);
|
|
|
|
return S_OK;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
/* Retrieves a function's funcdesc, searching back into inherited interfaces. */
|
|
|
|
static HRESULT get_funcdesc(ITypeInfo *tinfo, int iMethod, ITypeInfo **tactual, const FUNCDESC **fdesc,
|
|
|
|
BSTR *iname, BSTR *fname, UINT *num)
|
2004-09-07 22:42:26 +02:00
|
|
|
{
|
2007-04-26 12:56:44 +02:00
|
|
|
HRESULT hr;
|
|
|
|
UINT i, impl_types;
|
|
|
|
UINT inherited_funcs = 0;
|
|
|
|
TYPEATTR *attr;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
if (fname) *fname = NULL;
|
|
|
|
if (iname) *iname = NULL;
|
2007-04-26 12:56:44 +02:00
|
|
|
if (num) *num = 0;
|
|
|
|
*tactual = NULL;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
hr = ITypeInfo_GetTypeAttr(tinfo, &attr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("GetTypeAttr failed with %x\n",hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2007-05-17 16:29:41 +02:00
|
|
|
|
|
|
|
if(attr->typekind == TKIND_DISPATCH)
|
|
|
|
{
|
|
|
|
if(attr->wTypeFlags & TYPEFLAG_FDUAL)
|
|
|
|
{
|
|
|
|
HREFTYPE href;
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetRefTypeOfImplType(tinfo, -1, &href);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Cannot get interface href from dual dispinterface\n");
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Cannot get interface from dual dispinterface\n");
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
hr = get_funcdesc(tinfo2, iMethod, tactual, fdesc, iname, fname, num);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ERR("Shouldn't be called with a non-dual dispinterface\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
impl_types = attr->cImplTypes;
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
|
2005-12-06 21:24:19 +01:00
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
for (i = 0; i < impl_types; i++)
|
|
|
|
{
|
|
|
|
HREFTYPE href;
|
|
|
|
ITypeInfo *pSubTypeInfo;
|
|
|
|
UINT sub_funcs;
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetRefTypeOfImplType(tinfo, i, &href);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = ITypeInfo_GetRefTypeInfo(tinfo, href, &pSubTypeInfo);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
hr = get_funcdesc(pSubTypeInfo, iMethod, tactual, fdesc, iname, fname, &sub_funcs);
|
|
|
|
inherited_funcs += sub_funcs;
|
|
|
|
ITypeInfo_Release(pSubTypeInfo);
|
|
|
|
if(SUCCEEDED(hr)) return hr;
|
|
|
|
}
|
|
|
|
if(iMethod < inherited_funcs)
|
|
|
|
{
|
|
|
|
ERR("shouldn't be here\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
for(i = inherited_funcs; i <= iMethod; i++)
|
|
|
|
{
|
|
|
|
hr = ITypeInfoImpl_GetInternalFuncDesc(tinfo, i - inherited_funcs, fdesc);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
if(num) *num = i;
|
|
|
|
return hr;
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2007-04-26 12:56:44 +02:00
|
|
|
|
|
|
|
/* found it. We don't care about num so zero it */
|
|
|
|
if(num) *num = 0;
|
|
|
|
*tactual = tinfo;
|
|
|
|
ITypeInfo_AddRef(*tactual);
|
|
|
|
if (fname) ITypeInfo_GetDocumentation(tinfo,(*fdesc)->memid,fname,NULL,NULL,NULL);
|
|
|
|
if (iname) ITypeInfo_GetDocumentation(tinfo,-1,iname,NULL,NULL,NULL);
|
|
|
|
return S_OK;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
2007-02-07 20:19:26 +01:00
|
|
|
static inline BOOL is_in_elem(const ELEMDESC *elem)
|
|
|
|
{
|
|
|
|
return (elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN || !elem->u.paramdesc.wParamFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_out_elem(const ELEMDESC *elem)
|
|
|
|
{
|
|
|
|
return (elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT || !elem->u.paramdesc.wParamFlags);
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
static DWORD
|
2004-09-07 22:42:26 +02:00
|
|
|
xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
|
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
DWORD *args = ((DWORD*)&tpinfo)+1, *xargs;
|
2005-12-06 21:24:19 +01:00
|
|
|
const FUNCDESC *fdesc;
|
2002-02-05 19:11:17 +01:00
|
|
|
HRESULT hres;
|
|
|
|
int i, relaydeb = TRACE_ON(olerelay);
|
|
|
|
marshal_state buf;
|
|
|
|
RPCOLEMESSAGE msg;
|
|
|
|
ULONG status;
|
|
|
|
BSTR fname,iname;
|
|
|
|
BSTR names[10];
|
2005-08-08 20:38:29 +02:00
|
|
|
UINT nrofnames;
|
2005-03-28 12:00:49 +02:00
|
|
|
DWORD remoteresult = 0;
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo *tinfo;
|
2005-11-02 21:00:00 +01:00
|
|
|
IRpcChannelBuffer *chanbuf;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
EnterCriticalSection(&tpinfo->crit);
|
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
hres = get_funcdesc(tpinfo->tinfo,method,&tinfo,&fdesc,&iname,&fname,NULL);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2005-11-02 21:00:00 +01:00
|
|
|
ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method);
|
2004-09-07 22:42:26 +02:00
|
|
|
LeaveCriticalSection(&tpinfo->crit);
|
2005-11-02 21:00:00 +01:00
|
|
|
return E_FAIL;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
2004-12-14 12:44:11 +01:00
|
|
|
if (!tpinfo->chanbuf)
|
|
|
|
{
|
|
|
|
WARN("Tried to use disconnected proxy\n");
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo_Release(tinfo);
|
2004-12-14 12:44:11 +01:00
|
|
|
LeaveCriticalSection(&tpinfo->crit);
|
|
|
|
return RPC_E_DISCONNECTED;
|
|
|
|
}
|
2005-11-02 21:00:00 +01:00
|
|
|
chanbuf = tpinfo->chanbuf;
|
|
|
|
IRpcChannelBuffer_AddRef(chanbuf);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&tpinfo->crit);
|
2004-12-14 12:44:11 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
if (relaydeb) {
|
2004-06-23 02:10:29 +02:00
|
|
|
TRACE_(olerelay)("->");
|
2002-02-05 19:11:17 +01:00
|
|
|
if (iname)
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("%s:",relaystr(iname));
|
2002-02-05 19:11:17 +01:00
|
|
|
if (fname)
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("%s(%d)",relaystr(fname),method);
|
2002-02-05 19:11:17 +01:00
|
|
|
else
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("%d",method);
|
|
|
|
TRACE_(olerelay)("(");
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
|
2008-09-21 15:52:16 +02:00
|
|
|
SysFreeString(iname);
|
|
|
|
SysFreeString(fname);
|
2005-03-27 19:51:59 +02:00
|
|
|
|
|
|
|
memset(&buf,0,sizeof(buf));
|
|
|
|
|
|
|
|
/* normal typelib driven serializing */
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
/* Need them for hack below */
|
|
|
|
memset(names,0,sizeof(names));
|
2005-06-01 13:03:40 +02:00
|
|
|
if (ITypeInfo_GetNames(tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames))
|
2002-06-10 04:30:20 +02:00
|
|
|
nrofnames = 0;
|
|
|
|
if (nrofnames > sizeof(names)/sizeof(names[0]))
|
2002-02-05 19:11:17 +01:00
|
|
|
ERR("Need more names!\n");
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2005-03-27 19:51:59 +02:00
|
|
|
xargs = args;
|
|
|
|
for (i=0;i<fdesc->cParams;i++) {
|
|
|
|
ELEMDESC *elem = fdesc->lprgelemdescParam+i;
|
|
|
|
if (relaydeb) {
|
|
|
|
if (i) TRACE_(olerelay)(",");
|
|
|
|
if (i+1<nrofnames && names[i+1])
|
|
|
|
TRACE_(olerelay)("%s=",relaystr(names[i+1]));
|
|
|
|
}
|
|
|
|
/* No need to marshal other data than FIN and any VT_PTR. */
|
2007-02-07 20:19:26 +01:00
|
|
|
if (!is_in_elem(elem) && (elem->tdesc.vt != VT_PTR)) {
|
2008-09-12 22:04:00 +02:00
|
|
|
xargs+=_argsize(&elem->tdesc, tinfo);
|
2005-03-27 19:51:59 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)("[out]");
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
hres = serialize_param(
|
|
|
|
tinfo,
|
2007-02-07 20:19:26 +01:00
|
|
|
is_in_elem(elem),
|
2005-10-26 12:12:30 +02:00
|
|
|
relaydeb,
|
|
|
|
FALSE,
|
|
|
|
&elem->tdesc,
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2005-03-27 19:51:59 +02:00
|
|
|
|
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed to serialize param, hres %x\n",hres);
|
2005-03-27 19:51:59 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-12 22:04:00 +02:00
|
|
|
xargs+=_argsize(&elem->tdesc, tinfo);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2004-06-18 01:03:26 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)(")");
|
2005-03-27 19:51:59 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
memset(&msg,0,sizeof(msg));
|
|
|
|
msg.cbBuffer = buf.curoff;
|
|
|
|
msg.iMethod = method;
|
2005-11-02 21:00:00 +01:00
|
|
|
hres = IRpcChannelBuffer_GetBuffer(chanbuf,&msg,&(tpinfo->iid));
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("RpcChannelBuffer GetBuffer failed, %x\n",hres);
|
2005-11-02 21:00:00 +01:00
|
|
|
goto exit;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
memcpy(msg.Buffer,buf.base,buf.curoff);
|
2004-06-18 01:03:26 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)("\n");
|
2005-11-02 21:00:00 +01:00
|
|
|
hres = IRpcChannelBuffer_SendReceive(chanbuf,&msg,&status);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("RpcChannelBuffer SendReceive failed, %x\n",hres);
|
2005-11-02 21:00:00 +01:00
|
|
|
goto exit;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2004-06-18 01:03:26 +02:00
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)(" status = %08x (",status);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (buf.base)
|
|
|
|
buf.base = HeapReAlloc(GetProcessHeap(),0,buf.base,msg.cbBuffer);
|
|
|
|
else
|
|
|
|
buf.base = HeapAlloc(GetProcessHeap(),0,msg.cbBuffer);
|
|
|
|
buf.size = msg.cbBuffer;
|
|
|
|
memcpy(buf.base,msg.Buffer,buf.size);
|
|
|
|
buf.curoff = 0;
|
2005-03-27 19:51:59 +02:00
|
|
|
|
|
|
|
/* generic deserializer using typelib description */
|
|
|
|
xargs = args;
|
2005-03-28 12:00:49 +02:00
|
|
|
status = S_OK;
|
2005-03-27 19:51:59 +02:00
|
|
|
for (i=0;i<fdesc->cParams;i++) {
|
|
|
|
ELEMDESC *elem = fdesc->lprgelemdescParam+i;
|
|
|
|
|
|
|
|
if (relaydeb) {
|
|
|
|
if (i) TRACE_(olerelay)(",");
|
|
|
|
if (i+1<nrofnames && names[i+1]) TRACE_(olerelay)("%s=",relaystr(names[i+1]));
|
|
|
|
}
|
|
|
|
/* No need to marshal other data than FOUT and any VT_PTR */
|
2007-02-07 20:19:26 +01:00
|
|
|
if (!is_out_elem(elem) && (elem->tdesc.vt != VT_PTR)) {
|
2008-09-12 22:04:00 +02:00
|
|
|
xargs += _argsize(&elem->tdesc, tinfo);
|
2005-03-27 19:51:59 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)("[in]");
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
hres = deserialize_param(
|
|
|
|
tinfo,
|
2007-02-07 20:19:26 +01:00
|
|
|
is_out_elem(elem),
|
2005-10-26 12:12:30 +02:00
|
|
|
relaydeb,
|
|
|
|
FALSE,
|
|
|
|
&(elem->tdesc),
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2005-03-27 19:51:59 +02:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed to unmarshall param, hres %x\n",hres);
|
2005-03-27 19:51:59 +02:00
|
|
|
status = hres;
|
|
|
|
break;
|
|
|
|
}
|
2008-09-12 22:04:00 +02:00
|
|
|
xargs += _argsize(&elem->tdesc, tinfo);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2005-03-28 12:00:49 +02:00
|
|
|
hres = xbuf_get(&buf, (LPBYTE)&remoteresult, sizeof(DWORD));
|
|
|
|
if (hres != S_OK)
|
2005-11-02 21:00:00 +01:00
|
|
|
goto exit;
|
2006-10-12 20:57:10 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)(") = %08x\n", remoteresult);
|
2004-09-07 22:42:26 +02:00
|
|
|
|
2005-11-02 21:00:00 +01:00
|
|
|
hres = remoteresult;
|
2004-09-07 22:42:26 +02:00
|
|
|
|
2005-11-02 21:00:00 +01:00
|
|
|
exit:
|
2008-01-25 17:59:19 +01:00
|
|
|
IRpcChannelBuffer_FreeBuffer(chanbuf,&msg);
|
2006-10-23 12:29:09 +02:00
|
|
|
for (i = 0; i < nrofnames; i++)
|
|
|
|
SysFreeString(names[i]);
|
2005-03-28 12:00:49 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,buf.base);
|
2005-11-02 21:00:00 +01:00
|
|
|
IRpcChannelBuffer_Release(chanbuf);
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo_Release(tinfo);
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("-- 0x%08x\n", hres);
|
2005-11-02 21:00:00 +01:00
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:59:33 +02:00
|
|
|
static HRESULT WINAPI ProxyIUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
2005-03-11 11:18:31 +01:00
|
|
|
{
|
|
|
|
TMProxyImpl *proxy = (TMProxyImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (proxy->outerunknown)
|
|
|
|
return IUnknown_QueryInterface(proxy->outerunknown, riid, ppv);
|
|
|
|
|
|
|
|
FIXME("No interface\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:59:33 +02:00
|
|
|
static ULONG WINAPI ProxyIUnknown_AddRef(IUnknown *iface)
|
2005-03-11 11:18:31 +01:00
|
|
|
{
|
|
|
|
TMProxyImpl *proxy = (TMProxyImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (proxy->outerunknown)
|
|
|
|
return IUnknown_AddRef(proxy->outerunknown);
|
|
|
|
|
|
|
|
return 2; /* FIXME */
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:59:33 +02:00
|
|
|
static ULONG WINAPI ProxyIUnknown_Release(IUnknown *iface)
|
2005-03-11 11:18:31 +01:00
|
|
|
{
|
|
|
|
TMProxyImpl *proxy = (TMProxyImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (proxy->outerunknown)
|
|
|
|
return IUnknown_Release(proxy->outerunknown);
|
|
|
|
|
|
|
|
return 1; /* FIXME */
|
|
|
|
}
|
|
|
|
|
2005-10-26 12:12:30 +02:00
|
|
|
static HRESULT WINAPI ProxyIDispatch_GetTypeInfoCount(LPDISPATCH iface, UINT * pctinfo)
|
|
|
|
{
|
|
|
|
TMProxyImpl *This = (TMProxyImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pctinfo);
|
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
return IDispatch_GetTypeInfoCount(This->dispatch, pctinfo);
|
2005-10-26 12:12:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProxyIDispatch_GetTypeInfo(LPDISPATCH iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
|
|
|
|
{
|
|
|
|
TMProxyImpl *This = (TMProxyImpl *)iface;
|
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%d, %x, %p)\n", iTInfo, lcid, ppTInfo);
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
return IDispatch_GetTypeInfo(This->dispatch, iTInfo, lcid, ppTInfo);
|
2005-10-26 12:12:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProxyIDispatch_GetIDsOfNames(LPDISPATCH iface, REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId)
|
|
|
|
{
|
|
|
|
TMProxyImpl *This = (TMProxyImpl *)iface;
|
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%s, %p, %d, 0x%x, %p)\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
return IDispatch_GetIDsOfNames(This->dispatch, riid, rgszNames,
|
|
|
|
cNames, lcid, rgDispId);
|
2005-10-26 12:12:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProxyIDispatch_Invoke(LPDISPATCH iface, DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS * pDispParams, VARIANT * pVarResult,
|
|
|
|
EXCEPINFO * pExcepInfo, UINT * puArgErr)
|
|
|
|
{
|
|
|
|
TMProxyImpl *This = (TMProxyImpl *)iface;
|
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%d, %s, 0x%x, 0x%x, %p, %p, %p, %p)\n", dispIdMember,
|
2006-02-07 16:26:23 +01:00
|
|
|
debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult,
|
|
|
|
pExcepInfo, puArgErr);
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
return IDispatch_Invoke(This->dispatch, dispIdMember, riid, lcid,
|
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2007-02-06 20:19:56 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IRpcChannelBufferVtbl *lpVtbl;
|
|
|
|
LONG refs;
|
|
|
|
/* the IDispatch-derived interface we are handling */
|
|
|
|
IID tmarshal_iid;
|
|
|
|
IRpcChannelBuffer *pDelegateChannel;
|
|
|
|
} TMarshalDispatchChannel;
|
|
|
|
|
|
|
|
static HRESULT WINAPI TMarshalDispatchChannel_QueryInterface(LPRPCCHANNELBUFFER iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid,&IID_IRpcChannelBuffer) || IsEqualIID(riid,&IID_IUnknown))
|
|
|
|
{
|
2009-02-09 09:45:52 +01:00
|
|
|
*ppv = iface;
|
2007-02-06 20:19:56 +01:00
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TMarshalDispatchChannel_AddRef(LPRPCCHANNELBUFFER iface)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
return InterlockedIncrement(&This->refs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TMarshalDispatchChannel_Release(LPRPCCHANNELBUFFER iface)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->refs);
|
|
|
|
if (ref)
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
IRpcChannelBuffer_Release(This->pDelegateChannel);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TMarshalDispatchChannel_GetBuffer(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE* olemsg, REFIID riid)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
TRACE("(%p, %s)\n", olemsg, debugstr_guid(riid));
|
|
|
|
/* Note: we are pretending to invoke a method on the interface identified
|
|
|
|
* by tmarshal_iid so that we can re-use the IDispatch proxy/stub code
|
|
|
|
* without the RPC runtime getting confused by not exporting an IDispatch interface */
|
|
|
|
return IRpcChannelBuffer_GetBuffer(This->pDelegateChannel, olemsg, &This->tmarshal_iid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TMarshalDispatchChannel_SendReceive(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE *olemsg, ULONG *pstatus)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
TRACE("(%p, %p)\n", olemsg, pstatus);
|
|
|
|
return IRpcChannelBuffer_SendReceive(This->pDelegateChannel, olemsg, pstatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TMarshalDispatchChannel_FreeBuffer(LPRPCCHANNELBUFFER iface, RPCOLEMESSAGE* olemsg)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
TRACE("(%p)\n", olemsg);
|
|
|
|
return IRpcChannelBuffer_FreeBuffer(This->pDelegateChannel, olemsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TMarshalDispatchChannel_GetDestCtx(LPRPCCHANNELBUFFER iface, DWORD* pdwDestContext, void** ppvDestContext)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
TRACE("(%p,%p)\n", pdwDestContext, ppvDestContext);
|
|
|
|
return IRpcChannelBuffer_GetDestCtx(This->pDelegateChannel, pdwDestContext, ppvDestContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TMarshalDispatchChannel_IsConnected(LPRPCCHANNELBUFFER iface)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = (TMarshalDispatchChannel *)iface;
|
|
|
|
TRACE("()\n");
|
|
|
|
return IRpcChannelBuffer_IsConnected(This->pDelegateChannel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IRpcChannelBufferVtbl TMarshalDispatchChannelVtbl =
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel_QueryInterface,
|
|
|
|
TMarshalDispatchChannel_AddRef,
|
|
|
|
TMarshalDispatchChannel_Release,
|
|
|
|
TMarshalDispatchChannel_GetBuffer,
|
|
|
|
TMarshalDispatchChannel_SendReceive,
|
|
|
|
TMarshalDispatchChannel_FreeBuffer,
|
|
|
|
TMarshalDispatchChannel_GetDestCtx,
|
|
|
|
TMarshalDispatchChannel_IsConnected
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT TMarshalDispatchChannel_Create(
|
|
|
|
IRpcChannelBuffer *pDelegateChannel, REFIID tmarshal_riid,
|
|
|
|
IRpcChannelBuffer **ppChannel)
|
|
|
|
{
|
|
|
|
TMarshalDispatchChannel *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->lpVtbl = &TMarshalDispatchChannelVtbl;
|
|
|
|
This->refs = 1;
|
|
|
|
IRpcChannelBuffer_AddRef(pDelegateChannel);
|
|
|
|
This->pDelegateChannel = pDelegateChannel;
|
|
|
|
This->tmarshal_iid = *tmarshal_riid;
|
|
|
|
|
|
|
|
*ppChannel = (IRpcChannelBuffer *)&This->lpVtbl;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
static inline HRESULT get_facbuf_for_iid(REFIID riid, IPSFactoryBuffer **facbuf)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
CLSID clsid;
|
|
|
|
|
|
|
|
if ((hr = CoGetPSClsid(riid, &clsid)))
|
|
|
|
return hr;
|
|
|
|
return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IPSFactoryBuffer, (LPVOID*)facbuf);
|
2005-10-26 12:12:30 +02:00
|
|
|
}
|
|
|
|
|
2007-05-17 16:23:51 +02:00
|
|
|
static HRESULT init_proxy_entry_point(TMProxyImpl *proxy, unsigned int num)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
/* nrofargs without This */
|
|
|
|
int nrofargs;
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
TMAsmProxy *xasm = proxy->asmstubs + num;
|
|
|
|
HRESULT hres;
|
|
|
|
const FUNCDESC *fdesc;
|
|
|
|
|
|
|
|
hres = get_funcdesc(proxy->tinfo, num, &tinfo2, &fdesc, NULL, NULL, NULL);
|
|
|
|
if (hres) {
|
|
|
|
ERR("GetFuncDesc %x should not fail here.\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
/* some args take more than 4 byte on the stack */
|
|
|
|
nrofargs = 0;
|
|
|
|
for (j=0;j<fdesc->cParams;j++)
|
2008-09-12 22:04:00 +02:00
|
|
|
nrofargs += _argsize(&fdesc->lprgelemdescParam[j].tdesc, proxy->tinfo);
|
2007-05-17 16:23:51 +02:00
|
|
|
|
|
|
|
#ifdef __i386__
|
|
|
|
if (fdesc->callconv != CC_STDCALL) {
|
|
|
|
ERR("calling convention is not stdcall????\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
/* popl %eax - return ptr
|
|
|
|
* pushl <nr>
|
|
|
|
* pushl %eax
|
|
|
|
* call xCall
|
|
|
|
* lret <nr> (+4)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* arg3 arg2 arg1 <method> <returnptr>
|
|
|
|
*/
|
|
|
|
xasm->popleax = 0x58;
|
2007-11-12 13:18:38 +01:00
|
|
|
xasm->pushlval = 0x68;
|
2007-05-17 16:23:51 +02:00
|
|
|
xasm->nr = num;
|
|
|
|
xasm->pushleax = 0x50;
|
|
|
|
xasm->lcall = 0xe8; /* relative jump */
|
|
|
|
xasm->xcall = (DWORD)xCall;
|
|
|
|
xasm->xcall -= (DWORD)&(xasm->lret);
|
|
|
|
xasm->lret = 0xc2;
|
|
|
|
xasm->bytestopop = (nrofargs+2)*4; /* pop args, This, iMethod */
|
2007-11-12 13:18:38 +01:00
|
|
|
xasm->nop = 0x90;
|
2007-05-17 16:23:51 +02:00
|
|
|
proxy->lpvtbl[num] = xasm;
|
|
|
|
#else
|
|
|
|
FIXME("not implemented on non i386\n");
|
|
|
|
return E_FAIL;
|
|
|
|
#endif
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
static HRESULT WINAPI
|
|
|
|
PSFacBuf_CreateProxy(
|
|
|
|
LPPSFACTORYBUFFER iface, IUnknown* pUnkOuter, REFIID riid,
|
2004-09-07 22:42:26 +02:00
|
|
|
IRpcProxyBuffer **ppProxy, LPVOID *ppv)
|
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
HRESULT hres;
|
|
|
|
ITypeInfo *tinfo;
|
2007-05-17 16:29:41 +02:00
|
|
|
unsigned int i, nroffuncs;
|
2002-02-05 19:11:17 +01:00
|
|
|
TMProxyImpl *proxy;
|
2005-10-26 12:12:30 +02:00
|
|
|
TYPEATTR *typeattr;
|
2007-05-17 16:29:41 +02:00
|
|
|
BOOL defer_to_dispatch = FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
TRACE("(...%s...)\n",debugstr_guid(riid));
|
|
|
|
hres = _get_typeinfo_for_iid(riid,&tinfo);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("No typeinfo for %s?\n",debugstr_guid(riid));
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2007-05-17 16:29:41 +02:00
|
|
|
|
|
|
|
hres = num_of_funcs(tinfo, &nroffuncs);
|
|
|
|
if (FAILED(hres)) {
|
|
|
|
ERR("Cannot get number of functions for typeinfo %s\n",debugstr_guid(riid));
|
|
|
|
ITypeInfo_Release(tinfo);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
proxy = CoTaskMemAlloc(sizeof(TMProxyImpl));
|
2002-02-05 19:11:17 +01:00
|
|
|
if (!proxy) return E_OUTOFMEMORY;
|
|
|
|
|
2007-11-12 13:18:38 +01:00
|
|
|
assert(sizeof(TMAsmProxy) == 16);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2005-10-26 12:12:30 +02:00
|
|
|
proxy->dispatch = NULL;
|
2006-02-07 16:26:23 +01:00
|
|
|
proxy->dispatch_proxy = NULL;
|
2005-03-11 11:18:31 +01:00
|
|
|
proxy->outerunknown = pUnkOuter;
|
2004-06-29 01:51:24 +02:00
|
|
|
proxy->asmstubs = VirtualAlloc(NULL, sizeof(TMAsmProxy) * nroffuncs, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
|
|
|
if (!proxy->asmstubs) {
|
|
|
|
ERR("Could not commit pages for proxy thunks\n");
|
2004-09-07 22:42:26 +02:00
|
|
|
CoTaskMemFree(proxy);
|
2004-06-29 01:51:24 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2007-01-02 16:39:48 +01:00
|
|
|
proxy->lpvtbl2 = &tmproxyvtable;
|
|
|
|
/* one reference for the proxy */
|
|
|
|
proxy->ref = 1;
|
|
|
|
proxy->tinfo = tinfo;
|
2008-03-11 21:55:17 +01:00
|
|
|
proxy->iid = *riid;
|
2007-01-02 16:39:48 +01:00
|
|
|
proxy->chanbuf = 0;
|
2004-06-29 01:51:24 +02:00
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
InitializeCriticalSection(&proxy->crit);
|
2007-03-10 22:09:58 +01:00
|
|
|
proxy->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": TMProxyImpl.crit");
|
2004-09-07 22:42:26 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
proxy->lpvtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPBYTE)*nroffuncs);
|
2005-10-26 12:12:30 +02:00
|
|
|
|
|
|
|
/* if we derive from IDispatch then defer to its proxy for its methods */
|
|
|
|
hres = ITypeInfo_GetTypeAttr(tinfo, &typeattr);
|
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
if (typeattr->wTypeFlags & TYPEFLAG_FDISPATCHABLE)
|
|
|
|
{
|
2006-02-07 16:26:23 +01:00
|
|
|
IPSFactoryBuffer *factory_buffer;
|
|
|
|
hres = get_facbuf_for_iid(&IID_IDispatch, &factory_buffer);
|
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
hres = IPSFactoryBuffer_CreateProxy(factory_buffer, NULL,
|
|
|
|
&IID_IDispatch, &proxy->dispatch_proxy,
|
|
|
|
(void **)&proxy->dispatch);
|
|
|
|
IPSFactoryBuffer_Release(factory_buffer);
|
|
|
|
}
|
2007-01-02 16:39:48 +01:00
|
|
|
if ((hres == S_OK) && (nroffuncs < 7))
|
|
|
|
{
|
|
|
|
ERR("nroffuncs calculated incorrectly (%d)\n", nroffuncs);
|
|
|
|
hres = E_UNEXPECTED;
|
|
|
|
}
|
2006-02-07 16:26:23 +01:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2007-05-17 16:29:41 +02:00
|
|
|
defer_to_dispatch = TRUE;
|
2006-02-07 16:26:23 +01:00
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
}
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, typeattr);
|
|
|
|
}
|
|
|
|
|
2007-05-17 16:29:41 +02:00
|
|
|
for (i=0;i<nroffuncs;i++) {
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
proxy->lpvtbl[i] = ProxyIUnknown_QueryInterface;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
proxy->lpvtbl[i] = ProxyIUnknown_AddRef;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
proxy->lpvtbl[i] = ProxyIUnknown_Release;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if(!defer_to_dispatch)
|
|
|
|
{
|
|
|
|
hres = init_proxy_entry_point(proxy, i);
|
|
|
|
if(FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else proxy->lpvtbl[3] = ProxyIDispatch_GetTypeInfoCount;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if(!defer_to_dispatch)
|
|
|
|
{
|
|
|
|
hres = init_proxy_entry_point(proxy, i);
|
|
|
|
if(FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else proxy->lpvtbl[4] = ProxyIDispatch_GetTypeInfo;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if(!defer_to_dispatch)
|
|
|
|
{
|
|
|
|
hres = init_proxy_entry_point(proxy, i);
|
|
|
|
if(FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else proxy->lpvtbl[5] = ProxyIDispatch_GetIDsOfNames;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if(!defer_to_dispatch)
|
|
|
|
{
|
|
|
|
hres = init_proxy_entry_point(proxy, i);
|
|
|
|
if(FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
else proxy->lpvtbl[6] = ProxyIDispatch_Invoke;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hres = init_proxy_entry_point(proxy, i);
|
|
|
|
if(FAILED(hres)) return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-07 16:26:23 +01:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2009-02-09 09:45:52 +01:00
|
|
|
*ppv = proxy;
|
|
|
|
*ppProxy = (IRpcProxyBuffer *)&(proxy->lpvtbl2);
|
2006-02-07 16:26:23 +01:00
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TMProxyImpl_Release((IRpcProxyBuffer *)&proxy->lpvtbl2);
|
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _TMStubImpl {
|
2005-06-06 21:50:35 +02:00
|
|
|
const IRpcStubBufferVtbl *lpvtbl;
|
2005-07-11 12:25:19 +02:00
|
|
|
LONG ref;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
LPUNKNOWN pUnk;
|
|
|
|
ITypeInfo *tinfo;
|
|
|
|
IID iid;
|
2006-02-07 16:26:23 +01:00
|
|
|
IRpcStubBuffer *dispatch_stub;
|
2006-08-29 22:12:16 +02:00
|
|
|
BOOL dispatch_derivative;
|
2002-02-05 19:11:17 +01:00
|
|
|
} TMStubImpl;
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
if (IsEqualIID(riid,&IID_IRpcStubBuffer)||IsEqualIID(riid,&IID_IUnknown)){
|
2009-02-09 09:45:52 +01:00
|
|
|
*ppv = iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
IRpcStubBuffer_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("%s, not supported IID.\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMStubImpl_AddRef(LPRPCSTUBBUFFER iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
TMStubImpl *This = (TMStubImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2004-07-30 20:43:27 +02:00
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMStubImpl_Release(LPRPCSTUBBUFFER iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
TMStubImpl *This = (TMStubImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
|
2004-07-30 20:43:27 +02:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
if (!refCount)
|
2004-09-07 22:42:26 +02:00
|
|
|
{
|
|
|
|
IRpcStubBuffer_Disconnect(iface);
|
2005-07-19 22:00:07 +02:00
|
|
|
ITypeInfo_Release(This->tinfo);
|
2006-08-29 22:12:16 +02:00
|
|
|
if (This->dispatch_stub)
|
|
|
|
IRpcStubBuffer_Release(This->dispatch_stub);
|
2004-09-07 22:42:26 +02:00
|
|
|
CoTaskMemFree(This);
|
|
|
|
}
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMStubImpl_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN pUnkServer)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
TMStubImpl *This = (TMStubImpl *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-07-30 20:43:27 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, pUnkServer);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
IUnknown_AddRef(pUnkServer);
|
|
|
|
This->pUnk = pUnkServer;
|
2006-02-07 16:26:23 +01:00
|
|
|
|
|
|
|
if (This->dispatch_stub)
|
|
|
|
IRpcStubBuffer_Connect(This->dispatch_stub, pUnkServer);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI
|
2004-09-07 22:42:26 +02:00
|
|
|
TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
TMStubImpl *This = (TMStubImpl *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-07-30 20:43:27 +02:00
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
2005-07-19 22:00:07 +02:00
|
|
|
if (This->pUnk)
|
|
|
|
{
|
|
|
|
IUnknown_Release(This->pUnk);
|
|
|
|
This->pUnk = NULL;
|
|
|
|
}
|
2006-02-07 16:26:23 +01:00
|
|
|
|
|
|
|
if (This->dispatch_stub)
|
|
|
|
IRpcStubBuffer_Disconnect(This->dispatch_stub);
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
TMStubImpl_Invoke(
|
2004-09-07 22:42:26 +02:00
|
|
|
LPRPCSTUBBUFFER iface, RPCOLEMESSAGE* xmsg,IRpcChannelBuffer*rpcchanbuf)
|
|
|
|
{
|
2009-10-06 12:07:23 +02:00
|
|
|
#ifdef __i386__
|
2002-02-05 19:11:17 +01:00
|
|
|
int i;
|
2005-12-06 21:24:19 +01:00
|
|
|
const FUNCDESC *fdesc;
|
2004-09-09 23:03:58 +02:00
|
|
|
TMStubImpl *This = (TMStubImpl *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
HRESULT hres;
|
2006-10-23 12:38:20 +02:00
|
|
|
DWORD *args = NULL, res, *xargs, nrofargs;
|
2002-02-05 19:11:17 +01:00
|
|
|
marshal_state buf;
|
2007-01-16 11:15:20 +01:00
|
|
|
UINT nrofnames = 0;
|
2002-02-05 19:11:17 +01:00
|
|
|
BSTR names[10];
|
2005-10-26 12:12:30 +02:00
|
|
|
BSTR iname = NULL;
|
2006-10-23 12:38:20 +02:00
|
|
|
ITypeInfo *tinfo = NULL;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
TRACE("...\n");
|
2005-10-26 12:12:30 +02:00
|
|
|
|
|
|
|
if (xmsg->iMethod < 3) {
|
|
|
|
ERR("IUnknown methods cannot be marshaled by the typelib marshaler\n");
|
|
|
|
return E_UNEXPECTED;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2006-08-29 22:12:16 +02:00
|
|
|
if (This->dispatch_derivative && xmsg->iMethod < sizeof(IDispatchVtbl)/sizeof(void *))
|
|
|
|
{
|
|
|
|
IPSFactoryBuffer *factory_buffer;
|
|
|
|
hres = get_facbuf_for_iid(&IID_IDispatch, &factory_buffer);
|
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
hres = IPSFactoryBuffer_CreateStub(factory_buffer, &IID_IDispatch,
|
|
|
|
This->pUnk, &This->dispatch_stub);
|
|
|
|
IPSFactoryBuffer_Release(factory_buffer);
|
|
|
|
}
|
|
|
|
if (hres != S_OK)
|
|
|
|
return hres;
|
2006-02-07 16:26:23 +01:00
|
|
|
return IRpcStubBuffer_Invoke(This->dispatch_stub, xmsg, rpcchanbuf);
|
2006-08-29 22:12:16 +02:00
|
|
|
}
|
2006-02-07 16:26:23 +01:00
|
|
|
|
|
|
|
memset(&buf,0,sizeof(buf));
|
|
|
|
buf.size = xmsg->cbBuffer;
|
|
|
|
buf.base = HeapAlloc(GetProcessHeap(), 0, xmsg->cbBuffer);
|
|
|
|
memcpy(buf.base, xmsg->Buffer, xmsg->cbBuffer);
|
|
|
|
buf.curoff = 0;
|
|
|
|
|
2007-04-26 12:56:44 +02:00
|
|
|
hres = get_funcdesc(This->tinfo,xmsg->iMethod,&tinfo,&fdesc,&iname,NULL,NULL);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("GetFuncDesc on method %d failed with %x\n",xmsg->iMethod,hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
|
2005-10-26 12:12:30 +02:00
|
|
|
if (iname && !lstrcmpW(iname, IDispatchW))
|
|
|
|
{
|
|
|
|
ERR("IDispatch cannot be marshaled by the typelib marshaler\n");
|
2006-10-23 12:38:20 +02:00
|
|
|
hres = E_UNEXPECTED;
|
|
|
|
SysFreeString (iname);
|
|
|
|
goto exit;
|
2005-10-26 12:12:30 +02:00
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
|
2008-09-21 15:52:16 +02:00
|
|
|
SysFreeString (iname);
|
2005-03-27 19:51:59 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
/* Need them for hack below */
|
|
|
|
memset(names,0,sizeof(names));
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo_GetNames(tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (nrofnames > sizeof(names)/sizeof(names[0])) {
|
|
|
|
ERR("Need more names!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*dump_FUNCDESC(fdesc);*/
|
|
|
|
nrofargs = 0;
|
|
|
|
for (i=0;i<fdesc->cParams;i++)
|
2008-09-12 22:04:00 +02:00
|
|
|
nrofargs += _argsize(&fdesc->lprgelemdescParam[i].tdesc, tinfo);
|
2009-11-15 18:12:42 +01:00
|
|
|
args = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(nrofargs+1)*sizeof(DWORD));
|
2006-10-23 12:38:20 +02:00
|
|
|
if (!args)
|
|
|
|
{
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
goto exit;
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
/* Allocate all stuff used by call. */
|
|
|
|
xargs = args+1;
|
|
|
|
for (i=0;i<fdesc->cParams;i++) {
|
|
|
|
ELEMDESC *elem = fdesc->lprgelemdescParam+i;
|
2002-06-10 04:30:20 +02:00
|
|
|
|
2005-10-26 12:12:30 +02:00
|
|
|
hres = deserialize_param(
|
|
|
|
tinfo,
|
2007-02-07 20:19:26 +01:00
|
|
|
is_in_elem(elem),
|
2005-10-26 12:12:30 +02:00
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
&(elem->tdesc),
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2008-09-12 22:04:00 +02:00
|
|
|
xargs += _argsize(&elem->tdesc, tinfo);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed to deserialize param %s, hres %x\n",relaystr(names[i+1]),hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2005-10-27 14:08:58 +02:00
|
|
|
args[0] = (DWORD)This->pUnk;
|
2006-07-17 21:19:27 +02:00
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
res = _invoke(
|
|
|
|
(*((FARPROC**)args[0]))[fdesc->oVft/4],
|
|
|
|
fdesc->callconv,
|
|
|
|
(xargs-args),
|
|
|
|
args
|
|
|
|
);
|
|
|
|
}
|
2008-02-15 16:43:24 +01:00
|
|
|
__EXCEPT_ALL
|
2006-07-17 21:19:27 +02:00
|
|
|
{
|
|
|
|
DWORD dwExceptionCode = GetExceptionCode();
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("invoke call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode);
|
2006-07-17 21:19:27 +02:00
|
|
|
if (FAILED(dwExceptionCode))
|
|
|
|
hres = dwExceptionCode;
|
|
|
|
else
|
|
|
|
hres = HRESULT_FROM_WIN32(dwExceptionCode);
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
if (hres != S_OK)
|
2006-10-23 12:38:20 +02:00
|
|
|
goto exit;
|
2006-07-17 21:19:27 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
buf.curoff = 0;
|
2005-03-27 19:51:59 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
xargs = args+1;
|
|
|
|
for (i=0;i<fdesc->cParams;i++) {
|
|
|
|
ELEMDESC *elem = fdesc->lprgelemdescParam+i;
|
2005-10-26 12:12:30 +02:00
|
|
|
hres = serialize_param(
|
|
|
|
tinfo,
|
2007-02-07 20:19:26 +01:00
|
|
|
is_out_elem(elem),
|
2005-10-26 12:12:30 +02:00
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
&elem->tdesc,
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2008-09-12 22:04:00 +02:00
|
|
|
xargs += _argsize(&elem->tdesc, tinfo);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("Failed to stuballoc param, hres %x\n",hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
|
2005-03-28 12:00:49 +02:00
|
|
|
hres = xbuf_add (&buf, (LPBYTE)&res, sizeof(DWORD));
|
2006-10-23 12:29:09 +02:00
|
|
|
|
2005-03-28 12:00:49 +02:00
|
|
|
if (hres != S_OK)
|
2006-10-23 12:38:20 +02:00
|
|
|
goto exit;
|
2005-08-29 23:46:51 +02:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
xmsg->cbBuffer = buf.curoff;
|
2006-06-09 18:25:50 +02:00
|
|
|
hres = IRpcChannelBuffer_GetBuffer(rpcchanbuf, xmsg, &This->iid);
|
|
|
|
if (hres != S_OK)
|
2006-10-12 20:57:10 +02:00
|
|
|
ERR("IRpcChannelBuffer_GetBuffer failed with error 0x%08x\n", hres);
|
2005-08-29 23:46:51 +02:00
|
|
|
|
|
|
|
if (hres == S_OK)
|
|
|
|
memcpy(xmsg->Buffer, buf.base, buf.curoff);
|
|
|
|
|
2006-10-23 12:38:20 +02:00
|
|
|
exit:
|
|
|
|
for (i = 0; i < nrofnames; i++)
|
|
|
|
SysFreeString(names[i]);
|
|
|
|
|
|
|
|
ITypeInfo_Release(tinfo);
|
|
|
|
HeapFree(GetProcessHeap(), 0, args);
|
|
|
|
|
2005-08-29 23:46:51 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf.base);
|
|
|
|
|
|
|
|
TRACE("returning\n");
|
|
|
|
return hres;
|
2009-10-06 12:07:23 +02:00
|
|
|
#else
|
|
|
|
FIXME( "not implemented on non-i386\n" );
|
|
|
|
return E_FAIL;
|
|
|
|
#endif
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static LPRPCSTUBBUFFER WINAPI
|
|
|
|
TMStubImpl_IsIIDSupported(LPRPCSTUBBUFFER iface, REFIID riid) {
|
|
|
|
FIXME("Huh (%s)?\n",debugstr_guid(riid));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface) {
|
2004-09-09 23:03:58 +02:00
|
|
|
TMStubImpl *This = (TMStubImpl *)iface;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2005-08-29 23:46:51 +02:00
|
|
|
FIXME("()\n");
|
2002-02-05 19:11:17 +01:00
|
|
|
return This->ref; /*FIXME? */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
TMStubImpl_DebugServerQueryInterface(LPRPCSTUBBUFFER iface, LPVOID *ppv) {
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI
|
|
|
|
TMStubImpl_DebugServerRelease(LPRPCSTUBBUFFER iface, LPVOID ppv) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IRpcStubBufferVtbl tmstubvtbl = {
|
2002-02-05 19:11:17 +01:00
|
|
|
TMStubImpl_QueryInterface,
|
|
|
|
TMStubImpl_AddRef,
|
|
|
|
TMStubImpl_Release,
|
|
|
|
TMStubImpl_Connect,
|
|
|
|
TMStubImpl_Disconnect,
|
|
|
|
TMStubImpl_Invoke,
|
|
|
|
TMStubImpl_IsIIDSupported,
|
|
|
|
TMStubImpl_CountRefs,
|
|
|
|
TMStubImpl_DebugServerQueryInterface,
|
|
|
|
TMStubImpl_DebugServerRelease
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PSFacBuf_CreateStub(
|
|
|
|
LPPSFACTORYBUFFER iface, REFIID riid,IUnknown *pUnkServer,
|
|
|
|
IRpcStubBuffer** ppStub
|
|
|
|
) {
|
|
|
|
HRESULT hres;
|
|
|
|
ITypeInfo *tinfo;
|
|
|
|
TMStubImpl *stub;
|
2006-02-07 16:26:23 +01:00
|
|
|
TYPEATTR *typeattr;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_guid(riid),pUnkServer,ppStub);
|
2006-02-07 16:26:23 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = _get_typeinfo_for_iid(riid,&tinfo);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("No typeinfo for %s?\n",debugstr_guid(riid));
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2006-02-07 16:26:23 +01:00
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
stub = CoTaskMemAlloc(sizeof(TMStubImpl));
|
2002-02-05 19:11:17 +01:00
|
|
|
if (!stub)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
stub->lpvtbl = &tmstubvtbl;
|
|
|
|
stub->ref = 1;
|
|
|
|
stub->tinfo = tinfo;
|
2006-02-07 16:26:23 +01:00
|
|
|
stub->dispatch_stub = NULL;
|
2006-08-29 22:12:16 +02:00
|
|
|
stub->dispatch_derivative = FALSE;
|
2008-03-11 21:55:17 +01:00
|
|
|
stub->iid = *riid;
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = IRpcStubBuffer_Connect((LPRPCSTUBBUFFER)stub,pUnkServer);
|
|
|
|
*ppStub = (LPRPCSTUBBUFFER)stub;
|
2004-07-30 20:43:27 +02:00
|
|
|
TRACE("IRpcStubBuffer: %p\n", stub);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres)
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Connect to pUnkServer failed?\n");
|
2006-02-07 16:26:23 +01:00
|
|
|
|
|
|
|
/* if we derive from IDispatch then defer to its stub for some of its methods */
|
|
|
|
hres = ITypeInfo_GetTypeAttr(tinfo, &typeattr);
|
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
if (typeattr->wTypeFlags & TYPEFLAG_FDISPATCHABLE)
|
2006-08-29 22:12:16 +02:00
|
|
|
stub->dispatch_derivative = TRUE;
|
2006-02-07 16:26:23 +01:00
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, typeattr);
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPSFactoryBufferVtbl psfacbufvtbl = {
|
2002-02-05 19:11:17 +01:00
|
|
|
PSFacBuf_QueryInterface,
|
|
|
|
PSFacBuf_AddRef,
|
|
|
|
PSFacBuf_Release,
|
|
|
|
PSFacBuf_CreateProxy,
|
|
|
|
PSFacBuf_CreateStub
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is the whole PSFactoryBuffer object, just the vtableptr */
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPSFactoryBufferVtbl *lppsfac = &psfacbufvtbl;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2005-08-09 12:38:54 +02:00
|
|
|
* TMARSHAL_DllGetClassObject
|
2002-02-05 19:11:17 +01:00
|
|
|
*/
|
2005-08-09 12:38:54 +02:00
|
|
|
HRESULT TMARSHAL_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
|
2002-02-05 19:11:17 +01:00
|
|
|
{
|
|
|
|
if (IsEqualIID(iid,&IID_IPSFactoryBuffer)) {
|
|
|
|
*ppv = &lppsfac;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|