Commit 8b36e715 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

oleaut32: Make _argsize and _xsize receive the full TYPEDESC and parent…

oleaut32: Make _argsize and _xsize receive the full TYPEDESC and parent ITypeInfo, use a different function in IDispatch code.
parent 294c160c
...@@ -508,9 +508,9 @@ static const IRpcProxyBufferVtbl tmproxyvtable = { ...@@ -508,9 +508,9 @@ static const IRpcProxyBufferVtbl tmproxyvtable = {
}; };
/* how much space do we use on stack in DWORD steps. */ /* how much space do we use on stack in DWORD steps. */
int static int
_argsize(DWORD vt) { _argsize(TYPEDESC *tdesc, ITypeInfo *tinfo) {
switch (vt) { switch (tdesc->vt) {
case VT_UI8: case VT_UI8:
return 8/sizeof(DWORD); return 8/sizeof(DWORD);
case VT_R8: case VT_R8:
...@@ -526,8 +526,9 @@ _argsize(DWORD vt) { ...@@ -526,8 +526,9 @@ _argsize(DWORD vt) {
} }
} }
/* how much space do we use on the heap (in bytes) */
static int static int
_xsize(const TYPEDESC *td) { _xsize(const TYPEDESC *td, ITypeInfo *tinfo) {
switch (td->vt) { switch (td->vt) {
case VT_DATE: case VT_DATE:
return sizeof(DATE); return sizeof(DATE);
...@@ -539,7 +540,7 @@ _xsize(const TYPEDESC *td) { ...@@ -539,7 +540,7 @@ _xsize(const TYPEDESC *td) {
for (i=0;i<adesc->cDims;i++) for (i=0;i<adesc->cDims;i++)
arrsize *= adesc->rgbounds[i].cElements; arrsize *= adesc->rgbounds[i].cElements;
return arrsize*_xsize(&adesc->tdescElem); return arrsize*_xsize(&adesc->tdescElem, tinfo);
} }
case VT_UI8: case VT_UI8:
case VT_I8: case VT_I8:
...@@ -843,7 +844,7 @@ serialize_param( ...@@ -843,7 +844,7 @@ serialize_param(
if (debugout) TRACE_(olerelay)("(vt %s)",debugstr_vt(adesc->tdescElem.vt)); if (debugout) TRACE_(olerelay)("(vt %s)",debugstr_vt(adesc->tdescElem.vt));
if (debugout) TRACE_(olerelay)("["); if (debugout) TRACE_(olerelay)("[");
for (i=0;i<arrsize;i++) { for (i=0;i<arrsize;i++) {
hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (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) if (hres)
return hres; return hres;
if (debugout && (i<arrsize-1)) TRACE_(olerelay)(","); if (debugout && (i<arrsize-1)) TRACE_(olerelay)(",");
...@@ -1092,7 +1093,7 @@ deserialize_param( ...@@ -1092,7 +1093,7 @@ deserialize_param(
if (alloc) { if (alloc) {
/* Allocate space for the referenced struct */ /* Allocate space for the referenced struct */
if (derefhere) if (derefhere)
*arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc)); *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc, tinfo));
} }
if (derefhere) if (derefhere)
return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, (LPDWORD)*arg, buf); return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, (LPDWORD)*arg, buf);
...@@ -1207,7 +1208,7 @@ deserialize_param( ...@@ -1207,7 +1208,7 @@ deserialize_param(
debugout, debugout,
alloc, alloc,
&adesc->tdescElem, &adesc->tdescElem,
(DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem)), (DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem, tinfo)),
buf buf
); );
return S_OK; return S_OK;
...@@ -1407,7 +1408,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) ...@@ -1407,7 +1408,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
} }
/* No need to marshal other data than FIN and any VT_PTR. */ /* No need to marshal other data than FIN and any VT_PTR. */
if (!is_in_elem(elem) && (elem->tdesc.vt != 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]"); if (relaydeb) TRACE_(olerelay)("[out]");
continue; continue;
} }
...@@ -1425,7 +1426,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) ...@@ -1425,7 +1426,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
ERR("Failed to serialize param, hres %x\n",hres); ERR("Failed to serialize param, hres %x\n",hres);
break; break;
} }
xargs+=_argsize(elem->tdesc.vt); xargs+=_argsize(&elem->tdesc, tinfo);
} }
if (relaydeb) TRACE_(olerelay)(")"); if (relaydeb) TRACE_(olerelay)(")");
...@@ -1466,7 +1467,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) ...@@ -1466,7 +1467,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
} }
/* No need to marshal other data than FOUT and any VT_PTR */ /* No need to marshal other data than FOUT and any VT_PTR */
if (!is_out_elem(elem) && (elem->tdesc.vt != 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]"); if (relaydeb) TRACE_(olerelay)("[in]");
continue; continue;
} }
...@@ -1484,7 +1485,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) ...@@ -1484,7 +1485,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
status = hres; status = hres;
break; break;
} }
xargs += _argsize(elem->tdesc.vt); xargs += _argsize(&elem->tdesc, tinfo);
} }
hres = xbuf_get(&buf, (LPBYTE)&remoteresult, sizeof(DWORD)); hres = xbuf_get(&buf, (LPBYTE)&remoteresult, sizeof(DWORD));
...@@ -1725,7 +1726,7 @@ static HRESULT init_proxy_entry_point(TMProxyImpl *proxy, unsigned int num) ...@@ -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 */ /* some args take more than 4 byte on the stack */
nrofargs = 0; nrofargs = 0;
for (j=0;j<fdesc->cParams;j++) for (j=0;j<fdesc->cParams;j++)
nrofargs += _argsize(fdesc->lprgelemdescParam[j].tdesc.vt); nrofargs += _argsize(&fdesc->lprgelemdescParam[j].tdesc, proxy->tinfo);
#ifdef __i386__ #ifdef __i386__
if (fdesc->callconv != CC_STDCALL) { if (fdesc->callconv != CC_STDCALL) {
...@@ -2055,7 +2056,7 @@ TMStubImpl_Invoke( ...@@ -2055,7 +2056,7 @@ TMStubImpl_Invoke(
/*dump_FUNCDESC(fdesc);*/ /*dump_FUNCDESC(fdesc);*/
nrofargs = 0; nrofargs = 0;
for (i=0;i<fdesc->cParams;i++) for (i=0;i<fdesc->cParams;i++)
nrofargs += _argsize(fdesc->lprgelemdescParam[i].tdesc.vt); nrofargs += _argsize(&fdesc->lprgelemdescParam[i].tdesc, tinfo);
args = HeapAlloc(GetProcessHeap(),0,(nrofargs+1)*sizeof(DWORD)); args = HeapAlloc(GetProcessHeap(),0,(nrofargs+1)*sizeof(DWORD));
if (!args) if (!args)
{ {
...@@ -2077,7 +2078,7 @@ TMStubImpl_Invoke( ...@@ -2077,7 +2078,7 @@ TMStubImpl_Invoke(
xargs, xargs,
&buf &buf
); );
xargs += _argsize(elem->tdesc.vt); xargs += _argsize(&elem->tdesc, tinfo);
if (hres) { if (hres) {
ERR("Failed to deserialize param %s, hres %x\n",relaystr(names[i+1]),hres); ERR("Failed to deserialize param %s, hres %x\n",relaystr(names[i+1]),hres);
break; break;
...@@ -2123,7 +2124,7 @@ TMStubImpl_Invoke( ...@@ -2123,7 +2124,7 @@ TMStubImpl_Invoke(
xargs, xargs,
&buf &buf
); );
xargs += _argsize(elem->tdesc.vt); xargs += _argsize(&elem->tdesc, tinfo);
if (hres) { if (hres) {
ERR("Failed to stuballoc param, hres %x\n",hres); ERR("Failed to stuballoc param, hres %x\n",hres);
break; break;
......
...@@ -5483,7 +5483,32 @@ _invoke(FARPROC func,CALLCONV callconv, int nrargs, DWORD *args) { ...@@ -5483,7 +5483,32 @@ _invoke(FARPROC func,CALLCONV callconv, int nrargs, DWORD *args) {
return res; 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) static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt)
{ {
...@@ -5671,9 +5696,9 @@ DispCallFunc( ...@@ -5671,9 +5696,9 @@ DispCallFunc(
for (i=0;i<cActuals;i++) for (i=0;i<cActuals;i++)
{ {
TRACE("arg %d: type %d, size %d\n",i,prgvt[i],_argsize(prgvt[i])); TRACE("arg %d: type %d, size %d\n",i,prgvt[i],_dispargsize(prgvt[i]));
dump_Variant(prgpvarg[i]); dump_Variant(prgpvarg[i]);
argsize += _argsize(prgvt[i]); argsize += _dispargsize(prgvt[i]);
} }
args = HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*argsize); args = HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*argsize);
...@@ -5689,10 +5714,10 @@ DispCallFunc( ...@@ -5689,10 +5714,10 @@ DispCallFunc(
VARIANT *arg = prgpvarg[i]; VARIANT *arg = prgpvarg[i];
TRACE("Storing arg %d (%d as %d)\n",i,V_VT(arg),prgvt[i]); TRACE("Storing arg %d (%d as %d)\n",i,V_VT(arg),prgvt[i]);
if (prgvt[i] == VT_VARIANT) if (prgvt[i] == VT_VARIANT)
memcpy(&args[argspos], arg, _argsize(prgvt[i]) * sizeof(DWORD)); memcpy(&args[argspos], arg, _dispargsize(prgvt[i]) * sizeof(DWORD));
else else
memcpy(&args[argspos], &V_NONE(arg), _argsize(prgvt[i]) * sizeof(DWORD)); memcpy(&args[argspos], &V_NONE(arg), _dispargsize(prgvt[i]) * sizeof(DWORD));
argspos += _argsize(prgvt[i]); argspos += _dispargsize(prgvt[i]);
} }
if (pvInstance) if (pvInstance)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment