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
25 #include "wine/port.h"
35 #define NONAMELESSUNION
45 #include "propidl.h" /* for LPSAFEARRAY_User* functions */
48 #include "wine/debug.h"
49 #include "wine/exception.h"
51 static const WCHAR IDispatchW
[] = { 'I','D','i','s','p','a','t','c','h',0};
53 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
54 WINE_DECLARE_DEBUG_CHANNEL(olerelay
);
56 static HRESULT
TMarshalDispatchChannel_Create(
57 IRpcChannelBuffer
*pDelegateChannel
, REFIID tmarshal_riid
,
58 IRpcChannelBuffer
**ppChannel
);
60 typedef struct _marshal_state
{
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_resize(marshal_state
*buf
, DWORD newsize
)
77 if(buf
->size
>= newsize
)
82 buf
->base
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, buf
->base
, newsize
);
88 buf
->base
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, newsize
);
97 xbuf_add(marshal_state
*buf
, const BYTE
*stuff
, DWORD size
)
101 if(buf
->size
- buf
->curoff
< size
)
103 hr
= xbuf_resize(buf
, buf
->size
+ size
+ 100);
104 if(FAILED(hr
)) return hr
;
106 memcpy(buf
->base
+buf
->curoff
,stuff
,size
);
112 xbuf_get(marshal_state
*buf
, LPBYTE stuff
, DWORD size
) {
113 if (buf
->size
< buf
->curoff
+size
) return E_FAIL
;
114 memcpy(stuff
,buf
->base
+buf
->curoff
,size
);
120 xbuf_skip(marshal_state
*buf
, DWORD size
) {
121 if (buf
->size
< buf
->curoff
+size
) return E_FAIL
;
127 _unmarshal_interface(marshal_state
*buf
, REFIID riid
, LPUNKNOWN
*pUnk
) {
129 ULARGE_INTEGER newpos
;
130 LARGE_INTEGER seekto
;
135 TRACE("...%s...\n",debugstr_guid(riid
));
138 hres
= xbuf_get(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
140 ERR("xbuf_get failed\n");
144 if (xsize
== 0) return S_OK
;
146 hres
= CreateStreamOnHGlobal(0,TRUE
,&pStm
);
148 ERR("Stream create failed %x\n",hres
);
152 hres
= IStream_Write(pStm
,buf
->base
+buf
->curoff
,xsize
,&res
);
154 ERR("stream write %x\n",hres
);
155 IStream_Release(pStm
);
159 memset(&seekto
,0,sizeof(seekto
));
160 hres
= IStream_Seek(pStm
,seekto
,SEEK_SET
,&newpos
);
162 ERR("Failed Seek %x\n",hres
);
163 IStream_Release(pStm
);
167 hres
= CoUnmarshalInterface(pStm
,riid
,(LPVOID
*)pUnk
);
169 ERR("Unmarshalling interface %s failed with %x\n",debugstr_guid(riid
),hres
);
170 IStream_Release(pStm
);
174 IStream_Release(pStm
);
175 return xbuf_skip(buf
,xsize
);
179 _marshal_interface(marshal_state
*buf
, REFIID riid
, LPUNKNOWN pUnk
) {
180 LPBYTE tempbuf
= NULL
;
181 IStream
*pStm
= NULL
;
183 ULARGE_INTEGER newpos
;
184 LARGE_INTEGER seekto
;
190 /* this is valid, if for instance we serialize
191 * a VT_DISPATCH with NULL ptr which apparently
192 * can happen. S_OK to make sure we continue
195 WARN("pUnk is NULL\n");
197 return xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
200 TRACE("...%s...\n",debugstr_guid(riid
));
202 hres
= CreateStreamOnHGlobal(0,TRUE
,&pStm
);
204 ERR("Stream create failed %x\n",hres
);
208 hres
= CoMarshalInterface(pStm
,riid
,pUnk
,0,NULL
,0);
210 ERR("Marshalling interface %s failed with %x\n", debugstr_guid(riid
), hres
);
214 hres
= IStream_Stat(pStm
,&ststg
,STATFLAG_NONAME
);
216 ERR("Stream stat failed\n");
220 tempbuf
= HeapAlloc(GetProcessHeap(), 0, ststg
.cbSize
.u
.LowPart
);
221 memset(&seekto
,0,sizeof(seekto
));
222 hres
= IStream_Seek(pStm
,seekto
,SEEK_SET
,&newpos
);
224 ERR("Failed Seek %x\n",hres
);
228 hres
= IStream_Read(pStm
,tempbuf
,ststg
.cbSize
.u
.LowPart
,&res
);
230 ERR("Failed Read %x\n",hres
);
234 xsize
= ststg
.cbSize
.u
.LowPart
;
235 xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
236 hres
= xbuf_add(buf
,tempbuf
,ststg
.cbSize
.u
.LowPart
);
238 HeapFree(GetProcessHeap(),0,tempbuf
);
239 IStream_Release(pStm
);
245 xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
246 if (pStm
) IStream_Release(pStm
);
247 HeapFree(GetProcessHeap(), 0, tempbuf
);
251 /********************* OLE Proxy/Stub Factory ********************************/
252 static HRESULT WINAPI
253 PSFacBuf_QueryInterface(LPPSFACTORYBUFFER iface
, REFIID iid
, LPVOID
*ppv
) {
254 if (IsEqualIID(iid
,&IID_IPSFactoryBuffer
)||IsEqualIID(iid
,&IID_IUnknown
)) {
256 /* No ref counting, static class */
259 FIXME("(%s) unknown IID?\n",debugstr_guid(iid
));
260 return E_NOINTERFACE
;
263 static ULONG WINAPI
PSFacBuf_AddRef(LPPSFACTORYBUFFER iface
) { return 2; }
264 static ULONG WINAPI
PSFacBuf_Release(LPPSFACTORYBUFFER iface
) { return 1; }
267 _get_typeinfo_for_iid(REFIID riid
, ITypeInfo
**ti
) {
270 REGSAM opposite
= (sizeof(void*) == 8) ? KEY_WOW64_32KEY
: KEY_WOW64_64KEY
;
272 char tlguid
[200],typelibkey
[300],interfacekey
[300],ver
[100];
275 DWORD tlguidlen
, verlen
, type
;
279 sprintf( interfacekey
, "Interface\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
280 riid
->Data1
, riid
->Data2
, riid
->Data3
,
281 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
282 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]
285 err
= RegOpenKeyExA(HKEY_CLASSES_ROOT
,interfacekey
,0,KEY_READ
,&ikey
);
286 if (err
&& (opposite
== KEY_WOW64_32KEY
|| (IsWow64Process(GetCurrentProcess(), &is_wow64
)
288 err
= RegOpenKeyExA(HKEY_CLASSES_ROOT
,interfacekey
,0,KEY_READ
|opposite
,&ikey
);
291 ERR("No %s key found.\n",interfacekey
);
294 tlguidlen
= sizeof(tlguid
);
295 if (RegQueryValueExA(ikey
,NULL
,NULL
,&type
,(LPBYTE
)tlguid
,&tlguidlen
)) {
296 ERR("Getting typelib guid failed.\n");
300 verlen
= sizeof(ver
);
301 if (RegQueryValueExA(ikey
,"Version",NULL
,&type
,(LPBYTE
)ver
,&verlen
)) {
302 ERR("Could not get version value?\n");
307 sprintf(typelibkey
,"Typelib\\%s\\%s\\0\\win%u",tlguid
,ver
,(sizeof(void*) == 8) ? 64 : 32);
308 tlfnlen
= sizeof(tlfn
);
309 if (RegQueryValueA(HKEY_CLASSES_ROOT
,typelibkey
,tlfn
,&tlfnlen
)) {
311 sprintf(typelibkey
,"Typelib\\%s\\%s\\0\\win32",tlguid
,ver
);
312 tlfnlen
= sizeof(tlfn
);
313 if (RegQueryValueA(HKEY_CLASSES_ROOT
,typelibkey
,tlfn
,&tlfnlen
)) {
315 ERR("Could not get typelib fn?\n");
321 MultiByteToWideChar(CP_ACP
, 0, tlfn
, -1, tlfnW
, sizeof(tlfnW
) / sizeof(tlfnW
[0]));
322 hres
= LoadTypeLib(tlfnW
,&tl
);
324 ERR("Failed to load typelib for %s, but it should be there.\n",debugstr_guid(riid
));
327 hres
= ITypeLib_GetTypeInfoOfGuid(tl
,riid
,ti
);
329 ERR("typelib does not contain info for %s?\n",debugstr_guid(riid
));
330 ITypeLib_Release(tl
);
333 ITypeLib_Release(tl
);
338 * Determine the number of functions including all inherited functions
339 * and well as the size of the vtbl.
340 * Note for non-dual dispinterfaces we simply return the size of IDispatch.
342 static HRESULT
num_of_funcs(ITypeInfo
*tinfo
, unsigned int *num
,
343 unsigned int *vtbl_size
)
348 UINT inherited_funcs
= 0, i
;
351 if(vtbl_size
) *vtbl_size
= 0;
353 hr
= ITypeInfo_GetTypeAttr(tinfo
, &attr
);
356 ERR("GetTypeAttr failed with %x\n", hr
);
360 if(attr
->typekind
== TKIND_DISPATCH
)
362 if(attr
->wTypeFlags
& TYPEFLAG_FDUAL
)
366 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
367 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, -1, &href
);
370 ERR("Unable to get interface href from dual dispinterface\n");
373 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &tinfo2
);
376 ERR("Unable to get interface from dual dispinterface\n");
379 hr
= num_of_funcs(tinfo2
, num
, vtbl_size
);
380 ITypeInfo_Release(tinfo2
);
383 else /* non-dual dispinterface */
385 /* These will be the size of IDispatchVtbl */
386 *num
= attr
->cbSizeVft
/ sizeof(void *);
387 if(vtbl_size
) *vtbl_size
= attr
->cbSizeVft
;
388 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
393 for (i
= 0; i
< attr
->cImplTypes
; i
++)
396 ITypeInfo
*pSubTypeInfo
;
399 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, i
, &href
);
400 if (FAILED(hr
)) goto end
;
401 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &pSubTypeInfo
);
402 if (FAILED(hr
)) goto end
;
404 hr
= num_of_funcs(pSubTypeInfo
, &sub_funcs
, NULL
);
405 ITypeInfo_Release(pSubTypeInfo
);
407 if(FAILED(hr
)) goto end
;
408 inherited_funcs
+= sub_funcs
;
411 *num
= inherited_funcs
+ attr
->cFuncs
;
412 if(vtbl_size
) *vtbl_size
= attr
->cbSizeVft
;
415 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
421 #include "pshpack1.h"
423 typedef struct _TMAsmProxy
{
438 # warning You need to implement stubless proxies for your architecture
439 typedef struct _TMAsmProxy
{
443 typedef struct _TMProxyImpl
{
445 IRpcProxyBuffer IRpcProxyBuffer_iface
;
448 TMAsmProxy
*asmstubs
;
450 IRpcChannelBuffer
* chanbuf
;
452 CRITICAL_SECTION crit
;
453 IUnknown
*outerunknown
;
455 IRpcProxyBuffer
*dispatch_proxy
;
458 static inline TMProxyImpl
*impl_from_IRpcProxyBuffer( IRpcProxyBuffer
*iface
)
460 return CONTAINING_RECORD(iface
, TMProxyImpl
, IRpcProxyBuffer_iface
);
463 static HRESULT WINAPI
464 TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface
, REFIID riid
, LPVOID
*ppv
)
467 if (IsEqualIID(riid
,&IID_IUnknown
)||IsEqualIID(riid
,&IID_IRpcProxyBuffer
)) {
469 IRpcProxyBuffer_AddRef(iface
);
472 FIXME("no interface for %s\n",debugstr_guid(riid
));
473 return E_NOINTERFACE
;
477 TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface
)
479 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
480 ULONG refCount
= InterlockedIncrement(&This
->ref
);
482 TRACE("(%p)->(ref before=%u)\n",This
, refCount
- 1);
488 TMProxyImpl_Release(LPRPCPROXYBUFFER iface
)
490 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
491 ULONG refCount
= InterlockedDecrement(&This
->ref
);
493 TRACE("(%p)->(ref before=%u)\n",This
, refCount
+ 1);
497 if (This
->dispatch_proxy
) IRpcProxyBuffer_Release(This
->dispatch_proxy
);
498 This
->crit
.DebugInfo
->Spare
[0] = 0;
499 DeleteCriticalSection(&This
->crit
);
500 if (This
->chanbuf
) IRpcChannelBuffer_Release(This
->chanbuf
);
501 VirtualFree(This
->asmstubs
, 0, MEM_RELEASE
);
502 HeapFree(GetProcessHeap(), 0, This
->lpvtbl
);
503 ITypeInfo_Release(This
->tinfo
);
509 static HRESULT WINAPI
511 LPRPCPROXYBUFFER iface
,IRpcChannelBuffer
* pRpcChannelBuffer
)
513 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
515 TRACE("(%p)\n", pRpcChannelBuffer
);
517 EnterCriticalSection(&This
->crit
);
519 IRpcChannelBuffer_AddRef(pRpcChannelBuffer
);
520 This
->chanbuf
= pRpcChannelBuffer
;
522 LeaveCriticalSection(&This
->crit
);
524 if (This
->dispatch_proxy
)
526 IRpcChannelBuffer
*pDelegateChannel
;
527 HRESULT hr
= TMarshalDispatchChannel_Create(pRpcChannelBuffer
, &This
->iid
, &pDelegateChannel
);
530 hr
= IRpcProxyBuffer_Connect(This
->dispatch_proxy
, pDelegateChannel
);
531 IRpcChannelBuffer_Release(pDelegateChannel
);
539 TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface
)
541 TMProxyImpl
*This
= impl_from_IRpcProxyBuffer( iface
);
545 EnterCriticalSection(&This
->crit
);
547 IRpcChannelBuffer_Release(This
->chanbuf
);
548 This
->chanbuf
= NULL
;
550 LeaveCriticalSection(&This
->crit
);
552 if (This
->dispatch_proxy
)
553 IRpcProxyBuffer_Disconnect(This
->dispatch_proxy
);
557 static const IRpcProxyBufferVtbl tmproxyvtable
= {
558 TMProxyImpl_QueryInterface
,
562 TMProxyImpl_Disconnect
565 /* how much space do we use on stack in DWORD steps. */
567 _argsize(TYPEDESC
*tdesc
, ITypeInfo
*tinfo
) {
571 return 8/sizeof(DWORD
);
573 return sizeof(double)/sizeof(DWORD
);
575 return sizeof(CY
)/sizeof(DWORD
);
577 return sizeof(DATE
)/sizeof(DWORD
);
579 return (sizeof(DECIMAL
)+3)/sizeof(DWORD
);
581 return (sizeof(VARIANT
)+3)/sizeof(DWORD
);
589 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
591 return 0; /* should fail critically in serialize_param */
592 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
593 ret
= (tattr
->cbSizeInstance
+3)/sizeof(DWORD
);
594 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
595 ITypeInfo_Release(tinfo2
);
603 /* how much space do we use on the heap (in bytes) */
605 _xsize(const TYPEDESC
*td
, ITypeInfo
*tinfo
) {
612 return sizeof(VARIANT
);
615 const ARRAYDESC
*adesc
= td
->u
.lpadesc
;
617 for (i
=0;i
<adesc
->cDims
;i
++)
618 arrsize
*= adesc
->rgbounds
[i
].cElements
;
619 return arrsize
*_xsize(&adesc
->tdescElem
, tinfo
);
639 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,td
->u
.hreftype
,&tinfo2
);
642 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
643 ret
= tattr
->cbSizeInstance
;
644 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
645 ITypeInfo_Release(tinfo2
);
653 /* Whether we pass this type by reference or by value */
655 _passbyref(const TYPEDESC
*td
, ITypeInfo
*tinfo
) {
656 return (td
->vt
== VT_USERDEFINED
||
657 td
->vt
== VT_VARIANT
||
674 TRACE("(tdesc.vt %s)\n",debugstr_vt(tdesc
->vt
));
677 if ((vartype
& 0xf000) == VT_ARRAY
)
678 vartype
= VT_SAFEARRAY
;
687 if (debugout
) TRACE_(olerelay
)("%x%x\n",arg
[0],arg
[1]);
689 hres
= xbuf_add(buf
,(LPBYTE
)arg
,8);
698 if (debugout
) TRACE_(olerelay
)("%x\n",*arg
);
700 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
706 if (debugout
) TRACE_(olerelay
)("%04x\n",*arg
& 0xffff);
708 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
713 if (debugout
) TRACE_(olerelay
)("%02x\n",*arg
& 0xff);
715 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
718 if (debugout
) TRACE_(olerelay
)("%s", debugstr_variant((VARIANT
*)arg
));
721 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
722 ULONG size
= VARIANT_UserSize(&flags
, buf
->curoff
, (VARIANT
*)arg
);
723 xbuf_resize(buf
, size
);
724 VARIANT_UserMarshal(&flags
, buf
->base
+ buf
->curoff
, (VARIANT
*)arg
);
729 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
730 VARIANT_UserFree(&flags
, (VARIANT
*)arg
);
735 if (writeit
&& debugout
) {
737 TRACE_(olerelay
)("%s",relaystr((WCHAR
*)*arg
));
739 TRACE_(olerelay
)("<bstr NULL>");
743 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
744 ULONG size
= BSTR_UserSize(&flags
, buf
->curoff
, (BSTR
*)arg
);
745 xbuf_resize(buf
, size
);
746 BSTR_UserMarshal(&flags
, buf
->base
+ buf
->curoff
, (BSTR
*)arg
);
751 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
752 BSTR_UserFree(&flags
, (BSTR
*)arg
);
758 BOOL derefhere
= TRUE
;
760 if (tdesc
->u
.lptdesc
->vt
== VT_USERDEFINED
) {
764 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.lptdesc
->u
.hreftype
,&tinfo2
);
766 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
769 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
770 switch (tattr
->typekind
) {
772 if (tattr
->tdescAlias
.vt
== VT_USERDEFINED
)
774 DWORD href
= tattr
->tdescAlias
.u
.hreftype
;
775 ITypeInfo_ReleaseTypeAttr(tinfo
, tattr
);
776 ITypeInfo_Release(tinfo2
);
777 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,href
,&tinfo2
);
779 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
782 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
783 derefhere
= (tattr
->typekind
!= TKIND_DISPATCH
&& tattr
->typekind
!= TKIND_INTERFACE
);
786 case TKIND_ENUM
: /* confirmed */
787 case TKIND_RECORD
: /* FIXME: mostly untested */
789 case TKIND_DISPATCH
: /* will be done in VT_USERDEFINED case */
790 case TKIND_INTERFACE
: /* will be done in VT_USERDEFINED case */
794 FIXME("unhandled switch cases tattr->typekind %d\n", tattr
->typekind
);
798 ITypeInfo_ReleaseTypeAttr(tinfo
, tattr
);
799 ITypeInfo_Release(tinfo2
);
802 if (debugout
) TRACE_(olerelay
)("*");
803 /* Write always, so the other side knows when it gets a NULL pointer.
805 cookie
= *arg
? 0x42424242 : 0;
806 hres
= xbuf_add(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
810 if (debugout
) TRACE_(olerelay
)("NULL");
813 hres
= serialize_param(tinfo
,writeit
,debugout
,dealloc
,tdesc
->u
.lptdesc
,(DWORD
*)*arg
,buf
);
814 if (derefhere
&& dealloc
) HeapFree(GetProcessHeap(),0,(LPVOID
)*arg
);
818 if (debugout
) TRACE_(olerelay
)("unk(0x%x)",*arg
);
820 hres
= _marshal_interface(buf
,&IID_IUnknown
,(LPUNKNOWN
)*arg
);
821 if (dealloc
&& *(IUnknown
**)arg
)
822 IUnknown_Release((LPUNKNOWN
)*arg
);
825 if (debugout
) TRACE_(olerelay
)("idisp(0x%x)",*arg
);
827 hres
= _marshal_interface(buf
,&IID_IDispatch
,(LPUNKNOWN
)*arg
);
828 if (dealloc
&& *(IUnknown
**)arg
)
829 IUnknown_Release((LPUNKNOWN
)*arg
);
832 if (debugout
) TRACE_(olerelay
)("<void>");
834 case VT_USERDEFINED
: {
838 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
840 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.hreftype
);
843 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
844 switch (tattr
->typekind
) {
846 case TKIND_INTERFACE
:
848 hres
=_marshal_interface(buf
,&(tattr
->guid
),(LPUNKNOWN
)arg
);
850 IUnknown_Release((LPUNKNOWN
)arg
);
854 if (debugout
) TRACE_(olerelay
)("{");
855 for (i
=0;i
<tattr
->cVars
;i
++) {
860 hres
= ITypeInfo_GetVarDesc(tinfo2
, i
, &vdesc
);
862 ERR("Could not get vardesc of %d\n",i
);
865 elem2
= &vdesc
->elemdescVar
;
866 tdesc2
= &elem2
->tdesc
;
867 hres
= serialize_param(
873 (DWORD
*)(((LPBYTE
)arg
)+vdesc
->u
.oInst
),
876 ITypeInfo_ReleaseVarDesc(tinfo2
, vdesc
);
879 if (debugout
&& (i
<(tattr
->cVars
-1)))
880 TRACE_(olerelay
)(",");
882 if (debugout
) TRACE_(olerelay
)("}");
886 hres
= serialize_param(tinfo2
,writeit
,debugout
,dealloc
,&tattr
->tdescAlias
,arg
,buf
);
890 if (debugout
) TRACE_(olerelay
)("%x",*arg
);
892 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
895 FIXME("Unhandled typekind %d\n",tattr
->typekind
);
899 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
900 ITypeInfo_Release(tinfo2
);
904 ARRAYDESC
*adesc
= tdesc
->u
.lpadesc
;
907 if (debugout
) TRACE_(olerelay
)("carr");
908 for (i
=0;i
<adesc
->cDims
;i
++) {
909 if (debugout
) TRACE_(olerelay
)("[%d]",adesc
->rgbounds
[i
].cElements
);
910 arrsize
*= adesc
->rgbounds
[i
].cElements
;
912 if (debugout
) TRACE_(olerelay
)("(vt %s)",debugstr_vt(adesc
->tdescElem
.vt
));
913 if (debugout
) TRACE_(olerelay
)("[");
914 for (i
=0;i
<arrsize
;i
++) {
915 LPBYTE base
= _passbyref(&adesc
->tdescElem
, tinfo
) ? (LPBYTE
) *arg
: (LPBYTE
) arg
;
916 hres
= serialize_param(tinfo
, writeit
, debugout
, dealloc
, &adesc
->tdescElem
, (DWORD
*)((LPBYTE
)base
+i
*_xsize(&adesc
->tdescElem
, tinfo
)), buf
);
919 if (debugout
&& (i
<arrsize
-1)) TRACE_(olerelay
)(",");
921 if (debugout
) TRACE_(olerelay
)("]");
923 HeapFree(GetProcessHeap(), 0, *(void **)arg
);
929 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
930 ULONG size
= LPSAFEARRAY_UserSize(&flags
, buf
->curoff
, (LPSAFEARRAY
*)arg
);
931 xbuf_resize(buf
, size
);
932 LPSAFEARRAY_UserMarshal(&flags
, buf
->base
+ buf
->curoff
, (LPSAFEARRAY
*)arg
);
937 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
938 LPSAFEARRAY_UserFree(&flags
, (LPSAFEARRAY
*)arg
);
943 ERR("Unhandled marshal type %d.\n",tdesc
->vt
);
961 TRACE("vt %s at %p\n",debugstr_vt(tdesc
->vt
),arg
);
964 if ((vartype
& 0xf000) == VT_ARRAY
)
965 vartype
= VT_SAFEARRAY
;
972 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
973 unsigned char *buffer
;
974 buffer
= VARIANT_UserUnmarshal(&flags
, buf
->base
+ buf
->curoff
, (VARIANT
*)arg
);
975 buf
->curoff
= buffer
- buf
->base
;
985 hres
= xbuf_get(buf
,(LPBYTE
)arg
,8);
986 if (hres
) ERR("Failed to read integer 8 byte\n");
988 if (debugout
) TRACE_(olerelay
)("%x%x",arg
[0],arg
[1]);
997 hres
= xbuf_get(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
998 if (hres
) ERR("Failed to read integer 4 byte\n");
1000 if (debugout
) TRACE_(olerelay
)("%x",*arg
);
1007 hres
= xbuf_get(buf
,(LPBYTE
)&x
,sizeof(DWORD
));
1008 if (hres
) ERR("Failed to read integer 4 byte\n");
1011 if (debugout
) TRACE_(olerelay
)("%04x",*arg
& 0xffff);
1017 hres
= xbuf_get(buf
,(LPBYTE
)&x
,sizeof(DWORD
));
1018 if (hres
) ERR("Failed to read integer 4 byte\n");
1021 if (debugout
) TRACE_(olerelay
)("%02x",*arg
& 0xff);
1026 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
1027 unsigned char *buffer
;
1028 buffer
= BSTR_UserUnmarshal(&flags
, buf
->base
+ buf
->curoff
, (BSTR
*)arg
);
1029 buf
->curoff
= buffer
- buf
->base
;
1030 if (debugout
) TRACE_(olerelay
)("%s",debugstr_w(*(BSTR
*)arg
));
1036 BOOL derefhere
= TRUE
;
1038 if (tdesc
->u
.lptdesc
->vt
== VT_USERDEFINED
) {
1042 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.lptdesc
->u
.hreftype
,&tinfo2
);
1044 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
1047 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
1048 switch (tattr
->typekind
) {
1050 if (tattr
->tdescAlias
.vt
== VT_USERDEFINED
)
1052 DWORD href
= tattr
->tdescAlias
.u
.hreftype
;
1053 ITypeInfo_ReleaseTypeAttr(tinfo
, tattr
);
1054 ITypeInfo_Release(tinfo2
);
1055 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,href
,&tinfo2
);
1057 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.lptdesc
->u
.hreftype
);
1060 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
1061 derefhere
= (tattr
->typekind
!= TKIND_DISPATCH
&& tattr
->typekind
!= TKIND_INTERFACE
);
1064 case TKIND_ENUM
: /* confirmed */
1065 case TKIND_RECORD
: /* FIXME: mostly untested */
1067 case TKIND_DISPATCH
: /* will be done in VT_USERDEFINED case */
1068 case TKIND_INTERFACE
: /* will be done in VT_USERDEFINED case */
1072 FIXME("unhandled switch cases tattr->typekind %d\n", tattr
->typekind
);
1076 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
1077 ITypeInfo_Release(tinfo2
);
1079 /* read it in all cases, we need to know if we have
1080 * NULL pointer or not.
1082 hres
= xbuf_get(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
1084 ERR("Failed to load pointer cookie.\n");
1087 if (cookie
!= 0x42424242) {
1088 /* we read a NULL ptr from the remote side */
1089 if (debugout
) TRACE_(olerelay
)("NULL");
1093 if (debugout
) TRACE_(olerelay
)("*");
1095 /* Allocate space for the referenced struct */
1097 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,_xsize(tdesc
->u
.lptdesc
, tinfo
));
1100 return deserialize_param(tinfo
, readit
, debugout
, alloc
, tdesc
->u
.lptdesc
, (LPDWORD
)*arg
, buf
);
1102 return deserialize_param(tinfo
, readit
, debugout
, alloc
, tdesc
->u
.lptdesc
, arg
, buf
);
1105 /* FIXME: UNKNOWN is unknown ..., but allocate 4 byte for it */
1107 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DWORD
));
1110 hres
= _unmarshal_interface(buf
,&IID_IUnknown
,(LPUNKNOWN
*)arg
);
1112 TRACE_(olerelay
)("unk(%p)",arg
);
1117 hres
= _unmarshal_interface(buf
,&IID_IDispatch
,(LPUNKNOWN
*)arg
);
1119 TRACE_(olerelay
)("idisp(%p)",arg
);
1122 if (debugout
) TRACE_(olerelay
)("<void>");
1124 case VT_USERDEFINED
: {
1128 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
1130 ERR("Could not get typeinfo of hreftype %x for VT_USERDEFINED.\n",tdesc
->u
.hreftype
);
1133 hres
= ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
1135 ERR("Could not get typeattr in VT_USERDEFINED.\n");
1137 switch (tattr
->typekind
) {
1138 case TKIND_DISPATCH
:
1139 case TKIND_INTERFACE
:
1141 hres
= _unmarshal_interface(buf
,&(tattr
->guid
),(LPUNKNOWN
*)arg
);
1143 case TKIND_RECORD
: {
1146 if (debugout
) TRACE_(olerelay
)("{");
1147 for (i
=0;i
<tattr
->cVars
;i
++) {
1150 hres
= ITypeInfo_GetVarDesc(tinfo2
, i
, &vdesc
);
1152 ERR("Could not get vardesc of %d\n",i
);
1153 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
1154 ITypeInfo_Release(tinfo2
);
1157 hres
= deserialize_param(
1162 &vdesc
->elemdescVar
.tdesc
,
1163 (DWORD
*)(((LPBYTE
)arg
)+vdesc
->u
.oInst
),
1166 ITypeInfo_ReleaseVarDesc(tinfo2
, vdesc
);
1167 if (debugout
&& (i
<tattr
->cVars
-1)) TRACE_(olerelay
)(",");
1169 if (debugout
) TRACE_(olerelay
)("}");
1173 hres
= deserialize_param(tinfo2
,readit
,debugout
,alloc
,&tattr
->tdescAlias
,arg
,buf
);
1177 hres
= xbuf_get(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
1178 if (hres
) ERR("Failed to read enum (4 byte)\n");
1180 if (debugout
) TRACE_(olerelay
)("%x",*arg
);
1183 ERR("Unhandled typekind %d\n",tattr
->typekind
);
1187 ITypeInfo_ReleaseTypeAttr(tinfo2
, tattr
);
1190 ERR("failed to stuballoc in TKIND_RECORD.\n");
1191 ITypeInfo_Release(tinfo2
);
1195 /* arg is pointing to the start of the array. */
1196 LPBYTE base
= (LPBYTE
) arg
;
1197 ARRAYDESC
*adesc
= tdesc
->u
.lpadesc
;
1200 if (adesc
->cDims
> 1) FIXME("cDims > 1 in VT_CARRAY. Does it work?\n");
1201 for (i
=0;i
<adesc
->cDims
;i
++)
1202 arrsize
*= adesc
->rgbounds
[i
].cElements
;
1203 if (_passbyref(&adesc
->tdescElem
, tinfo
))
1205 base
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,_xsize(tdesc
->u
.lptdesc
, tinfo
) * arrsize
);
1206 *arg
= (DWORD
) base
;
1208 for (i
=0;i
<arrsize
;i
++)
1215 (DWORD
*)(base
+ i
*_xsize(&adesc
->tdescElem
, tinfo
)),
1220 case VT_SAFEARRAY
: {
1223 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
1224 unsigned char *buffer
;
1225 buffer
= LPSAFEARRAY_UserUnmarshal(&flags
, buf
->base
+ buf
->curoff
, (LPSAFEARRAY
*)arg
);
1226 buf
->curoff
= buffer
- buf
->base
;
1231 ERR("No handler for VT type %d!\n",tdesc
->vt
);
1237 /* Retrieves a function's funcdesc, searching back into inherited interfaces. */
1238 static HRESULT
get_funcdesc(ITypeInfo
*tinfo
, int iMethod
, ITypeInfo
**tactual
, const FUNCDESC
**fdesc
,
1239 BSTR
*iname
, BSTR
*fname
, UINT
*num
)
1243 UINT inherited_funcs
= 0;
1246 if (fname
) *fname
= NULL
;
1247 if (iname
) *iname
= NULL
;
1251 hr
= ITypeInfo_GetTypeAttr(tinfo
, &attr
);
1254 ERR("GetTypeAttr failed with %x\n",hr
);
1258 if(attr
->typekind
== TKIND_DISPATCH
)
1260 if(attr
->wTypeFlags
& TYPEFLAG_FDUAL
)
1265 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, -1, &href
);
1268 ERR("Cannot get interface href from dual dispinterface\n");
1269 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1272 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &tinfo2
);
1275 ERR("Cannot get interface from dual dispinterface\n");
1276 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1279 hr
= get_funcdesc(tinfo2
, iMethod
, tactual
, fdesc
, iname
, fname
, num
);
1280 ITypeInfo_Release(tinfo2
);
1281 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1284 ERR("Shouldn't be called with a non-dual dispinterface\n");
1288 impl_types
= attr
->cImplTypes
;
1289 ITypeInfo_ReleaseTypeAttr(tinfo
, attr
);
1291 for (i
= 0; i
< impl_types
; i
++)
1294 ITypeInfo
*pSubTypeInfo
;
1297 hr
= ITypeInfo_GetRefTypeOfImplType(tinfo
, i
, &href
);
1298 if (FAILED(hr
)) return hr
;
1299 hr
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &pSubTypeInfo
);
1300 if (FAILED(hr
)) return hr
;
1302 hr
= get_funcdesc(pSubTypeInfo
, iMethod
, tactual
, fdesc
, iname
, fname
, &sub_funcs
);
1303 inherited_funcs
+= sub_funcs
;
1304 ITypeInfo_Release(pSubTypeInfo
);
1305 if(SUCCEEDED(hr
)) return hr
;
1307 if(iMethod
< inherited_funcs
)
1309 ERR("shouldn't be here\n");
1310 return E_INVALIDARG
;
1313 for(i
= inherited_funcs
; i
<= iMethod
; i
++)
1315 hr
= ITypeInfoImpl_GetInternalFuncDesc(tinfo
, i
- inherited_funcs
, fdesc
);
1323 /* found it. We don't care about num so zero it */
1326 ITypeInfo_AddRef(*tactual
);
1327 if (fname
) ITypeInfo_GetDocumentation(tinfo
,(*fdesc
)->memid
,fname
,NULL
,NULL
,NULL
);
1328 if (iname
) ITypeInfo_GetDocumentation(tinfo
,-1,iname
,NULL
,NULL
,NULL
);
1332 static inline BOOL
is_in_elem(const ELEMDESC
*elem
)
1334 return (elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
|| !elem
->u
.paramdesc
.wParamFlags
);
1337 static inline BOOL
is_out_elem(const ELEMDESC
*elem
)
1339 return (elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
|| !elem
->u
.paramdesc
.wParamFlags
);
1342 static DWORD WINAPI
xCall(int method
, void **args
)
1344 TMProxyImpl
*tpinfo
= args
[0];
1346 const FUNCDESC
*fdesc
;
1355 DWORD remoteresult
= 0;
1357 IRpcChannelBuffer
*chanbuf
;
1359 EnterCriticalSection(&tpinfo
->crit
);
1361 hres
= get_funcdesc(tpinfo
->tinfo
,method
,&tinfo
,&fdesc
,&iname
,&fname
,NULL
);
1363 ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method
);
1364 LeaveCriticalSection(&tpinfo
->crit
);
1368 if (!tpinfo
->chanbuf
)
1370 WARN("Tried to use disconnected proxy\n");
1371 ITypeInfo_Release(tinfo
);
1372 LeaveCriticalSection(&tpinfo
->crit
);
1373 return RPC_E_DISCONNECTED
;
1375 chanbuf
= tpinfo
->chanbuf
;
1376 IRpcChannelBuffer_AddRef(chanbuf
);
1378 LeaveCriticalSection(&tpinfo
->crit
);
1380 if (TRACE_ON(olerelay
)) {
1381 TRACE_(olerelay
)("->");
1383 TRACE_(olerelay
)("%s:",relaystr(iname
));
1385 TRACE_(olerelay
)("%s(%d)",relaystr(fname
),method
);
1387 TRACE_(olerelay
)("%d",method
);
1388 TRACE_(olerelay
)("(");
1391 SysFreeString(iname
);
1392 SysFreeString(fname
);
1394 memset(&buf
,0,sizeof(buf
));
1396 /* normal typelib driven serializing */
1398 /* Need them for hack below */
1399 memset(names
,0,sizeof(names
));
1400 if (ITypeInfo_GetNames(tinfo
,fdesc
->memid
,names
,sizeof(names
)/sizeof(names
[0]),&nrofnames
))
1402 if (nrofnames
> sizeof(names
)/sizeof(names
[0]))
1403 ERR("Need more names!\n");
1405 xargs
= (DWORD
*)(args
+ 1);
1406 for (i
=0;i
<fdesc
->cParams
;i
++) {
1407 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1408 if (TRACE_ON(olerelay
)) {
1409 if (i
) TRACE_(olerelay
)(",");
1410 if (i
+1<nrofnames
&& names
[i
+1])
1411 TRACE_(olerelay
)("%s=",relaystr(names
[i
+1]));
1413 /* No need to marshal other data than FIN and any VT_PTR. */
1414 if (!is_in_elem(elem
))
1416 if (elem
->tdesc
.vt
!= VT_PTR
)
1418 xargs
+=_argsize(&elem
->tdesc
, tinfo
);
1419 TRACE_(olerelay
)("[out]");
1424 memset( *(void **)xargs
, 0, _xsize( elem
->tdesc
.u
.lptdesc
, tinfo
) );
1428 hres
= serialize_param(
1439 ERR("Failed to serialize param, hres %x\n",hres
);
1442 xargs
+=_argsize(&elem
->tdesc
, tinfo
);
1444 TRACE_(olerelay
)(")");
1446 memset(&msg
,0,sizeof(msg
));
1447 msg
.cbBuffer
= buf
.curoff
;
1448 msg
.iMethod
= method
;
1449 hres
= IRpcChannelBuffer_GetBuffer(chanbuf
,&msg
,&(tpinfo
->iid
));
1451 ERR("RpcChannelBuffer GetBuffer failed, %x\n",hres
);
1454 memcpy(msg
.Buffer
,buf
.base
,buf
.curoff
);
1455 TRACE_(olerelay
)("\n");
1456 hres
= IRpcChannelBuffer_SendReceive(chanbuf
,&msg
,&status
);
1458 ERR("RpcChannelBuffer SendReceive failed, %x\n",hres
);
1462 TRACE_(olerelay
)(" status = %08x (",status
);
1464 buf
.base
= HeapReAlloc(GetProcessHeap(),0,buf
.base
,msg
.cbBuffer
);
1466 buf
.base
= HeapAlloc(GetProcessHeap(),0,msg
.cbBuffer
);
1467 buf
.size
= msg
.cbBuffer
;
1468 memcpy(buf
.base
,msg
.Buffer
,buf
.size
);
1471 /* generic deserializer using typelib description */
1472 xargs
= (DWORD
*)(args
+ 1);
1474 for (i
=0;i
<fdesc
->cParams
;i
++) {
1475 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1477 if (i
) TRACE_(olerelay
)(",");
1478 if (i
+1<nrofnames
&& names
[i
+1]) TRACE_(olerelay
)("%s=",relaystr(names
[i
+1]));
1480 /* No need to marshal other data than FOUT and any VT_PTR */
1481 if (!is_out_elem(elem
) && (elem
->tdesc
.vt
!= VT_PTR
)) {
1482 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
1483 TRACE_(olerelay
)("[in]");
1486 hres
= deserialize_param(
1496 ERR("Failed to unmarshall param, hres %x\n",hres
);
1500 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
1503 hres
= xbuf_get(&buf
, (LPBYTE
)&remoteresult
, sizeof(DWORD
));
1506 TRACE_(olerelay
)(") = %08x\n", remoteresult
);
1508 hres
= remoteresult
;
1511 IRpcChannelBuffer_FreeBuffer(chanbuf
,&msg
);
1512 for (i
= 0; i
< nrofnames
; i
++)
1513 SysFreeString(names
[i
]);
1514 HeapFree(GetProcessHeap(),0,buf
.base
);
1515 IRpcChannelBuffer_Release(chanbuf
);
1516 ITypeInfo_Release(tinfo
);
1517 TRACE("-- 0x%08x\n", hres
);
1521 static HRESULT WINAPI
ProxyIUnknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
1523 TMProxyImpl
*proxy
= (TMProxyImpl
*)iface
;
1525 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
1527 if (proxy
->outerunknown
)
1528 return IUnknown_QueryInterface(proxy
->outerunknown
, riid
, ppv
);
1530 FIXME("No interface\n");
1531 return E_NOINTERFACE
;
1534 static ULONG WINAPI
ProxyIUnknown_AddRef(IUnknown
*iface
)
1536 TMProxyImpl
*proxy
= (TMProxyImpl
*)iface
;
1540 if (proxy
->outerunknown
)
1541 return IUnknown_AddRef(proxy
->outerunknown
);
1543 return 2; /* FIXME */
1546 static ULONG WINAPI
ProxyIUnknown_Release(IUnknown
*iface
)
1548 TMProxyImpl
*proxy
= (TMProxyImpl
*)iface
;
1552 if (proxy
->outerunknown
)
1553 return IUnknown_Release(proxy
->outerunknown
);
1555 return 1; /* FIXME */
1558 static HRESULT WINAPI
ProxyIDispatch_GetTypeInfoCount(LPDISPATCH iface
, UINT
* pctinfo
)
1560 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1562 TRACE("(%p)\n", pctinfo
);
1564 return IDispatch_GetTypeInfoCount(This
->dispatch
, pctinfo
);
1567 static HRESULT WINAPI
ProxyIDispatch_GetTypeInfo(LPDISPATCH iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1569 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1571 TRACE("(%d, %x, %p)\n", iTInfo
, lcid
, ppTInfo
);
1573 return IDispatch_GetTypeInfo(This
->dispatch
, iTInfo
, lcid
, ppTInfo
);
1576 static HRESULT WINAPI
ProxyIDispatch_GetIDsOfNames(LPDISPATCH iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1578 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1580 TRACE("(%s, %p, %d, 0x%x, %p)\n", debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
1582 return IDispatch_GetIDsOfNames(This
->dispatch
, riid
, rgszNames
,
1583 cNames
, lcid
, rgDispId
);
1586 static HRESULT WINAPI
ProxyIDispatch_Invoke(LPDISPATCH iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1587 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
1588 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1590 TMProxyImpl
*This
= (TMProxyImpl
*)iface
;
1592 TRACE("(%d, %s, 0x%x, 0x%x, %p, %p, %p, %p)\n", dispIdMember
,
1593 debugstr_guid(riid
), lcid
, wFlags
, pDispParams
, pVarResult
,
1594 pExcepInfo
, puArgErr
);
1596 return IDispatch_Invoke(This
->dispatch
, dispIdMember
, riid
, lcid
,
1597 wFlags
, pDispParams
, pVarResult
, pExcepInfo
,
1603 IRpcChannelBuffer IRpcChannelBuffer_iface
;
1605 /* the IDispatch-derived interface we are handling */
1607 IRpcChannelBuffer
*pDelegateChannel
;
1608 } TMarshalDispatchChannel
;
1610 static inline TMarshalDispatchChannel
*impl_from_IRpcChannelBuffer(IRpcChannelBuffer
*iface
)
1612 return CONTAINING_RECORD(iface
, TMarshalDispatchChannel
, IRpcChannelBuffer_iface
);
1615 static HRESULT WINAPI
TMarshalDispatchChannel_QueryInterface(IRpcChannelBuffer
*iface
, REFIID riid
, LPVOID
*ppv
)
1618 if (IsEqualIID(riid
,&IID_IRpcChannelBuffer
) || IsEqualIID(riid
,&IID_IUnknown
))
1621 IRpcChannelBuffer_AddRef(iface
);
1624 return E_NOINTERFACE
;
1627 static ULONG WINAPI
TMarshalDispatchChannel_AddRef(LPRPCCHANNELBUFFER iface
)
1629 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1630 return InterlockedIncrement(&This
->refs
);
1633 static ULONG WINAPI
TMarshalDispatchChannel_Release(LPRPCCHANNELBUFFER iface
)
1635 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1638 ref
= InterlockedDecrement(&This
->refs
);
1642 IRpcChannelBuffer_Release(This
->pDelegateChannel
);
1643 HeapFree(GetProcessHeap(), 0, This
);
1647 static HRESULT WINAPI
TMarshalDispatchChannel_GetBuffer(LPRPCCHANNELBUFFER iface
, RPCOLEMESSAGE
* olemsg
, REFIID riid
)
1649 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1650 TRACE("(%p, %s)\n", olemsg
, debugstr_guid(riid
));
1651 /* Note: we are pretending to invoke a method on the interface identified
1652 * by tmarshal_iid so that we can re-use the IDispatch proxy/stub code
1653 * without the RPC runtime getting confused by not exporting an IDispatch interface */
1654 return IRpcChannelBuffer_GetBuffer(This
->pDelegateChannel
, olemsg
, &This
->tmarshal_iid
);
1657 static HRESULT WINAPI
TMarshalDispatchChannel_SendReceive(LPRPCCHANNELBUFFER iface
, RPCOLEMESSAGE
*olemsg
, ULONG
*pstatus
)
1659 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1660 TRACE("(%p, %p)\n", olemsg
, pstatus
);
1661 return IRpcChannelBuffer_SendReceive(This
->pDelegateChannel
, olemsg
, pstatus
);
1664 static HRESULT WINAPI
TMarshalDispatchChannel_FreeBuffer(LPRPCCHANNELBUFFER iface
, RPCOLEMESSAGE
* olemsg
)
1666 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1667 TRACE("(%p)\n", olemsg
);
1668 return IRpcChannelBuffer_FreeBuffer(This
->pDelegateChannel
, olemsg
);
1671 static HRESULT WINAPI
TMarshalDispatchChannel_GetDestCtx(LPRPCCHANNELBUFFER iface
, DWORD
* pdwDestContext
, void** ppvDestContext
)
1673 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1674 TRACE("(%p,%p)\n", pdwDestContext
, ppvDestContext
);
1675 return IRpcChannelBuffer_GetDestCtx(This
->pDelegateChannel
, pdwDestContext
, ppvDestContext
);
1678 static HRESULT WINAPI
TMarshalDispatchChannel_IsConnected(LPRPCCHANNELBUFFER iface
)
1680 TMarshalDispatchChannel
*This
= impl_from_IRpcChannelBuffer(iface
);
1682 return IRpcChannelBuffer_IsConnected(This
->pDelegateChannel
);
1685 static const IRpcChannelBufferVtbl TMarshalDispatchChannelVtbl
=
1687 TMarshalDispatchChannel_QueryInterface
,
1688 TMarshalDispatchChannel_AddRef
,
1689 TMarshalDispatchChannel_Release
,
1690 TMarshalDispatchChannel_GetBuffer
,
1691 TMarshalDispatchChannel_SendReceive
,
1692 TMarshalDispatchChannel_FreeBuffer
,
1693 TMarshalDispatchChannel_GetDestCtx
,
1694 TMarshalDispatchChannel_IsConnected
1697 static HRESULT
TMarshalDispatchChannel_Create(
1698 IRpcChannelBuffer
*pDelegateChannel
, REFIID tmarshal_riid
,
1699 IRpcChannelBuffer
**ppChannel
)
1701 TMarshalDispatchChannel
*This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1703 return E_OUTOFMEMORY
;
1705 This
->IRpcChannelBuffer_iface
.lpVtbl
= &TMarshalDispatchChannelVtbl
;
1707 IRpcChannelBuffer_AddRef(pDelegateChannel
);
1708 This
->pDelegateChannel
= pDelegateChannel
;
1709 This
->tmarshal_iid
= *tmarshal_riid
;
1711 *ppChannel
= &This
->IRpcChannelBuffer_iface
;
1716 static inline HRESULT
get_facbuf_for_iid(REFIID riid
, IPSFactoryBuffer
**facbuf
)
1721 if ((hr
= CoGetPSClsid(riid
, &clsid
)))
1723 return CoGetClassObject(&clsid
, CLSCTX_INPROC_SERVER
, NULL
,
1724 &IID_IPSFactoryBuffer
, (LPVOID
*)facbuf
);
1727 static HRESULT
init_proxy_entry_point(TMProxyImpl
*proxy
, unsigned int num
)
1730 /* nrofargs including This */
1733 TMAsmProxy
*xasm
= proxy
->asmstubs
+ num
;
1735 const FUNCDESC
*fdesc
;
1737 hres
= get_funcdesc(proxy
->tinfo
, num
, &tinfo2
, &fdesc
, NULL
, NULL
, NULL
);
1739 ERR("GetFuncDesc %x should not fail here.\n",hres
);
1742 ITypeInfo_Release(tinfo2
);
1743 /* some args take more than 4 byte on the stack */
1744 for (j
=0;j
<fdesc
->cParams
;j
++)
1745 nrofargs
+= _argsize(&fdesc
->lprgelemdescParam
[j
].tdesc
, proxy
->tinfo
);
1748 if (fdesc
->callconv
!= CC_STDCALL
) {
1749 ERR("calling convention is not stdcall????\n");
1752 /* leal 4(%esp),%eax
1758 xasm
->lealeax
= 0x0424448d;
1759 xasm
->pushleax
= 0x50;
1760 xasm
->pushlval
= 0x68;
1763 xasm
->xcall
= (char *)xCall
- (char *)&xasm
->lret
;
1765 xasm
->bytestopop
= nrofargs
* 4;
1767 proxy
->lpvtbl
[fdesc
->oVft
/ sizeof(void *)] = xasm
;
1769 FIXME("not implemented on non i386\n");
1775 static HRESULT WINAPI
1776 PSFacBuf_CreateProxy(
1777 LPPSFACTORYBUFFER iface
, IUnknown
* pUnkOuter
, REFIID riid
,
1778 IRpcProxyBuffer
**ppProxy
, LPVOID
*ppv
)
1782 unsigned int i
, nroffuncs
, vtbl_size
;
1785 BOOL defer_to_dispatch
= FALSE
;
1787 TRACE("(...%s...)\n",debugstr_guid(riid
));
1788 hres
= _get_typeinfo_for_iid(riid
,&tinfo
);
1790 ERR("No typeinfo for %s?\n",debugstr_guid(riid
));
1794 hres
= num_of_funcs(tinfo
, &nroffuncs
, &vtbl_size
);
1795 TRACE("Got %d funcs, vtbl size %d\n", nroffuncs
, vtbl_size
);
1798 ERR("Cannot get number of functions for typeinfo %s\n",debugstr_guid(riid
));
1799 ITypeInfo_Release(tinfo
);
1803 proxy
= CoTaskMemAlloc(sizeof(TMProxyImpl
));
1804 if (!proxy
) return E_OUTOFMEMORY
;
1806 proxy
->dispatch
= NULL
;
1807 proxy
->dispatch_proxy
= NULL
;
1808 proxy
->outerunknown
= pUnkOuter
;
1809 proxy
->asmstubs
= VirtualAlloc(NULL
, sizeof(TMAsmProxy
) * nroffuncs
, MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
1810 if (!proxy
->asmstubs
) {
1811 ERR("Could not commit pages for proxy thunks\n");
1812 CoTaskMemFree(proxy
);
1813 return E_OUTOFMEMORY
;
1815 proxy
->IRpcProxyBuffer_iface
.lpVtbl
= &tmproxyvtable
;
1816 /* one reference for the proxy */
1818 proxy
->tinfo
= tinfo
;
1822 InitializeCriticalSection(&proxy
->crit
);
1823 proxy
->crit
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": TMProxyImpl.crit");
1825 proxy
->lpvtbl
= HeapAlloc(GetProcessHeap(), 0, vtbl_size
);
1827 /* if we derive from IDispatch then defer to its proxy for its methods */
1828 hres
= ITypeInfo_GetTypeAttr(tinfo
, &typeattr
);
1831 if (typeattr
->wTypeFlags
& TYPEFLAG_FDISPATCHABLE
)
1833 IPSFactoryBuffer
*factory_buffer
;
1834 hres
= get_facbuf_for_iid(&IID_IDispatch
, &factory_buffer
);
1837 hres
= IPSFactoryBuffer_CreateProxy(factory_buffer
, NULL
,
1838 &IID_IDispatch
, &proxy
->dispatch_proxy
,
1839 (void **)&proxy
->dispatch
);
1840 IPSFactoryBuffer_Release(factory_buffer
);
1842 if ((hres
== S_OK
) && (nroffuncs
< 7))
1844 ERR("nroffuncs calculated incorrectly (%d)\n", nroffuncs
);
1845 hres
= E_UNEXPECTED
;
1849 defer_to_dispatch
= TRUE
;
1852 ITypeInfo_ReleaseTypeAttr(tinfo
, typeattr
);
1855 for (i
=0;i
<nroffuncs
;i
++) {
1858 proxy
->lpvtbl
[i
] = ProxyIUnknown_QueryInterface
;
1861 proxy
->lpvtbl
[i
] = ProxyIUnknown_AddRef
;
1864 proxy
->lpvtbl
[i
] = ProxyIUnknown_Release
;
1867 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1868 else proxy
->lpvtbl
[3] = ProxyIDispatch_GetTypeInfoCount
;
1871 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1872 else proxy
->lpvtbl
[4] = ProxyIDispatch_GetTypeInfo
;
1875 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1876 else proxy
->lpvtbl
[5] = ProxyIDispatch_GetIDsOfNames
;
1879 if(!defer_to_dispatch
) hres
= init_proxy_entry_point(proxy
, i
);
1880 else proxy
->lpvtbl
[6] = ProxyIDispatch_Invoke
;
1883 hres
= init_proxy_entry_point(proxy
, i
);
1890 *ppProxy
= &proxy
->IRpcProxyBuffer_iface
;
1891 IUnknown_AddRef((IUnknown
*)*ppv
);
1895 TMProxyImpl_Release(&proxy
->IRpcProxyBuffer_iface
);
1899 typedef struct _TMStubImpl
{
1900 IRpcStubBuffer IRpcStubBuffer_iface
;
1906 IRpcStubBuffer
*dispatch_stub
;
1907 BOOL dispatch_derivative
;
1910 static inline TMStubImpl
*impl_from_IRpcStubBuffer(IRpcStubBuffer
*iface
)
1912 return CONTAINING_RECORD(iface
, TMStubImpl
, IRpcStubBuffer_iface
);
1915 static HRESULT WINAPI
1916 TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface
, REFIID riid
, LPVOID
*ppv
)
1918 if (IsEqualIID(riid
,&IID_IRpcStubBuffer
)||IsEqualIID(riid
,&IID_IUnknown
)){
1920 IRpcStubBuffer_AddRef(iface
);
1923 FIXME("%s, not supported IID.\n",debugstr_guid(riid
));
1924 return E_NOINTERFACE
;
1928 TMStubImpl_AddRef(LPRPCSTUBBUFFER iface
)
1930 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1931 ULONG refCount
= InterlockedIncrement(&This
->ref
);
1933 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
1939 TMStubImpl_Release(LPRPCSTUBBUFFER iface
)
1941 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1942 ULONG refCount
= InterlockedDecrement(&This
->ref
);
1944 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
1948 IRpcStubBuffer_Disconnect(iface
);
1949 ITypeInfo_Release(This
->tinfo
);
1950 if (This
->dispatch_stub
)
1951 IRpcStubBuffer_Release(This
->dispatch_stub
);
1952 CoTaskMemFree(This
);
1957 static HRESULT WINAPI
1958 TMStubImpl_Connect(LPRPCSTUBBUFFER iface
, LPUNKNOWN pUnkServer
)
1960 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1962 TRACE("(%p)->(%p)\n", This
, pUnkServer
);
1964 IUnknown_AddRef(pUnkServer
);
1965 This
->pUnk
= pUnkServer
;
1967 if (This
->dispatch_stub
)
1968 IRpcStubBuffer_Connect(This
->dispatch_stub
, pUnkServer
);
1974 TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface
)
1976 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1978 TRACE("(%p)->()\n", This
);
1982 IUnknown_Release(This
->pUnk
);
1986 if (This
->dispatch_stub
)
1987 IRpcStubBuffer_Disconnect(This
->dispatch_stub
);
1990 static HRESULT WINAPI
1992 LPRPCSTUBBUFFER iface
, RPCOLEMESSAGE
* xmsg
,IRpcChannelBuffer
*rpcchanbuf
)
1996 const FUNCDESC
*fdesc
;
1997 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
1999 DWORD
*args
= NULL
, res
, *xargs
, nrofargs
;
2004 ITypeInfo
*tinfo
= NULL
;
2008 if (xmsg
->iMethod
< 3) {
2009 ERR("IUnknown methods cannot be marshaled by the typelib marshaler\n");
2010 return E_UNEXPECTED
;
2013 if (This
->dispatch_derivative
&& xmsg
->iMethod
< sizeof(IDispatchVtbl
)/sizeof(void *))
2015 if (!This
->dispatch_stub
)
2017 IPSFactoryBuffer
*factory_buffer
;
2018 hres
= get_facbuf_for_iid(&IID_IDispatch
, &factory_buffer
);
2021 hres
= IPSFactoryBuffer_CreateStub(factory_buffer
, &IID_IDispatch
,
2022 This
->pUnk
, &This
->dispatch_stub
);
2023 IPSFactoryBuffer_Release(factory_buffer
);
2028 return IRpcStubBuffer_Invoke(This
->dispatch_stub
, xmsg
, rpcchanbuf
);
2031 memset(&buf
,0,sizeof(buf
));
2032 buf
.size
= xmsg
->cbBuffer
;
2033 buf
.base
= HeapAlloc(GetProcessHeap(), 0, xmsg
->cbBuffer
);
2034 memcpy(buf
.base
, xmsg
->Buffer
, xmsg
->cbBuffer
);
2037 hres
= get_funcdesc(This
->tinfo
,xmsg
->iMethod
,&tinfo
,&fdesc
,&iname
,NULL
,NULL
);
2039 ERR("GetFuncDesc on method %d failed with %x\n",xmsg
->iMethod
,hres
);
2043 if (iname
&& !lstrcmpW(iname
, IDispatchW
))
2045 ERR("IDispatch cannot be marshaled by the typelib marshaler\n");
2046 hres
= E_UNEXPECTED
;
2047 SysFreeString (iname
);
2051 SysFreeString (iname
);
2053 /* Need them for hack below */
2054 memset(names
,0,sizeof(names
));
2055 ITypeInfo_GetNames(tinfo
,fdesc
->memid
,names
,sizeof(names
)/sizeof(names
[0]),&nrofnames
);
2056 if (nrofnames
> sizeof(names
)/sizeof(names
[0])) {
2057 ERR("Need more names!\n");
2060 /*dump_FUNCDESC(fdesc);*/
2062 for (i
=0;i
<fdesc
->cParams
;i
++)
2063 nrofargs
+= _argsize(&fdesc
->lprgelemdescParam
[i
].tdesc
, tinfo
);
2064 args
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,(nrofargs
+1)*sizeof(DWORD
));
2067 hres
= E_OUTOFMEMORY
;
2071 /* Allocate all stuff used by call. */
2073 for (i
=0;i
<fdesc
->cParams
;i
++) {
2074 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
2076 hres
= deserialize_param(
2085 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
2087 ERR("Failed to deserialize param %s, hres %x\n",relaystr(names
[i
+1]),hres
);
2092 args
[0] = (DWORD
)This
->pUnk
;
2097 (*((FARPROC
**)args
[0]))[fdesc
->oVft
/4],
2105 DWORD dwExceptionCode
= GetExceptionCode();
2106 ERR("invoke call failed with exception 0x%08x (%d)\n", dwExceptionCode
, dwExceptionCode
);
2107 if (FAILED(dwExceptionCode
))
2108 hres
= dwExceptionCode
;
2110 hres
= HRESULT_FROM_WIN32(dwExceptionCode
);
2120 for (i
=0;i
<fdesc
->cParams
;i
++) {
2121 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
2122 hres
= serialize_param(
2131 xargs
+= _argsize(&elem
->tdesc
, tinfo
);
2133 ERR("Failed to stuballoc param, hres %x\n",hres
);
2138 hres
= xbuf_add (&buf
, (LPBYTE
)&res
, sizeof(DWORD
));
2143 xmsg
->cbBuffer
= buf
.curoff
;
2144 hres
= IRpcChannelBuffer_GetBuffer(rpcchanbuf
, xmsg
, &This
->iid
);
2146 ERR("IRpcChannelBuffer_GetBuffer failed with error 0x%08x\n", hres
);
2149 memcpy(xmsg
->Buffer
, buf
.base
, buf
.curoff
);
2152 for (i
= 0; i
< nrofnames
; i
++)
2153 SysFreeString(names
[i
]);
2155 ITypeInfo_Release(tinfo
);
2156 HeapFree(GetProcessHeap(), 0, args
);
2158 HeapFree(GetProcessHeap(), 0, buf
.base
);
2160 TRACE("returning\n");
2163 FIXME( "not implemented on non-i386\n" );
2168 static LPRPCSTUBBUFFER WINAPI
2169 TMStubImpl_IsIIDSupported(LPRPCSTUBBUFFER iface
, REFIID riid
) {
2170 FIXME("Huh (%s)?\n",debugstr_guid(riid
));
2175 TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface
) {
2176 TMStubImpl
*This
= impl_from_IRpcStubBuffer(iface
);
2179 return This
->ref
; /*FIXME? */
2182 static HRESULT WINAPI
2183 TMStubImpl_DebugServerQueryInterface(LPRPCSTUBBUFFER iface
, LPVOID
*ppv
) {
2188 TMStubImpl_DebugServerRelease(LPRPCSTUBBUFFER iface
, LPVOID ppv
) {
2192 static const IRpcStubBufferVtbl tmstubvtbl
= {
2193 TMStubImpl_QueryInterface
,
2197 TMStubImpl_Disconnect
,
2199 TMStubImpl_IsIIDSupported
,
2200 TMStubImpl_CountRefs
,
2201 TMStubImpl_DebugServerQueryInterface
,
2202 TMStubImpl_DebugServerRelease
2205 static HRESULT WINAPI
2206 PSFacBuf_CreateStub(
2207 LPPSFACTORYBUFFER iface
, REFIID riid
,IUnknown
*pUnkServer
,
2208 IRpcStubBuffer
** ppStub
2215 TRACE("(%s,%p,%p)\n",debugstr_guid(riid
),pUnkServer
,ppStub
);
2217 hres
= _get_typeinfo_for_iid(riid
,&tinfo
);
2219 ERR("No typeinfo for %s?\n",debugstr_guid(riid
));
2223 stub
= CoTaskMemAlloc(sizeof(TMStubImpl
));
2225 return E_OUTOFMEMORY
;
2226 stub
->IRpcStubBuffer_iface
.lpVtbl
= &tmstubvtbl
;
2228 stub
->tinfo
= tinfo
;
2229 stub
->dispatch_stub
= NULL
;
2230 stub
->dispatch_derivative
= FALSE
;
2232 hres
= IRpcStubBuffer_Connect(&stub
->IRpcStubBuffer_iface
,pUnkServer
);
2233 *ppStub
= &stub
->IRpcStubBuffer_iface
;
2234 TRACE("IRpcStubBuffer: %p\n", stub
);
2236 ERR("Connect to pUnkServer failed?\n");
2238 /* if we derive from IDispatch then defer to its stub for some of its methods */
2239 hres
= ITypeInfo_GetTypeAttr(tinfo
, &typeattr
);
2242 if (typeattr
->wTypeFlags
& TYPEFLAG_FDISPATCHABLE
)
2243 stub
->dispatch_derivative
= TRUE
;
2244 ITypeInfo_ReleaseTypeAttr(tinfo
, typeattr
);
2250 static const IPSFactoryBufferVtbl psfacbufvtbl
= {
2251 PSFacBuf_QueryInterface
,
2254 PSFacBuf_CreateProxy
,
2258 /* This is the whole PSFactoryBuffer object, just the vtableptr */
2259 static const IPSFactoryBufferVtbl
*lppsfac
= &psfacbufvtbl
;
2261 /***********************************************************************
2262 * TMARSHAL_DllGetClassObject
2264 HRESULT
TMARSHAL_DllGetClassObject(REFCLSID rclsid
, REFIID iid
,LPVOID
*ppv
)
2266 if (IsEqualIID(iid
,&IID_IPSFactoryBuffer
)) {
2270 return E_NOINTERFACE
;