From 22022d13d154b194d328294f31db7dc13a09d0d8 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 27 Dec 2010 03:43:19 +0300 Subject: [PATCH] oleaut32: Get rid of some magic offset values, use structure for that. --- dlls/oleaut32/typelib.c | 25 ++++++++++++++----------- dlls/oleaut32/typelib.h | 3 +-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 36328a63822..72e19327d3a 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -2094,7 +2094,7 @@ static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs, { int infolen, nameoffset, reclength; char recbuf[256]; - MSFT_VarRecord * pVarRec=(MSFT_VarRecord *) recbuf; + MSFT_VarRecord *pVarRec = (MSFT_VarRecord*)recbuf; int i; int recoffset; @@ -2111,17 +2111,20 @@ static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs, offset + infolen + (2*cFuncs + cVars + i + 1) * sizeof(INT)); (*pptvd)->Name=MSFT_ReadName(pcx, nameoffset); /* read the variable information record */ - MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset); - reclength &=0xff; - MSFT_ReadLEDWords(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK); - /* Optional data */ - if(reclength >(6*sizeof(INT)) ) - (*pptvd)->HelpContext=pVarRec->HelpContext; - if(reclength >(7*sizeof(INT)) ) + MSFT_ReadLEDWords(&reclength, sizeof(pVarRec->Info), pcx, recoffset); + reclength &= 0xff; + MSFT_ReadLEDWords(&pVarRec->DataType, reclength - FIELD_OFFSET(MSFT_VarRecord, DataType), pcx, DO_NOT_SEEK); + + /* optional data */ + if(reclength > FIELD_OFFSET(MSFT_VarRecord, HelpContext)) + (*pptvd)->HelpContext = pVarRec->HelpContext; + + if(reclength > FIELD_OFFSET(MSFT_VarRecord, oHelpString)) (*pptvd)->HelpString = MSFT_ReadString(pcx, pVarRec->oHelpString) ; - if(reclength >(8*sizeof(INT)) ) - if(reclength >(9*sizeof(INT)) ) - (*pptvd)->HelpStringContext=pVarRec->HelpStringContext; + + if(reclength > FIELD_OFFSET(MSFT_VarRecord, HelpStringContext)) + (*pptvd)->HelpStringContext = pVarRec->HelpStringContext; + /* fill the VarDesc Structure */ MSFT_ReadLEDWords(&(*pptvd)->vardesc.memid, sizeof(INT), pcx, offset + infolen + (cFuncs + i + 1) * sizeof(INT)); diff --git a/dlls/oleaut32/typelib.h b/dlls/oleaut32/typelib.h index 3b5f09b6110..210db33f1bd 100644 --- a/dlls/oleaut32/typelib.h +++ b/dlls/oleaut32/typelib.h @@ -231,7 +231,7 @@ typedef struct { /* Variable description data */ typedef struct { -/* INT recsize; // record size including some xtra stuff */ + INT Info; /* record size including some extra stuff */ INT DataType; /* data type of the variable */ INT Flags; /* VarFlags (LOWORD) */ #ifdef WORDS_BIGENDIAN @@ -250,7 +250,6 @@ typedef struct { INT res9; /* unknown (-1) */ INT oCustData; /* custom data for variable */ INT HelpStringContext; - } MSFT_VarRecord; /* Structure of the reference data */