4 * Copyright 2002 Marcus Meissner
6 * The olerelay debug channel allows you to see calls marshalled by
7 * the typelib marshaller. It is not a generic COM relaying system.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define NONAMELESSUNION
35 #define NONAMELESSSTRUCT
46 #include "wine/debug.h"
48 static const WCHAR riidW[5] = {'r','i','i','d',0};
49 static const WCHAR pdispparamsW[] = {'p','d','i','s','p','p','a','r','a','m','s',0};
50 static const WCHAR ppvObjectW[] = {'p','p','v','O','b','j','e','c','t',0};
52 WINE_DEFAULT_DEBUG_CHANNEL(ole);
53 WINE_DECLARE_DEBUG_CHANNEL(olerelay);
55 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
57 typedef struct _marshal_state {
63 IID iid; /* HACK: for VT_VOID */
66 /* used in the olerelay code to avoid having the L"" stuff added by debugstr_w */
67 static char *relaystr(WCHAR *in) {
68 char *tmp = (char *)debugstr_w(in);
70 tmp[strlen(tmp)-1] = '\0';
75 xbuf_add(marshal_state *buf, LPBYTE stuff, DWORD size) {
76 while (buf->size - buf->curoff < size) {
79 buf->base = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,buf->base,buf->size);
83 buf->base = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,32);
89 memcpy(buf->base+buf->curoff,stuff,size);
95 xbuf_get(marshal_state *buf, LPBYTE stuff, DWORD size) {
96 if (buf->size < buf->curoff+size) return E_FAIL;
97 memcpy(stuff,buf->base+buf->curoff,size);
103 xbuf_skip(marshal_state *buf, DWORD size) {
104 if (buf->size < buf->curoff+size) return E_FAIL;
110 _unmarshal_interface(marshal_state *buf, REFIID riid, LPUNKNOWN *pUnk) {
112 ULARGE_INTEGER newpos;
113 LARGE_INTEGER seekto;
118 TRACE("...%s...\n",debugstr_guid(riid));
121 hres = xbuf_get(buf,(LPBYTE)&xsize,sizeof(xsize));
123 ERR("xbuf_get failed\n");
127 if (xsize == 0) return S_OK;
129 hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
131 ERR("Stream create failed %lx\n",hres);
135 hres = IStream_Write(pStm,buf->base+buf->curoff,xsize,&res);
137 ERR("stream write %lx\n",hres);
141 memset(&seekto,0,sizeof(seekto));
142 hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
144 ERR("Failed Seek %lx\n",hres);
148 hres = CoUnmarshalInterface(pStm,riid,(LPVOID*)pUnk);
150 ERR("Unmarshalling interface %s failed with %lx\n",debugstr_guid(riid),hres);
154 IStream_Release(pStm);
155 return xbuf_skip(buf,xsize);
159 _marshal_interface(marshal_state *buf, REFIID riid, LPUNKNOWN pUnk) {
160 LPUNKNOWN newiface = NULL;
161 LPBYTE tempbuf = NULL;
162 IStream *pStm = NULL;
164 ULARGE_INTEGER newpos;
165 LARGE_INTEGER seekto;
172 ERR("pUnk is NULL?\n");
176 TRACE("...%s...\n",debugstr_guid(riid));
177 hres = IUnknown_QueryInterface(pUnk,riid,(LPVOID*)&newiface);
179 WARN("%p does not support iface %s\n",pUnk,debugstr_guid(riid));
183 hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
185 ERR("Stream create failed %lx\n",hres);
189 hres = CoMarshalInterface(pStm,riid,newiface,0,NULL,0);
191 ERR("Marshalling interface %s failed with %lx\n", debugstr_guid(riid), hres);
195 hres = IStream_Stat(pStm,&ststg,0);
197 ERR("Stream stat failed\n");
201 tempbuf = HeapAlloc(GetProcessHeap(), 0, ststg.cbSize.u.LowPart);
202 memset(&seekto,0,sizeof(seekto));
203 hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
205 ERR("Failed Seek %lx\n",hres);
209 hres = IStream_Read(pStm,tempbuf,ststg.cbSize.u.LowPart,&res);
211 ERR("Failed Read %lx\n",hres);
215 xsize = ststg.cbSize.u.LowPart;
216 xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
217 hres = xbuf_add(buf,tempbuf,ststg.cbSize.u.LowPart);
219 HeapFree(GetProcessHeap(),0,tempbuf);
220 IUnknown_Release(newiface);
221 IStream_Release(pStm);
227 xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
228 if (pStm) IUnknown_Release(pStm);
229 if (newiface) IUnknown_Release(newiface);
230 HeapFree(GetProcessHeap(), 0, tempbuf);
234 /********************* OLE Proxy/Stub Factory ********************************/
235 static HRESULT WINAPI
236 PSFacBuf_QueryInterface(LPPSFACTORYBUFFER iface, REFIID iid, LPVOID *ppv) {
237 if (IsEqualIID(iid,&IID_IPSFactoryBuffer)||IsEqualIID(iid,&IID_IUnknown)) {
238 *ppv = (LPVOID)iface;
239 /* No ref counting, static class */
242 FIXME("(%s) unknown IID?\n",debugstr_guid(iid));
243 return E_NOINTERFACE;
246 static ULONG WINAPI PSFacBuf_AddRef(LPPSFACTORYBUFFER iface) { return 2; }
247 static ULONG WINAPI PSFacBuf_Release(LPPSFACTORYBUFFER iface) { return 1; }
250 _get_typeinfo_for_iid(REFIID riid, ITypeInfo**ti) {
253 char tlguid[200],typelibkey[300],interfacekey[300],ver[100];
256 DWORD tlguidlen, verlen, type, tlfnlen;
259 sprintf( interfacekey, "Interface\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
260 riid->Data1, riid->Data2, riid->Data3,
261 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
262 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]
265 if (RegOpenKeyA(HKEY_CLASSES_ROOT,interfacekey,&ikey)) {
266 ERR("No %s key found.\n",interfacekey);
270 tlguidlen = sizeof(tlguid);
271 if (RegQueryValueExA(ikey,NULL,NULL,&type,tlguid,&tlguidlen)) {
272 ERR("Getting typelib guid failed.\n");
277 verlen = sizeof(ver);
278 if (RegQueryValueExA(ikey,"Version",NULL,&type,ver,&verlen)) {
279 ERR("Could not get version value?\n");
284 sprintf(typelibkey,"Typelib\\%s\\%s\\0\\win32",tlguid,ver);
285 tlfnlen = sizeof(tlfn);
286 if (RegQueryValueA(HKEY_CLASSES_ROOT,typelibkey,tlfn,&tlfnlen)) {
287 ERR("Could not get typelib fn?\n");
290 MultiByteToWideChar(CP_ACP, 0, tlfn, -1, tlfnW, -1);
291 hres = LoadTypeLib(tlfnW,&tl);
293 ERR("Failed to load typelib for %s, but it should be there.\n",debugstr_guid(riid));
296 hres = ITypeLib_GetTypeInfoOfGuid(tl,riid,ti);
298 ERR("typelib does not contain info for %s?\n",debugstr_guid(riid));
299 ITypeLib_Release(tl);
302 /* FIXME: do this? ITypeLib_Release(tl); */
306 /* Determine nr of functions. Since we use the toplevel interface and all
307 * inherited ones have lower numbers, we are ok to not to descent into
308 * the inheritance tree I think.
310 static int _nroffuncs(ITypeInfo *tinfo) {
317 hres = ITypeInfo_GetFuncDesc(tinfo,n,&fdesc);
320 if (fdesc->oVft/4 > max)
329 #include "pshpack1.h"
331 typedef struct _TMAsmProxy {
345 # error You need to implement stubless proxies for your architecture
348 typedef struct _TMProxyImpl {
350 IRpcProxyBufferVtbl *lpvtbl2;
353 TMAsmProxy *asmstubs;
355 IRpcChannelBuffer* chanbuf;
357 CRITICAL_SECTION crit;
358 IUnknown *outerunknown;
361 static HRESULT WINAPI
362 TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface, REFIID riid, LPVOID *ppv)
365 if (IsEqualIID(riid,&IID_IUnknown)||IsEqualIID(riid,&IID_IRpcProxyBuffer)) {
366 *ppv = (LPVOID)iface;
367 IRpcProxyBuffer_AddRef(iface);
370 FIXME("no interface for %s\n",debugstr_guid(riid));
371 return E_NOINTERFACE;
375 TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface)
377 ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
378 ULONG refCount = InterlockedIncrement(&This->ref);
380 TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
386 TMProxyImpl_Release(LPRPCPROXYBUFFER iface)
388 ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
389 ULONG refCount = InterlockedDecrement(&This->ref);
391 TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
395 DeleteCriticalSection(&This->crit);
396 if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf);
397 VirtualFree(This->asmstubs, 0, MEM_RELEASE);
403 static HRESULT WINAPI
405 LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer)
407 ICOM_THIS_MULTI(TMProxyImpl, lpvtbl2, iface);
409 TRACE("(%p)\n", pRpcChannelBuffer);
411 EnterCriticalSection(&This->crit);
413 IRpcChannelBuffer_AddRef(pRpcChannelBuffer);
414 This->chanbuf = pRpcChannelBuffer;
416 LeaveCriticalSection(&This->crit);
422 TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface)
424 ICOM_THIS_MULTI(TMProxyImpl, lpvtbl2, iface);
428 EnterCriticalSection(&This->crit);
430 IRpcChannelBuffer_Release(This->chanbuf);
431 This->chanbuf = NULL;
433 LeaveCriticalSection(&This->crit);
437 static IRpcProxyBufferVtbl tmproxyvtable = {
438 TMProxyImpl_QueryInterface,
442 TMProxyImpl_Disconnect
445 /* how much space do we use on stack in DWORD steps. */
450 return sizeof(DATE)/sizeof(DWORD);
452 return (sizeof(VARIANT)+3)/sizeof(DWORD);
459 _xsize(TYPEDESC *td) {
464 return sizeof(VARIANT)+3;
467 ARRAYDESC *adesc = td->u.lpadesc;
469 for (i=0;i<adesc->cDims;i++)
470 arrsize *= adesc->rgbounds[i].cElements;
471 return arrsize*_xsize(&adesc->tdescElem);
496 TRACE("(tdesc.vt %d)\n",tdesc->vt);
499 case VT_EMPTY: /* nothing. empty variant for instance */
512 if (debugout) TRACE_(olerelay)("%lx",*arg);
514 hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
518 VARIANT *vt = (VARIANT*)arg;
519 DWORD vttype = V_VT(vt);
521 if (debugout) TRACE_(olerelay)("Vt(%ld)(",vttype);
524 hres = xbuf_add(buf,(LPBYTE)&vttype,sizeof(vttype));
525 if (hres) return hres;
527 /* need to recurse since we need to free the stuff */
528 hres = serialize_param(tinfo,writeit,debugout,dealloc,&tdesc2,&(V_I4(vt)),buf);
529 if (debugout) TRACE_(olerelay)(")");
532 case VT_BSTR|VT_BYREF: {
533 if (debugout) TRACE_(olerelay)("[byref]'%s'", *arg ? relaystr(*((BSTR*)*arg)) : "<bstr NULL>");
535 /* ptr to ptr to magic widestring, basically */
536 BSTR *bstr = (BSTR *) *arg;
538 /* -1 means "null string" which is equivalent to empty string */
540 xbuf_add(buf, (LPBYTE)&fakelen,4);
542 /* BSTRs store the length behind the first character */
543 DWORD *len = ((DWORD *)(*bstr))-1;
544 hres = xbuf_add(buf, (LPBYTE) len, *len + 4);
545 if (hres) return hres;
549 if (dealloc && arg) {
550 BSTR *str = *((BSTR **)arg);
559 TRACE_(olerelay)("%s",relaystr((BSTR)*arg));
561 TRACE_(olerelay)("<bstr NULL>");
566 hres = xbuf_add(buf,(LPBYTE)&fakelen,4);
570 DWORD *bstr = ((DWORD*)(*arg))-1;
572 hres = xbuf_add(buf,(LPBYTE)bstr,bstr[0]+4);
579 SysFreeString((BSTR)*arg);
585 if (debugout) TRACE_(olerelay)("*");
587 cookie = *arg ? 0x42424242 : 0;
588 hres = xbuf_add(buf,(LPBYTE)&cookie,sizeof(cookie));
593 if (debugout) TRACE_(olerelay)("NULL");
596 hres = serialize_param(tinfo,writeit,debugout,dealloc,tdesc->u.lptdesc,(DWORD*)*arg,buf);
597 if (dealloc) HeapFree(GetProcessHeap(),0,(LPVOID)arg);
601 if (debugout) TRACE_(olerelay)("unk(0x%lx)",*arg);
603 hres = _marshal_interface(buf,&IID_IUnknown,(LPUNKNOWN)*arg);
606 if (debugout) TRACE_(olerelay)("idisp(0x%lx)",*arg);
608 hres = _marshal_interface(buf,&IID_IDispatch,(LPUNKNOWN)*arg);
611 if (debugout) TRACE_(olerelay)("<void>");
613 case VT_USERDEFINED: {
617 hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
619 ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.hreftype);
622 ITypeInfo_GetTypeAttr(tinfo2,&tattr);
623 switch (tattr->typekind) {
625 case TKIND_INTERFACE:
627 hres=_marshal_interface(buf,&(tattr->guid),(LPUNKNOWN)arg);
631 if (debugout) TRACE_(olerelay)("{");
632 for (i=0;i<tattr->cVars;i++) {
637 hres = ITypeInfo2_GetVarDesc(tinfo2, i, &vdesc);
639 ERR("Could not get vardesc of %d\n",i);
642 /* Need them for hack below */
644 memset(names,0,sizeof(names));
645 hres = ITypeInfo_GetNames(tinfo2,vdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames);
646 if (nrofnames > sizeof(names)/sizeof(names[0])) {
647 ERR("Need more names!\n");
649 if (!hres && debugout)
650 TRACE_(olerelay)("%s=",relaystr(names[0]));
652 elem2 = &vdesc->elemdescVar;
653 tdesc2 = &elem2->tdesc;
654 hres = serialize_param(
660 (DWORD*)(((LPBYTE)arg)+vdesc->u.oInst),
665 if (debugout && (i<(tattr->cVars-1)))
666 TRACE_(olerelay)(",");
668 if (buf->thisisiid && (tattr->cbSizeInstance==sizeof(GUID)))
669 memcpy(&(buf->iid),arg,sizeof(buf->iid));
670 if (debugout) TRACE_(olerelay)("}");
674 FIXME("Unhandled typekind %d\n",tattr->typekind);
678 ITypeInfo_Release(tinfo2);
682 ARRAYDESC *adesc = tdesc->u.lpadesc;
685 if (debugout) TRACE_(olerelay)("carr");
686 for (i=0;i<adesc->cDims;i++) {
687 if (debugout) TRACE_(olerelay)("[%ld]",adesc->rgbounds[i].cElements);
688 arrsize *= adesc->rgbounds[i].cElements;
690 if (debugout) TRACE_(olerelay)("[");
691 for (i=0;i<arrsize;i++) {
692 hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem)), buf);
695 if (debugout && (i<arrsize-1)) TRACE_(olerelay)(",");
697 if (debugout) TRACE_(olerelay)("]");
701 ERR("Unhandled marshal type %d.\n",tdesc->vt);
707 serialize_LPVOID_ptr(
719 if ((tdesc->vt != VT_PTR) ||
720 (tdesc->u.lptdesc->vt != VT_PTR) ||
721 (tdesc->u.lptdesc->u.lptdesc->vt != VT_VOID)
723 FIXME("ppvObject not expressed as VT_PTR -> VT_PTR -> VT_VOID?\n");
726 cookie = (*arg) ? 0x42424242: 0x0;
728 hres = xbuf_add(buf, (LPVOID)&cookie, sizeof(cookie));
733 if (debugout) TRACE_(olerelay)("<lpvoid NULL>");
737 TRACE_(olerelay)("ppv(%p)",*(LPUNKNOWN*)*arg);
739 hres = _marshal_interface(buf,&(buf->iid),*(LPUNKNOWN*)*arg);
744 HeapFree(GetProcessHeap(),0,(LPVOID)*arg);
749 serialize_DISPPARAM_ptr(
763 if ((tdesc->vt != VT_PTR) || (tdesc->u.lptdesc->vt != VT_USERDEFINED)) {
764 FIXME("DISPPARAMS not expressed as VT_PTR -> VT_USERDEFINED?\n");
768 cookie = *arg ? 0x42424242 : 0x0;
770 hres = xbuf_add(buf,(LPBYTE)&cookie,sizeof(cookie));
775 if (debugout) TRACE_(olerelay)("<DISPPARAMS NULL>");
778 disp = (DISPPARAMS*)*arg;
780 hres = xbuf_add(buf,(LPBYTE)&disp->cArgs,sizeof(disp->cArgs));
784 if (debugout) TRACE_(olerelay)("D{");
785 for (i=0;i<disp->cArgs;i++) {
788 vtdesc.vt = VT_VARIANT;
795 (DWORD*)(disp->rgvarg+i),
798 if (debugout && (i<disp->cArgs-1))
799 TRACE_(olerelay)(",");
802 HeapFree(GetProcessHeap(),0,disp->rgvarg);
804 hres = xbuf_add(buf,(LPBYTE)&disp->cNamedArgs,sizeof(disp->cNamedArgs));
808 if (debugout) TRACE_(olerelay)("}{");
809 for (i=0;i<disp->cNamedArgs;i++) {
819 (DWORD*)(disp->rgdispidNamedArgs+i),
822 if (debugout && (i<disp->cNamedArgs-1))
823 TRACE_(olerelay)(",");
825 if (debugout) TRACE_(olerelay)("}");
827 HeapFree(GetProcessHeap(),0,disp->rgdispidNamedArgs);
828 HeapFree(GetProcessHeap(),0,disp);
845 TRACE("vt %d at %p\n",tdesc->vt,arg);
850 if (debugout) TRACE_(olerelay)("<empty>");
853 if (debugout) TRACE_(olerelay)("<null>");
856 VARIANT *vt = (VARIANT*)arg;
861 hres = xbuf_get(buf,(LPBYTE)&vttype,sizeof(vttype));
863 FIXME("vt type not read?\n");
866 memset(&tdesc2,0,sizeof(tdesc2));
869 if (debugout) TRACE_(olerelay)("Vt(%ld)(",vttype);
870 hres = deserialize_param(tinfo, readit, debugout, alloc, &tdesc2, &(V_I4(vt)), buf);
871 TRACE_(olerelay)(")");
889 hres = xbuf_get(buf,(LPBYTE)arg,sizeof(DWORD));
890 if (hres) ERR("Failed to read integer 4 byte\n");
892 if (debugout) TRACE_(olerelay)("%lx",*arg);
894 case VT_BSTR|VT_BYREF: {
895 BSTR **bstr = (BSTR **)arg;
900 hres = xbuf_get(buf,(LPBYTE)&len,sizeof(DWORD));
902 ERR("failed to read bstr klen\n");
907 if (debugout) TRACE_(olerelay)("<bstr NULL>");
909 str = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,len+sizeof(WCHAR));
910 hres = xbuf_get(buf,(LPBYTE)str,len);
912 ERR("Failed to read BSTR.\n");
915 *bstr = CoTaskMemAlloc(sizeof(BSTR *));
916 **bstr = SysAllocStringLen(str,len);
917 if (debugout) TRACE_(olerelay)("%s",relaystr(str));
918 HeapFree(GetProcessHeap(),0,str);
930 hres = xbuf_get(buf,(LPBYTE)&len,sizeof(DWORD));
932 ERR("failed to read bstr klen\n");
937 if (debugout) TRACE_(olerelay)("<bstr NULL>");
939 str = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,len+sizeof(WCHAR));
940 hres = xbuf_get(buf,(LPBYTE)str,len);
942 ERR("Failed to read BSTR.\n");
945 *arg = (DWORD)SysAllocStringLen(str,len);
946 if (debugout) TRACE_(olerelay)("%s",relaystr(str));
947 HeapFree(GetProcessHeap(),0,str);
958 derefhere = (tdesc->u.lptdesc->vt != VT_USERDEFINED);
961 hres = xbuf_get(buf,(LPBYTE)&cookie,sizeof(cookie));
963 ERR("Failed to load pointer cookie.\n");
966 if (cookie != 0x42424242) {
967 if (debugout) TRACE_(olerelay)("NULL");
971 if (debugout) TRACE_(olerelay)("*");
975 *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc));
978 return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, (LPDWORD)*arg, buf);
980 return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, arg, buf);
983 /* FIXME: UNKNOWN is unknown ..., but allocate 4 byte for it */
985 *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DWORD));
988 hres = _unmarshal_interface(buf,&IID_IUnknown,(LPUNKNOWN*)arg);
990 TRACE_(olerelay)("unk(%p)",arg);
995 hres = _unmarshal_interface(buf,&IID_IDispatch,(LPUNKNOWN*)arg);
997 TRACE_(olerelay)("idisp(%p)",arg);
1000 if (debugout) TRACE_(olerelay)("<void>");
1002 case VT_USERDEFINED: {
1006 hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
1008 ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.hreftype);
1011 hres = ITypeInfo_GetTypeAttr(tinfo2,&tattr);
1013 ERR("Could not get typeattr in VT_USERDEFINED.\n");
1015 switch (tattr->typekind) {
1016 case TKIND_DISPATCH:
1017 case TKIND_INTERFACE:
1019 hres = _unmarshal_interface(buf,&(tattr->guid),(LPUNKNOWN*)arg);
1021 case TKIND_RECORD: {
1025 *arg = (DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,tattr->cbSizeInstance);
1027 if (debugout) TRACE_(olerelay)("{");
1028 for (i=0;i<tattr->cVars;i++) {
1031 hres = ITypeInfo2_GetVarDesc(tinfo2, i, &vdesc);
1033 ERR("Could not get vardesc of %d\n",i);
1036 hres = deserialize_param(
1041 &vdesc->elemdescVar.tdesc,
1042 (DWORD*)(((LPBYTE)*arg)+vdesc->u.oInst),
1045 if (debugout && (i<tattr->cVars-1)) TRACE_(olerelay)(",");
1047 if (buf->thisisiid && (tattr->cbSizeInstance==sizeof(GUID)))
1048 memcpy(&(buf->iid),(LPBYTE)*arg,sizeof(buf->iid));
1049 if (debugout) TRACE_(olerelay)("}");
1053 ERR("Unhandled typekind %d\n",tattr->typekind);
1059 ERR("failed to stuballoc in TKIND_RECORD.\n");
1060 ITypeInfo_Release(tinfo2);
1064 /* arg is pointing to the start of the array. */
1065 ARRAYDESC *adesc = tdesc->u.lpadesc;
1068 if (adesc->cDims > 1) FIXME("cDims > 1 in VT_CARRAY. Does it work?\n");
1069 for (i=0;i<adesc->cDims;i++)
1070 arrsize *= adesc->rgbounds[i].cElements;
1071 for (i=0;i<arrsize;i++)
1078 (DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem)),
1084 ERR("No handler for VT type %d!\n",tdesc->vt);
1091 deserialize_LPVOID_ptr(
1103 if ((tdesc->vt != VT_PTR) ||
1104 (tdesc->u.lptdesc->vt != VT_PTR) ||
1105 (tdesc->u.lptdesc->u.lptdesc->vt != VT_VOID)
1107 FIXME("ppvObject not expressed as VT_PTR -> VT_PTR -> VT_VOID?\n");
1111 *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(LPVOID));
1113 hres = xbuf_get(buf, (LPVOID)&cookie, sizeof(cookie));
1116 if (cookie != 0x42424242) {
1118 if (debugout) TRACE_(olerelay)("<lpvoid NULL>");
1123 hres = _unmarshal_interface(buf,&buf->iid,(LPUNKNOWN*)*arg);
1127 if (debugout) TRACE_(olerelay)("ppv(%p)",(LPVOID)*arg);
1132 deserialize_DISPPARAM_ptr(
1146 if ((tdesc->vt != VT_PTR) || (tdesc->u.lptdesc->vt != VT_USERDEFINED)) {
1147 FIXME("DISPPARAMS not expressed as VT_PTR -> VT_USERDEFINED?\n");
1151 hres = xbuf_get(buf,(LPBYTE)&cookie,sizeof(cookie));
1156 if (debugout) TRACE_(olerelay)("<DISPPARAMS NULL>");
1161 *arg = (DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DISPPARAMS));
1162 disps = (DISPPARAMS*)*arg;
1165 hres = xbuf_get(buf, (LPBYTE)&disps->cArgs, sizeof(disps->cArgs));
1169 disps->rgvarg = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(VARIANT)*disps->cArgs);
1170 if (debugout) TRACE_(olerelay)("D{");
1171 for (i=0; i< disps->cArgs; i++) {
1174 vdesc.vt = VT_VARIANT;
1175 hres = deserialize_param(
1181 (DWORD*)(disps->rgvarg+i),
1185 if (debugout) TRACE_(olerelay)("}{");
1186 hres = xbuf_get(buf, (LPBYTE)&disps->cNamedArgs, sizeof(disps->cNamedArgs));
1189 if (disps->cNamedArgs) {
1191 disps->rgdispidNamedArgs = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DISPID)*disps->cNamedArgs);
1192 for (i=0; i< disps->cNamedArgs; i++) {
1196 hres = deserialize_param(
1202 (DWORD*)(disps->rgdispidNamedArgs+i),
1205 if (debugout && i<(disps->cNamedArgs-1)) TRACE_(olerelay)(",");
1208 if (debugout) TRACE_(olerelay)("}");
1212 /* Searches function, also in inherited interfaces */
1215 ITypeInfo *tinfo, int iMethod, FUNCDESC **fdesc, BSTR *iname, BSTR *fname)
1220 if (fname) *fname = NULL;
1221 if (iname) *iname = NULL;
1224 hres = ITypeInfo_GetFuncDesc(tinfo, i, fdesc);
1230 hres = ITypeInfo_GetTypeAttr(tinfo, &attr);
1232 ERR("GetTypeAttr failed with %lx\n",hres);
1235 /* Not found, so look in inherited ifaces. */
1236 for (j=0;j<attr->cImplTypes;j++) {
1237 hres = ITypeInfo_GetRefTypeOfImplType(tinfo, j, &href);
1239 ERR("Did not find a reftype for interface offset %d?\n",j);
1242 hres = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
1244 ERR("Did not find a typeinfo for reftype %ld?\n",href);
1247 hres = _get_funcdesc(tinfo2,iMethod,fdesc,iname,fname);
1248 ITypeInfo_Release(tinfo2);
1249 if (!hres) return S_OK;
1253 if (((*fdesc)->oVft/4) == iMethod) {
1255 ITypeInfo_GetDocumentation(tinfo,(*fdesc)->memid,fname,NULL,NULL,NULL);
1257 ITypeInfo_GetDocumentation(tinfo,-1,iname,NULL,NULL,NULL);
1265 xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
1267 DWORD *args = ((DWORD*)&tpinfo)+1, *xargs;
1270 int i, relaydeb = TRACE_ON(olerelay);
1278 EnterCriticalSection(&tpinfo->crit);
1280 hres = _get_funcdesc(tpinfo->tinfo,method,&fdesc,&iname,&fname);
1282 ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method);
1283 LeaveCriticalSection(&tpinfo->crit);
1287 if (!tpinfo->chanbuf)
1289 WARN("Tried to use disconnected proxy\n");
1290 LeaveCriticalSection(&tpinfo->crit);
1291 return RPC_E_DISCONNECTED;
1295 TRACE_(olerelay)("->");
1297 TRACE_(olerelay)("%s:",relaystr(iname));
1299 TRACE_(olerelay)("%s(%d)",relaystr(fname),method);
1301 TRACE_(olerelay)("%d",method);
1302 TRACE_(olerelay)("(");
1303 if (iname) SysFreeString(iname);
1304 if (fname) SysFreeString(fname);
1306 /* Need them for hack below */
1307 memset(names,0,sizeof(names));
1308 if (ITypeInfo_GetNames(tpinfo->tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames))
1310 if (nrofnames > sizeof(names)/sizeof(names[0]))
1311 ERR("Need more names!\n");
1313 memset(&buf,0,sizeof(buf));
1314 buf.iid = IID_IUnknown;
1316 xbuf_add(&buf,(LPBYTE)args[0],sizeof(IID));
1317 if (relaydeb) TRACE_(olerelay)("riid=%s,[out]",debugstr_guid((REFIID)args[0]));
1320 for (i=0;i<fdesc->cParams;i++) {
1321 ELEMDESC *elem = fdesc->lprgelemdescParam+i;
1322 BOOL isserialized = FALSE;
1324 if (i) TRACE_(olerelay)(",");
1325 if (i+1<nrofnames && names[i+1])
1326 TRACE_(olerelay)("%s=",relaystr(names[i+1]));
1328 /* No need to marshal other data than FIN */
1329 if (!(elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN)) {
1330 xargs+=_argsize(elem->tdesc.vt);
1331 if (relaydeb) TRACE_(olerelay)("[out]");
1334 if (((i+1)<nrofnames) && !IsBadStringPtrW(names[i+1],1)) {
1335 /* If the parameter is 'riid', we use it as interface IID
1336 * for a later ppvObject serialization.
1338 buf.thisisiid = !lstrcmpW(names[i+1],riidW);
1340 /* DISPPARAMS* needs special serializer */
1341 if (!lstrcmpW(names[i+1],pdispparamsW)) {
1342 hres = serialize_DISPPARAM_ptr(
1344 elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN,
1351 isserialized = TRUE;
1353 if (!lstrcmpW(names[i+1],ppvObjectW)) {
1354 hres = serialize_LPVOID_ptr(
1356 elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN,
1364 isserialized = TRUE;
1368 hres = serialize_param(
1370 elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN,
1379 ERR("Failed to serialize param, hres %lx\n",hres);
1382 xargs+=_argsize(elem->tdesc.vt);
1385 if (relaydeb) TRACE_(olerelay)(")");
1386 memset(&msg,0,sizeof(msg));
1387 msg.cbBuffer = buf.curoff;
1388 msg.iMethod = method;
1389 hres = IRpcChannelBuffer_GetBuffer(tpinfo->chanbuf,&msg,&(tpinfo->iid));
1391 ERR("RpcChannelBuffer GetBuffer failed, %lx\n",hres);
1392 LeaveCriticalSection(&tpinfo->crit);
1395 memcpy(msg.Buffer,buf.base,buf.curoff);
1396 if (relaydeb) TRACE_(olerelay)("\n");
1397 hres = IRpcChannelBuffer_SendReceive(tpinfo->chanbuf,&msg,&status);
1399 ERR("RpcChannelBuffer SendReceive failed, %lx\n",hres);
1400 LeaveCriticalSection(&tpinfo->crit);
1404 if (relaydeb) TRACE_(olerelay)(" = %08lx (",status);
1406 buf.base = HeapReAlloc(GetProcessHeap(),0,buf.base,msg.cbBuffer);
1408 buf.base = HeapAlloc(GetProcessHeap(),0,msg.cbBuffer);
1409 buf.size = msg.cbBuffer;
1410 memcpy(buf.base,msg.Buffer,buf.size);
1413 _unmarshal_interface(&buf,(REFIID)args[0],(LPUNKNOWN*)args[1]);
1414 if (relaydeb) TRACE_(olerelay)("[in],%p",*((DWORD**)args[1]));
1417 for (i=0;i<fdesc->cParams;i++) {
1418 ELEMDESC *elem = fdesc->lprgelemdescParam+i;
1419 BOOL isdeserialized = FALSE;
1422 if (i) TRACE_(olerelay)(",");
1423 if (i+1<nrofnames && names[i+1]) TRACE_(olerelay)("%s=",relaystr(names[i+1]));
1425 /* No need to marshal other data than FOUT I think */
1426 if (!(elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT)) {
1427 xargs += _argsize(elem->tdesc.vt);
1428 if (relaydeb) TRACE_(olerelay)("[in]");
1431 if (((i+1)<nrofnames) && !IsBadStringPtrW(names[i+1],1)) {
1432 /* If the parameter is 'riid', we use it as interface IID
1433 * for a later ppvObject serialization.
1435 buf.thisisiid = !lstrcmpW(names[i+1],riidW);
1437 /* deserialize DISPPARAM */
1438 if (!lstrcmpW(names[i+1],pdispparamsW)) {
1439 hres = deserialize_DISPPARAM_ptr(
1441 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1449 ERR("Failed to deserialize DISPPARAM*, hres %lx\n",hres);
1452 isdeserialized = TRUE;
1454 if (!lstrcmpW(names[i+1],ppvObjectW)) {
1455 hres = deserialize_LPVOID_ptr(
1457 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1465 isdeserialized = TRUE;
1468 if (!isdeserialized)
1469 hres = deserialize_param(
1471 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1479 ERR("Failed to unmarshall param, hres %lx\n",hres);
1483 xargs += _argsize(elem->tdesc.vt);
1486 if (relaydeb) TRACE_(olerelay)(")\n");
1487 HeapFree(GetProcessHeap(),0,buf.base);
1489 LeaveCriticalSection(&tpinfo->crit);
1494 HRESULT WINAPI ProxyIUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
1496 TMProxyImpl *proxy = (TMProxyImpl *)iface;
1498 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
1500 if (proxy->outerunknown)
1501 return IUnknown_QueryInterface(proxy->outerunknown, riid, ppv);
1503 FIXME("No interface\n");
1504 return E_NOINTERFACE;
1507 ULONG WINAPI ProxyIUnknown_AddRef(IUnknown *iface)
1509 TMProxyImpl *proxy = (TMProxyImpl *)iface;
1513 if (proxy->outerunknown)
1514 return IUnknown_AddRef(proxy->outerunknown);
1516 return 2; /* FIXME */
1519 ULONG WINAPI ProxyIUnknown_Release(IUnknown *iface)
1521 TMProxyImpl *proxy = (TMProxyImpl *)iface;
1525 if (proxy->outerunknown)
1526 return IUnknown_Release(proxy->outerunknown);
1528 return 1; /* FIXME */
1531 static HRESULT WINAPI
1532 PSFacBuf_CreateProxy(
1533 LPPSFACTORYBUFFER iface, IUnknown* pUnkOuter, REFIID riid,
1534 IRpcProxyBuffer **ppProxy, LPVOID *ppv)
1542 TRACE("(...%s...)\n",debugstr_guid(riid));
1543 hres = _get_typeinfo_for_iid(riid,&tinfo);
1545 ERR("No typeinfo for %s?\n",debugstr_guid(riid));
1548 nroffuncs = _nroffuncs(tinfo);
1549 proxy = CoTaskMemAlloc(sizeof(TMProxyImpl));
1550 if (!proxy) return E_OUTOFMEMORY;
1552 assert(sizeof(TMAsmProxy) == 12);
1554 proxy->outerunknown = pUnkOuter;
1555 proxy->asmstubs = VirtualAlloc(NULL, sizeof(TMAsmProxy) * nroffuncs, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
1556 if (!proxy->asmstubs) {
1557 ERR("Could not commit pages for proxy thunks\n");
1558 CoTaskMemFree(proxy);
1559 return E_OUTOFMEMORY;
1562 InitializeCriticalSection(&proxy->crit);
1564 proxy->lpvtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPBYTE)*nroffuncs);
1565 for (i=0;i<nroffuncs;i++) {
1566 TMAsmProxy *xasm = proxy->asmstubs+i;
1570 proxy->lpvtbl[i] = ProxyIUnknown_QueryInterface;
1573 proxy->lpvtbl[i] = ProxyIUnknown_AddRef;
1576 proxy->lpvtbl[i] = ProxyIUnknown_Release;
1580 /* nrofargs without This */
1582 hres = _get_funcdesc(tinfo,i,&fdesc,NULL,NULL);
1584 ERR("GetFuncDesc %lx should not fail here.\n",hres);
1587 /* some args take more than 4 byte on the stack */
1589 for (j=0;j<fdesc->cParams;j++)
1590 nrofargs += _argsize(fdesc->lprgelemdescParam[j].tdesc.vt);
1592 if (fdesc->callconv != CC_STDCALL) {
1593 ERR("calling convention is not stdcall????\n");
1596 /* popl %eax - return ptr
1603 * arg3 arg2 arg1 <method> <returnptr>
1605 xasm->popleax = 0x58;
1606 xasm->pushlval = 0x6a;
1608 xasm->pushleax = 0x50;
1609 xasm->lcall = 0xe8; /* relative jump */
1610 xasm->xcall = (DWORD)xCall;
1611 xasm->xcall -= (DWORD)&(xasm->lret);
1613 xasm->bytestopop= (nrofargs+2)*4; /* pop args, This, iMethod */
1614 proxy->lpvtbl[i] = xasm;
1619 proxy->lpvtbl2 = &tmproxyvtable;
1620 /* 1 reference for the proxy and 1 for the object */
1622 proxy->tinfo = tinfo;
1623 memcpy(&proxy->iid,riid,sizeof(*riid));
1625 *ppv = (LPVOID)proxy;
1626 *ppProxy = (IRpcProxyBuffer *)&(proxy->lpvtbl2);
1630 typedef struct _TMStubImpl {
1631 IRpcStubBufferVtbl *lpvtbl;
1639 static HRESULT WINAPI
1640 TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv)
1642 if (IsEqualIID(riid,&IID_IRpcStubBuffer)||IsEqualIID(riid,&IID_IUnknown)){
1643 *ppv = (LPVOID)iface;
1644 IRpcStubBuffer_AddRef(iface);
1647 FIXME("%s, not supported IID.\n",debugstr_guid(riid));
1648 return E_NOINTERFACE;
1652 TMStubImpl_AddRef(LPRPCSTUBBUFFER iface)
1654 TMStubImpl *This = (TMStubImpl *)iface;
1655 ULONG refCount = InterlockedIncrement(&This->ref);
1657 TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
1663 TMStubImpl_Release(LPRPCSTUBBUFFER iface)
1665 TMStubImpl *This = (TMStubImpl *)iface;
1666 ULONG refCount = InterlockedDecrement(&This->ref);
1668 TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1);
1672 IRpcStubBuffer_Disconnect(iface);
1673 CoTaskMemFree(This);
1678 static HRESULT WINAPI
1679 TMStubImpl_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN pUnkServer)
1681 TMStubImpl *This = (TMStubImpl *)iface;
1683 TRACE("(%p)->(%p)\n", This, pUnkServer);
1685 IUnknown_AddRef(pUnkServer);
1686 This->pUnk = pUnkServer;
1691 TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface)
1693 TMStubImpl *This = (TMStubImpl *)iface;
1695 TRACE("(%p)->()\n", This);
1697 IUnknown_Release(This->pUnk);
1702 static HRESULT WINAPI
1704 LPRPCSTUBBUFFER iface, RPCOLEMESSAGE* xmsg,IRpcChannelBuffer*rpcchanbuf)
1708 TMStubImpl *This = (TMStubImpl *)iface;
1710 DWORD *args, res, *xargs, nrofargs;
1715 memset(&buf,0,sizeof(buf));
1716 buf.size = xmsg->cbBuffer;
1717 buf.base = xmsg->Buffer;
1719 buf.iid = IID_IUnknown;
1722 if (xmsg->iMethod == 0) { /* QI */
1724 /* in: IID, out: <iface> */
1726 xbuf_get(&buf,(LPBYTE)&xiid,sizeof(xiid));
1728 hres = _marshal_interface(&buf,&xiid,This->pUnk);
1729 xmsg->Buffer = buf.base; /* Might have been reallocated */
1730 xmsg->cbBuffer = buf.size;
1733 hres = _get_funcdesc(This->tinfo,xmsg->iMethod,&fdesc,NULL,NULL);
1735 ERR("GetFuncDesc on method %ld failed with %lx\n",xmsg->iMethod,hres);
1738 /* Need them for hack below */
1739 memset(names,0,sizeof(names));
1740 ITypeInfo_GetNames(This->tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames);
1741 if (nrofnames > sizeof(names)/sizeof(names[0])) {
1742 ERR("Need more names!\n");
1745 /*dump_FUNCDESC(fdesc);*/
1747 for (i=0;i<fdesc->cParams;i++)
1748 nrofargs += _argsize(fdesc->lprgelemdescParam[i].tdesc.vt);
1749 args = HeapAlloc(GetProcessHeap(),0,(nrofargs+1)*sizeof(DWORD));
1750 if (!args) return E_OUTOFMEMORY;
1752 /* Allocate all stuff used by call. */
1754 for (i=0;i<fdesc->cParams;i++) {
1755 ELEMDESC *elem = fdesc->lprgelemdescParam+i;
1756 BOOL isdeserialized = FALSE;
1758 if (((i+1)<nrofnames) && !IsBadStringPtrW(names[i+1],1)) {
1759 /* If the parameter is 'riid', we use it as interface IID
1760 * for a later ppvObject serialization.
1762 buf.thisisiid = !lstrcmpW(names[i+1],riidW);
1764 /* deserialize DISPPARAM */
1765 if (!lstrcmpW(names[i+1],pdispparamsW)) {
1766 hres = deserialize_DISPPARAM_ptr(
1768 elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN,
1776 ERR("Failed to deserialize DISPPARAM*, hres %lx\n",hres);
1779 isdeserialized = TRUE;
1781 if (!lstrcmpW(names[i+1],ppvObjectW)) {
1782 hres = deserialize_LPVOID_ptr(
1784 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1792 isdeserialized = TRUE;
1795 if (!isdeserialized)
1796 hres = deserialize_param(
1798 elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN,
1805 xargs += _argsize(elem->tdesc.vt);
1807 ERR("Failed to deserialize param %s, hres %lx\n",relaystr(names[i+1]),hres);
1811 hres = IUnknown_QueryInterface(This->pUnk,&(This->iid),(LPVOID*)&(args[0]));
1813 ERR("Does not support iface %s\n",debugstr_guid(&(This->iid)));
1817 (*((FARPROC**)args[0]))[fdesc->oVft/4],
1822 IUnknown_Release((LPUNKNOWN)args[0]);
1825 for (i=0;i<fdesc->cParams;i++) {
1826 ELEMDESC *elem = fdesc->lprgelemdescParam+i;
1827 BOOL isserialized = FALSE;
1829 if (((i+1)<nrofnames) && !IsBadStringPtrW(names[i+1],1)) {
1830 /* If the parameter is 'riid', we use it as interface IID
1831 * for a later ppvObject serialization.
1833 buf.thisisiid = !lstrcmpW(names[i+1],riidW);
1835 /* DISPPARAMS* needs special serializer */
1836 if (!lstrcmpW(names[i+1],pdispparamsW)) {
1837 hres = serialize_DISPPARAM_ptr(
1839 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1846 isserialized = TRUE;
1848 if (!lstrcmpW(names[i+1],ppvObjectW)) {
1849 hres = serialize_LPVOID_ptr(
1851 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1859 isserialized = TRUE;
1863 hres = serialize_param(
1865 elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT,
1872 xargs += _argsize(elem->tdesc.vt);
1874 ERR("Failed to stuballoc param, hres %lx\n",hres);
1878 /* might need to use IRpcChannelBuffer_GetBuffer ? */
1879 xmsg->cbBuffer = buf.curoff;
1880 xmsg->Buffer = buf.base;
1881 HeapFree(GetProcessHeap(),0,args);
1885 static LPRPCSTUBBUFFER WINAPI
1886 TMStubImpl_IsIIDSupported(LPRPCSTUBBUFFER iface, REFIID riid) {
1887 FIXME("Huh (%s)?\n",debugstr_guid(riid));
1892 TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface) {
1893 TMStubImpl *This = (TMStubImpl *)iface;
1895 return This->ref; /*FIXME? */
1898 static HRESULT WINAPI
1899 TMStubImpl_DebugServerQueryInterface(LPRPCSTUBBUFFER iface, LPVOID *ppv) {
1904 TMStubImpl_DebugServerRelease(LPRPCSTUBBUFFER iface, LPVOID ppv) {
1908 IRpcStubBufferVtbl tmstubvtbl = {
1909 TMStubImpl_QueryInterface,
1913 TMStubImpl_Disconnect,
1915 TMStubImpl_IsIIDSupported,
1916 TMStubImpl_CountRefs,
1917 TMStubImpl_DebugServerQueryInterface,
1918 TMStubImpl_DebugServerRelease
1921 static HRESULT WINAPI
1922 PSFacBuf_CreateStub(
1923 LPPSFACTORYBUFFER iface, REFIID riid,IUnknown *pUnkServer,
1924 IRpcStubBuffer** ppStub
1930 TRACE("(%s,%p,%p)\n",debugstr_guid(riid),pUnkServer,ppStub);
1931 hres = _get_typeinfo_for_iid(riid,&tinfo);
1933 ERR("No typeinfo for %s?\n",debugstr_guid(riid));
1936 stub = CoTaskMemAlloc(sizeof(TMStubImpl));
1938 return E_OUTOFMEMORY;
1939 stub->lpvtbl = &tmstubvtbl;
1941 stub->tinfo = tinfo;
1942 memcpy(&(stub->iid),riid,sizeof(*riid));
1943 hres = IRpcStubBuffer_Connect((LPRPCSTUBBUFFER)stub,pUnkServer);
1944 *ppStub = (LPRPCSTUBBUFFER)stub;
1945 TRACE("IRpcStubBuffer: %p\n", stub);
1947 ERR("Connect to pUnkServer failed?\n");
1951 static IPSFactoryBufferVtbl psfacbufvtbl = {
1952 PSFacBuf_QueryInterface,
1955 PSFacBuf_CreateProxy,
1959 /* This is the whole PSFactoryBuffer object, just the vtableptr */
1960 static IPSFactoryBufferVtbl *lppsfac = &psfacbufvtbl;
1962 /***********************************************************************
1963 * DllGetClassObject [OLE32.63]
1966 TypeLibFac_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
1968 if (IsEqualIID(iid,&IID_IPSFactoryBuffer)) {
1972 return E_NOINTERFACE;