4 * Copyright 2002,2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include <wine/exception.h>
30 static const WCHAR IDispatchW
[] = { 'I','D','i','s','p','a','t','c','h',0};
32 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
33 WINE_DECLARE_DEBUG_CHANNEL(olerelay
);
35 static HRESULT
TMarshalDispatchChannel_Create(
36 IRpcChannelBuffer
*pDelegateChannel
, REFIID tmarshal_riid
,
37 IRpcChannelBuffer
**ppChannel
);
39 typedef struct _marshal_state
{
45 /* used in the olerelay code to avoid having the L"" stuff added by debugstr_w */
46 static char *relaystr(WCHAR
*in
) {
47 char *tmp
= (char *)debugstr_w(in
);
49 tmp
[strlen(tmp
)-1] = '\0';
54 xbuf_resize(marshal_state
*buf
, DWORD newsize
)
56 if(buf
->size
>= newsize
)
61 buf
->base
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, buf
->base
, newsize
);
67 buf
->base
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, newsize
);
76 xbuf_add(marshal_state
*buf
, const BYTE
*stuff
, DWORD size
)
80 if(buf
->size
- buf
->curoff
< size
)
82 hr
= xbuf_resize(buf
, buf
->size
+ size
+ 100);
83 if(FAILED(hr
)) return hr
;
85 memcpy(buf
->base
+buf
->curoff
,stuff
,size
);
91 xbuf_get(marshal_state
*buf
, LPBYTE stuff
, DWORD size
) {
92 if (buf
->size
< buf
->curoff
+size
) return E_FAIL
;
93 memcpy(stuff
,buf
->base
+buf
->curoff
,size
);
99 xbuf_skip(marshal_state
*buf
, DWORD size
) {
100 if (buf
->size
< buf
->curoff
+size
) return E_FAIL
;
106 _unmarshal_interface(marshal_state
*buf
, REFIID riid
, LPUNKNOWN
*pUnk
) {
108 ULARGE_INTEGER newpos
;
109 LARGE_INTEGER seekto
;
114 TRACE("...%s...\n",debugstr_guid(riid
));
117 hres
= xbuf_get(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
119 ERR("xbuf_get failed\n");
123 if (xsize
== 0) return S_OK
;
125 hres
= CreateStreamOnHGlobal(0,TRUE
,&pStm
);
127 ERR("Stream create failed %x\n",hres
);
131 hres
= IStream_Write(pStm
,buf
->base
+buf
->curoff
,xsize
,&res
);
133 ERR("stream write %x\n",hres
);
134 IStream_Release(pStm
);
138 memset(&seekto
,0,sizeof(seekto
));
139 hres
= IStream_Seek(pStm
,seekto
,SEEK_SET
,&newpos
);
141 ERR("Failed Seek %x\n",hres
);
142 IStream_Release(pStm
);
146 hres
= CoUnmarshalInterface(pStm
,riid
,(LPVOID
*)pUnk
);
148 ERR("Unmarshalling interface %s failed with %x\n",debugstr_guid(riid
),hres
);
149 IStream_Release(pStm
);
153 IStream_Release(pStm
);
154 return xbuf_skip(buf
,xsize
);
158 _marshal_interface(marshal_state
*buf
, REFIID riid
, LPUNKNOWN pUnk
) {
159 LPBYTE tempbuf
= NULL
;
160 IStream
*pStm
= NULL
;
162 ULARGE_INTEGER newpos
;
163 LARGE_INTEGER seekto
;
169 /* this is valid, if for instance we serialize
170 * a VT_DISPATCH with NULL ptr which apparently
171 * can happen. S_OK to make sure we continue
174 WARN("pUnk is NULL\n");
176 return xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
181 TRACE("...%s...\n",debugstr_guid(riid
));
183 hres
= CreateStreamOnHGlobal(0,TRUE
,&pStm
);
185 ERR("Stream create failed %x\n",hres
);
189 hres
= CoMarshalInterface(pStm
,riid
,pUnk
,0,NULL
,0);
191 ERR("Marshalling interface %s failed with %x\n", debugstr_guid(riid
), hres
);
195 hres
= IStream_Stat(pStm
,&ststg
,STATFLAG_NONAME
);
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 %x\n",hres
);
209 hres
= IStream_Read(pStm
,tempbuf
,ststg
.cbSize
.u
.LowPart
,&res
);
211 ERR("Failed Read %x\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 IStream_Release(pStm
);
226 xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
227 if (pStm
) IStream_Release(pStm
);
228 HeapFree(GetProcessHeap(), 0, tempbuf
);
232 /********************* OLE Proxy/Stub Factory ********************************/
233 static HRESULT WINAPI
234 PSFacBuf_QueryInterface(LPPSFACTORYBUFFER iface
, REFIID iid
, LPVOID
*ppv
) {
235 if (IsEqualIID(iid
,&IID_IPSFactoryBuffer
)||IsEqualIID(iid
,&IID_IUnknown
)) {
237 /* No ref counting, static class */
240 FIXME("(%s) unknown IID?\n",debugstr_guid(iid
));
241 return E_NOINTERFACE
;
244 static ULONG WINAPI
PSFacBuf_AddRef(LPPSFACTORYBUFFER iface
) { return 2; }
245 static ULONG WINAPI
PSFacBuf_Release(LPPSFACTORYBUFFER iface
) { return 1; }
248 _get_typeinfo_for_iid(REFIID riid
, ITypeInfo
**ti
) {
251 char tlguid
[200],typelibkey
[300],interfacekey
[300],ver
[100];
254 DWORD tlguidlen
, verlen
, type
;
258 sprintf( interfacekey
, "Interface\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
259 riid
->Data1
, riid
->Data2
, riid
->Data3
,
260 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
261 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]
264 if (RegOpenKeyA(HKEY_CLASSES_ROOT
,interfacekey
,&ikey
)) {
265 ERR("No %s key found.\n",interfacekey
);
268 tlguidlen
= sizeof(tlguid
);
269 if (RegQueryValueExA(ikey
,NULL
,NULL
,&type
,(LPBYTE
)tlguid
,&tlguidlen
)) {
270 ERR("Getting typelib guid failed.\n");
274 verlen
= sizeof(ver
);
275 if (RegQueryValueExA(ikey
,"Version",NULL
,&type
,(LPBYTE
)ver
,&verlen
)) {
276 ERR("Could not get version value?\n");
281 sprintf(typelibkey
,"Typelib\\%s\\%s\\0\\win%u",tlguid
,ver
,(sizeof(void*) == 8) ? 64 : 32);
282 tlfnlen
= sizeof(tlfn
);
283 if (RegQueryValueA(HKEY_CLASSES_ROOT
,typelibkey
,tlfn
,&tlfnlen
)) {
285 sprintf(typelibkey
,"Typelib\\%s\\%s\\0\\win32",tlguid
,ver
);
286 tlfnlen
= sizeof(tlfn
);
287 if (RegQueryValueA(HKEY_CLASSES_ROOT
,typelibkey
,tlfn
,&tlfnlen
)) {
289 ERR("Could not get typelib fn?\n");
295 MultiByteToWideChar(CP_ACP
, 0, tlfn
, -1, tlfnW
, sizeof(tlfnW
) / sizeof(tlfnW
[0]));
296 hres
= LoadTypeLib(tlfnW
,&tl
);
298 ERR("Failed to load typelib for %s, but it should be there.\n",debugstr_guid(riid
));
301 hres
= ITypeLib_GetTypeInfoOfGuid(tl
,riid
,ti
);
303 ERR("typelib does not contain info for %s?\n",debugstr_guid(riid
));
304 ITypeLib_Release(tl
);
307 ITypeLib_Release(tl
);
312 * Determine the number of functions including all inherited functions
313 * and well as the size of the vtbl.
314 * Note for non-dual dispinterfaces we simply return the size of IDispatch.
316 static HRESULT
num_of_funcs(ITypeInfo
*tinfo
, unsigned int *num
,
317 unsigned int *vtbl_size
)
322 UINT inherited_funcs
= 0, i
;
325 if(vtbl_size
) *vtbl_size
= 0;
327 hr
= ITypeInfo_GetTypeAttr(tinfo
, &attr
);
330 ERR("GetTypeAttr failed with %x\n", hr
);
334 if(attr
->typekind
== TKIND_DISPATCH
)
336 if(attr
->wTypeFlags
& TYPEFLAG_FDUAL
)
340 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
341 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, -1, &href
);
344 ERR("Unable to get interface href from dual dispinterface\n");
347 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &tinfo2
);
350 ERR("Unable to get interface from dual dispinterface\n");
353 hr
= num_of_funcs(tinfo2
, num
, vtbl_size
);
354 ITypeInfo_Release(tinfo2
);
357 else /* non-dual dispinterface */
359 /* These will be the size of IDispatchVtbl */
360 *num
= attr
->cbSizeVft
/ sizeof(void *);
361 if(vtbl_size
) *vtbl_size
= attr
->cbSizeVft
;
362 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
367 for (i
= 0; i
< attr
->cImplTypes
; i
++)
370 ITypeInfo
*pSubTypeInfo
;
373 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, i
, &href
);
374 if (FAILED(hr
)) goto end
;
375 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &pSubTypeInfo
);
376 if (FAILED(hr
)) goto end
;
378 hr
= num_of_funcs(pSubTypeInfo
, &sub_funcs
, NULL
);
379 ITypeInfo_Release(pSubTypeInfo
);
381 if(FAILED(hr
)) goto end
;
382 inherited_funcs
+= sub_funcs
;
385 *num
= inherited_funcs
+ attr
->cFuncs
;
386 if(vtbl_size
) *vtbl_size
= attr
->cbSizeVft
;
389 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
395 #include "pshpack1.h"
397 typedef struct _TMAsmProxy
{
413 #pragma message("You need to implement stubless proxies for your architecture")
415 # warning You need to implement stubless proxies for your architecture
417 typedef struct _TMAsmProxy
{
422 typedef struct _TMProxyImpl
{
424 IRpcProxyBuffer IRpcProxyBuffer_iface
;
427 TMAsmProxy
*asmstubs
;
429 IRpcChannelBuffer
* chanbuf
;
431 CRITICAL_SECTION crit
;
432 IUnknown
*outerunknown
;
434 IRpcProxyBuffer
*dispatch_proxy
;
437 static inline TMProxyImpl
*impl_from_IRpcProxyBuffer( IRpcProxyBuffer
*iface
)
439 return CONTAINING_RECORD(iface
, TMProxyImpl
, IRpcProxyBuffer_iface
);
442 static HRESULT WINAPI
443 TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface
, REFIID riid
, LPVOID
*ppv
)
446 if (IsEqualIID(riid
,&IID_IUnknown
)||IsEqualIID(riid
,&IID_IRpcProxyBuffer
)) {
448 IRpcProxyBuffer_AddRef(iface
);
451 FIXME("no interface for %s\n",debugstr_guid(riid
));
452 return E_NOINTERFACE
;
456 TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface
)
458 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
459 ULONG refCount
= InterlockedIncrement(&This
->ref
);
461 TRACE("(%p)->(ref before=%u)\n",This
, refCount
- 1);
467 TMProxyImpl_Release(LPRPCPROXYBUFFER iface
)
469 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
470 ULONG refCount
= InterlockedDecrement(&This
->ref
);
472 TRACE("(%p)->(ref before=%u)\n",This
, refCount
+ 1);
476 if (This
->dispatch_proxy
) IRpcProxyBuffer_Release(This
->dispatch_proxy
);
477 This
->crit
.DebugInfo
->Spare
[0] = 0;
478 DeleteCriticalSection(&This
->crit
);
479 if (This
->chanbuf
) IRpcChannelBuffer_Release(This
->chanbuf
);
480 VirtualFree(This
->asmstubs
, 0, MEM_RELEASE
);
481 HeapFree(GetProcessHeap(), 0, This
->lpvtbl
);
482 ITypeInfo_Release(This
->tinfo
);
488 static HRESULT WINAPI
490 LPRPCPROXYBUFFER iface
,IRpcChannelBuffer
* pRpcChannelBuffer
)
492 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
494 TRACE("(%p)\n", pRpcChannelBuffer
);
496 EnterCriticalSection(&This
->crit
);
498 IRpcChannelBuffer_AddRef(pRpcChannelBuffer
);
499 This
->chanbuf
= pRpcChannelBuffer
;
501 LeaveCriticalSection(&This
->crit
);
503 if (This
->dispatch_proxy
)
505 IRpcChannelBuffer
*pDelegateChannel
;
506 HRESULT hr
= TMarshalDispatchChannel_Create(pRpcChannelBuffer
, &This
->iid
, &pDelegateChannel
);
509 hr
= IRpcProxyBuffer_Connect(This
->dispatch_proxy
, pDelegateChannel
);
510 IRpcChannelBuffer_Release(pDelegateChannel
);
518 TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface
)
520 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
524 EnterCriticalSection(&This
->crit
);
526 IRpcChannelBuffer_Release(This
->chanbuf
);
527 This
->chanbuf
= NULL
;
529 LeaveCriticalSection(&This
->crit
);
531 if (This
->dispatch_proxy
)
532 IRpcProxyBuffer_Disconnect(This
->dispatch_proxy
);
536 static const IRpcProxyBufferVtbl tmproxyvtable
= {
537 TMProxyImpl_QueryInterface
,
541 TMProxyImpl_Disconnect
544 /* how much space do we use on stack in DWORD steps. */
546 _argsize(TYPEDESC
*tdesc
, ITypeInfo
*tinfo
) {
550 return 8/sizeof(DWORD
);
552 return sizeof(double)/sizeof(DWORD
);
554 return sizeof(CY
)/sizeof(DWORD
);
556 return sizeof(DATE
)/sizeof(DWORD
);
558 return (sizeof(DECIMAL
)+3)/sizeof(DWORD
);
560 return (sizeof(VARIANT
)+3)/sizeof(DWORD
);
568 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
570 return 0; /* should fail critically in serialize_param */
571 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
572 ret
= (tattr
->cbSizeInstance
+3)/sizeof(DWORD
);
573 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
574 ITypeInfo_Release(tinfo2
);
582 /* how much space do we use on the heap (in bytes) */
584 _xsize(const TYPEDESC
*td
, ITypeInfo
*tinfo
) {
591 return sizeof(VARIANT
);
594 const ARRAYDESC
*adesc
= td
->u
.lpadesc
;
596 for (i
=0;i
<adesc
->cDims
;i
++)
597 arrsize
*= adesc
->rgbounds
[i
].cElements
;
598 return arrsize
*_xsize(&adesc
->tdescElem
, tinfo
);
618 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,td
->u
.hreftype
,&tinfo2
);
621 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
622 ret
= tattr
->cbSizeInstance
;
623 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
624 ITypeInfo_Release(tinfo2
);
632 /* Whether we pass this type by reference or by value */
634 _passbyref(const TYPEDESC
*td
, ITypeInfo
*tinfo
) {
635 return (td
->vt
== VT_USERDEFINED
||
636 td
->vt
== VT_VARIANT
||
653 TRACE("(tdesc.vt %s)\n",debugstr_vt(tdesc
->vt
));
656 if ((vartype
& 0xf000) == VT_ARRAY
)
657 vartype
= VT_SAFEARRAY
;
666 if (debugout
) TRACE_(olerelay
)("%x%x\n",arg
[0],arg
[1]);
668 hres
= xbuf_add(buf
,(LPBYTE
)arg
,8);
677 if (debugout
) TRACE_(olerelay
)("%x\n",*arg
);
679 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
685 if (debugout
) TRACE_(olerelay
)("%04x\n",*arg
& 0xffff);
687 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
692 if (debugout
) TRACE_(olerelay
)("%02x\n",*arg
& 0xff);
694 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
697 if (debugout
) TRACE_(olerelay
)("Vt(%s%s)(",debugstr_vt(V_VT((VARIANT
*)arg
)),debugstr_vf(V_VT((VARIANT
*)arg
)));
700 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
701 ULONG size
= VARIANT_UserSize(&flags
, buf
->curoff
, (VARIANT
*)arg
);
702 xbuf_resize(buf
, size
);
703 VARIANT_UserMarshal(&flags
, buf
->base
+ buf
->curoff
, (VARIANT
*)arg
);
708 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
709 VARIANT_UserFree(&flags
, (VARIANT
*)arg
);
714 if (writeit
&& debugout
) {
716 TRACE_(olerelay
)("%s",relaystr((WCHAR
*)*arg
));
718 TRACE_(olerelay
)("<bstr NULL>");
722 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
723 ULONG size
= BSTR_UserSize(&flags
, buf
->curoff
, (BSTR
*)arg
);
724 xbuf_resize(buf
, size
);
725 BSTR_UserMarshal(&flags
, buf
->base
+ buf
->curoff
, (BSTR
*)arg
);
730 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
731 BSTR_UserFree(&flags
, (BSTR
*)arg
);
737 BOOL derefhere
= TRUE
;
739 if (tdesc
->u
.lptdesc
->vt
== VT_USERDEFINED
) {
743 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.lptdesc
->u
.hreftype
,&tinfo2
);
745 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
748 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
749 switch (tattr
->typekind
) {
751 if (tattr
->tdescAlias
.vt
== VT_USERDEFINED
)
753 DWORD href
= tattr
->tdescAlias
.u
.hreftype
;
754 ITypeInfo_ReleaseTypeAttr(tinfo
, tattr
);
755 ITypeInfo_Release(tinfo2
);
756 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,href
,&tinfo2
);
758 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
761 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
762 derefhere
= (tattr
->typekind
!= TKIND_DISPATCH
&& tattr
->typekind
!= TKIND_INTERFACE
);
765 case TKIND_ENUM
: /* confirmed */
766 case TKIND_RECORD
: /* FIXME: mostly untested */
768 case TKIND_DISPATCH
: /* will be done in VT_USERDEFINED case */
769 case TKIND_INTERFACE
: /* will be done in VT_USERDEFINED case */
773 FIXME("unhandled switch cases tattr->typekind %d\n", tattr
->typekind
);
777 ITypeInfo_ReleaseTypeAttr(tinfo
, tattr
);
778 ITypeInfo_Release(tinfo2
);
781 if (debugout
) TRACE_(olerelay
)("*");
782 /* Write always, so the other side knows when it gets a NULL pointer.
784 cookie
= *arg
? 0x42424242 : 0;
785 hres
= xbuf_add(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
789 if (debugout
) TRACE_(olerelay
)("NULL");
792 hres
= serialize_param(tinfo
,writeit
,debugout
,dealloc
,tdesc
->u
.lptdesc
,(DWORD
*)*arg
,buf
);
793 if (derefhere
&& dealloc
) HeapFree(GetProcessHeap(),0,(LPVOID
)*arg
);
797 if (debugout
) TRACE_(olerelay
)("unk(0x%x)",*arg
);
799 hres
= _marshal_interface(buf
,&IID_IUnknown
,(LPUNKNOWN
)*arg
);
800 if (dealloc
&& *(IUnknown
**)arg
)
801 IUnknown_Release((LPUNKNOWN
)*arg
);
804 if (debugout
) TRACE_(olerelay
)("idisp(0x%x)",*arg
);
806 hres
= _marshal_interface(buf
,&IID_IDispatch
,(LPUNKNOWN
)*arg
);
807 if (dealloc
&& *(IUnknown
**)arg
)
808 IUnknown_Release((LPUNKNOWN
)*arg
);
811 if (debugout
) TRACE_(olerelay
)("<void>");
813 case VT_USERDEFINED
: {
817 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
819 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.hreftype
);
822 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
823 switch (tattr
->typekind
) {
825 case TKIND_INTERFACE
:
827 hres
=_marshal_interface(buf
,&(tattr
->guid
),(LPUNKNOWN
)arg
);
829 IUnknown_Release((LPUNKNOWN
)arg
);
833 if (debugout
) TRACE_(olerelay
)("{");
834 for (i
=0;i
<tattr
->cVars
;i
++) {
839 hres
= ITypeInfo_GetVarDesc(tinfo2
, i
, &vdesc
);
841 ERR("Could not get vardesc of %d\n",i
);
844 elem2
= &vdesc
->elemdescVar
;
845 tdesc2
= &elem2
->tdesc
;
846 hres
= serialize_param(
852 (DWORD
*)(((LPBYTE
)arg
)+vdesc
->u
.oInst
),
855 ITypeInfo_ReleaseVarDesc(tinfo2
, vdesc
);
858 if (debugout
&& (i
<(tattr
->cVars
-1)))
859 TRACE_(olerelay
)(",");
861 if (debugout
) TRACE_(olerelay
)("}");
865 hres
= serialize_param(tinfo2
,writeit
,debugout
,dealloc
,&tattr
->tdescAlias
,arg
,buf
);
869 if (debugout
) TRACE_(olerelay
)("%x",*arg
);
871 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
874 FIXME("Unhandled typekind %d\n",tattr
->typekind
);
878 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
879 ITypeInfo_Release(tinfo2
);
883 ARRAYDESC
*adesc
= tdesc
->u
.lpadesc
;
886 if (debugout
) TRACE_(olerelay
)("carr");
887 for (i
=0;i
<adesc
->cDims
;i
++) {
888 if (debugout
) TRACE_(olerelay
)("[%d]",adesc
->rgbounds
[i
].cElements
);
889 arrsize
*= adesc
->rgbounds
[i
].cElements
;
891 if (debugout
) TRACE_(olerelay
)("(vt %s)",debugstr_vt(adesc
->tdescElem
.vt
));
892 if (debugout
) TRACE_(olerelay
)("[");
893 for (i
=0;i
<arrsize
;i
++) {
894 LPBYTE base
= _passbyref(&adesc
->tdescElem
, tinfo
) ? (LPBYTE
) *arg
: (LPBYTE
) arg
;
895 hres
= serialize_param(tinfo
, writeit
, debugout
, dealloc
, &adesc
->tdescElem
, (DWORD
*)((LPBYTE
)base
+i
*_xsize(&adesc
->tdescElem
, tinfo
)), buf
);
898 if (debugout
&& (i
<arrsize
-1)) TRACE_(olerelay
)(",");
900 if (debugout
) TRACE_(olerelay
)("]");
902 HeapFree(GetProcessHeap(), 0, *(void **)arg
);
908 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
909 ULONG size
= LPSAFEARRAY_UserSize(&flags
, buf
->curoff
, (LPSAFEARRAY
*)arg
);
910 xbuf_resize(buf
, size
);
911 LPSAFEARRAY_UserMarshal(&flags
, buf
->base
+ buf
->curoff
, (LPSAFEARRAY
*)arg
);
916 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
917 LPSAFEARRAY_UserFree(&flags
, (LPSAFEARRAY
*)arg
);
922 ERR("Unhandled marshal type %d.\n",tdesc
->vt
);
940 TRACE("vt %s at %p\n",debugstr_vt(tdesc
->vt
),arg
);
943 if ((vartype
& 0xf000) == VT_ARRAY
)
944 vartype
= VT_SAFEARRAY
;
951 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
952 unsigned char *buffer
;
953 buffer
= VARIANT_UserUnmarshal(&flags
, buf
->base
+ buf
->curoff
, (VARIANT
*)arg
);
954 buf
->curoff
= buffer
- buf
->base
;
964 hres
= xbuf_get(buf
,(LPBYTE
)arg
,8);
965 if (hres
) ERR("Failed to read integer 8 byte\n");
967 if (debugout
) TRACE_(olerelay
)("%x%x",arg
[0],arg
[1]);
976 hres
= xbuf_get(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
977 if (hres
) ERR("Failed to read integer 4 byte\n");
979 if (debugout
) TRACE_(olerelay
)("%x",*arg
);
986 hres
= xbuf_get(buf
,(LPBYTE
)&x
,sizeof(DWORD
));
987 if (hres
) ERR("Failed to read integer 4 byte\n");
990 if (debugout
) TRACE_(olerelay
)("%04x",*arg
& 0xffff);
996 hres
= xbuf_get(buf
,(LPBYTE
)&x
,sizeof(DWORD
));
997 if (hres
) ERR("Failed to read integer 4 byte\n");
1000 if (debugout
) TRACE_(olerelay
)("%02x",*arg
& 0xff);
1005 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
1006 unsigned char *buffer
;
1007 buffer
= BSTR_UserUnmarshal(&flags
, buf
->base
+ buf
->curoff
, (BSTR
*)arg
);
1008 buf
->curoff
= buffer
- buf
->base
;
1009 if (debugout
) TRACE_(olerelay
)("%s",debugstr_w(*(BSTR
*)arg
));
1015 BOOL derefhere
= TRUE
;
1017 if (tdesc
->u
.lptdesc
->vt
== VT_USERDEFINED
) {
1021 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.lptdesc
->u
.hreftype
,&tinfo2
);
1023 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
1026 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
1027 switch (tattr
->typekind
) {
1029 if (tattr
->tdescAlias
.vt
== VT_USERDEFINED
)
1031 DWORD href
= tattr
->tdescAlias
.u
.hreftype
;
1032 ITypeInfo_ReleaseTypeAttr(tinfo
, tattr
);
1033 ITypeInfo_Release(tinfo2
);
1034 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,href
,&tinfo2
);
1036 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
1039 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
1040 derefhere
= (tattr
->typekind
!= TKIND_DISPATCH
&& tattr
->typekind
!= TKIND_INTERFACE
);
1043 case TKIND_ENUM
: /* confirmed */
1044 case TKIND_RECORD
: /* FIXME: mostly untested */
1046 case TKIND_DISPATCH
: /* will be done in VT_USERDEFINED case */
1047 case TKIND_INTERFACE
: /* will be done in VT_USERDEFINED case */
1051 FIXME("unhandled switch cases tattr->typekind %d\n", tattr
->typekind
);
1055 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
1056 ITypeInfo_Release(tinfo2
);
1058 /* read it in all cases, we need to know if we have
1059 * NULL pointer or not.
1061 hres
= xbuf_get(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
1063 ERR("Failed to load pointer cookie.\n");
1066 if (cookie
!= 0x42424242) {
1067 /* we read a NULL ptr from the remote side */
1068 if (debugout
) TRACE_(olerelay
)("NULL");
1072 if (debugout
) TRACE_(olerelay
)("*");
1074 /* Allocate space for the referenced struct */
1076 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,_xsize(tdesc
->u
.lptdesc
, tinfo
));
1079 return deserialize_param(tinfo
, readit
, debugout
, alloc
, tdesc
->u
.lptdesc
, (LPDWORD
)*arg
, buf
);
1081 return deserialize_param(tinfo
, readit
, debugout
, alloc
, tdesc
->u
.lptdesc
, arg
, buf
);
1084 /* FIXME: UNKNOWN is unknown ..., but allocate 4 byte for it */
1086 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DWORD
));
1089 hres
= _unmarshal_interface(buf
,&IID_IUnknown
,(LPUNKNOWN
*)arg
);
1091 TRACE_(olerelay
)("unk(%p)",arg
);
1096 hres
= _unmarshal_interface(buf
,&IID_IDispatch
,(LPUNKNOWN
*)arg
);
1098 TRACE_(olerelay
)("idisp(%p)",arg
);
1101 if (debugout
) TRACE_(olerelay
)("<void>");
1103 case VT_USERDEFINED
: {
1107 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
1109 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.hreftype
);
1112 hres
= ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
1114 ERR("Could not get typeattr in VT_USERDEFINED.\n");
1116 switch (tattr
->typekind
) {
1117 case TKIND_DISPATCH
:
1118 case TKIND_INTERFACE
:
1120 hres
= _unmarshal_interface(buf
,&(tattr
->guid
),(LPUNKNOWN
*)arg
);
1122 case TKIND_RECORD
: {
1125 if (debugout
) TRACE_(olerelay
)("{");
1126 for (i
=0;i
<tattr
->cVars
;i
++) {
1129 hres
= ITypeInfo_GetVarDesc(tinfo2
, i
, &vdesc
);
1131 ERR("Could not get vardesc of %d\n",i
);
1132 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
1133 ITypeInfo_Release(tinfo2
);
1136 hres
= deserialize_param(
1141 &vdesc
->elemdescVar
.tdesc
,
1142 (DWORD
*)(((LPBYTE
)arg
)+vdesc
->u
.oInst
),
1145 ITypeInfo_ReleaseVarDesc(tinfo2
, vdesc
);
1146 if (debugout
&& (i
<tattr
->cVars
-1)) TRACE_(olerelay
)(",");
1148 if (debugout
) TRACE_(olerelay
)("}");
1152 hres
= deserialize_param(tinfo2
,readit
,debugout
,alloc
,&tattr
->tdescAlias
,arg
,buf
);
1156 hres
= xbuf_get(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
1157 if (hres
) ERR("Failed to read enum (4 byte)\n");
1159 if (debugout
) TRACE_(olerelay
)("%x",*arg
);
1162 ERR("Unhandled typekind %d\n",tattr
->typekind
);
1166 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
1169 ERR("failed to stuballoc in TKIND_RECORD.\n");
1170 ITypeInfo_Release(tinfo2
);
1174 /* arg is pointing to the start of the array. */
1175 LPBYTE base
= (LPBYTE
) arg
;
1176 ARRAYDESC
*adesc
= tdesc
->u
.lpadesc
;
1179 if (adesc
->cDims
> 1) FIXME("cDims > 1 in VT_CARRAY. Does it work?\n");
1180 for (i
=0;i
<adesc
->cDims
;i
++)
1181 arrsize
*= adesc
->rgbounds
[i
].cElements
;
1182 if (_passbyref(&adesc
->tdescElem
, tinfo
))
1184 base
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,_xsize(tdesc
->u
.lptdesc
, tinfo
) * arrsize
);
1185 *arg
= (DWORD
) base
;
1187 for (i
=0;i
<arrsize
;i
++)
1194 (DWORD
*)(base
+ i
*_xsize(&adesc
->tdescElem
, tinfo
)),
1199 case VT_SAFEARRAY
: {
1202 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
1203 unsigned char *buffer
;
1204 buffer
= LPSAFEARRAY_UserUnmarshal(&flags
, buf
->base
+ buf
->curoff
, (LPSAFEARRAY
*)arg
);
1205 buf
->curoff
= buffer
- buf
->base
;
1210 ERR("No handler for VT type %d!\n",tdesc
->vt
);
1216 /* Retrieves a function's funcdesc, searching back into inherited interfaces. */
1217 static HRESULT
get_funcdesc(ITypeInfo
*tinfo
, int iMethod
, ITypeInfo
**tactual
, const FUNCDESC
**fdesc
,
1218 BSTR
*iname
, BSTR
*fname
, UINT
*num
)
1222 UINT inherited_funcs
= 0;
1225 if (fname
) *fname
= NULL
;
1226 if (iname
) *iname
= NULL
;
1230 hr
= ITypeInfo_GetTypeAttr(tinfo
, &attr
);
1233 ERR("GetTypeAttr failed with %x\n",hr
);
1237 if(attr
->typekind
== TKIND_DISPATCH
)
1239 if(attr
->wTypeFlags
& TYPEFLAG_FDUAL
)
1244 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, -1, &href
);
1247 ERR("Cannot get interface href from dual dispinterface\n");
1248 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1251 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &tinfo2
);
1254 ERR("Cannot get interface from dual dispinterface\n");
1255 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1258 hr
= get_funcdesc(tinfo2
, iMethod
, tactual
, fdesc
, iname
, fname
, num
);
1259 ITypeInfo_Release(tinfo2
);
1260 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1263 ERR("Shouldn't be called with a non-dual dispinterface\n");
1267 impl_types
= attr
->cImplTypes
;
1268 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1270 for (i
= 0; i
< impl_types
; i
++)
1273 ITypeInfo
*pSubTypeInfo
;
1276 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, i
, &href
);
1277 if (FAILED(hr
)) return hr
;
1278 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &pSubTypeInfo
);
1279 if (FAILED(hr
)) return hr
;
1281 hr
= get_funcdesc(pSubTypeInfo
, iMethod
, tactual
, fdesc
, iname
, fname
, &sub_funcs
);
1282 inherited_funcs
+= sub_funcs
;
1283 ITypeInfo_Release(pSubTypeInfo
);
1284 if(SUCCEEDED(hr
)) return hr
;
1286 if(iMethod
< inherited_funcs
)
1288 ERR("shouldn't be here\n");
1289 return E_INVALIDARG
;
1292 for(i
= inherited_funcs
; i
<= iMethod
; i
++)
1294 hr
= ITypeInfoImpl_GetInternalFuncDesc(tinfo
, i
- inherited_funcs
, fdesc
);
1302 /* found it. We don't care about num so zero it */
1305 ITypeInfo_AddRef(*tactual
);
1306 if (fname
) ITypeInfo_GetDocumentation(tinfo
,(*fdesc
)->memid
,fname
,NULL
,NULL
,NULL
);
1307 if (iname
) ITypeInfo_GetDocumentation(tinfo
,-1,iname
,NULL
,NULL
,NULL
);
1311 static inline BOOL
is_in_elem(const ELEMDESC
*elem
)
1313 return (elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
|| !elem
->u
.paramdesc
.wParamFlags
);
1316 static inline BOOL
is_out_elem(const ELEMDESC
*elem
)
1318 return (elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
|| !elem
->u
.paramdesc
.wParamFlags
);
1321 static DWORD WINAPI
xCall(int method
, void **args
)
1323 TMProxyImpl
*tpinfo
= args
[0];
1325 const FUNCDESC
*fdesc
;
1334 DWORD remoteresult
= 0;
1336 IRpcChannelBuffer
*chanbuf
;
1338 EnterCriticalSection(&tpinfo
->crit
);
1340 hres
= get_funcdesc(tpinfo
->tinfo
,method
,&tinfo
,&fdesc
,&iname
,&fname
,NULL
);
1342 ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method
);
1343 LeaveCriticalSection(&tpinfo
->crit
);
1347 if (!tpinfo
->chanbuf
)
1349 WARN("Tried to use disconnected proxy\n");
1350 ITypeInfo_Release(tinfo
);
1351 LeaveCriticalSection(&tpinfo
->crit
);
1352 return RPC_E_DISCONNECTED
;
1354 chanbuf
= tpinfo
->chanbuf
;
1355 IRpcChannelBuffer_AddRef(chanbuf
);
1357 LeaveCriticalSection(&tpinfo
->crit
);
1359 if (TRACE_ON(olerelay
)) {
1360 TRACE_(olerelay
)("->");
1362 TRACE_(olerelay
)("%s:",relaystr(iname
));
1364 TRACE_(olerelay
)("%s(%d)",relaystr(fname
),method
);
1366 TRACE_(olerelay
)("%d",method
);
1367 TRACE_(olerelay
)("(");
1370 SysFreeString(iname
);
1371 SysFreeString(fname
);
1373 memset(&buf
,0,sizeof(buf
));
1375 /* normal typelib driven serializing */
1377 /* Need them for hack below */
1378 memset(names
,0,sizeof(names
));
1379 if (ITypeInfo_GetNames(tinfo
,fdesc
->memid
,names
,sizeof(names
)/sizeof(names
[0]),&nrofnames
))
1381 if (nrofnames
> sizeof(names
)/sizeof(names
[0]))
1382 ERR("Need more names!\n");
1384 xargs
= (DWORD
*)(args
+ 1);
1385 for (i
=0;i
<fdesc
->cParams
;i
++) {
1386 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1387 if (TRACE_ON(olerelay
)) {
1388 if (i
) TRACE_(olerelay
)(",");
1389 if (i
+1<nrofnames
&& names
[i
+1])
1390 TRACE_(olerelay
)("%s=",relaystr(names
[i
+1]));
1392 /* No need to marshal other data than FIN and any VT_PTR. */
1393 if (!is_in_elem(elem
))
1395 if (elem
->tdesc
.vt
!= VT_PTR
)
1397 xargs
+=_argsize(&elem
->tdesc
, tinfo
);
1398 TRACE_(olerelay
)("[out]");
1403 memset( *(void **)xargs
, 0, _xsize( elem
->tdesc
.u
.lptdesc
, tinfo
) );
1407 hres
= serialize_param(
1418 ERR("Failed to serialize param, hres %x\n",hres
);
1421 xargs
+=_argsize(&elem
->tdesc
, tinfo
);
1423 TRACE_(olerelay
)(")");
1425 memset(&msg
,0,sizeof(msg
));
1426 msg
.cbBuffer
= buf
.curoff
;
1427 msg
.iMethod
= method
;
1428 hres
= IRpcChannelBuffer_GetBuffer(chanbuf
,&msg
,&(tpinfo
->iid
));
1430 ERR("RpcChannelBuffer GetBuffer failed, %x\n",hres
);
1433 memcpy(msg
.Buffer
,buf
.base
,buf
.curoff
);
1434 TRACE_(olerelay
)("\n");
1435 hres
= IRpcChannelBuffer_SendReceive(chanbuf
,&msg
,&status
);
1437 ERR("RpcChannelBuffer SendReceive failed, %x\n",hres
);
1441 TRACE_(olerelay
)(" status = %08x (",status
);
1443 buf
.base
= HeapReAlloc(GetProcessHeap(),0,buf
.base
,msg
.cbBuffer
);
1445 buf
.base
= HeapAlloc(GetProcessHeap(),0,msg
.cbBuffer
);
1446 buf
.size
= msg
.cbBuffer
;
1447 memcpy(buf
.base
,msg
.Buffer
,buf
.size
);
1450 /* generic deserializer using typelib description */
1451 xargs
= (DWORD
*)(args
+ 1);
1453 for (i
=0;i
<fdesc
->cParams
;i
++) {
1454 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1456 if (i
) TRACE_(olerelay
)(",");
1457 if (i
+1<nrofnames
&& names
[i
+1]) TRACE_(olerelay
)("%s=",relaystr(names
[i
+1]));
1459 /* No need to marshal other data than FOUT and any VT_PTR */
1460 if (!is_out_elem(elem
) && (elem
->tdesc
.vt
!= VT_PTR
)) {
1461 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
1462 TRACE_(olerelay
)("[in]");
1465 hres
= deserialize_param(
1475 ERR("Failed to unmarshall param, hres %x\n",hres
);
1479 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
1482 hres
= xbuf_get(&buf
, (LPBYTE
)&remoteresult
, sizeof(DWORD
));
1485 TRACE_(olerelay
)(") = %08x\n", remoteresult
);
1487 hres
= remoteresult
;
1490 IRpcChannelBuffer_FreeBuffer(chanbuf
,&msg
);
1491 for (i
= 0; i
< nrofnames
; i
++)
1492 SysFreeString(names
[i
]);
1493 HeapFree(GetProcessHeap(),0,buf
.base
);
1494 IRpcChannelBuffer_Release(chanbuf
);
1495 ITypeInfo_Release(tinfo
);
1496 TRACE("-- 0x%08x\n", hres
);
1500 static HRESULT WINAPI
ProxyIUnknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
1502 TMProxyImpl
*proxy
= (TMProxyImpl
*)iface
;
1504 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
1506 if (proxy
->outerunknown
)
1507 return IUnknown_QueryInterface(proxy
->outerunknown
, riid
, ppv
);
1509 FIXME("No interface\n");
1510 return E_NOINTERFACE
;
1513 static ULONG WINAPI
ProxyIUnknown_AddRef(IUnknown
*iface
)
1515 TMProxyImpl
*proxy
= (TMProxyImpl
*)iface
;
1519 if (proxy
->outerunknown
)
1520 return IUnknown_AddRef(proxy
->outerunknown
);
1522 return 2; /* FIXME */
1525 static ULONG WINAPI
ProxyIUnknown_Release(IUnknown
*iface
)
1527 TMProxyImpl
*proxy
= (TMProxyImpl
*)iface
;
1531 if (proxy
->outerunknown
)
1532 return IUnknown_Release(proxy
->outerunknown
);
1534 return 1; /* FIXME */
1537 static HRESULT WINAPI
ProxyIDispatch_GetTypeInfoCount(LPDISPATCH iface
, UINT
* pctinfo
)
1539 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1541 TRACE("(%p)\n", pctinfo
);
1543 return IDispatch_GetTypeInfoCount(This
->dispatch
, pctinfo
);
1546 static HRESULT WINAPI
ProxyIDispatch_GetTypeInfo(LPDISPATCH iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1548 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1550 TRACE("(%d, %x, %p)\n", iTInfo
, lcid
, ppTInfo
);
1552 return IDispatch_GetTypeInfo(This
->dispatch
, iTInfo
, lcid
, ppTInfo
);
1555 static HRESULT WINAPI
ProxyIDispatch_GetIDsOfNames(LPDISPATCH iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1557 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1559 TRACE("(%s, %p, %d, 0x%x, %p)\n", debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
1561 return IDispatch_GetIDsOfNames(This
->dispatch
, riid
, rgszNames
,
1562 cNames
, lcid
, rgDispId
);
1565 static HRESULT WINAPI
ProxyIDispatch_Invoke(LPDISPATCH iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1566 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
1567 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1569 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1571 TRACE("(%d, %s, 0x%x, 0x%x, %p, %p, %p, %p)\n", dispIdMember
,
1572 debugstr_guid(riid
), lcid
, wFlags
, pDispParams
, pVarResult
,
1573 pExcepInfo
, puArgErr
);
1575 return IDispatch_Invoke(This
->dispatch
, dispIdMember
, riid
, lcid
,
1576 wFlags
, pDispParams
, pVarResult
, pExcepInfo
,
1582 IRpcChannelBuffer IRpcChannelBuffer_iface
;
1584 /* the IDispatch-derived interface we are handling */
1586 IRpcChannelBuffer
*pDelegateChannel
;
1587 } TMarshalDispatchChannel
;
1589 static inline TMarshalDispatchChannel
*impl_from_IRpcChannelBuffer(IRpcChannelBuffer
*iface
)
1591 return CONTAINING_RECORD(iface
, TMarshalDispatchChannel
, IRpcChannelBuffer_iface
);
1594 static HRESULT WINAPI
TMarshalDispatchChannel_QueryInterface(IRpcChannelBuffer
*iface
, REFIID riid
, LPVOID
*ppv
)
1597 if (IsEqualIID(riid
,&IID_IRpcChannelBuffer
) || IsEqualIID(riid
,&IID_IUnknown
))
1600 IRpcChannelBuffer_AddRef(iface
);
1603 return E_NOINTERFACE
;
1606 static ULONG WINAPI
TMarshalDispatchChannel_AddRef(LPRPCCHANNELBUFFER iface
)
1608 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1609 return InterlockedIncrement(&This
->refs
);
1612 static ULONG WINAPI
TMarshalDispatchChannel_Release(LPRPCCHANNELBUFFER iface
)
1614 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1617 ref
= InterlockedDecrement(&This
->refs
);
1621 IRpcChannelBuffer_Release(This
->pDelegateChannel
);
1622 HeapFree(GetProcessHeap(), 0, This
);
1626 static HRESULT WINAPI
TMarshalDispatchChannel_GetBuffer(LPRPCCHANNELBUFFER iface
, RPCOLEMESSAGE
* olemsg
, REFIID riid
)
1628 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1629 TRACE("(%p, %s)\n", olemsg
, debugstr_guid(riid
));
1630 /* Note: we are pretending to invoke a method on the interface identified
1631 * by tmarshal_iid so that we can re-use the IDispatch proxy/stub code
1632 * without the RPC runtime getting confused by not exporting an IDispatch interface */
1633 return IRpcChannelBuffer_GetBuffer(This
->pDelegateChannel
, olemsg
, &This
->tmarshal_iid
);
1636 static HRESULT WINAPI
TMarshalDispatchChannel_SendReceive(LPRPCCHANNELBUFFER iface
, RPCOLEMESSAGE
*olemsg
, ULONG
*pstatus
)
1638 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1639 TRACE("(%p, %p)\n", olemsg
, pstatus
);
1640 return IRpcChannelBuffer_SendReceive(This
->pDelegateChannel
, olemsg
, pstatus
);
1643 static HRESULT WINAPI
TMarshalDispatchChannel_FreeBuffer(LPRPCCHANNELBUFFER iface
, RPCOLEMESSAGE
* olemsg
)
1645 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1646 TRACE("(%p)\n", olemsg
);
1647 return IRpcChannelBuffer_FreeBuffer(This
->pDelegateChannel
, olemsg
);
1650 static HRESULT WINAPI
TMarshalDispatchChannel_GetDestCtx(LPRPCCHANNELBUFFER iface
, DWORD
* pdwDestContext
, void** ppvDestContext
)
1652 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1653 TRACE("(%p,%p)\n", pdwDestContext
, ppvDestContext
);
1654 return IRpcChannelBuffer_GetDestCtx(This
->pDelegateChannel
, pdwDestContext
, ppvDestContext
);
1657 static HRESULT WINAPI
TMarshalDispatchChannel_IsConnected(LPRPCCHANNELBUFFER iface
)
1659 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1661 return IRpcChannelBuffer_IsConnected(This
->pDelegateChannel
);
1664 static const IRpcChannelBufferVtbl TMarshalDispatchChannelVtbl
=
1666 TMarshalDispatchChannel_QueryInterface
,
1667 TMarshalDispatchChannel_AddRef
,
1668 TMarshalDispatchChannel_Release
,
1669 TMarshalDispatchChannel_GetBuffer
,
1670 TMarshalDispatchChannel_SendReceive
,
1671 TMarshalDispatchChannel_FreeBuffer
,
1672 TMarshalDispatchChannel_GetDestCtx
,
1673 TMarshalDispatchChannel_IsConnected
1676 static HRESULT
TMarshalDispatchChannel_Create(
1677 IRpcChannelBuffer
*pDelegateChannel
, REFIID tmarshal_riid
,
1678 IRpcChannelBuffer
**ppChannel
)
1680 TMarshalDispatchChannel
*This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1682 return E_OUTOFMEMORY
;
1684 This
->IRpcChannelBuffer_iface
.lpVtbl
= &TMarshalDispatchChannelVtbl
;
1686 IRpcChannelBuffer_AddRef(pDelegateChannel
);
1687 This
->pDelegateChannel
= pDelegateChannel
;
1688 This
->tmarshal_iid
= *tmarshal_riid
;
1690 *ppChannel
= &This
->IRpcChannelBuffer_iface
;
1695 static inline HRESULT
get_facbuf_for_iid(REFIID riid
, IPSFactoryBuffer
**facbuf
)
1700 if ((hr
= CoGetPSClsid(riid
, &clsid
)))
1702 return CoGetClassObject(&clsid
, CLSCTX_INPROC_SERVER
, NULL
,
1703 &IID_IPSFactoryBuffer
, (LPVOID
*)facbuf
);
1706 static HRESULT
init_proxy_entry_point(TMProxyImpl
*proxy
, unsigned int num
)
1709 /* nrofargs including This */
1712 TMAsmProxy
*xasm
= proxy
->asmstubs
+ num
;
1714 const FUNCDESC
*fdesc
;
1716 hres
= get_funcdesc(proxy
->tinfo
, num
, &tinfo2
, &fdesc
, NULL
, NULL
, NULL
);
1718 ERR("GetFuncDesc %x should not fail here.\n",hres
);
1721 ITypeInfo_Release(tinfo2
);
1722 /* some args take more than 4 byte on the stack */
1723 for (j
=0;j
<fdesc
->cParams
;j
++)
1724 nrofargs
+= _argsize(&fdesc
->lprgelemdescParam
[j
].tdesc
, proxy
->tinfo
);
1727 if (fdesc
->callconv
!= CC_STDCALL
) {
1728 ERR("calling convention is not stdcall????\n");
1731 /* leal 4(%esp),%eax
1737 xasm
->lealeax
= 0x0424448d;
1738 xasm
->pushleax
= 0x50;
1739 xasm
->pushlval
= 0x68;
1742 xasm
->xcall
= (char *)xCall
- (char *)&xasm
->lret
;
1744 xasm
->bytestopop
= nrofargs
* 4;
1746 proxy
->lpvtbl
[fdesc
->oVft
/ sizeof(void *)] = xasm
;
1748 FIXME("not implemented on non i386\n");
1754 static HRESULT WINAPI
1755 PSFacBuf_CreateProxy(
1756 LPPSFACTORYBUFFER iface
, IUnknown
* pUnkOuter
, REFIID riid
,
1757 IRpcProxyBuffer
**ppProxy
, LPVOID
*ppv
)
1761 unsigned int i
, nroffuncs
, vtbl_size
;
1764 BOOL defer_to_dispatch
= FALSE
;
1766 TRACE("(...%s...)\n",debugstr_guid(riid
));
1767 hres
= _get_typeinfo_for_iid(riid
,&tinfo
);
1769 ERR("No typeinfo for %s?\n",debugstr_guid(riid
));
1773 hres
= num_of_funcs(tinfo
, &nroffuncs
, &vtbl_size
);
1774 TRACE("Got %d funcs, vtbl size %d\n", nroffuncs
, vtbl_size
);
1777 ERR("Cannot get number of functions for typeinfo %s\n",debugstr_guid(riid
));
1778 ITypeInfo_Release(tinfo
);
1782 proxy
= CoTaskMemAlloc(sizeof(TMProxyImpl
));
1783 if (!proxy
) return E_OUTOFMEMORY
;
1785 proxy
->dispatch
= NULL
;
1786 proxy
->dispatch_proxy
= NULL
;
1787 proxy
->outerunknown
= pUnkOuter
;
1788 proxy
->asmstubs
= VirtualAlloc(NULL
, sizeof(TMAsmProxy
) * nroffuncs
, MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
1789 if (!proxy
->asmstubs
) {
1790 ERR("Could not commit pages for proxy thunks\n");
1791 CoTaskMemFree(proxy
);
1792 return E_OUTOFMEMORY
;
1794 proxy
->IRpcProxyBuffer_iface
.lpVtbl
= &tmproxyvtable
;
1795 /* one reference for the proxy */
1797 proxy
->tinfo
= tinfo
;
1801 InitializeCriticalSection(&proxy
->crit
);
1802 proxy
->crit
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": TMProxyImpl.crit");
1804 proxy
->lpvtbl
= HeapAlloc(GetProcessHeap(), 0, vtbl_size
);
1806 /* if we derive from IDispatch then defer to its proxy for its methods */
1807 hres
= ITypeInfo_GetTypeAttr(tinfo
, &typeattr
);
1810 if (typeattr
->wTypeFlags
& TYPEFLAG_FDISPATCHABLE
)
1812 IPSFactoryBuffer
*factory_buffer
;
1813 hres
= get_facbuf_for_iid(&IID_IDispatch
, &factory_buffer
);
1816 hres
= IPSFactoryBuffer_CreateProxy(factory_buffer
, NULL
,
1817 &IID_IDispatch
, &proxy
->dispatch_proxy
,
1818 (void **)&proxy
->dispatch
);
1819 IPSFactoryBuffer_Release(factory_buffer
);
1821 if ((hres
== S_OK
) && (nroffuncs
< 7))
1823 ERR("nroffuncs calculated incorrectly (%d)\n", nroffuncs
);
1824 hres
= E_UNEXPECTED
;
1828 defer_to_dispatch
= TRUE
;
1831 ITypeInfo_ReleaseTypeAttr(tinfo
, typeattr
);
1834 for (i
=0;i
<nroffuncs
;i
++) {
1837 proxy
->lpvtbl
[i
] = ProxyIUnknown_QueryInterface
;
1840 proxy
->lpvtbl
[i
] = ProxyIUnknown_AddRef
;
1843 proxy
->lpvtbl
[i
] = ProxyIUnknown_Release
;
1846 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1847 else proxy
->lpvtbl
[3] = ProxyIDispatch_GetTypeInfoCount
;
1850 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1851 else proxy
->lpvtbl
[4] = ProxyIDispatch_GetTypeInfo
;
1854 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1855 else proxy
->lpvtbl
[5] = ProxyIDispatch_GetIDsOfNames
;
1858 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1859 else proxy
->lpvtbl
[6] = ProxyIDispatch_Invoke
;
1862 hres
= init_proxy_entry_point(proxy
, i
);
1869 *ppProxy
= &proxy
->IRpcProxyBuffer_iface
;
1870 IUnknown_AddRef((IUnknown
*)*ppv
);
1874 TMProxyImpl_Release(&proxy
->IRpcProxyBuffer_iface
);
1878 typedef struct _TMStubImpl
{
1879 IRpcStubBuffer IRpcStubBuffer_iface
;
1885 IRpcStubBuffer
*dispatch_stub
;
1886 BOOL dispatch_derivative
;
1889 static inline TMStubImpl
*impl_from_IRpcStubBuffer(IRpcStubBuffer
*iface
)
1891 return CONTAINING_RECORD(iface
, TMStubImpl
, IRpcStubBuffer_iface
);
1894 static HRESULT WINAPI
1895 TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface
, REFIID riid
, LPVOID
*ppv
)
1897 if (IsEqualIID(riid
,&IID_IRpcStubBuffer
)||IsEqualIID(riid
,&IID_IUnknown
)){
1899 IRpcStubBuffer_AddRef(iface
);
1902 FIXME("%s, not supported IID.\n",debugstr_guid(riid
));
1903 return E_NOINTERFACE
;
1907 TMStubImpl_AddRef(LPRPCSTUBBUFFER iface
)
1909 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1910 ULONG refCount
= InterlockedIncrement(&This
->ref
);
1912 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
1918 TMStubImpl_Release(LPRPCSTUBBUFFER iface
)
1920 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1921 ULONG refCount
= InterlockedDecrement(&This
->ref
);
1923 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
1927 IRpcStubBuffer_Disconnect(iface
);
1928 ITypeInfo_Release(This
->tinfo
);
1929 if (This
->dispatch_stub
)
1930 IRpcStubBuffer_Release(This
->dispatch_stub
);
1931 CoTaskMemFree(This
);
1936 static HRESULT WINAPI
1937 TMStubImpl_Connect(LPRPCSTUBBUFFER iface
, LPUNKNOWN pUnkServer
)
1939 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1941 TRACE("(%p)->(%p)\n", This
, pUnkServer
);
1943 IUnknown_AddRef(pUnkServer
);
1944 This
->pUnk
= pUnkServer
;
1946 if (This
->dispatch_stub
)
1947 IRpcStubBuffer_Connect(This
->dispatch_stub
, pUnkServer
);
1953 TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface
)
1955 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1957 TRACE("(%p)->()\n", This
);
1961 IUnknown_Release(This
->pUnk
);
1965 if (This
->dispatch_stub
)
1966 IRpcStubBuffer_Disconnect(This
->dispatch_stub
);
1969 static HRESULT WINAPI
1971 LPRPCSTUBBUFFER iface
, RPCOLEMESSAGE
* xmsg
,IRpcChannelBuffer
*rpcchanbuf
)
1975 const FUNCDESC
*fdesc
;
1976 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1978 DWORD
*args
= NULL
, res
, *xargs
, nrofargs
;
1983 ITypeInfo
*tinfo
= NULL
;
1987 if (xmsg
->iMethod
< 3) {
1988 ERR("IUnknown methods cannot be marshaled by the typelib marshaler\n");
1989 return E_UNEXPECTED
;
1992 if (This
->dispatch_derivative
&& xmsg
->iMethod
< sizeof(IDispatchVtbl
)/sizeof(void *))
1994 if (!This
->dispatch_stub
)
1996 IPSFactoryBuffer
*factory_buffer
;
1997 hres
= get_facbuf_for_iid(&IID_IDispatch
, &factory_buffer
);
2000 hres
= IPSFactoryBuffer_CreateStub(factory_buffer
, &IID_IDispatch
,
2001 This
->pUnk
, &This
->dispatch_stub
);
2002 IPSFactoryBuffer_Release(factory_buffer
);
2007 return IRpcStubBuffer_Invoke(This
->dispatch_stub
, xmsg
, rpcchanbuf
);
2010 memset(&buf
,0,sizeof(buf
));
2011 buf
.size
= xmsg
->cbBuffer
;
2012 buf
.base
= HeapAlloc(GetProcessHeap(), 0, xmsg
->cbBuffer
);
2013 memcpy(buf
.base
, xmsg
->Buffer
, xmsg
->cbBuffer
);
2016 hres
= get_funcdesc(This
->tinfo
,xmsg
->iMethod
,&tinfo
,&fdesc
,&iname
,NULL
,NULL
);
2018 ERR("GetFuncDesc on method %d failed with %x\n",xmsg
->iMethod
,hres
);
2022 if (iname
&& !lstrcmpW(iname
, IDispatchW
))
2024 ERR("IDispatch cannot be marshaled by the typelib marshaler\n");
2025 hres
= E_UNEXPECTED
;
2026 SysFreeString (iname
);
2030 SysFreeString (iname
);
2032 /* Need them for hack below */
2033 memset(names
,0,sizeof(names
));
2034 ITypeInfo_GetNames(tinfo
,fdesc
->memid
,names
,sizeof(names
)/sizeof(names
[0]),&nrofnames
);
2035 if (nrofnames
> sizeof(names
)/sizeof(names
[0])) {
2036 ERR("Need more names!\n");
2039 /*dump_FUNCDESC(fdesc);*/
2041 for (i
=0;i
<fdesc
->cParams
;i
++)
2042 nrofargs
+= _argsize(&fdesc
->lprgelemdescParam
[i
].tdesc
, tinfo
);
2043 args
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,(nrofargs
+1)*sizeof(DWORD
));
2046 hres
= E_OUTOFMEMORY
;
2050 /* Allocate all stuff used by call. */
2052 for (i
=0;i
<fdesc
->cParams
;i
++) {
2053 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
2055 hres
= deserialize_param(
2064 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
2066 ERR("Failed to deserialize param %s, hres %x\n",relaystr(names
[i
+1]),hres
);
2071 args
[0] = (DWORD
)This
->pUnk
;
2076 (*((FARPROC
**)args
[0]))[fdesc
->oVft
/4],
2084 DWORD dwExceptionCode
= GetExceptionCode();
2085 ERR("invoke call failed with exception 0x%08x (%d)\n", dwExceptionCode
, dwExceptionCode
);
2086 if (FAILED(dwExceptionCode
))
2087 hres
= dwExceptionCode
;
2089 hres
= HRESULT_FROM_WIN32(dwExceptionCode
);
2099 for (i
=0;i
<fdesc
->cParams
;i
++) {
2100 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
2101 hres
= serialize_param(
2110 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
2112 ERR("Failed to stuballoc param, hres %x\n",hres
);
2117 hres
= xbuf_add (&buf
, (LPBYTE
)&res
, sizeof(DWORD
));
2122 xmsg
->cbBuffer
= buf
.curoff
;
2123 hres
= IRpcChannelBuffer_GetBuffer(rpcchanbuf
, xmsg
, &This
->iid
);
2125 ERR("IRpcChannelBuffer_GetBuffer failed with error 0x%08x\n", hres
);
2128 memcpy(xmsg
->Buffer
, buf
.base
, buf
.curoff
);
2131 for (i
= 0; i
< nrofnames
; i
++)
2132 SysFreeString(names
[i
]);
2134 ITypeInfo_Release(tinfo
);
2135 HeapFree(GetProcessHeap(), 0, args
);
2137 HeapFree(GetProcessHeap(), 0, buf
.base
);
2139 TRACE("returning\n");
2142 FIXME( "not implemented on non-i386\n" );
2147 static LPRPCSTUBBUFFER WINAPI
2148 TMStubImpl_IsIIDSupported(LPRPCSTUBBUFFER iface
, REFIID riid
) {
2149 FIXME("Huh (%s)?\n",debugstr_guid(riid
));
2154 TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface
) {
2155 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
2158 return This
->ref
; /*FIXME? */
2161 static HRESULT WINAPI
2162 TMStubImpl_DebugServerQueryInterface(LPRPCSTUBBUFFER iface
, LPVOID
*ppv
) {
2167 TMStubImpl_DebugServerRelease(LPRPCSTUBBUFFER iface
, LPVOID ppv
) {
2171 static const IRpcStubBufferVtbl tmstubvtbl
= {
2172 TMStubImpl_QueryInterface
,
2176 TMStubImpl_Disconnect
,
2178 TMStubImpl_IsIIDSupported
,
2179 TMStubImpl_CountRefs
,
2180 TMStubImpl_DebugServerQueryInterface
,
2181 TMStubImpl_DebugServerRelease
2184 static HRESULT WINAPI
2185 PSFacBuf_CreateStub(
2186 LPPSFACTORYBUFFER iface
, REFIID riid
,IUnknown
*pUnkServer
,
2187 IRpcStubBuffer
** ppStub
2194 TRACE("(%s,%p,%p)\n",debugstr_guid(riid
),pUnkServer
,ppStub
);
2196 hres
= _get_typeinfo_for_iid(riid
,&tinfo
);
2198 ERR("No typeinfo for %s?\n",debugstr_guid(riid
));
2202 stub
= CoTaskMemAlloc(sizeof(TMStubImpl
));
2204 return E_OUTOFMEMORY
;
2205 stub
->IRpcStubBuffer_iface
.lpVtbl
= &tmstubvtbl
;
2207 stub
->tinfo
= tinfo
;
2208 stub
->dispatch_stub
= NULL
;
2209 stub
->dispatch_derivative
= FALSE
;
2211 hres
= IRpcStubBuffer_Connect(&stub
->IRpcStubBuffer_iface
,pUnkServer
);
2212 *ppStub
= &stub
->IRpcStubBuffer_iface
;
2213 TRACE("IRpcStubBuffer: %p\n", stub
);
2215 ERR("Connect to pUnkServer failed?\n");
2217 /* if we derive from IDispatch then defer to its stub for some of its methods */
2218 hres
= ITypeInfo_GetTypeAttr(tinfo
, &typeattr
);
2221 if (typeattr
->wTypeFlags
& TYPEFLAG_FDISPATCHABLE
)
2222 stub
->dispatch_derivative
= TRUE
;
2223 ITypeInfo_ReleaseTypeAttr(tinfo
, typeattr
);
2229 static const IPSFactoryBufferVtbl psfacbufvtbl
= {
2230 PSFacBuf_QueryInterface
,
2233 PSFacBuf_CreateProxy
,
2237 /* This is the whole PSFactoryBuffer object, just the vtableptr */
2238 static const IPSFactoryBufferVtbl
*lppsfac
= &psfacbufvtbl
;
2240 /***********************************************************************
2241 * TMARSHAL_DllGetClassObject
2243 HRESULT
TMARSHAL_DllGetClassObject(REFCLSID rclsid
, REFIID iid
,LPVOID
*ppv
)
2245 if (IsEqualIID(iid
,&IID_IPSFactoryBuffer
)) {
2249 return E_NOINTERFACE
;