Commit b3514b47 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32: Use function description layout instead of hardcoded byte offsets.

parent 7234ddd2
...@@ -1906,11 +1906,11 @@ MSFT_DoFuncs(TLBContext* pcx, ...@@ -1906,11 +1906,11 @@ MSFT_DoFuncs(TLBContext* pcx,
* in the first part of this file segment. * in the first part of this file segment.
*/ */
int infolen, nameoffset, reclength, nrattributes, i; int infolen, nameoffset, reclength, i;
int recoffset = offset + sizeof(INT); int recoffset = offset + sizeof(INT);
char *recbuf = HeapAlloc(GetProcessHeap(), 0, 0xffff); char *recbuf = HeapAlloc(GetProcessHeap(), 0, 0xffff);
MSFT_FuncRecord * pFuncRec=(MSFT_FuncRecord *) recbuf; MSFT_FuncRecord *pFuncRec = (MSFT_FuncRecord*)recbuf;
TLBFuncDesc *ptfd_prev = NULL; TLBFuncDesc *ptfd_prev = NULL;
TRACE_(typelib)("\n"); TRACE_(typelib)("\n");
...@@ -1919,6 +1919,8 @@ MSFT_DoFuncs(TLBContext* pcx, ...@@ -1919,6 +1919,8 @@ MSFT_DoFuncs(TLBContext* pcx,
for ( i = 0; i < cFuncs ; i++ ) for ( i = 0; i < cFuncs ; i++ )
{ {
int optional;
*pptfd = TLB_Alloc(sizeof(TLBFuncDesc)); *pptfd = TLB_Alloc(sizeof(TLBFuncDesc));
/* name, eventually add to a hash table */ /* name, eventually add to a hash table */
...@@ -1933,56 +1935,40 @@ MSFT_DoFuncs(TLBContext* pcx, ...@@ -1933,56 +1935,40 @@ MSFT_DoFuncs(TLBContext* pcx,
(*pptfd)->Name = MSFT_ReadName(pcx, nameoffset); (*pptfd)->Name = MSFT_ReadName(pcx, nameoffset);
/* read the function information record */ /* read the function information record */
MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset); MSFT_ReadLEDWords(&reclength, sizeof(pFuncRec->Info), pcx, recoffset);
reclength &= 0xffff; reclength &= 0xffff;
MSFT_ReadLEDWords(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK); MSFT_ReadLEDWords(&pFuncRec->DataType, reclength - FIELD_OFFSET(MSFT_FuncRecord, DataType), pcx, DO_NOT_SEEK);
/* do the attributes */ /* size without argument data */
nrattributes = (reclength - pFuncRec->nrargs * 3 * sizeof(int) - 0x18) optional = reclength - pFuncRec->nrargs*sizeof(MSFT_ParameterInfo);
/ sizeof(int);
if ( nrattributes > 0 ) if (optional > FIELD_OFFSET(MSFT_FuncRecord, HelpContext))
{ (*pptfd)->helpcontext = pFuncRec->HelpContext;
(*pptfd)->helpcontext = pFuncRec->OptAttr[0] ;
if ( nrattributes > 1 ) if (optional > FIELD_OFFSET(MSFT_FuncRecord, oHelpString))
{ (*pptfd)->HelpString = MSFT_ReadString(pcx, pFuncRec->oHelpString);
(*pptfd)->HelpString = MSFT_ReadString(pcx,
pFuncRec->OptAttr[1]) ;
if ( nrattributes > 2 ) if (optional > FIELD_OFFSET(MSFT_FuncRecord, oEntry))
{ {
if ( pFuncRec->FKCCIC & 0x2000 ) if (pFuncRec->FKCCIC & 0x2000 )
{ {
if (!IS_INTRESOURCE(pFuncRec->OptAttr[2])) if (!IS_INTRESOURCE(pFuncRec->oEntry))
ERR("ordinal 0x%08x invalid, IS_INTRESOURCE is false\n", pFuncRec->OptAttr[2]); ERR("ordinal 0x%08x invalid, IS_INTRESOURCE is false\n", pFuncRec->oEntry);
(*pptfd)->Entry = (BSTR)(DWORD_PTR)LOWORD(pFuncRec->OptAttr[2]); (*pptfd)->Entry = (BSTR)(DWORD_PTR)LOWORD(pFuncRec->oEntry);
} }
else else
{ (*pptfd)->Entry = MSFT_ReadString(pcx, pFuncRec->oEntry);
(*pptfd)->Entry = MSFT_ReadString(pcx,
pFuncRec->OptAttr[2]);
}
if( nrattributes > 5 )
{
(*pptfd)->HelpStringContext = pFuncRec->OptAttr[5] ;
if ( nrattributes > 6 && pFuncRec->FKCCIC & 0x80 )
{
MSFT_CustData(pcx,
pFuncRec->OptAttr[6],
&(*pptfd)->pCustData);
}
}
} }
else else
{
(*pptfd)->Entry = (BSTR)-1; (*pptfd)->Entry = (BSTR)-1;
}
} if (optional > FIELD_OFFSET(MSFT_FuncRecord, HelpStringContext))
} (*pptfd)->HelpStringContext = pFuncRec->HelpStringContext;
if (optional > FIELD_OFFSET(MSFT_FuncRecord, oCustData) && pFuncRec->FKCCIC & 0x80)
MSFT_CustData(pcx, pFuncRec->oCustData, &(*pptfd)->pCustData);
/* fill the FuncDesc Structure */ /* fill the FuncDesc Structure */
MSFT_ReadLEDWords( & (*pptfd)->funcdesc.memid, sizeof(INT), pcx, MSFT_ReadLEDWords( & (*pptfd)->funcdesc.memid, sizeof(INT), pcx,
...@@ -2047,7 +2033,7 @@ MSFT_DoFuncs(TLBContext* pcx, ...@@ -2047,7 +2033,7 @@ MSFT_DoFuncs(TLBContext* pcx,
{ {
INT* pInt = (INT *)((char *)pFuncRec + INT* pInt = (INT *)((char *)pFuncRec +
reclength - reclength -
(pFuncRec->nrargs * 4 + 1) * sizeof(INT) ); (pFuncRec->nrargs * 4) * sizeof(INT) );
PARAMDESC* pParamDesc = &elemdesc->u.paramdesc; PARAMDESC* pParamDesc = &elemdesc->u.paramdesc;
...@@ -2059,11 +2045,14 @@ MSFT_DoFuncs(TLBContext* pcx, ...@@ -2059,11 +2045,14 @@ MSFT_DoFuncs(TLBContext* pcx,
} }
else else
elemdesc->u.paramdesc.pparamdescex = NULL; elemdesc->u.paramdesc.pparamdescex = NULL;
/* custom info */ /* custom info */
if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 ) if (optional > (FIELD_OFFSET(MSFT_FuncRecord, oArgCustData) +
j*sizeof(pFuncRec->oArgCustData[0])) &&
pFuncRec->FKCCIC & 0x80 )
{ {
MSFT_CustData(pcx, MSFT_CustData(pcx,
pFuncRec->OptAttr[7+j], pFuncRec->oArgCustData[j],
&(*pptfd)->pParamDesc[j].pCustData); &(*pptfd)->pParamDesc[j].pCustData);
} }
...@@ -2120,7 +2109,7 @@ static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs, ...@@ -2120,7 +2109,7 @@ static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs,
(*pptvd)->HelpContext = pVarRec->HelpContext; (*pptvd)->HelpContext = pVarRec->HelpContext;
if(reclength > FIELD_OFFSET(MSFT_VarRecord, oHelpString)) if(reclength > FIELD_OFFSET(MSFT_VarRecord, oHelpString))
(*pptvd)->HelpString = MSFT_ReadString(pcx, pVarRec->oHelpString) ; (*pptvd)->HelpString = MSFT_ReadString(pcx, pVarRec->oHelpString);
if(reclength > FIELD_OFFSET(MSFT_VarRecord, HelpStringContext)) if(reclength > FIELD_OFFSET(MSFT_VarRecord, HelpStringContext))
(*pptvd)->HelpStringContext = pVarRec->HelpStringContext; (*pptvd)->HelpStringContext = pVarRec->HelpStringContext;
......
...@@ -177,7 +177,7 @@ typedef struct tagMSFT_ImpInfo { ...@@ -177,7 +177,7 @@ typedef struct tagMSFT_ImpInfo {
/* function description data */ /* function description data */
typedef struct { typedef struct {
/* INT recsize; record size including some xtra stuff */ INT Info; /* record size including some extra stuff */
INT DataType; /* data type of the member, eg return of function */ INT DataType; /* data type of the member, eg return of function */
INT Flags; /* something to do with attribute flags (LOWORD) */ INT Flags; /* something to do with attribute flags (LOWORD) */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
...@@ -202,19 +202,17 @@ typedef struct { ...@@ -202,19 +202,17 @@ typedef struct {
INT16 nrargs; /* number of arguments (including optional ????) */ INT16 nrargs; /* number of arguments (including optional ????) */
INT16 nroargs; /* nr of optional arguments */ INT16 nroargs; /* nr of optional arguments */
#endif #endif
/* optional attribute fields, the number of them is variable */ /* optional attribute fields, the number of them is variable */
INT OptAttr[1]; INT HelpContext;
/* INT oHelpString;
0* INT helpcontext; INT oEntry; /* either offset in string table or numeric as it is */
1* INT oHelpString; INT res9; /* unknown (-1) */
2* INT oEntry; // either offset in string table or numeric as it is // INT resA; /* unknown (-1) */
3* INT res9; // unknown (-1) // INT HelpStringContext;
4* INT resA; // unknown (-1) // /* these are controlled by a bit set in the FKCCIC field */
5* INT HelpStringContext; INT oCustData; /* custom data for function */
// these are controlled by a bit set in the FKCCIC field // INT oArgCustData[1]; /* custom data per argument */
6* INT oCustData; // custom data for function //
7* INT oArgCustData[1]; // custom data per argument //
*/
} MSFT_FuncRecord; } MSFT_FuncRecord;
/* after this may follow an array with default value pointers if the /* after this may follow an array with default value pointers if the
......
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