oleaut: Fix importing the IDispatch interface for TKIND_DISPATCH type infos.

Fix importing the IDispatch interface for TKIND_DISPATCH type infos
when the offset isn't specified. It should be fetched from the
dispatch offset stored in the header, rather than using a hack that
doesn't work.
This commit is contained in:
Robert Shearman 2006-02-10 14:50:53 +01:00 committed by Alexandre Julliard
parent bcac0cd5d5
commit 265f042801
1 changed files with 12 additions and 36 deletions

View File

@ -1964,6 +1964,7 @@ static void MSFT_DoRefType(TLBContext *pcx, ITypeInfoImpl *pTI,
(*ppRefType)->pImpTLInfo = pImpLib; (*ppRefType)->pImpTLInfo = pImpLib;
if(impinfo.flags & MSFT_IMPINFO_OFFSET_IS_GUID) { if(impinfo.flags & MSFT_IMPINFO_OFFSET_IS_GUID) {
MSFT_ReadGuid(&(*ppRefType)->guid, impinfo.oGuid, pcx); MSFT_ReadGuid(&(*ppRefType)->guid, impinfo.oGuid, pcx);
TRACE("importing by guid %s\n", debugstr_guid(&(*ppRefType)->guid));
(*ppRefType)->index = TLB_REF_USE_GUID; (*ppRefType)->index = TLB_REF_USE_GUID;
} else } else
(*ppRefType)->index = impinfo.oGuid; (*ppRefType)->index = impinfo.oGuid;
@ -2009,6 +2010,7 @@ static void MSFT_DoImplTypes(TLBContext *pcx, ITypeInfoImpl *pTI, int count,
static ITypeInfoImpl * MSFT_DoTypeInfo( static ITypeInfoImpl * MSFT_DoTypeInfo(
TLBContext *pcx, TLBContext *pcx,
int count, int count,
INT dispatch_href,
ITypeLibImpl * pLibInfo) ITypeLibImpl * pLibInfo)
{ {
MSFT_TypeInfoBase tiBase; MSFT_TypeInfoBase tiBase;
@ -2089,38 +2091,10 @@ static ITypeInfoImpl * MSFT_DoTypeInfo(
ptiRet->impltypelist->hRef = tiBase.datatype1; ptiRet->impltypelist->hRef = tiBase.datatype1;
} }
else else
{ /* FIXME: This is a really bad hack to add IDispatch */ {
const char* szStdOle = "stdole2.tlb\0"; MSFT_DoRefType(pcx, ptiRet, dispatch_href);
int nStdOleLen = strlen(szStdOle); ptiRet->impltypelist->hRef = dispatch_href;
TLBRefType **ppRef = &ptiRet->reflist; }
while(*ppRef) {
if((*ppRef)->reference == -1)
break;
ppRef = &(*ppRef)->next;
}
if(!*ppRef) {
*ppRef = TLB_Alloc(sizeof(**ppRef));
(*ppRef)->guid = IID_IDispatch;
(*ppRef)->reference = -1;
(*ppRef)->index = TLB_REF_USE_GUID;
(*ppRef)->pImpTLInfo = TLB_Alloc(sizeof(TLBImpLib));
(*ppRef)->pImpTLInfo->guid = IID_StdOle;
(*ppRef)->pImpTLInfo->name = SysAllocStringLen(NULL,
nStdOleLen + 1);
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED,
szStdOle,
-1,
(*ppRef)->pImpTLInfo->name,
SysStringLen((*ppRef)->pImpTLInfo->name));
(*ppRef)->pImpTLInfo->lcid = 0;
(*ppRef)->pImpTLInfo->wVersionMajor = 2;
(*ppRef)->pImpTLInfo->wVersionMinor = 0;
}
}
break; break;
default: default:
ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType)); ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType));
@ -2342,12 +2316,14 @@ static ITypeLib2* ITypeLib2_Constructor_MSFT(LPVOID pLib, DWORD dwTLBLength)
/* read header */ /* read header */
MSFT_ReadLEDWords((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0); MSFT_ReadLEDWords((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);
TRACE("header:\n"); TRACE_(typelib)("header:\n");
TRACE("\tmagic1=0x%08x ,magic2=0x%08x\n",tlbHeader.magic1,tlbHeader.magic2 ); TRACE_(typelib)("\tmagic1=0x%08x ,magic2=0x%08x\n",tlbHeader.magic1,tlbHeader.magic2 );
if (tlbHeader.magic1 != MSFT_SIGNATURE) { if (tlbHeader.magic1 != MSFT_SIGNATURE) {
FIXME("Header type magic 0x%08x not supported.\n",tlbHeader.magic1); FIXME("Header type magic 0x%08x not supported.\n",tlbHeader.magic1);
return NULL; return NULL;
} }
TRACE_(typelib)("\tdispatchpos = 0x%x\n", tlbHeader.dispatchpos);
/* there is a small amount of information here until the next important /* there is a small amount of information here until the next important
* part: * part:
* the segment directory . Try to calculate the amount of data */ * the segment directory . Try to calculate the amount of data */
@ -2512,7 +2488,7 @@ static ITypeLib2* ITypeLib2_Constructor_MSFT(LPVOID pLib, DWORD dwTLBLength)
for(i = 0; i<(int)tlbHeader.nrtypeinfos; i++) for(i = 0; i<(int)tlbHeader.nrtypeinfos; i++)
{ {
*ppTI = MSFT_DoTypeInfo(&cx, i, pTypeLibImpl); *ppTI = MSFT_DoTypeInfo(&cx, i, tlbHeader.dispatchpos, pTypeLibImpl);
ppTI = &((*ppTI)->next); ppTI = &((*ppTI)->next);
(pTypeLibImpl->TypeInfoCount)++; (pTypeLibImpl->TypeInfoCount)++;