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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-02-05 19:11:17 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#include "typelib.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.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))
|
|
|
|
|
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
|
|
|
|
xbuf_add(marshal_state *buf, LPBYTE stuff, DWORD size) {
|
|
|
|
while (buf->size - buf->curoff < size) {
|
|
|
|
if (buf->base) {
|
|
|
|
buf->size += 100;
|
|
|
|
buf->base = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,buf->base,buf->size);
|
|
|
|
if (!buf->base)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
} else {
|
|
|
|
buf->base = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,32);
|
|
|
|
buf->size = 32;
|
|
|
|
if (!buf->base)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Stream create failed %lx\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) {
|
|
|
|
ERR("stream write %lx\n",hres);
|
|
|
|
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) {
|
|
|
|
ERR("Failed Seek %lx\n",hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = CoUnmarshalInterface(pStm,riid,(LPVOID*)pUnk);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Unmarshalling interface %s failed with %lx\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.
|
|
|
|
*/
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Stream create failed %lx\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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Marshalling interface %s failed with %lx\n", debugstr_guid(riid), hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
2005-01-27 12:11:32 +01:00
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
hres = IStream_Stat(pStm,&ststg,0);
|
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) {
|
|
|
|
ERR("Failed Seek %lx\n",hres);
|
|
|
|
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) {
|
|
|
|
ERR("Failed Read %lx\n",hres);
|
|
|
|
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)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
*ppv = (LPVOID)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;
|
|
|
|
|
|
|
|
sprintf( interfacekey, "Interface\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
type = (1<<REG_SZ);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
type = (1<<REG_SZ);
|
|
|
|
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);
|
|
|
|
sprintf(typelibkey,"Typelib\\%s\\%s\\0\\win32",tlguid,ver);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, tlfn, -1, tlfnW, -1);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
/* FIXME: do this? ITypeLib_Release(tl); */
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine nr of functions. Since we use the toplevel interface and all
|
2002-06-01 01:06:46 +02:00
|
|
|
* inherited ones have lower numbers, we are ok to not to descent into
|
2002-02-05 19:11:17 +01:00
|
|
|
* the inheritance tree I think.
|
|
|
|
*/
|
|
|
|
static int _nroffuncs(ITypeInfo *tinfo) {
|
|
|
|
int n, max = 0;
|
2005-12-06 21:24:19 +01:00
|
|
|
const FUNCDESC *fdesc;
|
2002-02-05 19:11:17 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
n=0;
|
|
|
|
while (1) {
|
2005-12-06 21:24:19 +01:00
|
|
|
hres = ITypeInfoImpl_GetInternalFuncDesc(tinfo,n,&fdesc);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres)
|
|
|
|
return max+1;
|
2003-09-22 21:21:32 +02:00
|
|
|
if (fdesc->oVft/4 > max)
|
|
|
|
max = fdesc->oVft/4;
|
2002-02-05 19:11:17 +01:00
|
|
|
n++;
|
|
|
|
}
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
BYTE nr;
|
|
|
|
BYTE pushleax;
|
|
|
|
BYTE lcall;
|
|
|
|
DWORD xcall;
|
|
|
|
BYTE lret;
|
|
|
|
WORD bytestopop;
|
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;
|
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)) {
|
2004-09-07 22:42:26 +02:00
|
|
|
*ppv = (LPVOID)iface;
|
|
|
|
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
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
TRACE("(%p)->(ref before=%lu)\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
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
TRACE("(%p)->(ref before=%lu)\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
|
|
|
{
|
2005-10-26 12:12:30 +02:00
|
|
|
if (This->dispatch) IDispatch_Release(This->dispatch);
|
2004-09-07 22:42:26 +02:00
|
|
|
DeleteCriticalSection(&This->crit);
|
|
|
|
if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf);
|
|
|
|
VirtualFree(This->asmstubs, 0, MEM_RELEASE);
|
|
|
|
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);
|
|
|
|
|
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);
|
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. */
|
2004-09-27 22:33:27 +02:00
|
|
|
int
|
2002-06-10 04:30:20 +02:00
|
|
|
_argsize(DWORD vt) {
|
|
|
|
switch (vt) {
|
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);
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_VARIANT:
|
|
|
|
return (sizeof(VARIANT)+3)/sizeof(DWORD);
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_xsize(TYPEDESC *td) {
|
|
|
|
switch (td->vt) {
|
2002-06-14 02:36:42 +02:00
|
|
|
case VT_DATE:
|
|
|
|
return sizeof(DATE);
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_VARIANT:
|
|
|
|
return sizeof(VARIANT)+3;
|
|
|
|
case VT_CARRAY: {
|
|
|
|
int i, arrsize = 1;
|
|
|
|
ARRAYDESC *adesc = td->u.lpadesc;
|
|
|
|
|
|
|
|
for (i=0;i<adesc->cDims;i++)
|
|
|
|
arrsize *= adesc->rgbounds[i].cElements;
|
|
|
|
return arrsize*_xsize(&adesc->tdescElem);
|
|
|
|
}
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_UI8:
|
|
|
|
case VT_I8:
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE("(tdesc.vt %d)\n",tdesc->vt);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
switch (tdesc->vt) {
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_EMPTY: /* nothing. empty variant for instance */
|
2002-02-05 19:11:17 +01:00
|
|
|
return S_OK;
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_I8:
|
|
|
|
case VT_UI8:
|
|
|
|
hres = S_OK;
|
|
|
|
if (debugout) TRACE_(olerelay)("%lx%lx",arg[0],arg[1]);
|
|
|
|
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:
|
|
|
|
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;
|
|
|
|
if (debugout) TRACE_(olerelay)("%lx",*arg);
|
|
|
|
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;
|
|
|
|
if (debugout) TRACE_(olerelay)("%04lx",*arg & 0xffff);
|
|
|
|
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;
|
2005-03-27 20:17:19 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%02lx",*arg & 0xff);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
return hres;
|
2005-03-29 13:29:11 +02:00
|
|
|
case VT_I4|VT_BYREF:
|
|
|
|
hres = S_OK;
|
|
|
|
if (debugout) TRACE_(olerelay)("&0x%lx",*arg);
|
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)(DWORD*)*arg,sizeof(DWORD));
|
|
|
|
/* do not dealloc at this time */
|
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
case VT_VARIANT: {
|
2002-06-10 04:30:20 +02:00
|
|
|
TYPEDESC tdesc2;
|
|
|
|
VARIANT *vt = (VARIANT*)arg;
|
|
|
|
DWORD vttype = V_VT(vt);
|
2002-02-05 19:11:17 +01:00
|
|
|
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("Vt(%ld)(",vttype);
|
2002-02-05 19:11:17 +01:00
|
|
|
tdesc2.vt = vttype;
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit) {
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)&vttype,sizeof(vttype));
|
|
|
|
if (hres) return hres;
|
|
|
|
}
|
|
|
|
/* need to recurse since we need to free the stuff */
|
2005-08-08 20:38:29 +02:00
|
|
|
hres = serialize_param(tinfo,writeit,debugout,dealloc,&tdesc2,(DWORD*)&(V_I4(vt)),buf);
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)(")");
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
2005-03-14 11:09:11 +01:00
|
|
|
case VT_BSTR|VT_BYREF: {
|
2005-03-29 13:29:11 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("[byref]'%s'", *(BSTR*)*arg ? relaystr(*((BSTR*)*arg)) : "<bstr NULL>");
|
2005-03-14 11:09:11 +01:00
|
|
|
if (writeit) {
|
|
|
|
/* ptr to ptr to magic widestring, basically */
|
|
|
|
BSTR *bstr = (BSTR *) *arg;
|
2005-07-19 21:42:50 +02:00
|
|
|
DWORD len;
|
2005-03-29 13:29:11 +02:00
|
|
|
if (!*bstr) {
|
2005-03-14 11:09:11 +01:00
|
|
|
/* -1 means "null string" which is equivalent to empty string */
|
2005-07-19 21:42:50 +02:00
|
|
|
len = -1;
|
|
|
|
hres = xbuf_add(buf, (LPBYTE)&len,sizeof(DWORD));
|
|
|
|
if (hres) return hres;
|
2005-03-14 11:09:11 +01:00
|
|
|
} else {
|
2005-07-19 21:42:50 +02:00
|
|
|
len = *((DWORD*)*bstr-1)/sizeof(WCHAR);
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)&len,sizeof(DWORD));
|
|
|
|
if (hres) return hres;
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)*bstr,len * sizeof(WCHAR));
|
|
|
|
if (hres) return hres;
|
2005-03-14 11:09:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dealloc && arg) {
|
|
|
|
BSTR *str = *((BSTR **)arg);
|
|
|
|
SysFreeString(*str);
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
if (writeit) {
|
2005-07-19 21:42:50 +02:00
|
|
|
BSTR bstr = (BSTR)*arg;
|
|
|
|
DWORD len;
|
|
|
|
if (!bstr) {
|
|
|
|
len = -1;
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)&len,sizeof(DWORD));
|
|
|
|
if (hres) return hres;
|
2002-06-10 04:30:20 +02:00
|
|
|
} else {
|
2005-07-19 21:42:50 +02:00
|
|
|
len = *((DWORD*)bstr-1)/sizeof(WCHAR);
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)&len,sizeof(DWORD));
|
|
|
|
if (hres) return hres;
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)bstr,len * sizeof(WCHAR));
|
|
|
|
if (hres) return hres;
|
2002-06-10 04:30:20 +02:00
|
|
|
}
|
|
|
|
}
|
2003-12-01 23:36:49 +01:00
|
|
|
|
2002-06-10 04:30:20 +02:00
|
|
|
if (dealloc && arg)
|
2003-12-01 23:36:49 +01:00
|
|
|
SysFreeString((BSTR)*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.lptdesc->u.hreftype);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
switch (tattr->typekind) {
|
|
|
|
case TKIND_ENUM: /* confirmed */
|
|
|
|
case TKIND_RECORD: /* FIXME: mostly untested */
|
|
|
|
derefhere=TRUE;
|
|
|
|
break;
|
|
|
|
case TKIND_ALIAS: /* FIXME: untested */
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
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:
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("unk(0x%lx)",*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = _marshal_interface(buf,&IID_IUnknown,(LPUNKNOWN)*arg);
|
|
|
|
return hres;
|
|
|
|
case VT_DISPATCH:
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("idisp(0x%lx)",*arg);
|
2002-06-10 04:30:20 +02:00
|
|
|
if (writeit)
|
|
|
|
hres = _marshal_interface(buf,&IID_IDispatch,(LPUNKNOWN)*arg);
|
|
|
|
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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get typeinfo of hreftype %lx 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;
|
|
|
|
}
|
|
|
|
/* Need them for hack below */
|
|
|
|
/*
|
|
|
|
memset(names,0,sizeof(names));
|
|
|
|
hres = ITypeInfo_GetNames(tinfo2,vdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames);
|
|
|
|
if (nrofnames > sizeof(names)/sizeof(names[0])) {
|
|
|
|
ERR("Need more names!\n");
|
|
|
|
}
|
|
|
|
if (!hres && debugout)
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)("%s=",relaystr(names[0]));
|
2002-06-10 04:30:20 +02:00
|
|
|
*/
|
|
|
|
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:
|
|
|
|
return serialize_param(tinfo2,writeit,debugout,dealloc,&tattr->tdescAlias,arg,buf);
|
|
|
|
case TKIND_ENUM:
|
|
|
|
hres = S_OK;
|
|
|
|
if (debugout) TRACE_(olerelay)("%lx",*arg);
|
|
|
|
if (writeit)
|
|
|
|
hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
return hres;
|
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;
|
|
|
|
}
|
|
|
|
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++) {
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("[%ld]",adesc->rgbounds[i].cElements);
|
2002-06-10 04:30:20 +02:00
|
|
|
arrsize *= adesc->rgbounds[i].cElements;
|
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("(vt %d)",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++) {
|
|
|
|
hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem)), buf);
|
|
|
|
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)("]");
|
2002-06-10 04:30:20 +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;
|
|
|
|
|
|
|
|
TRACE("vt %d at %p\n",tdesc->vt,arg);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
switch (tdesc->vt) {
|
|
|
|
case VT_EMPTY:
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("<empty>");
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
|
|
|
case VT_NULL:
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("<null>");
|
2002-06-10 04:30:20 +02:00
|
|
|
return S_OK;
|
|
|
|
case VT_VARIANT: {
|
|
|
|
VARIANT *vt = (VARIANT*)arg;
|
|
|
|
|
|
|
|
if (readit) {
|
|
|
|
DWORD vttype;
|
|
|
|
TYPEDESC tdesc2;
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&vttype,sizeof(vttype));
|
|
|
|
if (hres) {
|
|
|
|
FIXME("vt type not read?\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
memset(&tdesc2,0,sizeof(tdesc2));
|
|
|
|
tdesc2.vt = vttype;
|
|
|
|
V_VT(vt) = vttype;
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("Vt(%ld)(",vttype);
|
2005-08-08 20:38:29 +02:00
|
|
|
hres = deserialize_param(tinfo, readit, debugout, alloc, &tdesc2, (DWORD*)&(V_I4(vt)), buf);
|
2004-06-18 01:03:26 +02:00
|
|
|
TRACE_(olerelay)(")");
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
} else {
|
|
|
|
VariantInit(vt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2005-11-04 12:13:55 +01:00
|
|
|
case VT_I8:
|
|
|
|
case VT_UI8:
|
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)arg,8);
|
|
|
|
if (hres) ERR("Failed to read integer 8 byte\n");
|
|
|
|
}
|
|
|
|
if (debugout) TRACE_(olerelay)("%lx%lx",arg[0],arg[1]);
|
|
|
|
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:
|
|
|
|
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
|
|
|
}
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%lx",*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);
|
|
|
|
}
|
|
|
|
if (debugout) TRACE_(olerelay)("%04lx",*arg & 0xffff);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
if (debugout) TRACE_(olerelay)("%02lx",*arg & 0xff);
|
|
|
|
return hres;
|
2005-03-29 13:29:11 +02:00
|
|
|
case VT_I4|VT_BYREF:
|
|
|
|
hres = S_OK;
|
|
|
|
if (alloc)
|
|
|
|
*arg = (DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DWORD));
|
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)*arg,sizeof(DWORD));
|
|
|
|
if (hres) ERR("Failed to read integer 4 byte\n");
|
|
|
|
}
|
|
|
|
if (debugout) TRACE_(olerelay)("&0x%lx",*(DWORD*)*arg);
|
|
|
|
return hres;
|
2005-03-14 11:09:11 +01:00
|
|
|
case VT_BSTR|VT_BYREF: {
|
|
|
|
BSTR **bstr = (BSTR **)arg;
|
|
|
|
WCHAR *str;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&len,sizeof(DWORD));
|
|
|
|
if (hres) {
|
|
|
|
ERR("failed to read bstr klen\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
if (len == -1) {
|
2005-03-29 13:29:11 +02:00
|
|
|
*bstr = CoTaskMemAlloc(sizeof(BSTR *));
|
|
|
|
**bstr = NULL;
|
2005-03-14 11:09:11 +01:00
|
|
|
if (debugout) TRACE_(olerelay)("<bstr NULL>");
|
|
|
|
} else {
|
2005-07-19 21:42:50 +02:00
|
|
|
str = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(len+1)*sizeof(WCHAR));
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)str,len*sizeof(WCHAR));
|
2005-03-14 11:09:11 +01:00
|
|
|
if (hres) {
|
|
|
|
ERR("Failed to read BSTR.\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
*bstr = CoTaskMemAlloc(sizeof(BSTR *));
|
|
|
|
**bstr = SysAllocStringLen(str,len);
|
|
|
|
if (debugout) TRACE_(olerelay)("%s",relaystr(str));
|
|
|
|
HeapFree(GetProcessHeap(),0,str);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*bstr = NULL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-06-10 04:30:20 +02:00
|
|
|
case VT_BSTR: {
|
|
|
|
WCHAR *str;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)&len,sizeof(DWORD));
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("failed to read bstr klen\n");
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
if (len == -1) {
|
|
|
|
*arg = 0;
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("<bstr NULL>");
|
2002-06-10 04:30:20 +02:00
|
|
|
} else {
|
2005-07-19 21:42:50 +02:00
|
|
|
str = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(len+1)*sizeof(WCHAR));
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)str,len*sizeof(WCHAR));
|
2002-06-10 04:30:20 +02:00
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Failed to read BSTR.\n");
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
*arg = (DWORD)SysAllocStringLen(str,len);
|
2004-06-18 01:03:26 +02:00
|
|
|
if (debugout) TRACE_(olerelay)("%s",relaystr(str));
|
2002-06-10 04:30:20 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,str);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*arg = 0;
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.lptdesc->u.hreftype);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
ITypeInfo_GetTypeAttr(tinfo2,&tattr);
|
|
|
|
switch (tattr->typekind) {
|
|
|
|
case TKIND_ENUM: /* confirmed */
|
|
|
|
case TKIND_RECORD: /* FIXME: mostly untested */
|
|
|
|
derefhere=TRUE;
|
|
|
|
break;
|
|
|
|
case TKIND_ALIAS: /* FIXME: untested */
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
*arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc));
|
|
|
|
}
|
|
|
|
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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Could not get typeinfo of hreftype %lx 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;
|
|
|
|
|
2005-03-14 11:09:11 +01:00
|
|
|
if (alloc)
|
|
|
|
*arg = (DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,tattr->cbSizeInstance);
|
|
|
|
|
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);
|
2002-06-10 04:30:20 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
hres = deserialize_param(
|
|
|
|
tinfo2,
|
|
|
|
readit,
|
|
|
|
debugout,
|
|
|
|
alloc,
|
|
|
|
&vdesc->elemdescVar.tdesc,
|
|
|
|
(DWORD*)(((LPBYTE)*arg)+vdesc->u.oInst),
|
|
|
|
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:
|
|
|
|
return deserialize_param(tinfo2,readit,debugout,alloc,&tattr->tdescAlias,arg,buf);
|
|
|
|
case TKIND_ENUM:
|
|
|
|
if (readit) {
|
|
|
|
hres = xbuf_get(buf,(LPBYTE)arg,sizeof(DWORD));
|
|
|
|
if (hres) ERR("Failed to read enum (4 byte)\n");
|
|
|
|
}
|
|
|
|
if (debugout) TRACE_(olerelay)("%lx",*arg);
|
|
|
|
return hres;
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
for (i=0;i<arrsize;i++)
|
|
|
|
deserialize_param(
|
|
|
|
tinfo,
|
|
|
|
readit,
|
|
|
|
debugout,
|
|
|
|
alloc,
|
|
|
|
&adesc->tdescElem,
|
|
|
|
(DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem)),
|
|
|
|
buf
|
|
|
|
);
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
/* Searches function, also in inherited interfaces */
|
|
|
|
static HRESULT
|
|
|
|
_get_funcdesc(
|
2005-12-06 21:24:19 +01:00
|
|
|
ITypeInfo *tinfo, int iMethod, ITypeInfo **tactual, const FUNCDESC **fdesc, BSTR *iname, BSTR *fname)
|
2004-09-07 22:42:26 +02:00
|
|
|
{
|
2002-02-05 19:11:17 +01:00
|
|
|
int i = 0, j = 0;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (fname) *fname = NULL;
|
|
|
|
if (iname) *iname = NULL;
|
|
|
|
|
2005-06-01 13:03:40 +02:00
|
|
|
*tactual = tinfo;
|
|
|
|
ITypeInfo_AddRef(*tactual);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
while (1) {
|
2005-12-06 21:24:19 +01:00
|
|
|
hres = ITypeInfoImpl_GetInternalFuncDesc(tinfo, i, fdesc);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
HREFTYPE href;
|
|
|
|
TYPEATTR *attr;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetTypeAttr(tinfo, &attr);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("GetTypeAttr failed with %lx\n",hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
/* Not found, so look in inherited ifaces. */
|
|
|
|
for (j=0;j<attr->cImplTypes;j++) {
|
|
|
|
hres = ITypeInfo_GetRefTypeOfImplType(tinfo, j, &href);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Did not find a reftype for interface offset %d?\n",j);
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Did not find a typeinfo for reftype %ld?\n",href);
|
2002-02-05 19:11:17 +01:00
|
|
|
continue;
|
|
|
|
}
|
2005-06-01 13:03:40 +02:00
|
|
|
hres = _get_funcdesc(tinfo2,iMethod,tactual,fdesc,iname,fname);
|
2002-02-05 19:11:17 +01:00
|
|
|
ITypeInfo_Release(tinfo2);
|
|
|
|
if (!hres) return S_OK;
|
|
|
|
}
|
2005-01-26 20:42:17 +01:00
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
if (((*fdesc)->oVft/4) == iMethod) {
|
|
|
|
if (fname)
|
|
|
|
ITypeInfo_GetDocumentation(tinfo,(*fdesc)->memid,fname,NULL,NULL,NULL);
|
|
|
|
if (iname)
|
|
|
|
ITypeInfo_GetDocumentation(tinfo,-1,iname,NULL,NULL,NULL);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2005-06-01 13:03:40 +02:00
|
|
|
hres = _get_funcdesc(tpinfo->tinfo,method,&tinfo,&fdesc,&iname,&fname);
|
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);
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo_Release(tinfo);
|
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
|
|
|
|
|
|
|
if (iname) SysFreeString(iname);
|
|
|
|
if (fname) SysFreeString(fname);
|
|
|
|
|
|
|
|
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. */
|
2005-10-26 14:06:49 +02:00
|
|
|
if (!(elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN || !elem->u.paramdesc.wParamFlags) && (elem->tdesc.vt != VT_PTR)) {
|
2005-03-27 19:51:59 +02:00
|
|
|
xargs+=_argsize(elem->tdesc.vt);
|
|
|
|
if (relaydeb) TRACE_(olerelay)("[out]");
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
hres = serialize_param(
|
|
|
|
tinfo,
|
2005-10-26 14:06:49 +02:00
|
|
|
elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN || !elem->u.paramdesc.wParamFlags,
|
2005-10-26 12:12:30 +02:00
|
|
|
relaydeb,
|
|
|
|
FALSE,
|
|
|
|
&elem->tdesc,
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2005-03-27 19:51:59 +02:00
|
|
|
|
|
|
|
if (hres) {
|
|
|
|
ERR("Failed to serialize param, hres %lx\n",hres);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
xargs+=_argsize(elem->tdesc.vt);
|
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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("RpcChannelBuffer GetBuffer failed, %lx\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) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("RpcChannelBuffer SendReceive failed, %lx\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
|
|
|
|
2005-03-28 12:00:49 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)(" status = %08lx (",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 */
|
|
|
|
if (!(elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT) && (elem->tdesc.vt != VT_PTR)) {
|
|
|
|
xargs += _argsize(elem->tdesc.vt);
|
|
|
|
if (relaydeb) TRACE_(olerelay)("[in]");
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-26 12:12:30 +02:00
|
|
|
hres = deserialize_param(
|
|
|
|
tinfo,
|
|
|
|
elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
|
|
|
|
relaydeb,
|
|
|
|
FALSE,
|
|
|
|
&(elem->tdesc),
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2005-03-27 19:51:59 +02:00
|
|
|
if (hres) {
|
|
|
|
ERR("Failed to unmarshall param, hres %lx\n",hres);
|
|
|
|
status = hres;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
xargs += _argsize(elem->tdesc.vt);
|
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;
|
2005-03-28 12:00:49 +02:00
|
|
|
if (relaydeb) TRACE_(olerelay)(") = %08lx\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:
|
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);
|
2005-11-02 21:00:00 +01:00
|
|
|
TRACE("-- 0x%08lx\n", hres);
|
|
|
|
return hres;
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
|
|
|
|
2005-03-11 11:18:31 +01:00
|
|
|
HRESULT WINAPI ProxyIUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI ProxyIUnknown_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
TMProxyImpl *proxy = (TMProxyImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (proxy->outerunknown)
|
|
|
|
return IUnknown_AddRef(proxy->outerunknown);
|
|
|
|
|
|
|
|
return 2; /* FIXME */
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI ProxyIUnknown_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pctinfo);
|
|
|
|
|
|
|
|
if (!This->dispatch)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(This->outerunknown, &IID_IDispatch,
|
|
|
|
(LPVOID *)&This->dispatch);
|
|
|
|
}
|
|
|
|
if (This->dispatch)
|
|
|
|
hr = IDispatch_GetTypeInfoCount(This->dispatch, pctinfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProxyIDispatch_GetTypeInfo(LPDISPATCH iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
|
|
|
|
{
|
|
|
|
TMProxyImpl *This = (TMProxyImpl *)iface;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%d, %lx, %p)\n", iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
if (!This->dispatch)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(This->outerunknown, &IID_IDispatch,
|
|
|
|
(LPVOID *)&This->dispatch);
|
|
|
|
}
|
|
|
|
if (This->dispatch)
|
|
|
|
hr = IDispatch_GetTypeInfo(This->dispatch, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProxyIDispatch_GetIDsOfNames(LPDISPATCH iface, REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId)
|
|
|
|
{
|
|
|
|
TMProxyImpl *This = (TMProxyImpl *)iface;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %d, 0x%lx, %p)\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
|
|
|
|
|
|
|
|
if (!This->dispatch)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(This->outerunknown, &IID_IDispatch,
|
|
|
|
(LPVOID *)&This->dispatch);
|
|
|
|
}
|
|
|
|
if (This->dispatch)
|
|
|
|
hr = IDispatch_GetIDsOfNames(This->dispatch, riid, rgszNames,
|
|
|
|
cNames, lcid, rgDispId);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%ld, %s, 0x%lx, 0x%x, %p, %p, %p, %p)\n", dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
if (!This->dispatch)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(This->outerunknown, &IID_IDispatch,
|
|
|
|
(LPVOID *)&This->dispatch);
|
|
|
|
}
|
|
|
|
if (This->dispatch)
|
|
|
|
hr = IDispatch_Invoke(This->dispatch, dispIdMember, riid, lcid,
|
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
int i, nroffuncs;
|
2005-12-06 21:24:19 +01:00
|
|
|
const FUNCDESC *fdesc;
|
2002-02-05 19:11:17 +01:00
|
|
|
TMProxyImpl *proxy;
|
2005-10-26 12:12:30 +02:00
|
|
|
TYPEATTR *typeattr;
|
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;
|
|
|
|
}
|
|
|
|
nroffuncs = _nroffuncs(tinfo);
|
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;
|
|
|
|
|
|
|
|
assert(sizeof(TMAsmProxy) == 12);
|
|
|
|
|
2005-10-26 12:12:30 +02:00
|
|
|
proxy->dispatch = 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;
|
|
|
|
}
|
|
|
|
|
2004-09-07 22:42:26 +02:00
|
|
|
InitializeCriticalSection(&proxy->crit);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
proxy->lpvtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPBYTE)*nroffuncs);
|
|
|
|
for (i=0;i<nroffuncs;i++) {
|
|
|
|
TMAsmProxy *xasm = proxy->asmstubs+i;
|
|
|
|
|
|
|
|
switch (i) {
|
2005-03-11 11:18:31 +01:00
|
|
|
case 0:
|
|
|
|
proxy->lpvtbl[i] = ProxyIUnknown_QueryInterface;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
proxy->lpvtbl[i] = ProxyIUnknown_AddRef;
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
2005-03-11 11:18:31 +01:00
|
|
|
case 2:
|
|
|
|
proxy->lpvtbl[i] = ProxyIUnknown_Release;
|
2002-02-05 19:11:17 +01:00
|
|
|
break;
|
|
|
|
default: {
|
|
|
|
int j;
|
2005-03-11 11:18:31 +01:00
|
|
|
/* nrofargs without This */
|
|
|
|
int nrofargs;
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo *tinfo2;
|
|
|
|
hres = _get_funcdesc(tinfo,i,&tinfo2,&fdesc,NULL,NULL);
|
|
|
|
ITypeInfo_Release(tinfo2);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("GetFuncDesc %lx should not fail here.\n",hres);
|
2002-02-05 19:11:17 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
/* some args take more than 4 byte on the stack */
|
|
|
|
nrofargs = 0;
|
|
|
|
for (j=0;j<fdesc->cParams;j++)
|
|
|
|
nrofargs += _argsize(fdesc->lprgelemdescParam[j].tdesc.vt);
|
|
|
|
|
2005-10-19 21:06:49 +02:00
|
|
|
#ifdef __i386__
|
2002-02-05 19:11:17 +01:00
|
|
|
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>
|
|
|
|
*/
|
2005-03-11 11:18:31 +01:00
|
|
|
xasm->popleax = 0x58;
|
|
|
|
xasm->pushlval = 0x6a;
|
|
|
|
xasm->nr = i;
|
|
|
|
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 */
|
|
|
|
proxy->lpvtbl[i] = xasm;
|
|
|
|
break;
|
2005-10-19 21:06:49 +02:00
|
|
|
#else
|
|
|
|
FIXME("not implemented on non i386\n");
|
|
|
|
return E_FAIL;
|
|
|
|
#endif
|
2005-03-11 11:18:31 +01:00
|
|
|
}
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
proxy->lpvtbl[3] = ProxyIDispatch_GetTypeInfoCount;
|
|
|
|
proxy->lpvtbl[4] = ProxyIDispatch_GetTypeInfo;
|
|
|
|
proxy->lpvtbl[5] = ProxyIDispatch_GetIDsOfNames;
|
|
|
|
proxy->lpvtbl[6] = ProxyIDispatch_Invoke;
|
|
|
|
}
|
|
|
|
ITypeInfo_ReleaseTypeAttr(tinfo, typeattr);
|
|
|
|
}
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
proxy->lpvtbl2 = &tmproxyvtable;
|
2005-09-18 13:10:37 +02:00
|
|
|
/* one reference for the proxy */
|
|
|
|
proxy->ref = 1;
|
2002-02-05 19:11:17 +01:00
|
|
|
proxy->tinfo = tinfo;
|
|
|
|
memcpy(&proxy->iid,riid,sizeof(*riid));
|
2004-12-20 18:05:44 +01:00
|
|
|
proxy->chanbuf = 0;
|
2002-02-05 19:11:17 +01:00
|
|
|
*ppv = (LPVOID)proxy;
|
|
|
|
*ppProxy = (IRpcProxyBuffer *)&(proxy->lpvtbl2);
|
2005-09-18 13:10:37 +02:00
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
2002-02-05 19:11:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
} 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)){
|
|
|
|
*ppv = (LPVOID)iface;
|
|
|
|
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
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
TRACE("(%p)->(ref before=%lu)\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
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
TRACE("(%p)->(ref before=%lu)\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);
|
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;
|
|
|
|
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;
|
|
|
|
}
|
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)
|
|
|
|
{
|
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;
|
|
|
|
DWORD *args, res, *xargs, nrofargs;
|
|
|
|
marshal_state buf;
|
2005-08-08 20:38:29 +02:00
|
|
|
UINT nrofnames;
|
2002-02-05 19:11:17 +01:00
|
|
|
BSTR names[10];
|
2005-10-26 12:12:30 +02:00
|
|
|
BSTR iname = NULL;
|
2005-06-01 13:03:40 +02:00
|
|
|
ITypeInfo *tinfo;
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
memset(&buf,0,sizeof(buf));
|
|
|
|
buf.size = xmsg->cbBuffer;
|
2005-05-11 17:56:59 +02:00
|
|
|
buf.base = HeapAlloc(GetProcessHeap(), 0, xmsg->cbBuffer);
|
|
|
|
memcpy(buf.base, xmsg->Buffer, xmsg->cbBuffer);
|
2002-02-05 19:11:17 +01:00
|
|
|
buf.curoff = 0;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
hres = _get_funcdesc(This->tinfo,xmsg->iMethod,&tinfo,&fdesc,&iname,NULL);
|
2002-02-05 19:11:17 +01:00
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("GetFuncDesc on method %ld failed with %lx\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");
|
|
|
|
ITypeInfo_Release(tinfo);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
2005-03-27 19:51:59 +02:00
|
|
|
|
|
|
|
if (iname) SysFreeString (iname);
|
|
|
|
|
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++)
|
|
|
|
nrofargs += _argsize(fdesc->lprgelemdescParam[i].tdesc.vt);
|
|
|
|
args = HeapAlloc(GetProcessHeap(),0,(nrofargs+1)*sizeof(DWORD));
|
|
|
|
if (!args) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* 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,
|
2005-10-26 14:06:49 +02:00
|
|
|
elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN || !elem->u.paramdesc.wParamFlags,
|
2005-10-26 12:12:30 +02:00
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
&(elem->tdesc),
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2002-02-05 19:11:17 +01:00
|
|
|
xargs += _argsize(elem->tdesc.vt);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Failed to deserialize param %s, hres %lx\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;
|
2002-02-05 19:11:17 +01:00
|
|
|
res = _invoke(
|
2005-03-27 19:51:59 +02:00
|
|
|
(*((FARPROC**)args[0]))[fdesc->oVft/4],
|
|
|
|
fdesc->callconv,
|
|
|
|
(xargs-args),
|
|
|
|
args
|
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,
|
|
|
|
elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
&elem->tdesc,
|
|
|
|
xargs,
|
|
|
|
&buf
|
|
|
|
);
|
2002-02-05 19:11:17 +01:00
|
|
|
xargs += _argsize(elem->tdesc.vt);
|
|
|
|
if (hres) {
|
2005-01-27 12:11:32 +01:00
|
|
|
ERR("Failed to stuballoc param, hres %lx\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));
|
|
|
|
if (hres != S_OK)
|
|
|
|
return hres;
|
2005-06-01 13:03:40 +02:00
|
|
|
|
|
|
|
ITypeInfo_Release(tinfo);
|
2005-08-29 23:46:51 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, args);
|
|
|
|
|
2002-02-05 19:11:17 +01:00
|
|
|
xmsg->cbBuffer = buf.curoff;
|
2005-08-29 23:46:51 +02:00
|
|
|
if (rpcchanbuf)
|
|
|
|
{
|
|
|
|
hres = IRpcChannelBuffer_GetBuffer(rpcchanbuf, xmsg, &This->iid);
|
|
|
|
if (hres != S_OK)
|
|
|
|
ERR("IRpcChannelBuffer_GetBuffer failed with error 0x%08lx\n", hres);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: remove this case when we start sending an IRpcChannelBuffer
|
|
|
|
* object with builtin OLE */
|
|
|
|
RPC_STATUS status = I_RpcGetBuffer((RPC_MESSAGE *)xmsg);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
|
|
|
ERR("I_RpcGetBuffer failed with error %ld\n", status);
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hres == S_OK)
|
|
|
|
memcpy(xmsg->Buffer, buf.base, buf.curoff);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf.base);
|
|
|
|
|
|
|
|
TRACE("returning\n");
|
|
|
|
return hres;
|
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;
|
|
|
|
|
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_guid(riid),pUnkServer,ppStub);
|
|
|
|
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;
|
|
|
|
}
|
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;
|
|
|
|
memcpy(&(stub->iid),riid,sizeof(*riid));
|
|
|
|
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");
|
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;
|
|
|
|
}
|