4 * Copyright 2002 Marcus Meissner
6 * The olerelay debug channel allows you to see calls marshalled by
7 * the typelib marshaller. It is not a generic COM relaying system.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define NONAMELESSUNION
35 #define NONAMELESSSTRUCT
46 #include "wine/debug.h"
48 static const WCHAR riidW
[5] = {'r','i','i','d',0};
49 static const WCHAR pdispparamsW
[] = {'p','d','i','s','p','p','a','r','a','m','s',0};
50 static const WCHAR ppvObjectW
[] = {'p','p','v','O','b','j','e','c','t',0};
52 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
53 WINE_DECLARE_DEBUG_CHANNEL(olerelay
);
55 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
57 typedef struct _marshal_state
{
63 IID iid
; /* HACK: for VT_VOID */
66 /* used in the olerelay code to avoid having the L"" stuff added by debugstr_w */
67 static char *relaystr(WCHAR
*in
) {
68 char *tmp
= (char *)debugstr_w(in
);
70 tmp
[strlen(tmp
)-1] = '\0';
75 xbuf_add(marshal_state
*buf
, LPBYTE stuff
, DWORD size
) {
76 while (buf
->size
- buf
->curoff
< size
) {
79 buf
->base
= HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,buf
->base
,buf
->size
);
83 buf
->base
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,32);
89 memcpy(buf
->base
+buf
->curoff
,stuff
,size
);
95 xbuf_get(marshal_state
*buf
, LPBYTE stuff
, DWORD size
) {
96 if (buf
->size
< buf
->curoff
+size
) return E_FAIL
;
97 memcpy(stuff
,buf
->base
+buf
->curoff
,size
);
103 xbuf_skip(marshal_state
*buf
, DWORD size
) {
104 if (buf
->size
< buf
->curoff
+size
) return E_FAIL
;
110 _unmarshal_interface(marshal_state
*buf
, REFIID riid
, LPUNKNOWN
*pUnk
) {
112 ULARGE_INTEGER newpos
;
113 LARGE_INTEGER seekto
;
118 TRACE("...%s...\n",debugstr_guid(riid
));
121 hres
= xbuf_get(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
123 ERR("xbuf_get failed\n");
127 if (xsize
== 0) return S_OK
;
129 hres
= CreateStreamOnHGlobal(0,TRUE
,&pStm
);
131 ERR("Stream create failed %lx\n",hres
);
135 hres
= IStream_Write(pStm
,buf
->base
+buf
->curoff
,xsize
,&res
);
137 ERR("stream write %lx\n",hres
);
141 memset(&seekto
,0,sizeof(seekto
));
142 hres
= IStream_Seek(pStm
,seekto
,SEEK_SET
,&newpos
);
144 ERR("Failed Seek %lx\n",hres
);
148 hres
= CoUnmarshalInterface(pStm
,riid
,(LPVOID
*)pUnk
);
150 ERR("Unmarshalling interface %s failed with %lx\n",debugstr_guid(riid
),hres
);
154 IStream_Release(pStm
);
155 return xbuf_skip(buf
,xsize
);
159 _marshal_interface(marshal_state
*buf
, REFIID riid
, LPUNKNOWN pUnk
) {
160 LPUNKNOWN newiface
= NULL
;
161 LPBYTE tempbuf
= NULL
;
162 IStream
*pStm
= NULL
;
164 ULARGE_INTEGER newpos
;
165 LARGE_INTEGER seekto
;
172 ERR("pUnk is NULL?\n");
176 TRACE("...%s...\n",debugstr_guid(riid
));
177 hres
= IUnknown_QueryInterface(pUnk
,riid
,(LPVOID
*)&newiface
);
179 WARN("%p does not support iface %s\n",pUnk
,debugstr_guid(riid
));
183 hres
= CreateStreamOnHGlobal(0,TRUE
,&pStm
);
185 ERR("Stream create failed %lx\n",hres
);
189 hres
= CoMarshalInterface(pStm
,riid
,newiface
,0,NULL
,0);
191 ERR("Marshalling interface %s failed with %lx\n", debugstr_guid(riid
), hres
);
195 hres
= IStream_Stat(pStm
,&ststg
,0);
197 ERR("Stream stat failed\n");
201 tempbuf
= HeapAlloc(GetProcessHeap(), 0, ststg
.cbSize
.u
.LowPart
);
202 memset(&seekto
,0,sizeof(seekto
));
203 hres
= IStream_Seek(pStm
,seekto
,SEEK_SET
,&newpos
);
205 ERR("Failed Seek %lx\n",hres
);
209 hres
= IStream_Read(pStm
,tempbuf
,ststg
.cbSize
.u
.LowPart
,&res
);
211 ERR("Failed Read %lx\n",hres
);
215 xsize
= ststg
.cbSize
.u
.LowPart
;
216 xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
217 hres
= xbuf_add(buf
,tempbuf
,ststg
.cbSize
.u
.LowPart
);
219 HeapFree(GetProcessHeap(),0,tempbuf
);
220 IUnknown_Release(newiface
);
221 IStream_Release(pStm
);
227 xbuf_add(buf
,(LPBYTE
)&xsize
,sizeof(xsize
));
228 if (pStm
) IUnknown_Release(pStm
);
229 if (newiface
) IUnknown_Release(newiface
);
230 HeapFree(GetProcessHeap(), 0, tempbuf
);
234 /********************* OLE Proxy/Stub Factory ********************************/
235 static HRESULT WINAPI
236 PSFacBuf_QueryInterface(LPPSFACTORYBUFFER iface
, REFIID iid
, LPVOID
*ppv
) {
237 if (IsEqualIID(iid
,&IID_IPSFactoryBuffer
)||IsEqualIID(iid
,&IID_IUnknown
)) {
238 *ppv
= (LPVOID
)iface
;
239 /* No ref counting, static class */
242 FIXME("(%s) unknown IID?\n",debugstr_guid(iid
));
243 return E_NOINTERFACE
;
246 static ULONG WINAPI
PSFacBuf_AddRef(LPPSFACTORYBUFFER iface
) { return 2; }
247 static ULONG WINAPI
PSFacBuf_Release(LPPSFACTORYBUFFER iface
) { return 1; }
250 _get_typeinfo_for_iid(REFIID riid
, ITypeInfo
**ti
) {
253 char tlguid
[200],typelibkey
[300],interfacekey
[300],ver
[100];
256 DWORD tlguidlen
, verlen
, type
, tlfnlen
;
259 sprintf( interfacekey
, "Interface\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
260 riid
->Data1
, riid
->Data2
, riid
->Data3
,
261 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
262 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]
265 if (RegOpenKeyA(HKEY_CLASSES_ROOT
,interfacekey
,&ikey
)) {
266 ERR("No %s key found.\n",interfacekey
);
270 tlguidlen
= sizeof(tlguid
);
271 if (RegQueryValueExA(ikey
,NULL
,NULL
,&type
,tlguid
,&tlguidlen
)) {
272 ERR("Getting typelib guid failed.\n");
277 verlen
= sizeof(ver
);
278 if (RegQueryValueExA(ikey
,"Version",NULL
,&type
,ver
,&verlen
)) {
279 ERR("Could not get version value?\n");
284 sprintf(typelibkey
,"Typelib\\%s\\%s\\0\\win32",tlguid
,ver
);
285 tlfnlen
= sizeof(tlfn
);
286 if (RegQueryValueA(HKEY_CLASSES_ROOT
,typelibkey
,tlfn
,&tlfnlen
)) {
287 ERR("Could not get typelib fn?\n");
290 MultiByteToWideChar(CP_ACP
, 0, tlfn
, -1, tlfnW
, -1);
291 hres
= LoadTypeLib(tlfnW
,&tl
);
293 ERR("Failed to load typelib for %s, but it should be there.\n",debugstr_guid(riid
));
296 hres
= ITypeLib_GetTypeInfoOfGuid(tl
,riid
,ti
);
298 ERR("typelib does not contain info for %s?\n",debugstr_guid(riid
));
299 ITypeLib_Release(tl
);
302 /* FIXME: do this? ITypeLib_Release(tl); */
306 /* Determine nr of functions. Since we use the toplevel interface and all
307 * inherited ones have lower numbers, we are ok to not to descent into
308 * the inheritance tree I think.
310 static int _nroffuncs(ITypeInfo
*tinfo
) {
317 hres
= ITypeInfo_GetFuncDesc(tinfo
,n
,&fdesc
);
320 if (fdesc
->oVft
/4 > max
)
329 #include "pshpack1.h"
331 typedef struct _TMAsmProxy
{
345 # error You need to implement stubless proxies for your architecture
348 typedef struct _TMProxyImpl
{
350 IRpcProxyBufferVtbl
*lpvtbl2
;
353 TMAsmProxy
*asmstubs
;
355 IRpcChannelBuffer
* chanbuf
;
357 CRITICAL_SECTION crit
;
360 static HRESULT WINAPI
361 TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface
, REFIID riid
, LPVOID
*ppv
)
364 if (IsEqualIID(riid
,&IID_IUnknown
)||IsEqualIID(riid
,&IID_IRpcProxyBuffer
)) {
365 *ppv
= (LPVOID
)iface
;
366 IRpcProxyBuffer_AddRef(iface
);
369 FIXME("no interface for %s\n",debugstr_guid(riid
));
370 return E_NOINTERFACE
;
374 TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface
)
376 ICOM_THIS_MULTI(TMProxyImpl
,lpvtbl2
,iface
);
377 ULONG refCount
= InterlockedIncrement(&This
->ref
);
379 TRACE("(%p)->(ref before=%lu)\n",This
, refCount
- 1);
385 TMProxyImpl_Release(LPRPCPROXYBUFFER iface
)
387 ICOM_THIS_MULTI(TMProxyImpl
,lpvtbl2
,iface
);
388 ULONG refCount
= InterlockedDecrement(&This
->ref
);
390 TRACE("(%p)->(ref before=%lu)\n",This
, refCount
+ 1);
394 DeleteCriticalSection(&This
->crit
);
395 if (This
->chanbuf
) IRpcChannelBuffer_Release(This
->chanbuf
);
396 VirtualFree(This
->asmstubs
, 0, MEM_RELEASE
);
402 static HRESULT WINAPI
404 LPRPCPROXYBUFFER iface
,IRpcChannelBuffer
* pRpcChannelBuffer
)
406 ICOM_THIS_MULTI(TMProxyImpl
, lpvtbl2
, iface
);
408 TRACE("(%p)\n", pRpcChannelBuffer
);
410 EnterCriticalSection(&This
->crit
);
412 IRpcChannelBuffer_AddRef(pRpcChannelBuffer
);
413 This
->chanbuf
= pRpcChannelBuffer
;
415 LeaveCriticalSection(&This
->crit
);
421 TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface
)
423 ICOM_THIS_MULTI(TMProxyImpl
, lpvtbl2
, iface
);
427 EnterCriticalSection(&This
->crit
);
429 IRpcChannelBuffer_Release(This
->chanbuf
);
430 This
->chanbuf
= NULL
;
432 LeaveCriticalSection(&This
->crit
);
436 static IRpcProxyBufferVtbl tmproxyvtable
= {
437 TMProxyImpl_QueryInterface
,
441 TMProxyImpl_Disconnect
444 /* how much space do we use on stack in DWORD steps. */
449 return sizeof(DATE
)/sizeof(DWORD
);
451 return (sizeof(VARIANT
)+3)/sizeof(DWORD
);
458 _xsize(TYPEDESC
*td
) {
463 return sizeof(VARIANT
)+3;
466 ARRAYDESC
*adesc
= td
->u
.lpadesc
;
468 for (i
=0;i
<adesc
->cDims
;i
++)
469 arrsize
*= adesc
->rgbounds
[i
].cElements
;
470 return arrsize
*_xsize(&adesc
->tdescElem
);
495 TRACE("(tdesc.vt %d)\n",tdesc
->vt
);
498 case VT_EMPTY
: /* nothing. empty variant for instance */
509 if (debugout
) TRACE_(olerelay
)("%lx",*arg
);
511 hres
= xbuf_add(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
515 VARIANT
*vt
= (VARIANT
*)arg
;
516 DWORD vttype
= V_VT(vt
);
518 if (debugout
) TRACE_(olerelay
)("Vt(%ld)(",vttype
);
521 hres
= xbuf_add(buf
,(LPBYTE
)&vttype
,sizeof(vttype
));
522 if (hres
) return hres
;
524 /* need to recurse since we need to free the stuff */
525 hres
= serialize_param(tinfo
,writeit
,debugout
,dealloc
,&tdesc2
,&(V_I4(vt
)),buf
);
526 if (debugout
) TRACE_(olerelay
)(")");
532 TRACE_(olerelay
)("%s",relaystr((BSTR
)*arg
));
534 TRACE_(olerelay
)("<bstr NULL>");
539 hres
= xbuf_add(buf
,(LPBYTE
)&fakelen
,4);
543 DWORD
*bstr
= ((DWORD
*)(*arg
))-1;
545 hres
= xbuf_add(buf
,(LPBYTE
)bstr
,bstr
[0]+4);
552 SysFreeString((BSTR
)*arg
);
558 if (debugout
) TRACE_(olerelay
)("*");
560 cookie
= *arg
? 0x42424242 : 0;
561 hres
= xbuf_add(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
566 if (debugout
) TRACE_(olerelay
)("NULL");
569 hres
= serialize_param(tinfo
,writeit
,debugout
,dealloc
,tdesc
->u
.lptdesc
,(DWORD
*)*arg
,buf
);
570 if (dealloc
) HeapFree(GetProcessHeap(),0,(LPVOID
)arg
);
574 if (debugout
) TRACE_(olerelay
)("unk(0x%lx)",*arg
);
576 hres
= _marshal_interface(buf
,&IID_IUnknown
,(LPUNKNOWN
)*arg
);
579 if (debugout
) TRACE_(olerelay
)("idisp(0x%lx)",*arg
);
581 hres
= _marshal_interface(buf
,&IID_IDispatch
,(LPUNKNOWN
)*arg
);
584 if (debugout
) TRACE_(olerelay
)("<void>");
586 case VT_USERDEFINED
: {
590 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
592 ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc
->u
.hreftype
);
595 ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
596 switch (tattr
->typekind
) {
598 case TKIND_INTERFACE
:
600 hres
=_marshal_interface(buf
,&(tattr
->guid
),(LPUNKNOWN
)arg
);
604 if (debugout
) TRACE_(olerelay
)("{");
605 for (i
=0;i
<tattr
->cVars
;i
++) {
610 hres
= ITypeInfo2_GetVarDesc(tinfo2
, i
, &vdesc
);
612 ERR("Could not get vardesc of %d\n",i
);
615 /* Need them for hack below */
617 memset(names,0,sizeof(names));
618 hres = ITypeInfo_GetNames(tinfo2,vdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames);
619 if (nrofnames > sizeof(names)/sizeof(names[0])) {
620 ERR("Need more names!\n");
622 if (!hres && debugout)
623 TRACE_(olerelay)("%s=",relaystr(names[0]));
625 elem2
= &vdesc
->elemdescVar
;
626 tdesc2
= &elem2
->tdesc
;
627 hres
= serialize_param(
633 (DWORD
*)(((LPBYTE
)arg
)+vdesc
->u
.oInst
),
638 if (debugout
&& (i
<(tattr
->cVars
-1)))
639 TRACE_(olerelay
)(",");
641 if (buf
->thisisiid
&& (tattr
->cbSizeInstance
==sizeof(GUID
)))
642 memcpy(&(buf
->iid
),arg
,sizeof(buf
->iid
));
643 if (debugout
) TRACE_(olerelay
)("}");
647 FIXME("Unhandled typekind %d\n",tattr
->typekind
);
651 ITypeInfo_Release(tinfo2
);
655 ARRAYDESC
*adesc
= tdesc
->u
.lpadesc
;
658 if (debugout
) TRACE_(olerelay
)("carr");
659 for (i
=0;i
<adesc
->cDims
;i
++) {
660 if (debugout
) TRACE_(olerelay
)("[%ld]",adesc
->rgbounds
[i
].cElements
);
661 arrsize
*= adesc
->rgbounds
[i
].cElements
;
663 if (debugout
) TRACE_(olerelay
)("[");
664 for (i
=0;i
<arrsize
;i
++) {
665 hres
= serialize_param(tinfo
, writeit
, debugout
, dealloc
, &adesc
->tdescElem
, (DWORD
*)((LPBYTE
)arg
+i
*_xsize(&adesc
->tdescElem
)), buf
);
668 if (debugout
&& (i
<arrsize
-1)) TRACE_(olerelay
)(",");
670 if (debugout
) TRACE_(olerelay
)("]");
674 ERR("Unhandled marshal type %d.\n",tdesc
->vt
);
680 serialize_LPVOID_ptr(
692 if ((tdesc
->vt
!= VT_PTR
) ||
693 (tdesc
->u
.lptdesc
->vt
!= VT_PTR
) ||
694 (tdesc
->u
.lptdesc
->u
.lptdesc
->vt
!= VT_VOID
)
696 FIXME("ppvObject not expressed as VT_PTR -> VT_PTR -> VT_VOID?\n");
699 cookie
= (*arg
) ? 0x42424242: 0x0;
701 hres
= xbuf_add(buf
, (LPVOID
)&cookie
, sizeof(cookie
));
706 if (debugout
) TRACE_(olerelay
)("<lpvoid NULL>");
710 TRACE_(olerelay
)("ppv(%p)",*(LPUNKNOWN
*)*arg
);
712 hres
= _marshal_interface(buf
,&(buf
->iid
),*(LPUNKNOWN
*)*arg
);
717 HeapFree(GetProcessHeap(),0,(LPVOID
)*arg
);
722 serialize_DISPPARAM_ptr(
736 if ((tdesc
->vt
!= VT_PTR
) || (tdesc
->u
.lptdesc
->vt
!= VT_USERDEFINED
)) {
737 FIXME("DISPPARAMS not expressed as VT_PTR -> VT_USERDEFINED?\n");
741 cookie
= *arg
? 0x42424242 : 0x0;
743 hres
= xbuf_add(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
748 if (debugout
) TRACE_(olerelay
)("<DISPPARAMS NULL>");
751 disp
= (DISPPARAMS
*)*arg
;
753 hres
= xbuf_add(buf
,(LPBYTE
)&disp
->cArgs
,sizeof(disp
->cArgs
));
757 if (debugout
) TRACE_(olerelay
)("D{");
758 for (i
=0;i
<disp
->cArgs
;i
++) {
761 vtdesc
.vt
= VT_VARIANT
;
768 (DWORD
*)(disp
->rgvarg
+i
),
771 if (debugout
&& (i
<disp
->cArgs
-1))
772 TRACE_(olerelay
)(",");
775 HeapFree(GetProcessHeap(),0,disp
->rgvarg
);
777 hres
= xbuf_add(buf
,(LPBYTE
)&disp
->cNamedArgs
,sizeof(disp
->cNamedArgs
));
781 if (debugout
) TRACE_(olerelay
)("}{");
782 for (i
=0;i
<disp
->cNamedArgs
;i
++) {
792 (DWORD
*)(disp
->rgdispidNamedArgs
+i
),
795 if (debugout
&& (i
<disp
->cNamedArgs
-1))
796 TRACE_(olerelay
)(",");
798 if (debugout
) TRACE_(olerelay
)("}");
800 HeapFree(GetProcessHeap(),0,disp
->rgdispidNamedArgs
);
801 HeapFree(GetProcessHeap(),0,disp
);
818 TRACE("vt %d at %p\n",tdesc
->vt
,arg
);
823 if (debugout
) TRACE_(olerelay
)("<empty>");
826 if (debugout
) TRACE_(olerelay
)("<null>");
829 VARIANT
*vt
= (VARIANT
*)arg
;
834 hres
= xbuf_get(buf
,(LPBYTE
)&vttype
,sizeof(vttype
));
836 FIXME("vt type not read?\n");
839 memset(&tdesc2
,0,sizeof(tdesc2
));
842 if (debugout
) TRACE_(olerelay
)("Vt(%ld)(",vttype
);
843 hres
= deserialize_param(tinfo
, readit
, debugout
, alloc
, &tdesc2
, &(V_I4(vt
)), buf
);
844 TRACE_(olerelay
)(")");
852 case VT_BOOL
: case VT_I4
: case VT_UI4
: case VT_UINT
: case VT_R4
:
856 hres
= xbuf_get(buf
,(LPBYTE
)arg
,sizeof(DWORD
));
857 if (hres
) ERR("Failed to read integer 4 byte\n");
859 if (debugout
) TRACE_(olerelay
)("%lx",*arg
);
866 hres
= xbuf_get(buf
,(LPBYTE
)&len
,sizeof(DWORD
));
868 ERR("failed to read bstr klen\n");
873 if (debugout
) TRACE_(olerelay
)("<bstr NULL>");
875 str
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,len
+sizeof(WCHAR
));
876 hres
= xbuf_get(buf
,(LPBYTE
)str
,len
);
878 ERR("Failed to read BSTR.\n");
881 *arg
= (DWORD
)SysAllocStringLen(str
,len
);
882 if (debugout
) TRACE_(olerelay
)("%s",relaystr(str
));
883 HeapFree(GetProcessHeap(),0,str
);
894 derefhere
= (tdesc
->u
.lptdesc
->vt
!= VT_USERDEFINED
);
897 hres
= xbuf_get(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
899 ERR("Failed to load pointer cookie.\n");
902 if (cookie
!= 0x42424242) {
903 if (debugout
) TRACE_(olerelay
)("NULL");
907 if (debugout
) TRACE_(olerelay
)("*");
911 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,_xsize(tdesc
->u
.lptdesc
));
914 return deserialize_param(tinfo
, readit
, debugout
, alloc
, tdesc
->u
.lptdesc
, (LPDWORD
)*arg
, buf
);
916 return deserialize_param(tinfo
, readit
, debugout
, alloc
, tdesc
->u
.lptdesc
, arg
, buf
);
919 /* FIXME: UNKNOWN is unknown ..., but allocate 4 byte for it */
921 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DWORD
));
924 hres
= _unmarshal_interface(buf
,&IID_IUnknown
,(LPUNKNOWN
*)arg
);
926 TRACE_(olerelay
)("unk(%p)",arg
);
931 hres
= _unmarshal_interface(buf
,&IID_IDispatch
,(LPUNKNOWN
*)arg
);
933 TRACE_(olerelay
)("idisp(%p)",arg
);
936 if (debugout
) TRACE_(olerelay
)("<void>");
938 case VT_USERDEFINED
: {
942 hres
= ITypeInfo_GetRefTypeInfo(tinfo
,tdesc
->u
.hreftype
,&tinfo2
);
944 ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc
->u
.hreftype
);
947 hres
= ITypeInfo_GetTypeAttr(tinfo2
,&tattr
);
949 ERR("Could not get typeattr in VT_USERDEFINED.\n");
952 *arg
= (DWORD
)HeapAlloc(GetProcessHeap(),0,tattr
->cbSizeInstance
);
953 switch (tattr
->typekind
) {
955 case TKIND_INTERFACE
:
957 hres
= _unmarshal_interface(buf
,&(tattr
->guid
),(LPUNKNOWN
*)arg
);
962 if (debugout
) TRACE_(olerelay
)("{");
963 for (i
=0;i
<tattr
->cVars
;i
++) {
966 hres
= ITypeInfo2_GetVarDesc(tinfo2
, i
, &vdesc
);
968 ERR("Could not get vardesc of %d\n",i
);
971 hres
= deserialize_param(
976 &vdesc
->elemdescVar
.tdesc
,
977 (DWORD
*)(((LPBYTE
)*arg
)+vdesc
->u
.oInst
),
980 if (debugout
&& (i
<tattr
->cVars
-1)) TRACE_(olerelay
)(",");
982 if (buf
->thisisiid
&& (tattr
->cbSizeInstance
==sizeof(GUID
)))
983 memcpy(&(buf
->iid
),(LPBYTE
)*arg
,sizeof(buf
->iid
));
984 if (debugout
) TRACE_(olerelay
)("}");
988 ERR("Unhandled typekind %d\n",tattr
->typekind
);
994 ERR("failed to stuballoc in TKIND_RECORD.\n");
995 ITypeInfo_Release(tinfo2
);
999 /* arg is pointing to the start of the array. */
1000 ARRAYDESC
*adesc
= tdesc
->u
.lpadesc
;
1003 if (adesc
->cDims
> 1) FIXME("cDims > 1 in VT_CARRAY. Does it work?\n");
1004 for (i
=0;i
<adesc
->cDims
;i
++)
1005 arrsize
*= adesc
->rgbounds
[i
].cElements
;
1006 for (i
=0;i
<arrsize
;i
++)
1013 (DWORD
*)((LPBYTE
)(arg
)+i
*_xsize(&adesc
->tdescElem
)),
1019 ERR("No handler for VT type %d!\n",tdesc
->vt
);
1026 deserialize_LPVOID_ptr(
1038 if ((tdesc
->vt
!= VT_PTR
) ||
1039 (tdesc
->u
.lptdesc
->vt
!= VT_PTR
) ||
1040 (tdesc
->u
.lptdesc
->u
.lptdesc
->vt
!= VT_VOID
)
1042 FIXME("ppvObject not expressed as VT_PTR -> VT_PTR -> VT_VOID?\n");
1046 *arg
=(DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(LPVOID
));
1048 hres
= xbuf_get(buf
, (LPVOID
)&cookie
, sizeof(cookie
));
1051 if (cookie
!= 0x42424242) {
1053 if (debugout
) TRACE_(olerelay
)("<lpvoid NULL>");
1058 hres
= _unmarshal_interface(buf
,&buf
->iid
,(LPUNKNOWN
*)*arg
);
1062 if (debugout
) TRACE_(olerelay
)("ppv(%p)",(LPVOID
)*arg
);
1067 deserialize_DISPPARAM_ptr(
1081 if ((tdesc
->vt
!= VT_PTR
) || (tdesc
->u
.lptdesc
->vt
!= VT_USERDEFINED
)) {
1082 FIXME("DISPPARAMS not expressed as VT_PTR -> VT_USERDEFINED?\n");
1086 hres
= xbuf_get(buf
,(LPBYTE
)&cookie
,sizeof(cookie
));
1091 if (debugout
) TRACE_(olerelay
)("<DISPPARAMS NULL>");
1096 *arg
= (DWORD
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DISPPARAMS
));
1097 disps
= (DISPPARAMS
*)*arg
;
1100 hres
= xbuf_get(buf
, (LPBYTE
)&disps
->cArgs
, sizeof(disps
->cArgs
));
1104 disps
->rgvarg
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(VARIANT
)*disps
->cArgs
);
1105 if (debugout
) TRACE_(olerelay
)("D{");
1106 for (i
=0; i
< disps
->cArgs
; i
++) {
1109 vdesc
.vt
= VT_VARIANT
;
1110 hres
= deserialize_param(
1116 (DWORD
*)(disps
->rgvarg
+i
),
1120 if (debugout
) TRACE_(olerelay
)("}{");
1121 hres
= xbuf_get(buf
, (LPBYTE
)&disps
->cNamedArgs
, sizeof(disps
->cNamedArgs
));
1124 if (disps
->cNamedArgs
) {
1126 disps
->rgdispidNamedArgs
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DISPID
)*disps
->cNamedArgs
);
1127 for (i
=0; i
< disps
->cNamedArgs
; i
++) {
1131 hres
= deserialize_param(
1137 (DWORD
*)(disps
->rgdispidNamedArgs
+i
),
1140 if (debugout
&& i
<(disps
->cNamedArgs
-1)) TRACE_(olerelay
)(",");
1143 if (debugout
) TRACE_(olerelay
)("}");
1147 /* Searches function, also in inherited interfaces */
1150 ITypeInfo
*tinfo
, int iMethod
, FUNCDESC
**fdesc
, BSTR
*iname
, BSTR
*fname
)
1155 if (fname
) *fname
= NULL
;
1156 if (iname
) *iname
= NULL
;
1159 hres
= ITypeInfo_GetFuncDesc(tinfo
, i
, fdesc
);
1165 hres
= ITypeInfo_GetTypeAttr(tinfo
, &attr
);
1167 ERR("GetTypeAttr failed with %lx\n",hres
);
1170 /* Not found, so look in inherited ifaces. */
1171 for (j
=0;j
<attr
->cImplTypes
;j
++) {
1172 hres
= ITypeInfo_GetRefTypeOfImplType(tinfo
, j
, &href
);
1174 ERR("Did not find a reftype for interface offset %d?\n",j
);
1177 hres
= ITypeInfo_GetRefTypeInfo(tinfo
, href
, &tinfo2
);
1179 ERR("Did not find a typeinfo for reftype %ld?\n",href
);
1182 hres
= _get_funcdesc(tinfo2
,iMethod
,fdesc
,iname
,fname
);
1183 ITypeInfo_Release(tinfo2
);
1184 if (!hres
) return S_OK
;
1188 if (((*fdesc
)->oVft
/4) == iMethod
) {
1190 ITypeInfo_GetDocumentation(tinfo
,(*fdesc
)->memid
,fname
,NULL
,NULL
,NULL
);
1192 ITypeInfo_GetDocumentation(tinfo
,-1,iname
,NULL
,NULL
,NULL
);
1200 xCall(LPVOID retptr
, int method
, TMProxyImpl
*tpinfo
/*, args */)
1202 DWORD
*args
= ((DWORD
*)&tpinfo
)+1, *xargs
;
1205 int i
, relaydeb
= TRACE_ON(olerelay
);
1213 EnterCriticalSection(&tpinfo
->crit
);
1215 hres
= _get_funcdesc(tpinfo
->tinfo
,method
,&fdesc
,&iname
,&fname
);
1217 ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method
);
1218 LeaveCriticalSection(&tpinfo
->crit
);
1222 if (!tpinfo
->chanbuf
)
1224 WARN("Tried to use disconnected proxy\n");
1225 LeaveCriticalSection(&tpinfo
->crit
);
1226 return RPC_E_DISCONNECTED
;
1230 TRACE_(olerelay
)("->");
1232 TRACE_(olerelay
)("%s:",relaystr(iname
));
1234 TRACE_(olerelay
)("%s(%d)",relaystr(fname
),method
);
1236 TRACE_(olerelay
)("%d",method
);
1237 TRACE_(olerelay
)("(");
1238 if (iname
) SysFreeString(iname
);
1239 if (fname
) SysFreeString(fname
);
1241 /* Need them for hack below */
1242 memset(names
,0,sizeof(names
));
1243 if (ITypeInfo_GetNames(tpinfo
->tinfo
,fdesc
->memid
,names
,sizeof(names
)/sizeof(names
[0]),&nrofnames
))
1245 if (nrofnames
> sizeof(names
)/sizeof(names
[0]))
1246 ERR("Need more names!\n");
1248 memset(&buf
,0,sizeof(buf
));
1249 buf
.iid
= IID_IUnknown
;
1251 xbuf_add(&buf
,(LPBYTE
)args
[0],sizeof(IID
));
1252 if (relaydeb
) TRACE_(olerelay
)("riid=%s,[out]",debugstr_guid((REFIID
)args
[0]));
1255 for (i
=0;i
<fdesc
->cParams
;i
++) {
1256 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1257 BOOL isserialized
= FALSE
;
1259 if (i
) TRACE_(olerelay
)(",");
1260 if (i
+1<nrofnames
&& names
[i
+1])
1261 TRACE_(olerelay
)("%s=",relaystr(names
[i
+1]));
1263 /* No need to marshal other data than FIN */
1264 if (!(elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
)) {
1265 xargs
+=_argsize(elem
->tdesc
.vt
);
1266 if (relaydeb
) TRACE_(olerelay
)("[out]");
1269 if (((i
+1)<nrofnames
) && !IsBadStringPtrW(names
[i
+1],1)) {
1270 /* If the parameter is 'riid', we use it as interface IID
1271 * for a later ppvObject serialization.
1273 buf
.thisisiid
= !lstrcmpW(names
[i
+1],riidW
);
1275 /* DISPPARAMS* needs special serializer */
1276 if (!lstrcmpW(names
[i
+1],pdispparamsW
)) {
1277 hres
= serialize_DISPPARAM_ptr(
1279 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
,
1286 isserialized
= TRUE
;
1288 if (!lstrcmpW(names
[i
+1],ppvObjectW
)) {
1289 hres
= serialize_LPVOID_ptr(
1291 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
,
1299 isserialized
= TRUE
;
1303 hres
= serialize_param(
1305 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
,
1314 ERR("Failed to serialize param, hres %lx\n",hres
);
1317 xargs
+=_argsize(elem
->tdesc
.vt
);
1320 if (relaydeb
) TRACE_(olerelay
)(")");
1321 memset(&msg
,0,sizeof(msg
));
1322 msg
.cbBuffer
= buf
.curoff
;
1323 msg
.iMethod
= method
;
1324 hres
= IRpcChannelBuffer_GetBuffer(tpinfo
->chanbuf
,&msg
,&(tpinfo
->iid
));
1326 ERR("RpcChannelBuffer GetBuffer failed, %lx\n",hres
);
1327 LeaveCriticalSection(&tpinfo
->crit
);
1330 memcpy(msg
.Buffer
,buf
.base
,buf
.curoff
);
1331 if (relaydeb
) TRACE_(olerelay
)("\n");
1332 hres
= IRpcChannelBuffer_SendReceive(tpinfo
->chanbuf
,&msg
,&status
);
1334 ERR("RpcChannelBuffer SendReceive failed, %lx\n",hres
);
1335 LeaveCriticalSection(&tpinfo
->crit
);
1339 if (relaydeb
) TRACE_(olerelay
)(" = %08lx (",status
);
1341 buf
.base
= HeapReAlloc(GetProcessHeap(),0,buf
.base
,msg
.cbBuffer
);
1343 buf
.base
= HeapAlloc(GetProcessHeap(),0,msg
.cbBuffer
);
1344 buf
.size
= msg
.cbBuffer
;
1345 memcpy(buf
.base
,msg
.Buffer
,buf
.size
);
1348 _unmarshal_interface(&buf
,(REFIID
)args
[0],(LPUNKNOWN
*)args
[1]);
1349 if (relaydeb
) TRACE_(olerelay
)("[in],%p",*((DWORD
**)args
[1]));
1352 for (i
=0;i
<fdesc
->cParams
;i
++) {
1353 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1354 BOOL isdeserialized
= FALSE
;
1357 if (i
) TRACE_(olerelay
)(",");
1358 if (i
+1<nrofnames
&& names
[i
+1]) TRACE_(olerelay
)("%s=",relaystr(names
[i
+1]));
1360 /* No need to marshal other data than FOUT I think */
1361 if (!(elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
)) {
1362 xargs
+= _argsize(elem
->tdesc
.vt
);
1363 if (relaydeb
) TRACE_(olerelay
)("[in]");
1366 if (((i
+1)<nrofnames
) && !IsBadStringPtrW(names
[i
+1],1)) {
1367 /* If the parameter is 'riid', we use it as interface IID
1368 * for a later ppvObject serialization.
1370 buf
.thisisiid
= !lstrcmpW(names
[i
+1],riidW
);
1372 /* deserialize DISPPARAM */
1373 if (!lstrcmpW(names
[i
+1],pdispparamsW
)) {
1374 hres
= deserialize_DISPPARAM_ptr(
1376 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1384 ERR("Failed to deserialize DISPPARAM*, hres %lx\n",hres
);
1387 isdeserialized
= TRUE
;
1389 if (!lstrcmpW(names
[i
+1],ppvObjectW
)) {
1390 hres
= deserialize_LPVOID_ptr(
1392 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1400 isdeserialized
= TRUE
;
1403 if (!isdeserialized
)
1404 hres
= deserialize_param(
1406 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1414 ERR("Failed to unmarshall param, hres %lx\n",hres
);
1418 xargs
+= _argsize(elem
->tdesc
.vt
);
1421 if (relaydeb
) TRACE_(olerelay
)(")\n");
1422 HeapFree(GetProcessHeap(),0,buf
.base
);
1424 LeaveCriticalSection(&tpinfo
->crit
);
1429 static HRESULT WINAPI
1430 PSFacBuf_CreateProxy(
1431 LPPSFACTORYBUFFER iface
, IUnknown
* pUnkOuter
, REFIID riid
,
1432 IRpcProxyBuffer
**ppProxy
, LPVOID
*ppv
)
1440 TRACE("(...%s...)\n",debugstr_guid(riid
));
1441 hres
= _get_typeinfo_for_iid(riid
,&tinfo
);
1443 ERR("No typeinfo for %s?\n",debugstr_guid(riid
));
1446 nroffuncs
= _nroffuncs(tinfo
);
1447 proxy
= CoTaskMemAlloc(sizeof(TMProxyImpl
));
1448 if (!proxy
) return E_OUTOFMEMORY
;
1450 assert(sizeof(TMAsmProxy
) == 12);
1452 proxy
->asmstubs
= VirtualAlloc(NULL
, sizeof(TMAsmProxy
) * nroffuncs
, MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
1453 if (!proxy
->asmstubs
) {
1454 ERR("Could not commit pages for proxy thunks\n");
1455 CoTaskMemFree(proxy
);
1456 return E_OUTOFMEMORY
;
1459 InitializeCriticalSection(&proxy
->crit
);
1461 proxy
->lpvtbl
= HeapAlloc(GetProcessHeap(),0,sizeof(LPBYTE
)*nroffuncs
);
1462 for (i
=0;i
<nroffuncs
;i
++) {
1464 TMAsmProxy
*xasm
= proxy
->asmstubs
+i
;
1466 /* nrofargs without This */
1468 case 0: nrofargs
= 2;
1470 case 1: case 2: nrofargs
= 0;
1474 hres
= _get_funcdesc(tinfo
,i
,&fdesc
,NULL
,NULL
);
1476 ERR("GetFuncDesc %lx should not fail here.\n",hres
);
1479 /* some args take more than 4 byte on the stack */
1481 for (j
=0;j
<fdesc
->cParams
;j
++)
1482 nrofargs
+= _argsize(fdesc
->lprgelemdescParam
[j
].tdesc
.vt
);
1484 if (fdesc
->callconv
!= CC_STDCALL
) {
1485 ERR("calling convention is not stdcall????\n");
1491 /* popl %eax - return ptr
1498 * arg3 arg2 arg1 <method> <returnptr>
1500 xasm
->popleax
= 0x58;
1501 xasm
->pushlval
= 0x6a;
1503 xasm
->pushleax
= 0x50;
1504 xasm
->lcall
= 0xe8; /* relative jump */
1505 xasm
->xcall
= (DWORD
)xCall
;
1506 xasm
->xcall
-= (DWORD
)&(xasm
->lret
);
1508 xasm
->bytestopop
= (nrofargs
+2)*4; /* pop args, This, iMethod */
1509 proxy
->lpvtbl
[i
] = xasm
;
1511 proxy
->lpvtbl2
= &tmproxyvtable
;
1512 /* 1 reference for the proxy and 1 for the object */
1514 proxy
->tinfo
= tinfo
;
1515 memcpy(&proxy
->iid
,riid
,sizeof(*riid
));
1517 *ppv
= (LPVOID
)proxy
;
1518 *ppProxy
= (IRpcProxyBuffer
*)&(proxy
->lpvtbl2
);
1522 typedef struct _TMStubImpl
{
1523 IRpcStubBufferVtbl
*lpvtbl
;
1531 static HRESULT WINAPI
1532 TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface
, REFIID riid
, LPVOID
*ppv
)
1534 if (IsEqualIID(riid
,&IID_IRpcStubBuffer
)||IsEqualIID(riid
,&IID_IUnknown
)){
1535 *ppv
= (LPVOID
)iface
;
1536 IRpcStubBuffer_AddRef(iface
);
1539 FIXME("%s, not supported IID.\n",debugstr_guid(riid
));
1540 return E_NOINTERFACE
;
1544 TMStubImpl_AddRef(LPRPCSTUBBUFFER iface
)
1546 TMStubImpl
*This
= (TMStubImpl
*)iface
;
1547 ULONG refCount
= InterlockedIncrement(&This
->ref
);
1549 TRACE("(%p)->(ref before=%lu)\n", This
, refCount
- 1);
1555 TMStubImpl_Release(LPRPCSTUBBUFFER iface
)
1557 TMStubImpl
*This
= (TMStubImpl
*)iface
;
1558 ULONG refCount
= InterlockedDecrement(&This
->ref
);
1560 TRACE("(%p)->(ref before=%lu)\n", This
, refCount
+ 1);
1564 IRpcStubBuffer_Disconnect(iface
);
1565 CoTaskMemFree(This
);
1570 static HRESULT WINAPI
1571 TMStubImpl_Connect(LPRPCSTUBBUFFER iface
, LPUNKNOWN pUnkServer
)
1573 TMStubImpl
*This
= (TMStubImpl
*)iface
;
1575 TRACE("(%p)->(%p)\n", This
, pUnkServer
);
1577 IUnknown_AddRef(pUnkServer
);
1578 This
->pUnk
= pUnkServer
;
1583 TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface
)
1585 TMStubImpl
*This
= (TMStubImpl
*)iface
;
1587 TRACE("(%p)->()\n", This
);
1589 IUnknown_Release(This
->pUnk
);
1594 static HRESULT WINAPI
1596 LPRPCSTUBBUFFER iface
, RPCOLEMESSAGE
* xmsg
,IRpcChannelBuffer
*rpcchanbuf
)
1600 TMStubImpl
*This
= (TMStubImpl
*)iface
;
1602 DWORD
*args
, res
, *xargs
, nrofargs
;
1607 memset(&buf
,0,sizeof(buf
));
1608 buf
.size
= xmsg
->cbBuffer
;
1609 buf
.base
= xmsg
->Buffer
;
1611 buf
.iid
= IID_IUnknown
;
1614 if (xmsg
->iMethod
== 0) { /* QI */
1616 /* in: IID, out: <iface> */
1618 xbuf_get(&buf
,(LPBYTE
)&xiid
,sizeof(xiid
));
1620 hres
= _marshal_interface(&buf
,&xiid
,This
->pUnk
);
1621 xmsg
->Buffer
= buf
.base
; /* Might have been reallocated */
1622 xmsg
->cbBuffer
= buf
.size
;
1625 hres
= _get_funcdesc(This
->tinfo
,xmsg
->iMethod
,&fdesc
,NULL
,NULL
);
1627 ERR("GetFuncDesc on method %ld failed with %lx\n",xmsg
->iMethod
,hres
);
1630 /* Need them for hack below */
1631 memset(names
,0,sizeof(names
));
1632 ITypeInfo_GetNames(This
->tinfo
,fdesc
->memid
,names
,sizeof(names
)/sizeof(names
[0]),&nrofnames
);
1633 if (nrofnames
> sizeof(names
)/sizeof(names
[0])) {
1634 ERR("Need more names!\n");
1637 /*dump_FUNCDESC(fdesc);*/
1639 for (i
=0;i
<fdesc
->cParams
;i
++)
1640 nrofargs
+= _argsize(fdesc
->lprgelemdescParam
[i
].tdesc
.vt
);
1641 args
= HeapAlloc(GetProcessHeap(),0,(nrofargs
+1)*sizeof(DWORD
));
1642 if (!args
) return E_OUTOFMEMORY
;
1644 /* Allocate all stuff used by call. */
1646 for (i
=0;i
<fdesc
->cParams
;i
++) {
1647 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1648 BOOL isdeserialized
= FALSE
;
1650 if (((i
+1)<nrofnames
) && !IsBadStringPtrW(names
[i
+1],1)) {
1651 /* If the parameter is 'riid', we use it as interface IID
1652 * for a later ppvObject serialization.
1654 buf
.thisisiid
= !lstrcmpW(names
[i
+1],riidW
);
1656 /* deserialize DISPPARAM */
1657 if (!lstrcmpW(names
[i
+1],pdispparamsW
)) {
1658 hres
= deserialize_DISPPARAM_ptr(
1660 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
,
1668 ERR("Failed to deserialize DISPPARAM*, hres %lx\n",hres
);
1671 isdeserialized
= TRUE
;
1673 if (!lstrcmpW(names
[i
+1],ppvObjectW
)) {
1674 hres
= deserialize_LPVOID_ptr(
1676 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1684 isdeserialized
= TRUE
;
1687 if (!isdeserialized
)
1688 hres
= deserialize_param(
1690 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FIN
,
1697 xargs
+= _argsize(elem
->tdesc
.vt
);
1699 ERR("Failed to deserialize param %s, hres %lx\n",relaystr(names
[i
+1]),hres
);
1703 hres
= IUnknown_QueryInterface(This
->pUnk
,&(This
->iid
),(LPVOID
*)&(args
[0]));
1705 ERR("Does not support iface %s\n",debugstr_guid(&(This
->iid
)));
1709 (*((FARPROC
**)args
[0]))[fdesc
->oVft
/4],
1714 IUnknown_Release((LPUNKNOWN
)args
[0]);
1717 for (i
=0;i
<fdesc
->cParams
;i
++) {
1718 ELEMDESC
*elem
= fdesc
->lprgelemdescParam
+i
;
1719 BOOL isserialized
= FALSE
;
1721 if (((i
+1)<nrofnames
) && !IsBadStringPtrW(names
[i
+1],1)) {
1722 /* If the parameter is 'riid', we use it as interface IID
1723 * for a later ppvObject serialization.
1725 buf
.thisisiid
= !lstrcmpW(names
[i
+1],riidW
);
1727 /* DISPPARAMS* needs special serializer */
1728 if (!lstrcmpW(names
[i
+1],pdispparamsW
)) {
1729 hres
= serialize_DISPPARAM_ptr(
1731 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1738 isserialized
= TRUE
;
1740 if (!lstrcmpW(names
[i
+1],ppvObjectW
)) {
1741 hres
= serialize_LPVOID_ptr(
1743 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1751 isserialized
= TRUE
;
1755 hres
= serialize_param(
1757 elem
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FOUT
,
1764 xargs
+= _argsize(elem
->tdesc
.vt
);
1766 ERR("Failed to stuballoc param, hres %lx\n",hres
);
1770 /* might need to use IRpcChannelBuffer_GetBuffer ? */
1771 xmsg
->cbBuffer
= buf
.curoff
;
1772 xmsg
->Buffer
= buf
.base
;
1773 HeapFree(GetProcessHeap(),0,args
);
1777 static LPRPCSTUBBUFFER WINAPI
1778 TMStubImpl_IsIIDSupported(LPRPCSTUBBUFFER iface
, REFIID riid
) {
1779 FIXME("Huh (%s)?\n",debugstr_guid(riid
));
1784 TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface
) {
1785 TMStubImpl
*This
= (TMStubImpl
*)iface
;
1787 return This
->ref
; /*FIXME? */
1790 static HRESULT WINAPI
1791 TMStubImpl_DebugServerQueryInterface(LPRPCSTUBBUFFER iface
, LPVOID
*ppv
) {
1796 TMStubImpl_DebugServerRelease(LPRPCSTUBBUFFER iface
, LPVOID ppv
) {
1800 IRpcStubBufferVtbl tmstubvtbl
= {
1801 TMStubImpl_QueryInterface
,
1805 TMStubImpl_Disconnect
,
1807 TMStubImpl_IsIIDSupported
,
1808 TMStubImpl_CountRefs
,
1809 TMStubImpl_DebugServerQueryInterface
,
1810 TMStubImpl_DebugServerRelease
1813 static HRESULT WINAPI
1814 PSFacBuf_CreateStub(
1815 LPPSFACTORYBUFFER iface
, REFIID riid
,IUnknown
*pUnkServer
,
1816 IRpcStubBuffer
** ppStub
1822 TRACE("(%s,%p,%p)\n",debugstr_guid(riid
),pUnkServer
,ppStub
);
1823 hres
= _get_typeinfo_for_iid(riid
,&tinfo
);
1825 ERR("No typeinfo for %s?\n",debugstr_guid(riid
));
1828 stub
= CoTaskMemAlloc(sizeof(TMStubImpl
));
1830 return E_OUTOFMEMORY
;
1831 stub
->lpvtbl
= &tmstubvtbl
;
1833 stub
->tinfo
= tinfo
;
1834 memcpy(&(stub
->iid
),riid
,sizeof(*riid
));
1835 hres
= IRpcStubBuffer_Connect((LPRPCSTUBBUFFER
)stub
,pUnkServer
);
1836 *ppStub
= (LPRPCSTUBBUFFER
)stub
;
1837 TRACE("IRpcStubBuffer: %p\n", stub
);
1839 ERR("Connect to pUnkServer failed?\n");
1843 static IPSFactoryBufferVtbl psfacbufvtbl
= {
1844 PSFacBuf_QueryInterface
,
1847 PSFacBuf_CreateProxy
,
1851 /* This is the whole PSFactoryBuffer object, just the vtableptr */
1852 static IPSFactoryBufferVtbl
*lppsfac
= &psfacbufvtbl
;
1854 /***********************************************************************
1855 * DllGetClassObject [OLE32.63]
1858 TypeLibFac_DllGetClassObject(REFCLSID rclsid
, REFIID iid
,LPVOID
*ppv
)
1860 if (IsEqualIID(iid
,&IID_IPSFactoryBuffer
)) {
1864 return E_NOINTERFACE
;