diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index 97500bf944e..9f26a300eeb 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -508,9 +508,9 @@ static const IRpcProxyBufferVtbl tmproxyvtable = { }; /* how much space do we use on stack in DWORD steps. */ -int -_argsize(DWORD vt) { - switch (vt) { +static int +_argsize(TYPEDESC *tdesc, ITypeInfo *tinfo) { + switch (tdesc->vt) { case VT_UI8: return 8/sizeof(DWORD); case VT_R8: @@ -526,8 +526,9 @@ _argsize(DWORD vt) { } } +/* how much space do we use on the heap (in bytes) */ static int -_xsize(const TYPEDESC *td) { +_xsize(const TYPEDESC *td, ITypeInfo *tinfo) { switch (td->vt) { case VT_DATE: return sizeof(DATE); @@ -539,7 +540,7 @@ _xsize(const TYPEDESC *td) { for (i=0;icDims;i++) arrsize *= adesc->rgbounds[i].cElements; - return arrsize*_xsize(&adesc->tdescElem); + return arrsize*_xsize(&adesc->tdescElem, tinfo); } case VT_UI8: case VT_I8: @@ -843,7 +844,7 @@ serialize_param( if (debugout) TRACE_(olerelay)("(vt %s)",debugstr_vt(adesc->tdescElem.vt)); if (debugout) TRACE_(olerelay)("["); for (i=0;itdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem)), buf); + hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem, tinfo)), buf); if (hres) return hres; if (debugout && (iu.lptdesc)); + *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc, tinfo)); } if (derefhere) return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, (LPDWORD)*arg, buf); @@ -1207,7 +1208,7 @@ deserialize_param( debugout, alloc, &adesc->tdescElem, - (DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem)), + (DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem, tinfo)), buf ); return S_OK; @@ -1407,7 +1408,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) } /* No need to marshal other data than FIN and any VT_PTR. */ if (!is_in_elem(elem) && (elem->tdesc.vt != VT_PTR)) { - xargs+=_argsize(elem->tdesc.vt); + xargs+=_argsize(&elem->tdesc, tinfo); if (relaydeb) TRACE_(olerelay)("[out]"); continue; } @@ -1425,7 +1426,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) ERR("Failed to serialize param, hres %x\n",hres); break; } - xargs+=_argsize(elem->tdesc.vt); + xargs+=_argsize(&elem->tdesc, tinfo); } if (relaydeb) TRACE_(olerelay)(")"); @@ -1466,7 +1467,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) } /* No need to marshal other data than FOUT and any VT_PTR */ if (!is_out_elem(elem) && (elem->tdesc.vt != VT_PTR)) { - xargs += _argsize(elem->tdesc.vt); + xargs += _argsize(&elem->tdesc, tinfo); if (relaydeb) TRACE_(olerelay)("[in]"); continue; } @@ -1484,7 +1485,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) status = hres; break; } - xargs += _argsize(elem->tdesc.vt); + xargs += _argsize(&elem->tdesc, tinfo); } hres = xbuf_get(&buf, (LPBYTE)&remoteresult, sizeof(DWORD)); @@ -1725,7 +1726,7 @@ static HRESULT init_proxy_entry_point(TMProxyImpl *proxy, unsigned int num) /* some args take more than 4 byte on the stack */ nrofargs = 0; for (j=0;jcParams;j++) - nrofargs += _argsize(fdesc->lprgelemdescParam[j].tdesc.vt); + nrofargs += _argsize(&fdesc->lprgelemdescParam[j].tdesc, proxy->tinfo); #ifdef __i386__ if (fdesc->callconv != CC_STDCALL) { @@ -2055,7 +2056,7 @@ TMStubImpl_Invoke( /*dump_FUNCDESC(fdesc);*/ nrofargs = 0; for (i=0;icParams;i++) - nrofargs += _argsize(fdesc->lprgelemdescParam[i].tdesc.vt); + nrofargs += _argsize(&fdesc->lprgelemdescParam[i].tdesc, tinfo); args = HeapAlloc(GetProcessHeap(),0,(nrofargs+1)*sizeof(DWORD)); if (!args) { @@ -2077,7 +2078,7 @@ TMStubImpl_Invoke( xargs, &buf ); - xargs += _argsize(elem->tdesc.vt); + xargs += _argsize(&elem->tdesc, tinfo); if (hres) { ERR("Failed to deserialize param %s, hres %x\n",relaystr(names[i+1]),hres); break; @@ -2123,7 +2124,7 @@ TMStubImpl_Invoke( xargs, &buf ); - xargs += _argsize(elem->tdesc.vt); + xargs += _argsize(&elem->tdesc, tinfo); if (hres) { ERR("Failed to stuballoc param, hres %x\n",hres); break; diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 9c7ef98d72c..fb572925be6 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -5483,7 +5483,32 @@ _invoke(FARPROC func,CALLCONV callconv, int nrargs, DWORD *args) { return res; } -extern int _argsize(DWORD vt); +/* The size of the argument on the stack in DWORD units (in all x86 call + * convetions the arguments on the stack are DWORD-aligned) + */ +int _dispargsize(VARTYPE vt) +{ + switch (vt) { + case VT_I8: + case VT_UI8: + return 8/sizeof(DWORD); + case VT_R8: + return sizeof(double)/sizeof(DWORD); + case VT_DECIMAL: + return (sizeof(DECIMAL)+3)/sizeof(DWORD); + case VT_CY: + return sizeof(CY)/sizeof(DWORD); + case VT_DATE: + return sizeof(DATE)/sizeof(DWORD); + case VT_VARIANT: + return (sizeof(VARIANT)+3)/sizeof(DWORD); + case VT_RECORD: + FIXME("VT_RECORD not implemented\n"); + return 1; + default: + return 1; + } +} static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt) { @@ -5671,9 +5696,9 @@ DispCallFunc( for (i=0;i