- Read DLL name from modules in MSFT typelibs.

- A name offset of -1 for a parameter means that it has the same name
  as the function.
- Print an error if a ReadName is attempted with an offset of -1,
  since this will read garbage.
- Implement ITypeInfo_GetDllEntry.
This commit is contained in:
Robert Shearman 2005-10-29 10:30:57 +00:00 committed by Alexandre Julliard
parent 1f2a9e2c31
commit 0033a5a8e7
2 changed files with 40 additions and 12 deletions

View File

@ -979,6 +979,7 @@ typedef struct tagITypeInfoImpl
*/ */
BSTR Name; BSTR Name;
BSTR DocString; BSTR DocString;
BSTR DllName;
unsigned long dwHelpContext; unsigned long dwHelpContext;
unsigned long dwHelpStringContext; unsigned long dwHelpStringContext;
@ -1275,6 +1276,7 @@ static void dump_TypeInfo(ITypeInfoImpl * pty)
pty->TypeAttr.cFuncs, pty->TypeAttr.cVars, pty->TypeAttr.cImplTypes); pty->TypeAttr.cFuncs, pty->TypeAttr.cVars, pty->TypeAttr.cImplTypes);
TRACE("parent tlb:%p index in TLB:%u\n",pty->pTypeLib, pty->index); TRACE("parent tlb:%p index in TLB:%u\n",pty->pTypeLib, pty->index);
TRACE("%s %s\n", debugstr_w(pty->Name), debugstr_w(pty->DocString)); TRACE("%s %s\n", debugstr_w(pty->Name), debugstr_w(pty->DocString));
if (pty->TypeAttr.typekind == TKIND_MODULE) TRACE("dllname:%s\n", debugstr_w(pty->DllName));
dump_TLBFuncDesc(pty->funclist); dump_TLBFuncDesc(pty->funclist);
dump_TLBVarDesc(pty->varlist); dump_TLBVarDesc(pty->varlist);
dump_TLBImplType(pty->impltypelist); dump_TLBImplType(pty->impltypelist);
@ -1437,6 +1439,11 @@ static BSTR MSFT_ReadName( TLBContext *pcx, int offset)
WCHAR* pwstring = NULL; WCHAR* pwstring = NULL;
BSTR bstrName = NULL; BSTR bstrName = NULL;
if (offset < 0)
{
ERR_(typelib)("bad offset %d\n", offset);
return NULL;
}
MSFT_ReadLEDWords(&niName, sizeof(niName), pcx, MSFT_ReadLEDWords(&niName, sizeof(niName), pcx,
pcx->pTblDir->pNametab.offset+offset); pcx->pTblDir->pNametab.offset+offset);
niName.namelen &= 0xFF; /* FIXME: correct ? */ niName.namelen &= 0xFF; /* FIXME: correct ? */
@ -1765,7 +1772,16 @@ MSFT_DoFuncs(TLBContext* pcx,
(*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags = paraminfo.Flags; (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags = paraminfo.Flags;
(*pptfd)->pParamDesc[j].Name = (void *) paraminfo.oName; /* name */
if (paraminfo.oName == -1)
/* this occurs for [propput] or [propget] methods, so
* we should just set the name of the parameter to the
* name of the method. */
(*pptfd)->pParamDesc[j].Name = SysAllocString((*pptfd)->Name);
else
(*pptfd)->pParamDesc[j].Name =
MSFT_ReadName( pcx, paraminfo.oName );
TRACE_(typelib)("param[%d] = %s\n", j, debugstr_w((*pptfd)->pParamDesc[j].Name));
/* SEEK value = jump to offset, /* SEEK value = jump to offset,
* from there jump to the end of record, * from there jump to the end of record,
@ -1844,10 +1860,6 @@ MSFT_DoFuncs(TLBContext* pcx,
/* second time around */ /* second time around */
for(j=0;j<pFuncRec->nrargs;j++) for(j=0;j<pFuncRec->nrargs;j++)
{ {
/* name */
(*pptfd)->pParamDesc[j].Name =
MSFT_ReadName( pcx, (int)(*pptfd)->pParamDesc[j].Name );
/* default value */ /* default value */
if ( (PARAMFLAG_FHASDEFAULT & if ( (PARAMFLAG_FHASDEFAULT &
(*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) && (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) &&
@ -2029,6 +2041,7 @@ static ITypeInfoImpl * MSFT_DoTypeInfo(
ptiRet = (ITypeInfoImpl*) ITypeInfo_Constructor(); ptiRet = (ITypeInfoImpl*) ITypeInfo_Constructor();
MSFT_ReadLEDWords(&tiBase, sizeof(tiBase) ,pcx , MSFT_ReadLEDWords(&tiBase, sizeof(tiBase) ,pcx ,
pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase)); pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase));
/* this is where we are coming from */ /* this is where we are coming from */
ptiRet->pTypeLib = pLibInfo; ptiRet->pTypeLib = pLibInfo;
ptiRet->index=count; ptiRet->index=count;
@ -2064,6 +2077,10 @@ static ITypeInfoImpl * MSFT_DoTypeInfo(
ptiRet->DocString=MSFT_ReadString(pcx, tiBase.docstringoffs); ptiRet->DocString=MSFT_ReadString(pcx, tiBase.docstringoffs);
ptiRet->dwHelpStringContext=tiBase.helpstringcontext; ptiRet->dwHelpStringContext=tiBase.helpstringcontext;
ptiRet->dwHelpContext=tiBase.helpcontext; ptiRet->dwHelpContext=tiBase.helpcontext;
if (ptiRet->TypeAttr.typekind == TKIND_MODULE)
ptiRet->DllName = MSFT_ReadString(pcx, tiBase.datatype1);
/* note: InfoType's Help file and HelpStringDll come from the containing /* note: InfoType's Help file and HelpStringDll come from the containing
* library. Further HelpString and Docstring appear to be the same thing :( * library. Further HelpString and Docstring appear to be the same thing :(
*/ */
@ -4160,6 +4177,12 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface)
This->DocString = 0; This->DocString = 0;
} }
if (This->DllName)
{
SysFreeString(This->DllName);
This->DllName = 0;
}
if (This->next) if (This->next)
{ {
ITypeInfo_Release((ITypeInfo*)This->next); ITypeInfo_Release((ITypeInfo*)This->next);
@ -5171,18 +5194,22 @@ static HRESULT WINAPI ITypeInfo_fnGetDllEntry( ITypeInfo2 *iface, MEMBERID memid
ITypeInfoImpl *This = (ITypeInfoImpl *)iface; ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
TLBFuncDesc *pFDesc; TLBFuncDesc *pFDesc;
FIXME("(%p, memid %lx, %d, %p, %p, %p), partial stub!\n", This, memid, invKind, pBstrDllName, pBstrName, pwOrdinal); TRACE("(%p)->(memid %lx, %d, %p, %p, %p)\n", This, memid, invKind, pBstrDllName, pBstrName, pwOrdinal);
if (pBstrDllName) *pBstrDllName = NULL;
if (pBstrName) *pBstrName = NULL;
if (pwOrdinal) *pwOrdinal = 0;
if (This->TypeAttr.typekind != TKIND_MODULE)
return TYPE_E_BADMODULEKIND;
for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next)
if(pFDesc->funcdesc.memid==memid){ if(pFDesc->funcdesc.memid==memid){
dump_TypeInfo(This); dump_TypeInfo(This);
dump_TLBFuncDescOne(pFDesc); dump_TLBFuncDescOne(pFDesc);
/* FIXME: This is wrong, but how do you find that out? */ if (pBstrDllName)
if (pBstrDllName) { *pBstrDllName = SysAllocString(This->DllName);
static const WCHAR oleaut32W[] = {'O','L','E','A','U','T','3','2','.','D','L','L',0};
*pBstrDllName = SysAllocString(oleaut32W);
}
if (HIWORD(pFDesc->Entry) && (pFDesc->Entry != (void*)-1)) { if (HIWORD(pFDesc->Entry) && (pFDesc->Entry != (void*)-1)) {
if (pBstrName) if (pBstrName)
@ -5197,7 +5224,7 @@ static HRESULT WINAPI ITypeInfo_fnGetDllEntry( ITypeInfo2 *iface, MEMBERID memid
*pwOrdinal = (DWORD)pFDesc->Entry; *pwOrdinal = (DWORD)pFDesc->Entry;
return S_OK; return S_OK;
} }
return E_FAIL; return TYPE_E_ELEMENTNOTFOUND;
} }
/* ITypeInfo::GetRefTypeInfo /* ITypeInfo::GetRefTypeInfo

View File

@ -152,6 +152,7 @@ typedef struct tagMSFT_TypeInfoBase {
/* or in base intefaces */ /* or in base intefaces */
/* if coclass: offset in reftable */ /* if coclass: offset in reftable */
/* if interface: reference to inherited if */ /* if interface: reference to inherited if */
/* if module: offset to dllname in name table */
INT datatype2; /* if 0x8000, entry above is valid */ INT datatype2; /* if 0x8000, entry above is valid */
/* actually dunno */ /* actually dunno */
/* else it is zero? */ /* else it is zero? */