- Timestamp:
- Sep 9, 2001, 10:45:20 PM (24 years ago)
- Location:
- trunk/src/oleaut32
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/oleaut32/connpt.c
r6648 r6689 1 /* $Id: connpt.c,v 1.2 2001-09-05 13:18:59 bird Exp $ */2 1 /* 3 2 * Implementation of a generic ConnectionPoint object. -
trunk/src/oleaut32/dispatch.c
r6648 r6689 1 /* $Id: dispatch.c,v 1.2 2001-09-05 13:19:00 bird Exp $ */2 1 /** 3 2 * Dispatch API functions -
trunk/src/oleaut32/initterm.cpp
r6648 r6689 1 /* $Id: initterm.cpp,v 1.10 2001-09-05 13:19:00 bird Exp $ */2 1 /* 3 2 * DLL entry point -
trunk/src/oleaut32/ole2disp.c
r6648 r6689 1 /* $Id: ole2disp.c,v 1.2 2001-09-05 13:19:00 bird Exp $ */2 1 /* 3 2 * OLE2DISP library -
trunk/src/oleaut32/oleaut.c
r6648 r6689 1 /* $Id: oleaut.c,v 1.2 2001-09-05 13:19:00 bird Exp $ */2 1 /* 3 2 * OLEAUT32 -
trunk/src/oleaut32/olefont.c
r6648 r6689 1 /* $Id: olefont.c,v 1.3 2001-09-05 13:19:00 bird Exp $ */2 1 /* 3 2 * OLE Font encapsulation implementation -
trunk/src/oleaut32/olepicture.c
r6648 r6689 1 /* $Id: olepicture.c,v 1.5 2001-09-05 13:19:01 bird Exp $ */2 1 /* 3 2 * OLE Picture object -
trunk/src/oleaut32/parsedt.c
r6648 r6689 1 /* $Id: parsedt.c,v 1.2 2001-09-05 13:19:01 bird Exp $ */2 1 /* 3 2 PostgreSQL Data Base Management System (formerly known as Postgres, then -
trunk/src/oleaut32/safearray.c
r6648 r6689 1 /* $Id: safearray.c,v 1.3 2001-09-05 13:19:01 bird Exp $ */2 1 /************************************************************************* 3 2 * OLE Automation -
trunk/src/oleaut32/typelib.c
r6648 r6689 1 /* $Id: typelib.c,v 1.6 2001-09-05 13:19:01 bird Exp $ */2 1 /* 3 * TYPELIB 4 * 5 * Copyright 1997 Marcus Meissner 6 * 1999 Rein Klazes 7 * 2000 Francois Jacques 2 * TYPELIB 3 * 4 * Copyright 1997 Marcus Meissner 5 * 1999 Rein Klazes 6 * 2000 Francois Jacques 7 * 2001 Huw D M Davies for CodeWeavers 8 * 8 9 * -------------------------------------------------------------------------------------- 9 10 * Known problems (2000, Francois Jacques) 10 11 * 11 12 * - Tested using OLEVIEW (Platform SDK tool) only. 12 * 13 * - dual interface dispinterfaces. vtable-interface ITypeInfo instances are 14 * creating by doing a straight copy of the dispinterface instance and just changing 13 * 14 * - dual interface dispinterfaces. vtable-interface ITypeInfo instances are 15 * creating by doing a straight copy of the dispinterface instance and just changing 15 16 * its typekind. Pointed structures aren't copied - only the address of the pointers. 16 17 * So when you release the dispinterface, you delete the vtable-interface structures 17 18 * as well... fortunately, clean up of structures is not implemented. 18 * 19 * 19 20 * - locale stuff is partially implemented but hasn't been tested. 20 21 * 21 * - imported typelib should be stored together in a linked list instead of having 22 * independant TLBImpLib structures in each ITypeInfo. This way, imported libraries 23 * are just imported once (major optimization) 24 * 25 * - typelib file is still read it's in entirety, but it is released now. 26 * - some garbage is read from function names on some very rare occasion 22 * - typelib file is still read in its entirety, but it is released now. 23 * - some garbage is read from function names on some very rare occasions. 27 24 * 28 25 * -------------------------------------------------------------------------------------- 29 26 * Known problems left from previous implementation (1999, Rein Klazes) : 30 27 * 31 * -. Only one format of typelibs is supported32 28 * -. Data structures are straightforward, but slow for look-ups. 33 29 * -. (related) nothing is hashed … … 40 36 * -. some methods just return pointers to internal data structures, this is 41 37 * partly laziness, partly I want to check how windows does it. 42 * 38 * 43 39 */ 44 40 #ifdef __WIN32OS2__ … … 46 42 #define WINE_LARGE_INTEGER 47 43 #include "oleaut32.h" 48 49 44 #endif 50 45 … … 85 80 #ifndef __WIN32OS2__ 86 81 /**************************************************************************** 87 * QueryPathOfRegTypeLib[TYPELIB.14]82 * QueryPathOfRegTypeLib [TYPELIB.14] 88 83 * 89 84 * the path is "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\" 90 85 * RETURNS 91 * 86 * path of typelib 92 87 */ 93 88 HRESULT WINAPI 94 QueryPathOfRegTypeLib16( 95 REFGUID guid,/* [in] referenced guid */96 WORD wMaj,/* [in] major version */97 WORD wMin,/* [in] minor version */98 LCID lcid,/* [in] locale id */99 LPBSTR16 path/* [out] path of typelib */89 QueryPathOfRegTypeLib16( 90 REFGUID guid, /* [in] referenced guid */ 91 WORD wMaj, /* [in] major version */ 92 WORD wMin, /* [in] minor version */ 93 LCID lcid, /* [in] locale id */ 94 LPBSTR16 path /* [out] path of typelib */ 100 95 ) { 101 charxguid[80];102 chartypelibkey[100],pathname[260];103 DWORDplen;104 105 106 107 96 char xguid[80]; 97 char typelibkey[100],pathname[260]; 98 DWORD plen; 99 100 TRACE("\n"); 101 102 if (HIWORD(guid)) { 108 103 sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win16", 109 104 guid->Data1, guid->Data2, guid->Data3, … … 111 106 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7], 112 107 wMaj,wMin,lcid); 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 108 } else { 109 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid); 110 FIXME("(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,(DWORD)lcid,path); 111 return E_FAIL; 112 } 113 plen = sizeof(pathname); 114 if (RegQueryValueA(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) { 115 /* try again without lang specific id */ 116 if (SUBLANGID(lcid)) 117 return QueryPathOfRegTypeLib16(guid,wMaj,wMin,PRIMARYLANGID(lcid),path); 118 FIXME("key %s not found\n",typelibkey); 119 return E_FAIL; 120 } 121 *path = SysAllocString16(pathname); 122 return S_OK; 128 123 } 129 124 #endif 130 125 131 126 /**************************************************************************** 132 * QueryPathOfRegTypeLib[OLEAUT32.164]127 * QueryPathOfRegTypeLib [OLEAUT32.164] 133 128 * RETURNS 134 * 129 * path of typelib 135 130 */ 136 131 HRESULT WINAPI 137 QueryPathOfRegTypeLib( 138 REFGUID guid,/* [in] referenced guid */139 WORD wMaj,/* [in] major version */140 WORD wMin,/* [in] minor version */141 LCID lcid,/* [in] locale id */142 LPBSTR path )/* [out] path of typelib */132 QueryPathOfRegTypeLib( 133 REFGUID guid, /* [in] referenced guid */ 134 WORD wMaj, /* [in] major version */ 135 WORD wMin, /* [in] minor version */ 136 LCID lcid, /* [in] locale id */ 137 LPBSTR path ) /* [out] path of typelib */ 143 138 { 144 139 /* don't need to ZeroMemory those arrays since sprintf and RegQueryValue add … … 157 152 char szPath[dwPathLen]; 158 153 #endif 154 159 155 if ( !HIWORD(guid) ) 160 156 { … … 172 168 "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win32", 173 169 guid->Data1, guid->Data2, guid->Data3, 174 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], 170 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], 175 171 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7], 176 172 wMaj, … … 212 208 } 213 209 } 214 210 215 211 if (hr != S_OK) 216 217 212 TRACE_(typelib)("%s not found\n", szTypeLibKey); 213 218 214 return hr; 219 215 } … … 227 223 */ 228 224 HRESULT WINAPI CreateTypeLib( 229 225 SYSKIND syskind, LPCOLESTR szFile, ICreateTypeLib** ppctlib 230 226 ) { 231 227 FIXME("(%d,%s,%p), stub!\n",syskind,debugstr_w(szFile),ppctlib); … … 257 253 258 254 /****************************************************************************** 259 * LoadTypeLib[OLEAUT32.161]255 * LoadTypeLib [OLEAUT32.161] 260 256 * Loads and registers a type library 261 257 * NOTES … … 278 274 279 275 /****************************************************************************** 280 * LoadTypeLibEx[OLEAUT32.183]276 * LoadTypeLibEx [OLEAUT32.183] 281 277 * Loads and optionally registers a type library 282 278 * … … 290 286 ITypeLib **pptLib) /* [out] Pointer to pointer to loaded type library */ 291 287 { 292 LPSTR p; 288 LPSTR p=NULL; 289 WCHAR szPath[MAX_PATH+1]; 293 290 HRESULT res; 294 291 TRACE("(%s,%d,%p)\n",debugstr_w(szFile), regkind, pptLib); 295 296 p=HEAP_strdupWtoA(GetProcessHeap(),0,szFile); 297 298 res= TLB_ReadTypeLib(p, (ITypeLib2**)pptLib); 299 292 293 if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath,NULL)) 294 res = TYPE_E_CANTLOADLIBRARY; 295 else { 296 p=HEAP_strdupWtoA(GetProcessHeap(),0,szPath); 297 res= TLB_ReadTypeLib(p, (ITypeLib2**)pptLib); 298 } 300 299 if (SUCCEEDED(res)) 301 300 switch(regkind) … … 303 302 case REGKIND_DEFAULT: 304 303 /* FIXME: is this correct? */ 305 if (!p || !p[0] || (p[0] != '\\' && p[0] != '/' && p[1] != ':')) 304 if (!szFile || !szFile[0] || 305 (szFile[0] != '\\' && szFile[0] != '/' && szFile[1] != ':')) 306 306 break; 307 307 /* else fall-through */ … … 318 318 } 319 319 320 HeapFree(GetProcessHeap(),0,p);320 if(p) HeapFree(GetProcessHeap(),0,p); 321 321 TRACE(" returns %08lx\n",res); 322 322 return res; … … 324 324 325 325 /****************************************************************************** 326 * LoadRegTypeLib[OLEAUT32.162]327 */ 328 HRESULT WINAPI LoadRegTypeLib( 329 REFGUID rguid,/* [in] referenced guid */330 WORD wVerMajor,/* [in] major version */331 WORD wVerMinor,/* [in] minor version */332 LCID lcid,/* [in] locale id */333 ITypeLib **ppTLib)/* [out] path of typelib */326 * LoadRegTypeLib [OLEAUT32.162] 327 */ 328 HRESULT WINAPI LoadRegTypeLib( 329 REFGUID rguid, /* [in] referenced guid */ 330 WORD wVerMajor, /* [in] major version */ 331 WORD wVerMinor, /* [in] minor version */ 332 LCID lcid, /* [in] locale id */ 333 ITypeLib **ppTLib) /* [out] path of typelib */ 334 334 { 335 335 BSTR bstr=NULL; … … 345 345 346 346 return res; 347 } 347 } 348 348 349 349 350 350 /****************************************************************************** 351 * RegisterTypeLib[OLEAUT32.163]352 * Adds information about a type library to the System Registry 351 * RegisterTypeLib [OLEAUT32.163] 352 * Adds information about a type library to the System Registry 353 353 * NOTES 354 354 * Docs: ITypeLib FAR * ptlib … … 364 364 OLECHAR * szFullPath, /* [in] full Path of the library*/ 365 365 OLECHAR * szHelpDir) /* [in] dir to the helpfile for the library, 366 366 may be NULL*/ 367 367 { 368 368 HRESULT res; … … 445 445 446 446 /****************************************************************************** 447 * UnRegisterTypeLib[OLEAUT32.186]448 * Removes information about a type library from the System Registry 447 * UnRegisterTypeLib [OLEAUT32.186] 448 * Removes information about a type library from the System Registry 449 449 * NOTES 450 450 * … … 454 454 */ 455 455 HRESULT WINAPI UnRegisterTypeLib( 456 REFGUID libid, 457 WORD wVerMajor,/* [in] major version */458 WORD wVerMinor,/* [in] minor version */459 LCID lcid,/* [in] locale id */460 461 { 456 REFGUID libid, /* [in] Guid of the library */ 457 WORD wVerMajor, /* [in] major version */ 458 WORD wVerMinor, /* [in] minor version */ 459 LCID lcid, /* [in] locale id */ 460 SYSKIND syskind) 461 { 462 462 TRACE("(IID: %s): stub\n",debugstr_guid(libid)); 463 return S_OK; 463 return S_OK; /* FIXME: pretend everything is OK */ 464 464 } 465 465 466 466 #ifndef __WIN32OS2__ 467 467 /**************************************************************************** 468 * OaBuildVersion(TYPELIB.15)468 * OaBuildVersion (TYPELIB.15) 469 469 * 470 470 * known TYPELIB.DLL versions: 471 471 * 472 * OLE 2.01 no OaBuildVersion() avail 1993 -----473 * OLE 2.02 1993-9402 3002474 * OLE 2.03 23730475 * OLE 2.03 476 * OLE 2.03 W98 SE orig. file !! 1993-9510 3024477 * OLE 2.1 NT 1993-95 ?????478 * OLE 2.3.1 W95 23700479 * OLE2 4.0 NT4SP6 1993-9840 4277472 * OLE 2.01 no OaBuildVersion() avail 1993 -- --- 473 * OLE 2.02 1993-94 02 3002 474 * OLE 2.03 23 730 475 * OLE 2.03 03 3025 476 * OLE 2.03 W98 SE orig. file !! 1993-95 10 3024 477 * OLE 2.1 NT 1993-95 ?? ??? 478 * OLE 2.3.1 W95 23 700 479 * OLE2 4.0 NT4SP6 1993-98 40 4277 480 480 */ 481 481 DWORD WINAPI OaBuildVersion16(void) … … 489 489 { 490 490 case 0x80000a03: /* WIN31 */ 491 491 return MAKELONG(3027, 3); /* WfW 3.11 */ 492 492 case 0x80000004: /* WIN95 */ 493 493 return MAKELONG(700, 23); /* Win95A */ 494 494 case 0x80000a04: /* WIN98 */ 495 495 return MAKELONG(3024, 10); /* W98 SE */ 496 496 case 0x00000004: /* NT4 */ 497 497 return MAKELONG(4277, 40); /* NT4 SP6 */ 498 498 default: 499 500 499 FIXME("Version value not known yet. Please investigate it!\n"); 500 return 0; 501 501 } 502 502 } 503 503 #endif 504 505 504 /* for better debugging info leave the static out for the time being */ 506 505 #define static … … 508 507 /*======================= ITypeLib implementation =======================*/ 509 508 510 typedef struct tagTLBCustData 509 typedef struct tagTLBCustData 511 510 { 512 511 GUID guid; … … 518 517 typedef struct tagTLBImpLib 519 518 { 520 int offset; /* offset in the file */ 519 int offset; /* offset in the file (MSFT) 520 offset in nametable (SLTG) 521 just used to identify library while reading 522 data from file */ 521 523 GUID guid; /* libid */ 522 BSTR name; /* name ;*/524 BSTR name; /* name */ 523 525 524 526 LCID lcid; /* lcid of imported typelib */ … … 527 529 WORD wVersionMinor; /* minor version number */ 528 530 529 struct tagITypeLibImpl *pImpTypeLib; /* pointer to loaded typelib */ 531 struct tagITypeLibImpl *pImpTypeLib; /* pointer to loaded typelib, or 532 NULL if not yet loaded */ 530 533 struct tagTLBImpLib * next; 531 534 } TLBImpLib; … … 537 540 UINT ref; 538 541 TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */ 539 542 540 543 /* strings can be stored in tlb as multibyte strings BUT they are *always* 541 544 * exported to the application as a UNICODE string. … … 549 552 struct tagITypeInfoImpl *pTypeInfo; /* linked list of type info data */ 550 553 int ctCustData; /* number of items in cust data list */ 551 TLBCustData * pCustData; /* linked list to cust data ;*/554 TLBCustData * pCustData; /* linked list to cust data */ 552 555 TLBImpLib * pImpLibs; /* linked list to all imported typelibs */ 553 TYPEDESC * pTypeDesc; /* array of TypeDescriptions found in the libary */ 556 TYPEDESC * pTypeDesc; /* array of TypeDescriptions found in the 557 libary. Only used while read MSFT 558 typelibs */ 554 559 } ITypeLibImpl; 555 560 … … 557 562 558 563 /* ITypeLib methods */ 559 static ITypeLib2* ITypeLib2_Constructor(LPVOID pLib, DWORD dwTLBLength); 564 static ITypeLib2* ITypeLib2_Constructor_MSFT(LPVOID pLib, DWORD dwTLBLength); 565 static ITypeLib2* ITypeLib2_Constructor_SLTG(LPVOID pLib, DWORD dwTLBLength); 560 566 561 567 /*======================= ITypeInfo implementation =======================*/ 562 568 563 /* data for refernced types in a coclass, or an inherited interface*/569 /* data for refernced types */ 564 570 typedef struct tagTLBRefType 565 571 { 572 INT index; /* Type index for internal ref or for external ref 573 it the format is SLTG. -2 indicates to 574 use guid */ 575 566 576 GUID guid; /* guid of the referenced type */ 567 /* (important if its a imported type) */ 568 HREFTYPE reference; 569 int flags; 570 int ctCustData; 571 TLBCustData * pCustData;/* linked list to custom data; */ 572 TLBImpLib *pImpTLInfo; 577 /* if index == TLB_REF_USE_GUID */ 578 579 HREFTYPE reference; /* The href of this ref */ 580 TLBImpLib *pImpTLInfo; /* If ref is external ptr to library data 581 TLB_REF_INTERNAL for internal refs 582 TLB_REF_NOT_FOUND for broken refs */ 583 573 584 struct tagTLBRefType * next; 574 585 } TLBRefType; 575 586 587 #define TLB_REF_USE_GUID -2 588 589 #define TLB_REF_INTERNAL (void*)-2 590 #define TLB_REF_NOT_FOUND (void*)-1 591 576 592 /* internal Parameter data */ 577 593 typedef struct tagTLBParDesc … … 579 595 BSTR Name; 580 596 int ctCustData; 581 TLBCustData * pCustData; /* linked list to cust data; */ 582 TLBRefType * pRefType; /* linked list to referenced types */ 597 TLBCustData * pCustData; /* linked list to cust data */ 583 598 } TLBParDesc; 584 599 … … 588 603 FUNCDESC funcdesc; /* lots of info on the function and its attributes. */ 589 604 BSTR Name; /* the name of this function */ 590 TLBParDesc *pParamDesc; /* array with nameand custom data */605 TLBParDesc *pParamDesc; /* array with param names and custom data */ 591 606 int helpcontext; 592 607 int HelpStringContext; … … 595 610 int ctCustData; 596 611 TLBCustData * pCustData; /* linked list to cust data; */ 597 struct tagTLBFuncDesc * next; 612 struct tagTLBFuncDesc * next; 598 613 } TLBFuncDesc; 599 614 … … 608 623 int ctCustData; 609 624 TLBCustData * pCustData;/* linked list to cust data; */ 610 struct tagTLBVarDesc * next; 625 struct tagTLBVarDesc * next; 611 626 } TLBVarDesc; 627 628 /* internal implemented interface data */ 629 typedef struct tagTLBImplType 630 { 631 HREFTYPE hRef; /* hRef of interface */ 632 int implflags; /* IMPLFLAG_*s */ 633 int ctCustData; 634 TLBCustData * pCustData;/* linked list to custom data; */ 635 struct tagTLBImplType *next; 636 } TLBImplType; 612 637 613 638 /* internal TypeInfo data */ … … 619 644 ITypeLibImpl * pTypeLib; /* back pointer to typelib */ 620 645 int index; /* index in this typelib; */ 621 /* type libs seem to store the doc strings in ascii 646 /* type libs seem to store the doc strings in ascii 622 647 * so why should we do it in unicode? 623 648 */ … … 634 659 635 660 /* Implemented Interfaces */ 636 TLBRefType * impltypelist; 661 TLBImplType * impltypelist; 662 663 TLBRefType * reflist; 637 664 int ctCustData; 638 665 TLBCustData * pCustData; /* linked list to cust data; */ … … 646 673 typedef struct tagTLBContext 647 674 { 648 649 650 651 652 TLBSegDir * pTblDir;653 675 unsigned int oStart; /* start of TLB in file */ 676 unsigned int pos; /* current pos */ 677 unsigned int length; /* total length */ 678 void *mapping; /* memory mapping */ 679 MSFT_SegDir * pTblDir; 680 ITypeLibImpl* pLibInfo; 654 681 } TLBContext; 655 682 656 683 657 static void TLB_DoRefType(TLBContext *pcx, int offset, TLBRefType ** pprtd);684 static void MSFT_DoRefType(TLBContext *pcx, ITypeInfoImpl *pTI, int offset); 658 685 659 686 //#define TYPELIBDEBUG … … 680 707 case VT_DISPATCH: sprintf(szVarType, "VT_DISPATCH"); break; 681 708 case VT_ARRAY: sprintf(szVarType, "VT_ARRAY"); break; 682 case VT_I1: sprintf(szVarType, "VT_I 2"); break;709 case VT_I1: sprintf(szVarType, "VT_I1"); break; 683 710 case VT_UI2: sprintf(szVarType, "VT_UI2"); break; 684 711 case VT_UI4: sprintf(szVarType, "VT_UI4"); break; 685 712 case VT_INT: sprintf(szVarType, "VT_INT"); break; 686 713 case VT_UINT: sprintf(szVarType, "VT_UINT"); break; 714 case VT_USERDEFINED: sprintf(szVarType, "VT_USERDEFINED\n"); break; 687 715 default: sprintf(szVarType, "unknown");break; 688 716 } 689 717 } 718 719 static void dump_TypeDesc(TYPEDESC *pTD,char *szVarType) { 720 switch(pTD->vt) { 721 case VT_UI1: sprintf(szVarType, "VT_UI1"); break; 722 case VT_I2: sprintf(szVarType, "VT_I2"); break; 723 case VT_I4: sprintf(szVarType, "VT_I4"); break; 724 case VT_R4: sprintf(szVarType, "VT_R4"); break; 725 case VT_R8: sprintf(szVarType, "VT_R8"); break; 726 case VT_BOOL: sprintf(szVarType, "VT_BOOL"); break; 727 case VT_ERROR: sprintf(szVarType, "VT_ERROR"); break; 728 case VT_CY: sprintf(szVarType, "VT_CY"); break; 729 case VT_DATE: sprintf(szVarType, "VT_DATE"); break; 730 case VT_BSTR: sprintf(szVarType, "VT_BSTR"); break; 731 case VT_BYREF: case VT_UNKNOWN: sprintf(szVarType, "VT_BYREF"); break; 732 case VT_DISPATCH: sprintf(szVarType, "VT_DISPATCH"); break; 733 case VT_ARRAY: sprintf(szVarType, "VT_ARRAY"); break; 734 case VT_I1: sprintf(szVarType, "VT_I1"); break; 735 case VT_UI2: sprintf(szVarType, "VT_UI2"); break; 736 case VT_UI4: sprintf(szVarType, "VT_UI4"); break; 737 case VT_INT: sprintf(szVarType, "VT_INT"); break; 738 case VT_UINT: sprintf(szVarType, "VT_UINT"); break; 739 case VT_VARIANT: sprintf(szVarType, "VT_VARIANT"); break; 740 case VT_VOID: sprintf(szVarType, "VT_VOID"); break; 741 case VT_USERDEFINED: sprintf(szVarType, "VT_USERDEFINED ref = %lx", 742 pTD->u.hreftype); break; 743 case VT_PTR: sprintf(szVarType, "ptr to "); 744 dump_TypeDesc(pTD->u.lptdesc, szVarType + 7); 745 break; 746 case VT_SAFEARRAY: sprintf(szVarType, "safearray of "); 747 dump_TypeDesc(pTD->u.lptdesc, szVarType + 13); 748 break; 749 case VT_CARRAY: sprintf(szVarType, "%d dim array of ", 750 pTD->u.lpadesc->cDims); /* FIXME print out sizes */ 751 dump_TypeDesc(&pTD->u.lpadesc->tdescElem, szVarType + strlen(szVarType)); 752 break; 753 754 default: sprintf(szVarType, "unknown");break; 755 } 756 } 757 690 758 static void dump_ELEMDESC(ELEMDESC *edesc) { 691 759 char buf[200]; 692 dump_ VarType(edesc->tdesc.vt,buf);760 dump_TypeDesc(&edesc->tdesc,buf); 693 761 MESSAGE("\t\ttdesc.vartype %d (%s)\n",edesc->tdesc.vt,buf); 694 762 MESSAGE("\t\tu.parmadesc.flags %x\n",edesc->u.paramdesc.wParamFlags); … … 697 765 static void dump_FUNCDESC(FUNCDESC *funcdesc) { 698 766 int i; 699 MESSAGE("memid is %d\n",(int)funcdesc->memid); 700 for (i=0;i<funcdesc->cParams;i++) 701 MESSAGE("Param %d:\n",i);dump_ELEMDESC(funcdesc->lprgelemdescParam+i); 767 MESSAGE("memid is %08lx\n",funcdesc->memid); 768 for (i=0;i<funcdesc->cParams;i++) { 769 MESSAGE("Param %d:\n",i); 770 dump_ELEMDESC(funcdesc->lprgelemdescParam+i); 771 } 702 772 MESSAGE("\tfunckind: %d (",funcdesc->funckind); 703 773 switch (funcdesc->funckind) { … … 745 815 static void dump_TLBFuncDesc(TLBFuncDesc * pfd) 746 816 { 747 748 749 750 751 817 while (pfd) 818 { 819 dump_TLBFuncDescOne(pfd); 820 pfd = pfd->next; 821 }; 752 822 } 753 823 static void dump_TLBVarDesc(TLBVarDesc * pvd) 754 824 { 755 while (pvd) 756 { 757 TRACE_(typelib)("%s\n", debugstr_w(pvd->Name)); 758 pvd = pvd->next; 759 }; 760 } 825 while (pvd) 826 { 827 TRACE_(typelib)("%s\n", debugstr_w(pvd->Name)); 828 pvd = pvd->next; 829 }; 830 } 831 832 static void dump_TLBImpLib(TLBImpLib *import) 833 { 834 TRACE_(typelib)("%s %s\n", debugstr_guid(&(import->guid)), 835 debugstr_w(import->name)); 836 TRACE_(typelib)("v%d.%d lcid=%lx offset=%x\n", import->wVersionMajor, 837 import->wVersionMinor, import->lcid, import->offset); 838 } 839 761 840 static void dump_TLBRefType(TLBRefType * prt) 762 841 { 763 while (prt) 764 { 765 TRACE_(typelib)("%s\n", debugstr_guid(&(prt->guid))); 766 TRACE_(typelib)(" href:0x%08lx\n", prt->reference); 767 prt = prt->next; 768 }; 769 } 770 842 while (prt) 843 { 844 TRACE_(typelib)("href:0x%08lx\n", prt->reference); 845 if(prt->index == -1) 846 TRACE_(typelib)("%s\n", debugstr_guid(&(prt->guid))); 847 else 848 TRACE_(typelib)("type no: %d\n", prt->index); 849 850 if(prt->pImpTLInfo != TLB_REF_INTERNAL && 851 prt->pImpTLInfo != TLB_REF_NOT_FOUND) { 852 TRACE_(typelib)("in lib\n"); 853 dump_TLBImpLib(prt->pImpTLInfo); 854 } 855 prt = prt->next; 856 }; 857 } 858 859 static void dump_TLBImplType(TLBImplType * impl) 860 { 861 while (impl) { 862 TRACE_(typelib)( 863 "implementing/inheriting interface hRef = %lx implflags %x\n", 864 impl->hRef, impl->implflags); 865 impl = impl->next; 866 } 867 } 868 771 869 static void dump_Variant(VARIANT * pvar) 772 870 { 773 871 char szVarType[15]; 774 872 775 873 TRACE("(%p)\n", pvar); 776 874 777 875 if (!pvar) return; 778 876 779 877 ZeroMemory(szVarType, sizeof(szVarType)); 780 878 781 879 /* FIXME : we could have better trace here, depending on the VARTYPE 782 880 * of the variant … … 785 883 786 884 TRACE("VARTYPE: %s\n", szVarType); 787 885 788 886 switch (V_VT(pvar)) 789 887 { … … 791 889 TRACE("%3.3e\n", V_UNION(pvar, fltVal)); 792 890 break; 793 891 794 892 case VT_R8: 795 893 TRACE("%3.3e\n", V_UNION(pvar, dblVal)); 796 894 break; 797 895 798 896 default: 799 897 TRACE("%ld\n", V_UNION(pvar, lVal)); 800 898 break; 801 } 899 } 802 900 803 901 if (V_VT(pvar) & VT_BYREF) … … 808 906 { 809 907 int index = 0; 810 908 811 909 TRACE("args=%u named args=%u\n", pdp->cArgs, pdp->cNamedArgs); 812 910 … … 820 918 static char * typekind_desc[] = 821 919 { 822 823 824 825 826 827 828 829 830 920 "TKIND_ENUM", 921 "TKIND_RECORD", 922 "TKIND_MODULE", 923 "TKIND_INTERFACE", 924 "TKIND_DISPATCH", 925 "TKIND_COCLASS", 926 "TKIND_ALIAS", 927 "TKIND_UNION", 928 "TKIND_MAX" 831 929 }; 832 930 … … 842 940 dump_TLBFuncDesc(pty->funclist); 843 941 dump_TLBVarDesc(pty->varlist); 844 dump_TLB RefType(pty->impltypelist);942 dump_TLBImplType(pty->impltypelist); 845 943 } 846 944 #else 847 945 static char * typekind_desc[] = 848 946 { 849 850 851 852 853 854 855 856 857 947 "TKIND_ENUM", 948 "TKIND_RECORD", 949 "TKIND_MODULE", 950 "TKIND_INTERFACE", 951 "TKIND_DISPATCH", 952 "TKIND_COCLASS", 953 "TKIND_ALIAS", 954 "TKIND_UNION", 955 "TKIND_MAX" 858 956 }; 859 957 #define dump_TypeInfo(a) … … 861 959 #define dump_TLBFuncDescOne(a) 862 960 #define dump_TLBVarDesc(a) 961 #define dump_TLBRefType(a) 962 #define dump_TLBFuncDesc(a) 963 #define dump_TypeDesc(a,b) 863 964 #endif 864 965 … … 894 995 HeapFree(GetProcessHeap(), 0, ptr); 895 996 } 997 998 999 /********************************************************************** 1000 * 1001 * Functions for reading MSFT typelibs (those created by CreateTypeLib2) 1002 */ 896 1003 /* read function */ 897 DWORD TLB_Read(void *buffer, DWORD count, TLBContext *pcx, long where )1004 DWORD MSFT_Read(void *buffer, DWORD count, TLBContext *pcx, long where ) 898 1005 { 899 1006 TRACE_(typelib)("pos=0x%08x len=0x%08lx 0x%08x 0x%08x 0x%08lx\n", … … 917 1024 } 918 1025 919 static void TLB_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx)1026 static void MSFT_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx) 920 1027 { 921 1028 TRACE_(typelib)("%s\n", debugstr_guid(pGuid)); … … 925 1032 return; 926 1033 } 927 TLB_Read(pGuid, sizeof(GUID), pcx, pcx->pTblDir->pGuidTab.offset+offset );928 } 929 930 BSTR TLB_ReadName( TLBContext *pcx, int offset)1034 MSFT_Read(pGuid, sizeof(GUID), pcx, pcx->pTblDir->pGuidTab.offset+offset ); 1035 } 1036 1037 BSTR MSFT_ReadName( TLBContext *pcx, int offset) 931 1038 { 932 1039 char * name; 933 TLBNameIntro niName;1040 MSFT_NameIntro niName; 934 1041 int lengthInChars; 935 1042 WCHAR* pwstring = NULL; 936 1043 BSTR bstrName = NULL; 937 1044 938 TLB_Read(&niName, sizeof(niName), pcx,939 1045 MSFT_Read(&niName, sizeof(niName), pcx, 1046 pcx->pTblDir->pNametab.offset+offset); 940 1047 niName.namelen &= 0xFF; /* FIXME: correct ? */ 941 1048 name=TLB_Alloc((niName.namelen & 0xff) +1); 942 TLB_Read(name, (niName.namelen & 0xff), pcx, DO_NOT_SEEK);1049 MSFT_Read(name, (niName.namelen & 0xff), pcx, DO_NOT_SEEK); 943 1050 name[niName.namelen & 0xff]='\0'; 944 1051 … … 963 1070 } 964 1071 965 BSTR TLB_ReadString( TLBContext *pcx, int offset)1072 BSTR MSFT_ReadString( TLBContext *pcx, int offset) 966 1073 { 967 1074 char * string; … … 971 1078 972 1079 if(offset<0) return NULL; 973 TLB_Read(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset);1080 MSFT_Read(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset); 974 1081 if(length <= 0) return 0; 975 1082 string=TLB_Alloc(length +1); 976 TLB_Read(string, length, pcx, DO_NOT_SEEK);1083 MSFT_Read(string, length, pcx, DO_NOT_SEEK); 977 1084 string[length]='\0'; 978 1085 … … 997 1104 } 998 1105 /* 999 * read a value and fill a VARIANT structure 1000 */ 1001 static void TLB_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )1106 * read a value and fill a VARIANT structure 1107 */ 1108 static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx ) 1002 1109 { 1003 1110 int size; … … 1005 1112 TRACE_(typelib)("\n"); 1006 1113 1007 if(offset <0) { /* data ispacked in here */1114 if(offset <0) { /* data are packed in here */ 1008 1115 V_VT(pVar) = (offset & 0x7c000000 )>> 26; 1009 1116 V_UNION(pVar, iVal) = offset & 0xffff; 1010 1117 return; 1011 1118 } 1012 TLB_Read(&(V_VT(pVar)), sizeof(VARTYPE), pcx,1119 MSFT_Read(&(V_VT(pVar)), sizeof(VARTYPE), pcx, 1013 1120 pcx->pTblDir->pCustData.offset + offset ); 1014 1121 TRACE_(typelib)("Vartype = %x\n", V_VT(pVar)); … … 1019 1126 case VT_I4 : 1020 1127 case VT_R4 : 1021 case VT_ERROR : 1022 case VT_BOOL : 1023 case VT_I1 : 1024 case VT_UI1 : 1025 case VT_UI2 : 1026 case VT_UI4 : 1027 case VT_INT : 1028 case VT_UINT : 1128 case VT_ERROR : 1129 case VT_BOOL : 1130 case VT_I1 : 1131 case VT_UI1 : 1132 case VT_UI2 : 1133 case VT_UI4 : 1134 case VT_INT : 1135 case VT_UINT : 1029 1136 case VT_VOID : /* FIXME: is this right? */ 1030 case VT_HRESULT : 1137 case VT_HRESULT : 1031 1138 size=4; break; 1032 1139 case VT_R8 : 1033 1140 case VT_CY : 1034 case VT_DATE : 1035 case VT_I8 : 1036 case VT_UI8 : 1141 case VT_DATE : 1142 case VT_I8 : 1143 case VT_UI8 : 1037 1144 case VT_DECIMAL : /* FIXME: is this right? */ 1038 1145 case VT_FILETIME : … … 1041 1148 case VT_BSTR :{ 1042 1149 char * ptr; 1043 TLB_Read(&size, sizeof(INT), pcx, DO_NOT_SEEK );1044 1045 1046 1150 MSFT_Read(&size, sizeof(INT), pcx, DO_NOT_SEEK ); 1151 if(size <= 0) { 1152 FIXME("BSTR length = %d?\n", size); 1153 } else { 1047 1154 ptr=TLB_Alloc(size);/* allocate temp buffer */ 1048 TLB_Read(ptr, size, pcx, DO_NOT_SEEK);/* read string (ANSI) */1049 1050 1051 1052 1053 1054 1055 1056 1155 MSFT_Read(ptr, size, pcx, DO_NOT_SEEK);/* read string (ANSI) */ 1156 V_UNION(pVar, bstrVal)=SysAllocStringLen(NULL,size); 1157 /* FIXME: do we need a AtoW conversion here? */ 1158 V_UNION(pVar, bstrVal[size])=L'\0'; 1159 while(size--) V_UNION(pVar, bstrVal[size])=ptr[size]; 1160 TLB_Free(ptr); 1161 } 1162 } 1163 size=-4; break; 1057 1164 /* FIXME: this will not work AT ALL when the variant contains a pointer */ 1058 1165 case VT_DISPATCH : 1059 case VT_VARIANT : 1060 case VT_UNKNOWN : 1061 case VT_PTR : 1166 case VT_VARIANT : 1167 case VT_UNKNOWN : 1168 case VT_PTR : 1062 1169 case VT_SAFEARRAY : 1063 case VT_CARRAY : 1064 case VT_USERDEFINED : 1065 case VT_LPSTR : 1066 case VT_LPWSTR : 1067 case VT_BLOB : 1068 case VT_STREAM : 1069 case VT_STORAGE : 1070 case VT_STREAMED_OBJECT : 1071 case VT_STORED_OBJECT : 1072 case VT_BLOB_OBJECT : 1073 case VT_CF : 1074 case VT_CLSID : 1075 default: 1076 size=0; 1170 case VT_CARRAY : 1171 case VT_USERDEFINED : 1172 case VT_LPSTR : 1173 case VT_LPWSTR : 1174 case VT_BLOB : 1175 case VT_STREAM : 1176 case VT_STORAGE : 1177 case VT_STREAMED_OBJECT : 1178 case VT_STORED_OBJECT : 1179 case VT_BLOB_OBJECT : 1180 case VT_CF : 1181 case VT_CLSID : 1182 default: 1183 size=0; 1077 1184 FIXME("VARTYPE %d is not supported, setting pointer to NULL\n", 1078 1185 V_VT(pVar)); … … 1080 1187 1081 1188 if(size>0) /* (big|small) endian correct? */ 1082 TLB_Read(&(V_UNION(pVar, iVal)), size, pcx, DO_NOT_SEEK );1189 MSFT_Read(&(V_UNION(pVar, iVal)), size, pcx, DO_NOT_SEEK ); 1083 1190 return; 1084 1191 } … … 1086 1193 * create a linked list with custom data 1087 1194 */ 1088 static int TLB_CustData( TLBContext *pcx, int offset, TLBCustData** ppCustData )1089 { 1090 TLBCDGuid entry;1195 static int MSFT_CustData( TLBContext *pcx, int offset, TLBCustData** ppCustData ) 1196 { 1197 MSFT_CDGuid entry; 1091 1198 TLBCustData* pNew; 1092 1199 int count=0; … … 1097 1204 count++; 1098 1205 pNew=TLB_Alloc(sizeof(TLBCustData)); 1099 TLB_Read(&entry, sizeof(entry), pcx,1206 MSFT_Read(&entry, sizeof(entry), pcx, 1100 1207 pcx->pTblDir->pCDGuids.offset+offset); 1101 TLB_ReadGuid(&(pNew->guid), entry.GuidOffset , pcx);1102 TLB_ReadValue(&(pNew->data), entry.DataOffset, pcx);1208 MSFT_ReadGuid(&(pNew->guid), entry.GuidOffset , pcx); 1209 MSFT_ReadValue(&(pNew->data), entry.DataOffset, pcx); 1103 1210 /* add new custom data at head of the list */ 1104 1211 pNew->next=*ppCustData; … … 1109 1216 } 1110 1217 1111 static void TLB_GetTdesc(TLBContext *pcx, INT type,TYPEDESC * pTd ) 1218 static void MSFT_GetTdesc(TLBContext *pcx, INT type, TYPEDESC *pTd, 1219 ITypeInfoImpl *pTI) 1112 1220 { 1113 1221 if(type <0) … … 1116 1224 *pTd=pcx->pLibInfo->pTypeDesc[type/(2*sizeof(INT))]; 1117 1225 1226 if(pTd->vt == VT_USERDEFINED) 1227 MSFT_DoRefType(pcx, pTI, pTd->u.hreftype); 1228 1118 1229 TRACE_(typelib)("vt type = %X\n", pTd->vt); 1119 1230 } 1120 1231 1121 static void 1122 TLB_DoFuncs(TLBContext* pcx, 1123 int cFuncs, 1232 static void 1233 MSFT_DoFuncs(TLBContext* pcx, 1234 ITypeInfoImpl* pTI, 1235 int cFuncs, 1124 1236 int cVars, 1125 int offset, 1237 int offset, 1126 1238 TLBFuncDesc** pptfd) 1127 1239 { 1128 /* 1240 /* 1129 1241 * member information is stored in a data structure at offset 1130 1242 * indicated by the memoffset field of the typeinfo structure 1131 1243 * There are several distinctive parts. 1132 * the first part starts with a field that holds the total length 1244 * the first part starts with a field that holds the total length 1133 1245 * of this (first) part excluding this field. Then follow the records, 1134 1246 * for each member there is one record. 1135 1247 * 1136 1248 * First entry is always the length of the record (excluding this 1137 * length word). 1138 * Rest of the record depends on the type of the member. If there is 1249 * length word). 1250 * Rest of the record depends on the type of the member. If there is 1139 1251 * a field indicating the member type (function variable intereface etc) 1140 1252 * I have not found it yet. At this time we depend on the information … … 1143 1255 * Second follows an array sized nrMEM*sizeof(INT) with a memeber id 1144 1256 * for each member; 1145 * 1146 * Third is a equal sized array with file offsets to the name entry 1257 * 1258 * Third is a equal sized array with file offsets to the name entry 1147 1259 * of each member. 1148 * 1260 * 1149 1261 * Forth and last (?) part is an array with offsets to the records in the 1150 1262 * first part of this file segment. … … 1155 1267 1156 1268 char recbuf[512]; 1157 TLBFuncRecord * pFuncRec=(TLBFuncRecord *) recbuf;1269 MSFT_FuncRecord * pFuncRec=(MSFT_FuncRecord *) recbuf; 1158 1270 1159 1271 TRACE_(typelib)("\n"); 1160 1272 1161 TLB_Read(&infolen, sizeof(INT), pcx, offset);1273 MSFT_Read(&infolen, sizeof(INT), pcx, offset); 1162 1274 1163 1275 for ( i = 0; i < cFuncs ; i++ ) … … 1166 1278 1167 1279 /* name, eventually add to a hash table */ 1168 TLB_Read(&nameoffset,1169 sizeof(INT), 1170 pcx, 1280 MSFT_Read(&nameoffset, 1281 sizeof(INT), 1282 pcx, 1171 1283 offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT)); 1172 1284 1173 (*pptfd)->Name = TLB_ReadName(pcx, nameoffset);1285 (*pptfd)->Name = MSFT_ReadName(pcx, nameoffset); 1174 1286 1175 1287 /* read the function information record */ 1176 TLB_Read(&reclength, sizeof(INT), pcx, recoffset);1177 1288 MSFT_Read(&reclength, sizeof(INT), pcx, recoffset); 1289 1178 1290 reclength &= 0x1ff; 1179 1291 1180 TLB_Read(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;1292 MSFT_Read(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ; 1181 1293 1182 1294 /* do the attributes */ … … 1187 1299 { 1188 1300 (*pptfd)->helpcontext = pFuncRec->OptAttr[0] ; 1189 1301 1190 1302 if ( nrattributes > 1 ) 1191 1303 { 1192 (*pptfd)->HelpString = TLB_ReadString(pcx,1304 (*pptfd)->HelpString = MSFT_ReadString(pcx, 1193 1305 pFuncRec->OptAttr[1]) ; 1194 1306 … … 1201 1313 else 1202 1314 { 1203 (*pptfd)->Entry = TLB_ReadString(pcx,1315 (*pptfd)->Entry = MSFT_ReadString(pcx, 1204 1316 pFuncRec->OptAttr[2]); 1205 1317 } … … 1210 1322 if ( nrattributes > 6 && pFuncRec->FKCCIC & 0x80 ) 1211 1323 { 1212 TLB_CustData(pcx,1213 1214 1324 MSFT_CustData(pcx, 1325 pFuncRec->OptAttr[6], 1326 &(*pptfd)->pCustData); 1215 1327 } 1216 1328 } … … 1220 1332 1221 1333 /* fill the FuncDesc Structure */ 1222 TLB_Read( & (*pptfd)->funcdesc.memid,1223 sizeof(INT), pcx, 1334 MSFT_Read( & (*pptfd)->funcdesc.memid, 1335 sizeof(INT), pcx, 1224 1336 offset + infolen + ( i + 1) * sizeof(INT)); 1225 1337 … … 1232 1344 (*pptfd)->funcdesc.wFuncFlags = LOWORD(pFuncRec->Flags) ; 1233 1345 1234 TLB_GetTdesc(pcx, 1235 pFuncRec->DataType, 1236 &(*pptfd)->funcdesc.elemdescFunc.tdesc) ; 1346 MSFT_GetTdesc(pcx, 1347 pFuncRec->DataType, 1348 &(*pptfd)->funcdesc.elemdescFunc.tdesc, 1349 pTI); 1237 1350 1238 1351 /* do the parameters/arguments */ … … 1240 1353 { 1241 1354 int j = 0; 1242 TLBParameterInfo paraminfo;1243 1244 (*pptfd)->funcdesc.lprgelemdescParam = 1355 MSFT_ParameterInfo paraminfo; 1356 1357 (*pptfd)->funcdesc.lprgelemdescParam = 1245 1358 TLB_Alloc(pFuncRec->nrargs * sizeof(ELEMDESC)); 1246 1359 1247 (*pptfd)->pParamDesc = 1360 (*pptfd)->pParamDesc = 1248 1361 TLB_Alloc(pFuncRec->nrargs * sizeof(TLBParDesc)); 1249 1362 1250 TLB_Read(¶minfo,1251 sizeof(paraminfo), 1252 pcx, 1253 1254 pFuncRec->nrargs * sizeof(TLBParameterInfo));1363 MSFT_Read(¶minfo, 1364 sizeof(paraminfo), 1365 pcx, 1366 recoffset + reclength - 1367 pFuncRec->nrargs * sizeof(MSFT_ParameterInfo)); 1255 1368 1256 1369 for ( j = 0 ; j < pFuncRec->nrargs ; j++ ) … … 1258 1371 TYPEDESC* lpArgTypeDesc = 0; 1259 1372 1260 TLB_GetTdesc(pcx, 1261 paraminfo.DataType, 1262 &(*pptfd)->funcdesc.lprgelemdescParam[j].tdesc) ; 1373 MSFT_GetTdesc(pcx, 1374 paraminfo.DataType, 1375 &(*pptfd)->funcdesc.lprgelemdescParam[j].tdesc, 1376 pTI); 1263 1377 1264 1378 (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags = paraminfo.Flags; … … 1266 1380 (*pptfd)->pParamDesc[j].Name = (void *) paraminfo.oName; 1267 1381 1268 /* SEEK value = jump to offset, 1382 /* SEEK value = jump to offset, 1269 1383 * from there jump to the end of record, 1270 1384 * go back by (j-1) arguments 1271 1385 */ 1272 TLB_Read( ¶minfo ,1273 sizeof(TLBParameterInfo), pcx,1274 recoffset + reclength - ((pFuncRec->nrargs - j - 1) 1275 * sizeof(TLBParameterInfo)));1276 lpArgTypeDesc = 1386 MSFT_Read( ¶minfo , 1387 sizeof(MSFT_ParameterInfo), pcx, 1388 recoffset + reclength - ((pFuncRec->nrargs - j - 1) 1389 * sizeof(MSFT_ParameterInfo))); 1390 lpArgTypeDesc = 1277 1391 & ((*pptfd)->funcdesc.lprgelemdescParam[j].tdesc); 1278 1392 … … 1290 1404 1291 1405 case VT_USERDEFINED: 1292 (*pptfd)->pParamDesc[j].pRefType = 1293 TLB_Alloc(sizeof(TLBRefType)); 1294 1295 TLB_DoRefType(pcx, 1296 lpArgTypeDesc->u.hreftype, 1297 & ( (*pptfd)->pParamDesc[j].pRefType )); 1406 MSFT_DoRefType(pcx, pTI, 1407 lpArgTypeDesc->u.hreftype); 1298 1408 1299 1409 lpArgTypeDesc = NULL; … … 1312 1422 TYPEDESC* lpArgTypeDesc; 1313 1423 1314 (*pptfd)->funcdesc.elemdescFunc = 1424 (*pptfd)->funcdesc.elemdescFunc = 1315 1425 (*pptfd)->funcdesc.lprgelemdescParam[j]; 1316 1426 … … 1325 1435 break; 1326 1436 case VT_CARRAY: 1327 lpArgTypeDesc = 1437 lpArgTypeDesc = 1328 1438 & (lpArgTypeDesc->u.lpadesc->tdescElem); 1329 1439 … … 1331 1441 1332 1442 case VT_USERDEFINED: 1333 (*pptfd)->pParamDesc[j].pRefType 1334 = TLB_Alloc(sizeof(TLBRefType)); 1335 1336 TLB_DoRefType(pcx, 1337 lpArgTypeDesc->u.hreftype, 1338 &((*pptfd)->pParamDesc[j].pRefType)); 1443 MSFT_DoRefType(pcx, 1444 pTI, 1445 lpArgTypeDesc->u.hreftype); 1339 1446 1340 1447 lpArgTypeDesc = NULL; … … 1352 1459 /* name */ 1353 1460 (*pptfd)->pParamDesc[j].Name = 1354 TLB_ReadName( pcx, (int)(*pptfd)->pParamDesc[j].Name );1461 MSFT_ReadName( pcx, (int)(*pptfd)->pParamDesc[j].Name ); 1355 1462 1356 1463 /* default value */ 1357 if ( (PARAMFLAG_FHASDEFAULT & 1464 if ( (PARAMFLAG_FHASDEFAULT & 1358 1465 (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) && 1359 1466 ((pFuncRec->FKCCIC) & 0x1000) ) 1360 1467 { 1361 INT* pInt = (INT *)((char *)pFuncRec + 1362 reclength - 1468 INT* pInt = (INT *)((char *)pFuncRec + 1469 reclength - 1363 1470 (pFuncRec->nrargs * 4 + 1) * sizeof(INT) ); 1364 1471 … … 1368 1475 pParamDesc->pparamdescex->cBytes = sizeof(PARAMDESCEX); 1369 1476 1370 TLB_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), 1477 MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), 1371 1478 pInt[j], pcx); 1372 1479 } … … 1374 1481 if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 ) 1375 1482 { 1376 TLB_CustData(pcx,1377 1378 1483 MSFT_CustData(pcx, 1484 pFuncRec->OptAttr[7+j], 1485 &(*pptfd)->pParamDesc[j].pCustData); 1379 1486 } 1380 1487 } … … 1389 1496 } 1390 1497 } 1391 static void TLB_DoVars(TLBContext *pcx, int cFuncs, int cVars,1392 1498 static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs, 1499 int cVars, int offset, TLBVarDesc ** pptvd) 1393 1500 { 1394 1501 int infolen, nameoffset, reclength; 1395 1502 char recbuf[256]; 1396 TLBVarRecord * pVarRec=(TLBVarRecord *) recbuf;1503 MSFT_VarRecord * pVarRec=(MSFT_VarRecord *) recbuf; 1397 1504 int i; 1398 1505 int recoffset; … … 1400 1507 TRACE_(typelib)("\n"); 1401 1508 1402 TLB_Read(&infolen,sizeof(INT), pcx, offset);1403 TLB_Read(&recoffset,sizeof(INT), pcx, offset + infolen +1509 MSFT_Read(&infolen,sizeof(INT), pcx, offset); 1510 MSFT_Read(&recoffset,sizeof(INT), pcx, offset + infolen + 1404 1511 ((cFuncs+cVars)*2+cFuncs + 1)*sizeof(INT)); 1405 1512 recoffset += offset+sizeof(INT); … … 1407 1514 *pptvd=TLB_Alloc(sizeof(TLBVarDesc)); 1408 1515 /* name, eventually add to a hash table */ 1409 TLB_Read(&nameoffset, sizeof(INT), pcx,1516 MSFT_Read(&nameoffset, sizeof(INT), pcx, 1410 1517 offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT)); 1411 (*pptvd)->Name= TLB_ReadName(pcx, nameoffset);1518 (*pptvd)->Name=MSFT_ReadName(pcx, nameoffset); 1412 1519 /* read the variable information record */ 1413 TLB_Read(&reclength, sizeof(INT), pcx, recoffset);1520 MSFT_Read(&reclength, sizeof(INT), pcx, recoffset); 1414 1521 reclength &=0xff; 1415 TLB_Read(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;1522 MSFT_Read(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ; 1416 1523 /* Optional data */ 1417 1524 if(reclength >(6*sizeof(INT)) ) 1418 1525 (*pptvd)->HelpContext=pVarRec->HelpContext; 1419 1526 if(reclength >(7*sizeof(INT)) ) 1420 (*pptvd)->HelpString = TLB_ReadString(pcx, pVarRec->oHelpString) ;1527 (*pptvd)->HelpString = MSFT_ReadString(pcx, pVarRec->oHelpString) ; 1421 1528 if(reclength >(8*sizeof(INT)) ) 1422 1529 if(reclength >(9*sizeof(INT)) ) 1423 1530 (*pptvd)->HelpStringContext=pVarRec->HelpStringContext; 1424 1531 /* fill the VarDesc Structure */ 1425 TLB_Read(&(*pptvd)->vardesc.memid, sizeof(INT), pcx,1532 MSFT_Read(&(*pptvd)->vardesc.memid, sizeof(INT), pcx, 1426 1533 offset + infolen + ( i + 1) * sizeof(INT)); 1427 1534 (*pptvd)->vardesc.varkind = pVarRec->VarKind; 1428 1535 (*pptvd)->vardesc.wVarFlags = pVarRec->Flags; 1429 TLB_GetTdesc(pcx, pVarRec->DataType,1430 &(*pptvd)->vardesc.elemdescVar.tdesc );1536 MSFT_GetTdesc(pcx, pVarRec->DataType, 1537 &(*pptvd)->vardesc.elemdescVar.tdesc, pTI); 1431 1538 /* (*pptvd)->vardesc.lpstrSchema; is reserved (SDK) fixme?? */ 1432 1539 if(pVarRec->VarKind == VAR_CONST ){ 1433 1540 (*pptvd)->vardesc.u.lpvarValue=TLB_Alloc(sizeof(VARIANT)); 1434 TLB_ReadValue((*pptvd)->vardesc.u.lpvarValue,1541 MSFT_ReadValue((*pptvd)->vardesc.u.lpvarValue, 1435 1542 pVarRec->OffsValue, pcx); 1436 1543 } else … … 1441 1548 } 1442 1549 /* fill in data for a hreftype (offset). When the refernced type is contained 1443 * in the typelib, it s just an (file) offset in the type info base dir.1444 * If comes from import, it s an offset+1 in the ImpInfo table1550 * in the typelib, it's just an (file) offset in the type info base dir. 1551 * If comes from import, it's an offset+1 in the ImpInfo table 1445 1552 * */ 1446 static void TLB_DoRefType(TLBContext *pcx,1447 int offset , TLBRefType ** pprtd)1553 static void MSFT_DoRefType(TLBContext *pcx, ITypeInfoImpl *pTI, 1554 int offset) 1448 1555 { 1449 1556 int j; 1557 TLBRefType **ppRefType = &pTI->reflist; 1450 1558 1451 1559 TRACE_(typelib)("TLB context %p, TLB offset %x\n", pcx, offset); 1452 1560 1453 if(!HREFTYPE_INTHISFILE( offset)) { 1561 while(*ppRefType) { 1562 if((*ppRefType)->reference == offset) 1563 return; 1564 ppRefType = &(*ppRefType)->next; 1565 } 1566 1567 *ppRefType = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1568 sizeof(**ppRefType)); 1569 1570 if(!MSFT_HREFTYPE_INTHISFILE( offset)) { 1454 1571 /* external typelib */ 1455 TLBImpInfo impinfo;1572 MSFT_ImpInfo impinfo; 1456 1573 TLBImpLib *pImpLib=(pcx->pLibInfo->pImpLibs); 1457 1574 1458 1575 TRACE_(typelib)("offset %x, masked offset %x\n", offset, offset + (offset & 0xfffffffc)); 1459 1576 1460 TLB_Read(&impinfo, sizeof(impinfo), pcx,1577 MSFT_Read(&impinfo, sizeof(impinfo), pcx, 1461 1578 pcx->pTblDir->pImpInfo.offset + (offset & 0xfffffffc)); 1462 1579 for(j=0;pImpLib;j++){ /* search the known offsets of all import libraries */ … … 1465 1582 } 1466 1583 if(pImpLib){ 1467 (*pprtd)->reference=offset; 1468 (*pprtd)->pImpTLInfo = pImpLib; 1469 TLB_ReadGuid(&(*pprtd)->guid, impinfo.oGuid, pcx); 1584 (*ppRefType)->reference=offset; 1585 (*ppRefType)->pImpTLInfo = pImpLib; 1586 MSFT_ReadGuid(&(*ppRefType)->guid, impinfo.oGuid, pcx); 1587 (*ppRefType)->index = TLB_REF_USE_GUID; 1470 1588 }else{ 1471 1589 ERR("Cannot find a reference\n"); 1472 (*pp rtd)->reference=-1;1473 (*pp rtd)->pImpTLInfo=(void *)-1;1590 (*ppRefType)->reference=-1; 1591 (*ppRefType)->pImpTLInfo=TLB_REF_NOT_FOUND; 1474 1592 } 1475 1593 }else{ 1476 1594 /* in this typelib */ 1477 (*pprtd)->reference=offset; 1478 (*pprtd)->pImpTLInfo=(void *)-2; 1595 (*ppRefType)->index = MSFT_HREFTYPE_INDEX(offset); 1596 (*ppRefType)->reference=offset; 1597 (*ppRefType)->pImpTLInfo=TLB_REF_INTERNAL; 1479 1598 } 1480 1599 } 1481 1600 1482 1601 /* process Implemented Interfaces of a com class */ 1483 static void TLB_DoImplTypes(TLBContext *pcx, int count,1484 int offset, TLBRefType ** pprtd)1602 static void MSFT_DoImplTypes(TLBContext *pcx, ITypeInfoImpl *pTI, int count, 1603 int offset) 1485 1604 { 1486 1605 int i; 1487 TLBRefRecord refrec; 1606 MSFT_RefRecord refrec; 1607 TLBImplType **ppImpl = &pTI->impltypelist; 1488 1608 1489 1609 TRACE_(typelib)("\n"); … … 1491 1611 for(i=0;i<count;i++){ 1492 1612 if(offset<0) break; /* paranoia */ 1493 *pprtd=TLB_Alloc(sizeof(TLBRefType)); 1494 TLB_Read(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset); 1495 TLB_DoRefType(pcx, refrec.reftype, pprtd); 1496 (*pprtd)->flags=refrec.flags; 1497 (*pprtd)->ctCustData= 1498 TLB_CustData(pcx, refrec.oCustData, &(*pprtd)->pCustData); 1613 *ppImpl=TLB_Alloc(sizeof(**ppImpl)); 1614 MSFT_Read(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset); 1615 MSFT_DoRefType(pcx, pTI, refrec.reftype); 1616 (*ppImpl)->hRef = refrec.reftype; 1617 (*ppImpl)->implflags=refrec.flags; 1618 (*ppImpl)->ctCustData= 1619 MSFT_CustData(pcx, refrec.oCustData, &(*ppImpl)->pCustData); 1499 1620 offset=refrec.onext; 1500 pp rtd=&((*pprtd)->next);1621 ppImpl=&((*ppImpl)->next); 1501 1622 } 1502 1623 } … … 1504 1625 * process a typeinfo record 1505 1626 */ 1506 ITypeInfoImpl * TLB_DoTypeInfo(1627 ITypeInfoImpl * MSFT_DoTypeInfo( 1507 1628 TLBContext *pcx, 1508 1629 int count, 1509 1630 ITypeLibImpl * pLibInfo) 1510 1631 { 1511 TLBTypeInfoBase tiBase;1632 MSFT_TypeInfoBase tiBase; 1512 1633 ITypeInfoImpl *ptiRet; 1513 1634 … … 1515 1636 1516 1637 ptiRet = (ITypeInfoImpl*) ITypeInfo_Constructor(); 1517 TLB_Read(&tiBase, sizeof(tiBase) ,pcx ,1638 MSFT_Read(&tiBase, sizeof(tiBase) ,pcx , 1518 1639 pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase)); 1519 1640 /* this is where we are coming from */ … … 1523 1644 FIXME("Assign constructor/destructor memid\n"); 1524 1645 1525 TLB_ReadGuid(&ptiRet->TypeAttr.guid, tiBase.posguid, pcx);1646 MSFT_ReadGuid(&ptiRet->TypeAttr.guid, tiBase.posguid, pcx); 1526 1647 ptiRet->TypeAttr.lcid=pLibInfo->LibAttr.lcid; /* FIXME: correct? */ 1527 1648 ptiRet->TypeAttr.memidConstructor=MEMBERID_NIL ;/* FIXME */ … … 1539 1660 ptiRet->TypeAttr.cbSizeVft=tiBase.cbSizeVft; /* FIXME: this is only the non inherited part */ 1540 1661 if(ptiRet->TypeAttr.typekind == TKIND_ALIAS) 1541 TLB_GetTdesc(pcx, tiBase.datatype1,1542 &ptiRet->TypeAttr.tdescAlias );1662 MSFT_GetTdesc(pcx, tiBase.datatype1, 1663 &ptiRet->TypeAttr.tdescAlias, ptiRet); 1543 1664 1544 1665 /* FIXME: */ … … 1546 1667 1547 1668 /* name, eventually add to a hash table */ 1548 ptiRet->Name= TLB_ReadName(pcx, tiBase.NameOffset);1669 ptiRet->Name=MSFT_ReadName(pcx, tiBase.NameOffset); 1549 1670 TRACE_(typelib)("reading %s\n", debugstr_w(ptiRet->Name)); 1550 1671 /* help info */ 1551 ptiRet->DocString= TLB_ReadString(pcx, tiBase.docstringoffs);1672 ptiRet->DocString=MSFT_ReadString(pcx, tiBase.docstringoffs); 1552 1673 ptiRet->dwHelpStringContext=tiBase.helpstringcontext; 1553 1674 ptiRet->dwHelpContext=tiBase.helpcontext; … … 1557 1678 /* functions */ 1558 1679 if(ptiRet->TypeAttr.cFuncs >0 ) 1559 TLB_DoFuncs(pcx, ptiRet->TypeAttr.cFuncs ,ptiRet->TypeAttr.cVars, 1560 tiBase.memoffset, & ptiRet->funclist); 1680 MSFT_DoFuncs(pcx, ptiRet, ptiRet->TypeAttr.cFuncs, 1681 ptiRet->TypeAttr.cVars, 1682 tiBase.memoffset, & ptiRet->funclist); 1561 1683 /* variables */ 1562 1684 if(ptiRet->TypeAttr.cVars >0 ) 1563 TLB_DoVars(pcx, ptiRet->TypeAttr.cFuncs ,ptiRet->TypeAttr.cVars, 1564 tiBase.memoffset, & ptiRet->varlist); 1565 if(ptiRet->TypeAttr.cImplTypes >0 ){ 1685 MSFT_DoVars(pcx, ptiRet, ptiRet->TypeAttr.cFuncs, 1686 ptiRet->TypeAttr.cVars, 1687 tiBase.memoffset, & ptiRet->varlist); 1688 if(ptiRet->TypeAttr.cImplTypes >0 ) { 1566 1689 switch(ptiRet->TypeAttr.typekind) 1567 1690 { 1568 1691 case TKIND_COCLASS: 1569 TLB_DoImplTypes(pcx, ptiRet->TypeAttr.cImplTypes ,1570 tiBase.datatype1 , & ptiRet->impltypelist);1692 MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes , 1693 tiBase.datatype1); 1571 1694 break; 1572 1695 case TKIND_DISPATCH: 1573 ptiRet->impltypelist=TLB_Alloc(sizeof(TLB RefType));1574 1696 ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType)); 1697 1575 1698 if (tiBase.datatype1 != -1) 1576 1699 { 1577 TLB_DoRefType(pcx, tiBase.datatype1, & ptiRet->impltypelist); 1700 MSFT_DoRefType(pcx, ptiRet, tiBase.datatype1); 1701 ptiRet->impltypelist->hRef = tiBase.datatype1; 1578 1702 } 1579 1703 else 1580 { 1704 { /* FIXME: This is a really bad hack to add IDispatch */ 1581 1705 char* szStdOle = "stdole2.tlb\0"; 1582 1706 int nStdOleLen = strlen(szStdOle); 1583 1584 ptiRet->impltypelist->guid = IID_IDispatch; 1585 ptiRet->impltypelist->reference = -1; 1586 ptiRet->impltypelist->pImpTLInfo = TLB_Alloc(sizeof(TLBImpLib)); 1587 ptiRet->impltypelist->pImpTLInfo->guid = IID_StdOle; 1588 ptiRet->impltypelist->pImpTLInfo->name = SysAllocStringLen(NULL, nStdOleLen + 1); 1589 1590 MultiByteToWideChar(CP_ACP, 1591 MB_PRECOMPOSED, 1592 szStdOle, 1593 -1, 1594 ptiRet->impltypelist->pImpTLInfo->name, 1595 SysStringLen(ptiRet->impltypelist->pImpTLInfo->name)); 1596 1597 ptiRet->impltypelist->pImpTLInfo->lcid = 0; 1598 ptiRet->impltypelist->pImpTLInfo->wVersionMajor = 2; 1599 ptiRet->impltypelist->pImpTLInfo->wVersionMinor = 0; 1600 } 1707 TLBRefType **ppRef = &ptiRet->reflist; 1708 1709 while(*ppRef) { 1710 if((*ppRef)->reference == -1) 1711 break; 1712 ppRef = &(*ppRef)->next; 1713 } 1714 if(!*ppRef) { 1715 *ppRef = TLB_Alloc(sizeof(**ppRef)); 1716 (*ppRef)->guid = IID_IDispatch; 1717 (*ppRef)->reference = -1; 1718 (*ppRef)->index = TLB_REF_USE_GUID; 1719 (*ppRef)->pImpTLInfo = TLB_Alloc(sizeof(TLBImpLib)); 1720 (*ppRef)->pImpTLInfo->guid = IID_StdOle; 1721 (*ppRef)->pImpTLInfo->name = SysAllocStringLen(NULL, 1722 nStdOleLen + 1); 1723 1724 MultiByteToWideChar(CP_ACP, 1725 MB_PRECOMPOSED, 1726 szStdOle, 1727 -1, 1728 (*ppRef)->pImpTLInfo->name, 1729 SysStringLen((*ppRef)->pImpTLInfo->name)); 1730 1731 (*ppRef)->pImpTLInfo->lcid = 0; 1732 (*ppRef)->pImpTLInfo->wVersionMajor = 2; 1733 (*ppRef)->pImpTLInfo->wVersionMinor = 0; 1734 } 1735 } 1601 1736 break; 1602 1737 default: 1603 ptiRet->impltypelist=TLB_Alloc(sizeof(TLBRefType)); 1604 TLB_DoRefType(pcx, tiBase.datatype1, & ptiRet->impltypelist); 1738 ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType)); 1739 MSFT_DoRefType(pcx, ptiRet, tiBase.datatype1); 1740 ptiRet->impltypelist->hRef = tiBase.datatype1; 1605 1741 break; 1606 1742 } 1607 1743 } 1608 1744 ptiRet->ctCustData= 1609 TLB_CustData(pcx, tiBase.oCustData, &ptiRet->pCustData);1745 MSFT_CustData(pcx, tiBase.oCustData, &ptiRet->pCustData); 1610 1746 1611 1747 TRACE_(typelib)("%s guid: %s kind:%s\n", … … 1618 1754 1619 1755 /**************************************************************************** 1620 * 1756 * TLB_ReadTypeLib 1621 1757 * 1622 1758 * find the type of the typelib file and map the typelib resource into … … 1624 1760 */ 1625 1761 #define MSFT_SIGNATURE 0x5446534D /* "MSFT" */ 1762 #define SLTG_SIGNATURE 0x47544c53 /* "SLTG" */ 1626 1763 int TLB_ReadTypeLib(LPSTR pszFileName, ITypeLib2 **ppTypeLib) 1627 1764 { … … 1640 1777 1641 1778 /* is it a DLL? */ 1642 1643 1644 1645 1779 for (i=0 ; i < nStrLen ; ++i) 1780 { 1781 pszFileName[i] = tolower(pszFileName[i]); 1782 } 1646 1783 pszTypeLibIndex = strstr(pszFileName, ".dll"); 1647 1784 … … 1655 1792 if (pszTypeLibIndex && pszTypeLibIndex < pszFileName + nStrLen) 1656 1793 { 1657 /* yes -> it's a index! store DLL name, without the trailing back-slash */1794 /* yes -> it's an index! store DLL name, without the trailing back-slash */ 1658 1795 size_t nMemToAlloc = pszTypeLibIndex - pszFileName; 1659 1796 1660 1797 pszDllName = HeapAlloc(GetProcessHeap(), 1661 HEAP_ZERO_MEMORY, 1798 HEAP_ZERO_MEMORY, 1662 1799 nMemToAlloc + 1); 1663 1800 1664 1801 strncpy(pszDllName, pszFileName, nMemToAlloc); 1665 1802 1666 1803 /* move index string pointer pass the backslash */ 1667 1804 while (*pszTypeLibIndex == '\\') … … 1672 1809 /* No index, reset variable to 1 */ 1673 1810 pszDllName = HeapAlloc(GetProcessHeap(), 1674 HEAP_ZERO_MEMORY, 1811 HEAP_ZERO_MEMORY, 1675 1812 nStrLen + 1); 1676 1813 1677 1814 strncpy(pszDllName, pszFileName, nStrLen); 1678 1815 1679 1816 pszTypeLibIndex = "1\0"; 1680 1817 } … … 1694 1831 if(pBase) 1695 1832 { 1833 /* retrieve file size */ 1834 DWORD dwTLBLength = GetFileSize(hFile, NULL); 1835 1696 1836 /* first try to load as *.tlb */ 1697 1837 dwSignature = *((DWORD*) pBase); 1698 1838 if ( dwSignature == MSFT_SIGNATURE) 1699 1839 { 1700 /* retrieve file size */ 1701 DWORD dwTLBLength = GetFileSize(hFile, NULL); 1702 1703 *ppTypeLib = ITypeLib2_Constructor(pBase, dwTLBLength); 1840 *ppTypeLib = ITypeLib2_Constructor_MSFT(pBase, dwTLBLength); 1704 1841 ITypeLib2_AddRef(*ppTypeLib); 1705 1842 } 1843 else if ( dwSignature == SLTG_SIGNATURE) 1844 { 1845 *ppTypeLib = ITypeLib2_Constructor_SLTG(pBase, dwTLBLength); 1846 ITypeLib2_AddRef(*ppTypeLib); 1847 } 1706 1848 UnmapViewOfFile(pBase); 1707 1849 } … … 1726 1868 LPVOID pBase = LockResource(hGlobal); 1727 1869 DWORD dwTLBLength = SizeofResource(hinstDLL, hrsrc); 1728 1870 1729 1871 if (pBase) 1730 1872 { … … 1733 1875 if ( dwSignature == MSFT_SIGNATURE) 1734 1876 { 1735 *ppTypeLib = ITypeLib2_Constructor (pBase, dwTLBLength);1877 *ppTypeLib = ITypeLib2_Constructor_MSFT(pBase, dwTLBLength); 1736 1878 ITypeLib2_AddRef(*ppTypeLib); 1737 } 1879 } 1880 else if ( dwSignature == SLTG_SIGNATURE) 1881 { 1882 *ppTypeLib = ITypeLib2_Constructor_SLTG(pBase, dwTLBLength); 1883 ITypeLib2_AddRef(*ppTypeLib); 1884 } 1738 1885 else 1739 1886 { … … 1761 1908 1762 1909 /**************************************************************************** 1763 * ITypeLib2_Constructor1764 * 1765 * loading a typelib from ain-memory image1766 */ 1767 static ITypeLib2* ITypeLib2_Constructor (LPVOID pLib, DWORD dwTLBLength)1910 * ITypeLib2_Constructor_MSFT 1911 * 1912 * loading an MSFT typelib from an in-memory image 1913 */ 1914 static ITypeLib2* ITypeLib2_Constructor_MSFT(LPVOID pLib, DWORD dwTLBLength) 1768 1915 { 1769 1916 TLBContext cx; 1770 1917 long lPSegDir; 1771 TLB2Header tlbHeader;1772 TLBSegDir tlbSegDir;1918 MSFT_Header tlbHeader; 1919 MSFT_SegDir tlbSegDir; 1773 1920 ITypeLibImpl * pTypeLibImpl; 1774 1921 … … 1787 1934 cx.pLibInfo = pTypeLibImpl; 1788 1935 cx.length = dwTLBLength; 1789 1936 1790 1937 /* read header */ 1791 TLB_Read((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);1938 MSFT_Read((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0); 1792 1939 TRACE("header:\n"); 1793 1940 TRACE("\tmagic1=0x%08x ,magic2=0x%08x\n",tlbHeader.magic1,tlbHeader.magic2 ); 1794 1941 if (memcmp(&tlbHeader.magic1,TLBMAGIC2,4)) { 1795 1796 1797 } 1798 /* there is a small numberof information here until the next important1942 FIXME("Header type magic 0x%08x not supported.\n",tlbHeader.magic1); 1943 return NULL; 1944 } 1945 /* there is a small amount of information here until the next important 1799 1946 * part: 1800 1947 * the segment directory . Try to calculate the amount of data */ … … 1803 1950 /* now read the segment directory */ 1804 1951 TRACE("read segment directory (at %ld)\n",lPSegDir); 1805 TLB_Read((void*)&tlbSegDir, sizeof(tlbSegDir), &cx, lPSegDir);1952 MSFT_Read((void*)&tlbSegDir, sizeof(tlbSegDir), &cx, lPSegDir); 1806 1953 cx.pTblDir = &tlbSegDir; 1807 1954 … … 1810 1957 { 1811 1958 ERR("cannot find the table directory, ptr=0x%lx\n",lPSegDir); 1812 1813 1959 HeapFree(GetProcessHeap(),0,pTypeLibImpl); 1960 return NULL; 1814 1961 } 1815 1962 1816 1963 /* now fill our internal data */ 1817 1964 /* TLIBATTR fields */ 1818 TLB_ReadGuid(&pTypeLibImpl->LibAttr.guid, tlbHeader.posguid, &cx);1965 MSFT_ReadGuid(&pTypeLibImpl->LibAttr.guid, tlbHeader.posguid, &cx); 1819 1966 pTypeLibImpl->LibAttr.lcid = tlbHeader.lcid; 1820 1967 pTypeLibImpl->LibAttr.syskind = tlbHeader.varflags & 0x0f; /* check the mask */ … … 1824 1971 1825 1972 /* name, eventually add to a hash table */ 1826 pTypeLibImpl->Name = TLB_ReadName(&cx, tlbHeader.NameOffset);1973 pTypeLibImpl->Name = MSFT_ReadName(&cx, tlbHeader.NameOffset); 1827 1974 1828 1975 /* help info */ 1829 pTypeLibImpl->DocString = TLB_ReadString(&cx, tlbHeader.helpstring);1830 pTypeLibImpl->HelpFile = TLB_ReadString(&cx, tlbHeader.helpfile);1976 pTypeLibImpl->DocString = MSFT_ReadString(&cx, tlbHeader.helpstring); 1977 pTypeLibImpl->HelpFile = MSFT_ReadString(&cx, tlbHeader.helpfile); 1831 1978 1832 1979 if( tlbHeader.varflags & HELPDLLFLAG) 1833 1980 { 1834 1981 int offset; 1835 TLB_Read(&offset, sizeof(offset), &cx, sizeof(tlbHeader));1836 pTypeLibImpl->HelpStringDll = TLB_ReadString(&cx, offset);1982 MSFT_Read(&offset, sizeof(offset), &cx, sizeof(tlbHeader)); 1983 pTypeLibImpl->HelpStringDll = MSFT_ReadString(&cx, offset); 1837 1984 } 1838 1985 … … 1842 1989 if(tlbHeader.CustomDataOffset >= 0) 1843 1990 { 1844 pTypeLibImpl->ctCustData = TLB_CustData(&cx, tlbHeader.CustomDataOffset, &pTypeLibImpl->pCustData);1991 pTypeLibImpl->ctCustData = MSFT_CustData(&cx, tlbHeader.CustomDataOffset, &pTypeLibImpl->pCustData); 1845 1992 } 1846 1993 … … 1851 1998 INT16 td[4]; 1852 1999 pTypeLibImpl->pTypeDesc = TLB_Alloc( cTD * sizeof(TYPEDESC)); 1853 TLB_Read(td, sizeof(td), &cx, tlbSegDir.pTypdescTab.offset);2000 MSFT_Read(td, sizeof(td), &cx, tlbSegDir.pTypdescTab.offset); 1854 2001 for(i=0; i<cTD; ) 1855 2002 { 1856 2003 /* FIXME: add several sanity checks here */ 1857 2004 pTypeLibImpl->pTypeDesc[i].vt = td[0] & VT_TYPEMASK; 1858 2005 if(td[0] == VT_PTR || td[0] == VT_SAFEARRAY) 1859 1860 2006 { 2007 /* FIXME: check safearray */ 1861 2008 if(td[3] < 0) 1862 2009 pTypeLibImpl->pTypeDesc[i].u.lptdesc= & stndTypeDesc[td[2]]; … … 1864 2011 pTypeLibImpl->pTypeDesc[i].u.lptdesc= & pTypeLibImpl->pTypeDesc[td[2]/8]; 1865 2012 } 1866 2013 else if(td[0] == VT_CARRAY) 1867 2014 { 1868 1869 2015 /* array descr table here */ 2016 pTypeLibImpl->pTypeDesc[i].u.lpadesc = (void *)((int) td[2]); /* temp store offset in*/ 1870 2017 } 1871 2018 else if(td[0] == VT_USERDEFINED) 1872 2019 { 1873 2020 pTypeLibImpl->pTypeDesc[i].u.hreftype = MAKELONG(td[2],td[3]); 1874 2021 } 1875 if(++i<cTD) TLB_Read(td, sizeof(td), &cx, DO_NOT_SEEK);2022 if(++i<cTD) MSFT_Read(td, sizeof(td), &cx, DO_NOT_SEEK); 1876 2023 } 1877 2024 1878 2025 /* second time around to fill the array subscript info */ 1879 2026 for(i=0;i<cTD;i++) 1880 2027 { 1881 2028 if(pTypeLibImpl->pTypeDesc[i].vt != VT_CARRAY) continue; 1882 2029 if(tlbSegDir.pArrayDescriptions.offset>0) 1883 1884 TLB_Read(td, sizeof(td), &cx, tlbSegDir.pArrayDescriptions.offset + (int) pTypeLibImpl->pTypeDesc[i].u.lpadesc);2030 { 2031 MSFT_Read(td, sizeof(td), &cx, tlbSegDir.pArrayDescriptions.offset + (int) pTypeLibImpl->pTypeDesc[i].u.lpadesc); 1885 2032 pTypeLibImpl->pTypeDesc[i].u.lpadesc = TLB_Alloc(sizeof(ARRAYDESC)+sizeof(SAFEARRAYBOUND)*(td[3]-1)); 1886 2033 … … 1893 2040 1894 2041 for(j = 0; j<td[2]; j++) 1895 1896 TLB_Read(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].cElements,2042 { 2043 MSFT_Read(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].cElements, 1897 2044 sizeof(INT), &cx, DO_NOT_SEEK); 1898 TLB_Read(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].lLbound,2045 MSFT_Read(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].lLbound, 1899 2046 sizeof(INT), &cx, DO_NOT_SEEK); 1900 2047 } 1901 2048 } 1902 1903 2049 else 2050 { 1904 2051 pTypeLibImpl->pTypeDesc[i].u.lpadesc = NULL; 1905 2052 ERR("didn't find array description data\n"); … … 1916 2063 1917 2064 while(offset < tlbSegDir.pImpFiles.offset +tlbSegDir.pImpFiles.length) 1918 2065 { 1919 2066 *ppImpLib = TLB_Alloc(sizeof(TLBImpLib)); 1920 2067 (*ppImpLib)->offset = offset - tlbSegDir.pImpFiles.offset; 1921 TLB_Read(&oGuid, sizeof(INT), &cx, offset);1922 1923 TLB_Read(&(*ppImpLib)->lcid, sizeof(LCID), &cx, DO_NOT_SEEK);1924 TLB_Read(&(*ppImpLib)->wVersionMajor, sizeof(WORD), &cx, DO_NOT_SEEK);1925 TLB_Read(&(*ppImpLib)->wVersionMinor, sizeof(WORD), &cx, DO_NOT_SEEK);1926 TLB_Read(& size, sizeof(UINT16), &cx, DO_NOT_SEEK);2068 MSFT_Read(&oGuid, sizeof(INT), &cx, offset); 2069 2070 MSFT_Read(&(*ppImpLib)->lcid, sizeof(LCID), &cx, DO_NOT_SEEK); 2071 MSFT_Read(&(*ppImpLib)->wVersionMajor, sizeof(WORD), &cx, DO_NOT_SEEK); 2072 MSFT_Read(&(*ppImpLib)->wVersionMinor, sizeof(WORD), &cx, DO_NOT_SEEK); 2073 MSFT_Read(& size, sizeof(UINT16), &cx, DO_NOT_SEEK); 1927 2074 1928 2075 size >>= 2; 1929 2076 (*ppImpLib)->name = TLB_Alloc(size+1); 1930 TLB_Read((*ppImpLib)->name, size, &cx, DO_NOT_SEEK);1931 TLB_ReadGuid(&(*ppImpLib)->guid, oGuid, &cx);2077 MSFT_Read((*ppImpLib)->name, size, &cx, DO_NOT_SEEK); 2078 MSFT_ReadGuid(&(*ppImpLib)->guid, oGuid, &cx); 1932 2079 offset = (offset + sizeof(INT) + sizeof(DWORD) + sizeof(LCID) + sizeof(UINT16) + size + 3) & 0xfffffffc; 1933 2080 … … 1945 2092 for(i = 0; i<(int)tlbHeader.nrtypeinfos; i++) 1946 2093 { 1947 *ppTI = TLB_DoTypeInfo(&cx, i, pTypeLibImpl);2094 *ppTI = MSFT_DoTypeInfo(&cx, i, pTypeLibImpl); 1948 2095 1949 2096 ITypeInfo_AddRef((ITypeInfo*) *ppTI); … … 1957 2104 } 1958 2105 2106 2107 static BSTR TLB_MultiByteToBSTR(char *ptr) 2108 { 2109 DWORD len; 2110 WCHAR *nameW; 2111 BSTR ret; 2112 2113 len = MultiByteToWideChar(CP_ACP, 0, ptr, -1, NULL, 0); 2114 nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 2115 MultiByteToWideChar(CP_ACP, 0, ptr, -1, nameW, len); 2116 ret = SysAllocString(nameW); 2117 HeapFree(GetProcessHeap(), 0, nameW); 2118 return ret; 2119 } 2120 2121 static BOOL TLB_GUIDFromString(char *str, GUID *guid) 2122 { 2123 char b[3]; 2124 int i; 2125 short s; 2126 2127 if(sscanf(str, "%lx-%hx-%hx-%hx", &guid->Data1, &guid->Data2, &guid->Data3, &s) != 4) { 2128 FIXME("Can't parse guid %s\n", debugstr_guid(guid)); 2129 return FALSE; 2130 } 2131 2132 guid->Data4[0] = s >> 8; 2133 guid->Data4[1] = s & 0xff; 2134 2135 b[2] = '\0'; 2136 for(i = 0; i < 6; i++) { 2137 memcpy(b, str + 24 + 2 * i, 2); 2138 guid->Data4[i + 2] = strtol(b, NULL, 16); 2139 } 2140 return TRUE; 2141 } 2142 2143 static WORD SLTG_ReadString(char *ptr, BSTR *pBstr) 2144 { 2145 WORD bytelen; 2146 DWORD len; 2147 WCHAR *nameW; 2148 2149 *pBstr = NULL; 2150 bytelen = *(WORD*)ptr; 2151 if(bytelen == 0xffff) return 2; 2152 len = MultiByteToWideChar(CP_ACP, 0, ptr + 2, bytelen, NULL, 0); 2153 nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 2154 len = MultiByteToWideChar(CP_ACP, 0, ptr + 2, bytelen, nameW, len); 2155 *pBstr = SysAllocStringLen(nameW, len); 2156 HeapFree(GetProcessHeap(), 0, nameW); 2157 return bytelen + 2; 2158 } 2159 2160 static WORD SLTG_ReadStringA(char *ptr, char **str) 2161 { 2162 WORD bytelen; 2163 2164 *str = NULL; 2165 bytelen = *(WORD*)ptr; 2166 if(bytelen == 0xffff) return 2; 2167 *str = HeapAlloc(GetProcessHeap(), 0, bytelen + 1); 2168 memcpy(*str, ptr + 2, bytelen); 2169 (*str)[bytelen] = '\0'; 2170 return bytelen + 2; 2171 } 2172 2173 static DWORD SLTG_ReadLibBlk(LPVOID pLibBlk, ITypeLibImpl *pTypeLibImpl) 2174 { 2175 char *ptr = pLibBlk; 2176 WORD w; 2177 2178 if((w = *(WORD*)ptr) != SLTG_LIBBLK_MAGIC) { 2179 FIXME("libblk magic = %04x\n", w); 2180 return 0; 2181 } 2182 2183 ptr += 6; 2184 if((w = *(WORD*)ptr) != 0xffff) { 2185 FIXME("LibBlk.res06 = %04x. Assumung string and skipping\n", w); 2186 ptr += w; 2187 } 2188 ptr += 2; 2189 2190 ptr += SLTG_ReadString(ptr, &pTypeLibImpl->DocString); 2191 2192 ptr += SLTG_ReadString(ptr, &pTypeLibImpl->HelpFile); 2193 2194 pTypeLibImpl->dwHelpContext = *(DWORD*)ptr; 2195 ptr += 4; 2196 2197 pTypeLibImpl->LibAttr.syskind = *(WORD*)ptr; 2198 ptr += 2; 2199 2200 pTypeLibImpl->LibAttr.lcid = *(WORD*)ptr; 2201 ptr += 2; 2202 2203 ptr += 4; /* skip res12 */ 2204 2205 pTypeLibImpl->LibAttr.wLibFlags = *(WORD*)ptr; 2206 ptr += 2; 2207 2208 pTypeLibImpl->LibAttr.wMajorVerNum = *(WORD*)ptr; 2209 ptr += 2; 2210 2211 pTypeLibImpl->LibAttr.wMinorVerNum = *(WORD*)ptr; 2212 ptr += 2; 2213 2214 memcpy(&pTypeLibImpl->LibAttr.guid, ptr, sizeof(GUID)); 2215 ptr += sizeof(GUID); 2216 2217 return ptr - (char*)pLibBlk; 2218 } 2219 2220 static WORD *SLTG_DoType(WORD *pType, char *pBlk, ELEMDESC *pElem) 2221 { 2222 BOOL done = FALSE; 2223 TYPEDESC *pTD = &pElem->tdesc; 2224 2225 /* Handle [in/out] first */ 2226 if((*pType & 0xc000) == 0xc000) 2227 pElem->u.paramdesc.wParamFlags = PARAMFLAG_NONE; 2228 else if(*pType & 0x8000) 2229 pElem->u.paramdesc.wParamFlags = PARAMFLAG_FIN | PARAMFLAG_FOUT; 2230 else if(*pType & 0x4000) 2231 pElem->u.paramdesc.wParamFlags = PARAMFLAG_FOUT; 2232 else 2233 pElem->u.paramdesc.wParamFlags = PARAMFLAG_FIN; 2234 2235 if(*pType & 0x2000) 2236 pElem->u.paramdesc.wParamFlags |= PARAMFLAG_FLCID; 2237 2238 if(*pType & 0x80) 2239 pElem->u.paramdesc.wParamFlags |= PARAMFLAG_FRETVAL; 2240 2241 while(!done) { 2242 if((*pType & 0xe00) == 0xe00) { 2243 pTD->vt = VT_PTR; 2244 pTD->u.lptdesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2245 sizeof(TYPEDESC)); 2246 pTD = pTD->u.lptdesc; 2247 } 2248 switch(*pType & 0x7f) { 2249 case VT_PTR: 2250 pTD->vt = VT_PTR; 2251 pTD->u.lptdesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2252 sizeof(TYPEDESC)); 2253 pTD = pTD->u.lptdesc; 2254 break; 2255 2256 case VT_USERDEFINED: 2257 pTD->vt = VT_USERDEFINED; 2258 pTD->u.hreftype = *(++pType) / 4; 2259 done = TRUE; 2260 break; 2261 2262 case VT_CARRAY: 2263 { 2264 /* *(pType+1) is offset to a SAFEARRAY, *(pType+2) is type of 2265 array */ 2266 2267 SAFEARRAY *pSA = (SAFEARRAY *)(pBlk + *(++pType)); 2268 2269 pTD->vt = VT_CARRAY; 2270 pTD->u.lpadesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2271 sizeof(ARRAYDESC) + 2272 (pSA->cDims - 1) * sizeof(SAFEARRAYBOUND)); 2273 pTD->u.lpadesc->cDims = pSA->cDims; 2274 memcpy(pTD->u.lpadesc->rgbounds, pSA->rgsabound, 2275 pSA->cDims * sizeof(SAFEARRAYBOUND)); 2276 2277 pTD = &pTD->u.lpadesc->tdescElem; 2278 break; 2279 } 2280 2281 case VT_SAFEARRAY: 2282 { 2283 /* FIXME: *(pType+1) gives an offset to SAFEARRAY, is this 2284 useful? */ 2285 2286 pType++; 2287 pTD->vt = VT_SAFEARRAY; 2288 pTD->u.lptdesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2289 sizeof(TYPEDESC)); 2290 pTD = pTD->u.lptdesc; 2291 break; 2292 } 2293 default: 2294 pTD->vt = *pType & 0x7f; 2295 done = TRUE; 2296 break; 2297 } 2298 pType++; 2299 } 2300 return pType; 2301 } 2302 2303 2304 static void SLTG_DoRefs(SLTG_RefInfo *pRef, ITypeInfoImpl *pTI, 2305 char *pNameTable) 2306 { 2307 int ref; 2308 char *name; 2309 TLBRefType **ppRefType; 2310 2311 if(pRef->magic != SLTG_REF_MAGIC) { 2312 FIXME("Ref magic = %x\n", pRef->magic); 2313 return; 2314 } 2315 name = ( (char*)(&pRef->names) + pRef->number); 2316 2317 ppRefType = &pTI->reflist; 2318 for(ref = 0; ref < pRef->number >> 3; ref++) { 2319 char *refname; 2320 unsigned int lib_offs, type_num; 2321 2322 *ppRefType = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2323 sizeof(**ppRefType)); 2324 2325 name += SLTG_ReadStringA(name, &refname); 2326 if(sscanf(refname, "*\\R%x*#%x", &lib_offs, &type_num) != 2) 2327 FIXME("Can't sscanf ref\n"); 2328 if(lib_offs != 0xffff) { 2329 TLBImpLib **import = &pTI->pTypeLib->pImpLibs; 2330 2331 while(*import) { 2332 if((*import)->offset == lib_offs) 2333 break; 2334 import = &(*import)->next; 2335 } 2336 if(!*import) { 2337 char fname[MAX_PATH+1]; 2338 int len; 2339 2340 *import = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2341 sizeof(**import)); 2342 (*import)->offset = lib_offs; 2343 TLB_GUIDFromString( pNameTable + lib_offs + 4, 2344 &(*import)->guid); 2345 if(sscanf(pNameTable + lib_offs + 40, "}#%hd.%hd#%lx#%s", 2346 &(*import)->wVersionMajor, 2347 &(*import)->wVersionMinor, 2348 &(*import)->lcid, fname) != 4) { 2349 FIXME("can't sscanf ref %s\n", 2350 pNameTable + lib_offs + 40); 2351 } 2352 len = strlen(fname); 2353 if(fname[len-1] != '#') 2354 FIXME("fname = %s\n", fname); 2355 fname[len-1] = '\0'; 2356 (*import)->name = TLB_MultiByteToBSTR(fname); 2357 } 2358 (*ppRefType)->pImpTLInfo = *import; 2359 } else { /* internal ref */ 2360 (*ppRefType)->pImpTLInfo = TLB_REF_INTERNAL; 2361 } 2362 (*ppRefType)->reference = ref; 2363 (*ppRefType)->index = type_num; 2364 2365 HeapFree(GetProcessHeap(), 0, refname); 2366 ppRefType = &(*ppRefType)->next; 2367 } 2368 if((BYTE)*name != SLTG_REF_MAGIC) 2369 FIXME("End of ref block magic = %x\n", *name); 2370 dump_TLBRefType(pTI->reflist); 2371 } 2372 2373 static char *SLTG_DoImpls(SLTG_ImplInfo *info, ITypeInfoImpl *pTI, 2374 BOOL OneOnly) 2375 { 2376 TLBImplType **ppImplType = &pTI->impltypelist; 2377 2378 while(1) { 2379 *ppImplType = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2380 sizeof(**ppImplType)); 2381 (*ppImplType)->hRef = info->ref; 2382 (*ppImplType)->implflags = info->impltypeflags; 2383 pTI->TypeAttr.cImplTypes++; 2384 ppImplType = &(*ppImplType)->next; 2385 2386 if(info->next == 0xffff) 2387 break; 2388 if(OneOnly) 2389 FIXME("Interface inheriting more than one interface\n"); 2390 info++; 2391 } 2392 info++; 2393 return (char*)info; 2394 } 2395 2396 static void SLTG_ProcessCoClass(char *pBlk, ITypeInfoImpl *pTI, 2397 char *pNameTable) 2398 { 2399 SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk; 2400 SLTG_MemberHeader *pMemHeader; 2401 char *pFirstItem, *pNextItem; 2402 2403 if(pTIHeader->href_table != 0xffffffff) { 2404 SLTG_DoRefs((SLTG_RefInfo*)(pBlk + pTIHeader->href_table), pTI, 2405 pNameTable); 2406 } 2407 2408 2409 pMemHeader = (SLTG_MemberHeader*)(pBlk + pTIHeader->elem_table); 2410 2411 pFirstItem = pNextItem = (char*)(pMemHeader + 1); 2412 2413 if(*(WORD*)pFirstItem == SLTG_IMPL_MAGIC) { 2414 pNextItem = SLTG_DoImpls((SLTG_ImplInfo*)pFirstItem, pTI, FALSE); 2415 } 2416 2417 return; 2418 } 2419 2420 2421 static void SLTG_ProcessInterface(char *pBlk, ITypeInfoImpl *pTI, 2422 char *pNameTable) 2423 { 2424 SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk; 2425 SLTG_MemberHeader *pMemHeader; 2426 SLTG_Function *pFunc; 2427 char *pFirstItem, *pNextItem; 2428 TLBFuncDesc **ppFuncDesc = &pTI->funclist; 2429 int num = 0; 2430 2431 if(pTIHeader->href_table != 0xffffffff) { 2432 SLTG_DoRefs((SLTG_RefInfo*)(pBlk + pTIHeader->href_table), pTI, 2433 pNameTable); 2434 } 2435 2436 pMemHeader = (SLTG_MemberHeader*)(pBlk + pTIHeader->elem_table); 2437 2438 pFirstItem = pNextItem = (char*)(pMemHeader + 1); 2439 2440 if(*(WORD*)pFirstItem == SLTG_IMPL_MAGIC) { 2441 pNextItem = SLTG_DoImpls((SLTG_ImplInfo*)pFirstItem, pTI, TRUE); 2442 } 2443 2444 for(pFunc = (SLTG_Function*)pNextItem, num = 1; 1; 2445 pFunc = (SLTG_Function*)(pFirstItem + pFunc->next), num++) { 2446 2447 int param; 2448 WORD *pType, *pArg; 2449 2450 if(pFunc->magic != SLTG_FUNCTION_MAGIC && 2451 pFunc->magic != SLTG_FUNCTION_WITH_FLAGS_MAGIC) { 2452 FIXME("func magic = %02x\n", pFunc->magic); 2453 return; 2454 } 2455 *ppFuncDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2456 sizeof(**ppFuncDesc)); 2457 (*ppFuncDesc)->Name = TLB_MultiByteToBSTR(pFunc->name + pNameTable); 2458 2459 (*ppFuncDesc)->funcdesc.memid = pFunc->dispid; 2460 (*ppFuncDesc)->funcdesc.invkind = pFunc->inv >> 4; 2461 (*ppFuncDesc)->funcdesc.callconv = pFunc->nacc & 0x7; 2462 (*ppFuncDesc)->funcdesc.cParams = pFunc->nacc >> 3; 2463 (*ppFuncDesc)->funcdesc.cParamsOpt = (pFunc->retnextopt & 0x7e) >> 1; 2464 (*ppFuncDesc)->funcdesc.oVft = pFunc->vtblpos; 2465 2466 if(pFunc->magic == SLTG_FUNCTION_WITH_FLAGS_MAGIC) 2467 (*ppFuncDesc)->funcdesc.wFuncFlags = pFunc->funcflags; 2468 2469 if(pFunc->retnextopt & 0x80) 2470 pType = &pFunc->rettype; 2471 else 2472 pType = (WORD*)(pFirstItem + pFunc->rettype); 2473 2474 2475 SLTG_DoType(pType, pFirstItem, &(*ppFuncDesc)->funcdesc.elemdescFunc); 2476 2477 (*ppFuncDesc)->funcdesc.lprgelemdescParam = 2478 HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2479 (*ppFuncDesc)->funcdesc.cParams * sizeof(ELEMDESC)); 2480 (*ppFuncDesc)->pParamDesc = 2481 HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2482 (*ppFuncDesc)->funcdesc.cParams * sizeof(TLBParDesc)); 2483 2484 pArg = (WORD*)(pFirstItem + pFunc->arg_off); 2485 2486 for(param = 0; param < (*ppFuncDesc)->funcdesc.cParams; param++) { 2487 char *paramName = pNameTable + *pArg; 2488 /* right, if the arg type follows then paramName points to the 2nd 2489 letter of the name (or there is no name), else if the next 2490 WORD is an offset to the arg type then paramName points to the 2491 first letter. Before the name there always seems to be the byte 2492 0xff or 0x00, so let's take one char off paramName and see what 2493 we're pointing at. Got that? */ 2494 2495 if(*pArg == 0xffff) /* If we don't have a name the type seems to 2496 always follow. FIXME is this correct? */ 2497 paramName = NULL; 2498 2499 pArg++; 2500 2501 if(paramName && 2502 (*(paramName-1) == '\xff' || 2503 *(paramName-1) == '\x00')) { /* the next word is an offset to 2504 the type */ 2505 pType = (WORD*)(pFirstItem + *pArg); 2506 SLTG_DoType(pType, pFirstItem, 2507 &(*ppFuncDesc)->funcdesc.lprgelemdescParam[param]); 2508 pArg++; 2509 } else { 2510 if(paramName) 2511 paramName--; 2512 pArg = SLTG_DoType(pArg, pFirstItem, 2513 &(*ppFuncDesc)->funcdesc.lprgelemdescParam[param]); 2514 } 2515 2516 /* Are we an optional param ? */ 2517 if((*ppFuncDesc)->funcdesc.cParams - param <= 2518 (*ppFuncDesc)->funcdesc.cParamsOpt) 2519 (*ppFuncDesc)->funcdesc.lprgelemdescParam[param].u.paramdesc.wParamFlags |= PARAMFLAG_FOPT; 2520 2521 if(paramName) { 2522 (*ppFuncDesc)->pParamDesc[param].Name = 2523 TLB_MultiByteToBSTR(paramName); 2524 } 2525 } 2526 2527 ppFuncDesc = &((*ppFuncDesc)->next); 2528 if(pFunc->next == 0xffff) break; 2529 } 2530 pTI->TypeAttr.cFuncs = num; 2531 dump_TLBFuncDesc(pTI->funclist); 2532 } 2533 2534 static void SLTG_ProcessRecord(char *pBlk, ITypeInfoImpl *pTI, char *pNameTable) 2535 { 2536 SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk; 2537 SLTG_MemberHeader *pMemHeader; 2538 SLTG_RecordItem *pItem; 2539 char *pFirstItem; 2540 TLBVarDesc **ppVarDesc = &pTI->varlist; 2541 int num = 0; 2542 WORD *pType; 2543 char buf[300]; 2544 2545 pMemHeader = (SLTG_MemberHeader*)(pBlk + pTIHeader->elem_table); 2546 2547 pFirstItem = (char*)(pMemHeader + 1); 2548 for(pItem = (SLTG_RecordItem *)pFirstItem, num = 1; 1; 2549 pItem = (SLTG_RecordItem *)(pFirstItem + pItem->next), num++) { 2550 if(pItem->magic != SLTG_RECORD_MAGIC) { 2551 FIXME("record magic = %02x\n", pItem->magic); 2552 return; 2553 } 2554 *ppVarDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2555 sizeof(**ppVarDesc)); 2556 (*ppVarDesc)->Name = TLB_MultiByteToBSTR(pItem->name + pNameTable); 2557 (*ppVarDesc)->vardesc.memid = pItem->memid; 2558 (*ppVarDesc)->vardesc.u.oInst = pItem->byte_offs; 2559 (*ppVarDesc)->vardesc.varkind = VAR_PERINSTANCE; 2560 2561 if(pItem->typepos == 0x02) 2562 pType = &pItem->type; 2563 else if(pItem->typepos == 0x00) 2564 pType = (WORD*)(pFirstItem + pItem->type); 2565 else { 2566 FIXME("typepos = %02x\n", pItem->typepos); 2567 break; 2568 } 2569 2570 SLTG_DoType(pType, pFirstItem, 2571 &(*ppVarDesc)->vardesc.elemdescVar); 2572 2573 /* FIXME("helpcontext, helpstring\n"); */ 2574 2575 dump_TypeDesc(&(*ppVarDesc)->vardesc.elemdescVar.tdesc, buf); 2576 2577 ppVarDesc = &((*ppVarDesc)->next); 2578 if(pItem->next == 0xffff) break; 2579 } 2580 pTI->TypeAttr.cVars = num; 2581 } 2582 2583 static void SLTG_ProcessEnum(char *pBlk, ITypeInfoImpl *pTI, char *pNameTable) 2584 { 2585 SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk; 2586 SLTG_MemberHeader *pMemHeader; 2587 SLTG_EnumItem *pItem; 2588 char *pFirstItem; 2589 TLBVarDesc **ppVarDesc = &pTI->varlist; 2590 int num = 0; 2591 2592 pMemHeader = (SLTG_MemberHeader*)(pBlk + pTIHeader->elem_table); 2593 2594 pFirstItem = (char*)(pMemHeader + 1); 2595 for(pItem = (SLTG_EnumItem *)pFirstItem, num = 1; 1; 2596 pItem = (SLTG_EnumItem *)(pFirstItem + pItem->next), num++) { 2597 if(pItem->magic != SLTG_ENUMITEM_MAGIC) { 2598 FIXME("enumitem magic = %04x\n", pItem->magic); 2599 return; 2600 } 2601 *ppVarDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2602 sizeof(**ppVarDesc)); 2603 (*ppVarDesc)->Name = TLB_MultiByteToBSTR(pItem->name + pNameTable); 2604 (*ppVarDesc)->vardesc.memid = pItem->memid; 2605 (*ppVarDesc)->vardesc.u.lpvarValue = HeapAlloc(GetProcessHeap(), 0, 2606 sizeof(VARIANT)); 2607 V_VT((*ppVarDesc)->vardesc.u.lpvarValue) = VT_INT; 2608 V_UNION((*ppVarDesc)->vardesc.u.lpvarValue, intVal) = 2609 *(INT*)(pItem->value + pFirstItem); 2610 (*ppVarDesc)->vardesc.elemdescVar.tdesc.vt = VT_I4; 2611 (*ppVarDesc)->vardesc.varkind = VAR_CONST; 2612 /* FIXME("helpcontext, helpstring\n"); */ 2613 2614 ppVarDesc = &((*ppVarDesc)->next); 2615 if(pItem->next == 0xffff) break; 2616 } 2617 pTI->TypeAttr.cVars = num; 2618 } 2619 2620 /* Because SLTG_OtherTypeInfo is such a painfull struct, we make a more 2621 managable copy of it into this */ 2622 typedef struct { 2623 WORD small_no; 2624 char *index_name; 2625 char *other_name; 2626 WORD res1a; 2627 WORD name_offs; 2628 WORD more_bytes; 2629 char *extra; 2630 WORD res20; 2631 DWORD helpcontext; 2632 WORD res26; 2633 GUID uuid; 2634 } SLTG_InternalOtherTypeInfo; 2635 2636 /**************************************************************************** 2637 * ITypeLib2_Constructor_SLTG 2638 * 2639 * loading a SLTG typelib from an in-memory image 2640 */ 2641 static ITypeLib2* ITypeLib2_Constructor_SLTG(LPVOID pLib, DWORD dwTLBLength) 2642 { 2643 ITypeLibImpl *pTypeLibImpl; 2644 SLTG_Header *pHeader; 2645 SLTG_BlkEntry *pBlkEntry; 2646 SLTG_Magic *pMagic; 2647 SLTG_Index *pIndex; 2648 SLTG_Pad9 *pPad9; 2649 LPVOID pBlk, pFirstBlk; 2650 SLTG_LibBlk *pLibBlk; 2651 SLTG_InternalOtherTypeInfo *pOtherTypeInfoBlks; 2652 char *pAfterOTIBlks = NULL; 2653 char *pNameTable, *ptr; 2654 int i; 2655 DWORD len, order; 2656 ITypeInfoImpl **ppTypeInfoImpl; 2657 2658 TRACE("%p, TLB length = %ld\n", pLib, dwTLBLength); 2659 2660 pTypeLibImpl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ITypeLibImpl)); 2661 if (!pTypeLibImpl) return NULL; 2662 2663 ICOM_VTBL(pTypeLibImpl) = &tlbvt; 2664 pTypeLibImpl->ref = 1; 2665 2666 pHeader = pLib; 2667 2668 TRACE("header:\n"); 2669 TRACE("\tmagic=0x%08lx, file blocks = %d\n", pHeader->SLTG_magic, 2670 pHeader->nrOfFileBlks ); 2671 if (memcmp(&pHeader->SLTG_magic, TLBMAGIC1, 4)) { 2672 FIXME("Header type magic 0x%08lx not supported.\n", 2673 pHeader->SLTG_magic); 2674 return NULL; 2675 } 2676 2677 /* There are pHeader->nrOfFileBlks - 2 TypeInfo records in this typelib */ 2678 pTypeLibImpl->TypeInfoCount = pHeader->nrOfFileBlks - 2; 2679 2680 /* This points to pHeader->nrOfFileBlks - 1 of SLTG_BlkEntry */ 2681 pBlkEntry = (SLTG_BlkEntry*)(pHeader + 1); 2682 2683 /* Next we have a magic block */ 2684 pMagic = (SLTG_Magic*)(pBlkEntry + pHeader->nrOfFileBlks - 1); 2685 2686 /* Let's see if we're still in sync */ 2687 if(memcmp(pMagic->CompObj_magic, SLTG_COMPOBJ_MAGIC, 2688 sizeof(SLTG_COMPOBJ_MAGIC))) { 2689 FIXME("CompObj magic = %s\n", pMagic->CompObj_magic); 2690 return NULL; 2691 } 2692 if(memcmp(pMagic->dir_magic, SLTG_DIR_MAGIC, 2693 sizeof(SLTG_DIR_MAGIC))) { 2694 FIXME("dir magic = %s\n", pMagic->dir_magic); 2695 return NULL; 2696 } 2697 2698 pIndex = (SLTG_Index*)(pMagic+1); 2699 2700 pPad9 = (SLTG_Pad9*)(pIndex + pTypeLibImpl->TypeInfoCount); 2701 2702 pFirstBlk = (LPVOID)(pPad9 + 1); 2703 2704 /* We'll set up a ptr to the main library block, which is the last one. */ 2705 2706 for(pBlk = pFirstBlk, order = pHeader->first_blk - 1, i = 0; 2707 pBlkEntry[order].next != 0; 2708 order = pBlkEntry[order].next - 1, i++) { 2709 #ifdef __WIN32OS2__ 2710 pBlk = (LPBYTE)pBlk + pBlkEntry[order].len; 2711 #else 2712 pBlk += pBlkEntry[order].len; 2713 #endif 2714 } 2715 pLibBlk = pBlk; 2716 2717 len = SLTG_ReadLibBlk(pLibBlk, pTypeLibImpl); 2718 2719 /* Now there's 0x40 bytes of 0xffff with the numbers 0 to TypeInfoCount 2720 interspersed */ 2721 2722 len += 0x40; 2723 2724 /* And now TypeInfoCount of SLTG_OtherTypeInfo */ 2725 2726 pOtherTypeInfoBlks = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2727 sizeof(*pOtherTypeInfoBlks) * 2728 pTypeLibImpl->TypeInfoCount); 2729 2730 2731 ptr = (char*)pLibBlk + len; 2732 2733 for(i = 0; i < pTypeLibImpl->TypeInfoCount; i++) { 2734 WORD w, extra; 2735 len = 0; 2736 2737 pOtherTypeInfoBlks[i].small_no = *(WORD*)ptr; 2738 2739 w = *(WORD*)(ptr + 2); 2740 if(w != 0xffff) { 2741 len += w; 2742 pOtherTypeInfoBlks[i].index_name = HeapAlloc(GetProcessHeap(),0, 2743 w+1); 2744 memcpy(pOtherTypeInfoBlks[i].index_name, ptr + 4, w); 2745 pOtherTypeInfoBlks[i].index_name[w] = '\0'; 2746 } 2747 w = *(WORD*)(ptr + 4 + len); 2748 if(w != 0xffff) { 2749 TRACE("\twith %s\n", debugstr_an(ptr + 6 + len, w)); 2750 len += w; 2751 pOtherTypeInfoBlks[i].other_name = HeapAlloc(GetProcessHeap(),0, 2752 w+1); 2753 memcpy(pOtherTypeInfoBlks[i].other_name, ptr + 6 + len, w); 2754 pOtherTypeInfoBlks[i].other_name[w] = '\0'; 2755 } 2756 pOtherTypeInfoBlks[i].res1a = *(WORD*)(ptr + len + 6); 2757 pOtherTypeInfoBlks[i].name_offs = *(WORD*)(ptr + len + 8); 2758 extra = pOtherTypeInfoBlks[i].more_bytes = *(WORD*)(ptr + 10 + len); 2759 if(extra) { 2760 pOtherTypeInfoBlks[i].extra = HeapAlloc(GetProcessHeap(),0, 2761 extra); 2762 memcpy(pOtherTypeInfoBlks[i].extra, ptr + 12, extra); 2763 len += extra; 2764 } 2765 pOtherTypeInfoBlks[i].res20 = *(WORD*)(ptr + 12 + len); 2766 pOtherTypeInfoBlks[i].helpcontext = *(DWORD*)(ptr + 14 + len); 2767 pOtherTypeInfoBlks[i].res26 = *(WORD*)(ptr + 18 + len); 2768 memcpy(&pOtherTypeInfoBlks[i].uuid, ptr + 20 + len, sizeof(GUID)); 2769 len += sizeof(SLTG_OtherTypeInfo); 2770 ptr += len; 2771 } 2772 2773 pAfterOTIBlks = ptr; 2774 2775 /* Skip this WORD and get the next DWORD */ 2776 len = *(DWORD*)(pAfterOTIBlks + 2); 2777 2778 /* Now add this to pLibBLk and then add 0x216, sprinkle a bit a 2779 magic dust and we should be pointing at the beginning of the name 2780 table */ 2781 2782 pNameTable = (char*)pLibBlk + len + 0x216; 2783 2784 pNameTable += 2; 2785 2786 TRACE("Library name is %s\n", pNameTable + pLibBlk->name); 2787 2788 pTypeLibImpl->Name = TLB_MultiByteToBSTR(pNameTable + pLibBlk->name); 2789 2790 2791 /* Hopefully we now have enough ptrs set up to actually read in 2792 some TypeInfos. It's not clear which order to do them in, so 2793 I'll just follow the links along the BlkEntry chain and read 2794 them in in the order in which they're in the file */ 2795 2796 ppTypeInfoImpl = &(pTypeLibImpl->pTypeInfo); 2797 2798 for(pBlk = pFirstBlk, order = pHeader->first_blk - 1, i = 0; 2799 pBlkEntry[order].next != 0; 2800 order = pBlkEntry[order].next - 1, i++) { 2801 2802 SLTG_TypeInfoHeader *pTIHeader; 2803 2804 if(strcmp(pBlkEntry[order].index_string + (char*)pMagic, 2805 pOtherTypeInfoBlks[i].index_name)) { 2806 FIXME("Index strings don't match\n"); 2807 return NULL; 2808 } 2809 2810 pTIHeader = pBlk; 2811 if(pTIHeader->magic != SLTG_TIHEADER_MAGIC) { 2812 FIXME("TypeInfoHeader magic = %04x\n", pTIHeader->magic); 2813 return NULL; 2814 } 2815 *ppTypeInfoImpl = (ITypeInfoImpl*)ITypeInfo_Constructor(); 2816 (*ppTypeInfoImpl)->pTypeLib = pTypeLibImpl; 2817 (*ppTypeInfoImpl)->index = i; 2818 (*ppTypeInfoImpl)->Name = TLB_MultiByteToBSTR( 2819 pOtherTypeInfoBlks[i].name_offs + 2820 pNameTable); 2821 (*ppTypeInfoImpl)->dwHelpContext = pOtherTypeInfoBlks[i].helpcontext; 2822 memcpy(&((*ppTypeInfoImpl)->TypeAttr.guid), &pOtherTypeInfoBlks[i].uuid, 2823 sizeof(GUID)); 2824 (*ppTypeInfoImpl)->TypeAttr.typekind = pTIHeader->typekind; 2825 (*ppTypeInfoImpl)->TypeAttr.wMajorVerNum = pTIHeader->major_version; 2826 (*ppTypeInfoImpl)->TypeAttr.wMinorVerNum = pTIHeader->minor_version; 2827 (*ppTypeInfoImpl)->TypeAttr.wTypeFlags = 2828 (pTIHeader->typeflags1 >> 3) | (pTIHeader->typeflags2 << 5); 2829 2830 if((pTIHeader->typeflags1 & 7) != 2) 2831 FIXME("typeflags1 = %02x\n", pTIHeader->typeflags1); 2832 if(pTIHeader->typeflags3 != 2) 2833 FIXME("typeflags3 = %02x\n", pTIHeader->typeflags3); 2834 2835 TRACE("TypeInfo %s of kind %s guid %s typeflags %04x\n", 2836 debugstr_w((*ppTypeInfoImpl)->Name), 2837 typekind_desc[pTIHeader->typekind], 2838 debugstr_guid(&(*ppTypeInfoImpl)->TypeAttr.guid), 2839 (*ppTypeInfoImpl)->TypeAttr.wTypeFlags); 2840 2841 switch(pTIHeader->typekind) { 2842 case TKIND_ENUM: 2843 SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable); 2844 break; 2845 2846 case TKIND_RECORD: 2847 SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable); 2848 break; 2849 2850 case TKIND_INTERFACE: 2851 SLTG_ProcessInterface(pBlk, *ppTypeInfoImpl, pNameTable); 2852 break; 2853 2854 case TKIND_COCLASS: 2855 SLTG_ProcessCoClass(pBlk, *ppTypeInfoImpl, pNameTable); 2856 break; 2857 2858 default: 2859 FIXME("Not processing typekind %d\n", pTIHeader->typekind); 2860 break; 2861 2862 } 2863 2864 ppTypeInfoImpl = &((*ppTypeInfoImpl)->next); 2865 #ifdef __WIN32OS2__ 2866 pBlk = (LPBYTE)pBlk + pBlkEntry[order].len; 2867 #else 2868 pBlk += pBlkEntry[order].len; 2869 #endif 2870 } 2871 2872 if(i != pTypeLibImpl->TypeInfoCount) { 2873 FIXME("Somehow processed %d TypeInfos\n", i); 2874 return NULL; 2875 } 2876 2877 HeapFree(GetProcessHeap(), 0, pOtherTypeInfoBlks); 2878 return (ITypeLib2*)pTypeLibImpl; 2879 } 2880 1959 2881 /* ITypeLib::QueryInterface 1960 2882 */ 1961 2883 static HRESULT WINAPI ITypeLib2_fnQueryInterface( 1962 1963 1964 2884 ITypeLib2 * iface, 2885 REFIID riid, 2886 VOID **ppvObject) 1965 2887 { 1966 2888 ICOM_THIS( ITypeLibImpl, iface); … … 1969 2891 1970 2892 *ppvObject=NULL; 1971 if(IsEqualIID(riid, &IID_IUnknown) || 2893 if(IsEqualIID(riid, &IID_IUnknown) || 1972 2894 IsEqualIID(riid,&IID_ITypeLib)|| 1973 2895 IsEqualIID(riid,&IID_ITypeLib2)) … … 2004 2926 2005 2927 --(This->ref); 2006 2928 2007 2929 TRACE("(%p)->(%u)\n",This, This->ref); 2008 2930 … … 2036 2958 This->HelpStringDll = NULL; 2037 2959 } 2038 2960 2039 2961 ITypeInfo_Release((ITypeInfo*) This->pTypeInfo); 2040 2962 HeapFree(GetProcessHeap(),0,This); … … 2046 2968 2047 2969 /* ITypeLib::GetTypeInfoCount 2048 * 2970 * 2049 2971 * Returns the number of type descriptions in the type library 2050 2972 */ … … 2062 2984 static HRESULT WINAPI ITypeLib2_fnGetTypeInfo( 2063 2985 ITypeLib2 *iface, 2064 UINT index, 2986 UINT index, 2065 2987 ITypeInfo **ppTInfo) 2066 2988 { 2067 2989 int i; 2068 2990 2069 2991 ICOM_THIS( ITypeLibImpl, iface); 2070 2992 ITypeInfoImpl *pTypeInfo = This->pTypeInfo; … … 2073 2995 2074 2996 if (!ppTInfo) return E_INVALIDARG; 2075 2997 2076 2998 /* search element n in list */ 2077 2999 for(i=0; i < index; i++) … … 2083 3005 return TYPE_E_ELEMENTNOTFOUND; 2084 3006 } 2085 } 3007 } 2086 3008 2087 3009 *ppTInfo = (ITypeInfo *) pTypeInfo; 2088 3010 2089 3011 ITypeInfo_AddRef(*ppTInfo); 2090 3012 TRACE("-- found (%p)\n",*ppTInfo); … … 2109 3031 2110 3032 if(!pTKind) return E_INVALIDARG; 2111 3033 2112 3034 /* search element n in list */ 2113 3035 for(i=0; i < index; i++) … … 2156 3078 } 2157 3079 2158 TRACE("-- found (%p, %s)\n", 2159 pTypeInfo, 3080 TRACE("-- found (%p, %s)\n", 3081 pTypeInfo, 2160 3082 debugstr_w(pTypeInfo->Name)); 2161 3083 … … 2171 3093 */ 2172 3094 static HRESULT WINAPI ITypeLib2_fnGetLibAttr( 2173 ITypeLib2 *iface, 2174 3095 ITypeLib2 *iface, 3096 LPTLIBATTR *ppTLibAttr) 2175 3097 { 2176 3098 ICOM_THIS( ITypeLibImpl, iface); … … 2188 3110 */ 2189 3111 static HRESULT WINAPI ITypeLib2_fnGetTypeComp( 2190 2191 3112 ITypeLib2 *iface, 3113 ITypeComp **ppTComp) 2192 3114 { 2193 3115 ICOM_THIS( ITypeLibImpl, iface); … … 2208 3130 BSTR *pBstrName, 2209 3131 BSTR *pBstrDocString, 2210 DWORD *pdwHelpContext, 3132 DWORD *pdwHelpContext, 2211 3133 BSTR *pBstrHelpFile) 2212 3134 { 2213 3135 ICOM_THIS( ITypeLibImpl, iface); 2214 3136 2215 3137 HRESULT result = E_INVALIDARG; 2216 3138 2217 3139 ITypeInfo *pTInfo; 2218 3140 2219 3141 2220 3142 TRACE("(%p) index %d Name(%p) DocString(%p) HelpContext(%p) HelpFile(%p)\n", 2221 3143 This, index, 2222 pBstrName, pBstrDocString, 3144 pBstrName, pBstrDocString, 2223 3145 pdwHelpContext, pBstrHelpFile); 2224 3146 2225 3147 if(index<0) 2226 { 3148 { 2227 3149 /* documentation for the typelib */ 2228 3150 if(pBstrName && This->Name) … … 2238 3160 if (!(*pBstrDocString)) return STG_E_INSUFFICIENTMEMORY; 2239 3161 } 2240 3162 2241 3163 if(pdwHelpContext) 2242 3164 { … … 2252 3174 result = S_OK; 2253 3175 } 2254 else 3176 else 2255 3177 { 2256 3178 /* for a typeinfo */ … … 2259 3181 if(SUCCEEDED(result)) 2260 3182 { 2261 result = ITypeInfo_GetDocumentation(pTInfo, 2262 MEMBERID_NIL, 3183 result = ITypeInfo_GetDocumentation(pTInfo, 3184 MEMBERID_NIL, 2263 3185 pBstrName, 2264 pBstrDocString, 3186 pBstrDocString, 2265 3187 pdwHelpContext, pBstrHelpFile); 2266 3188 2267 3189 ITypeInfo_Release(pTInfo); 2268 3190 } … … 2278 3200 */ 2279 3201 static HRESULT WINAPI ITypeLib2_fnIsName( 2280 2281 2282 2283 3202 ITypeLib2 *iface, 3203 LPOLESTR szNameBuf, 3204 ULONG lHashVal, 3205 BOOL *pfName) 2284 3206 { 2285 3207 ICOM_THIS( ITypeLibImpl, iface); … … 2291 3213 2292 3214 TRACE("(%p)->(%s,%08lx,%p)\n", This, debugstr_w(szNameBuf), lHashVal, 2293 3215 pfName); 2294 3216 2295 3217 *pfName=TRUE; … … 2304 3226 for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next) 2305 3227 if(!memcmp(szNameBuf,pVInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit; 2306 3228 2307 3229 } 2308 3230 *pfName=FALSE; … … 2311 3233 TRACE("(%p)slow! search for %s: %s found!\n", This, 2312 3234 debugstr_w(szNameBuf), *pfName?"NOT":""); 2313 3235 2314 3236 return S_OK; 2315 3237 } … … 2322 3244 */ 2323 3245 static HRESULT WINAPI ITypeLib2_fnFindName( 2324 2325 2326 2327 2328 2329 3246 ITypeLib2 *iface, 3247 LPOLESTR szNameBuf, 3248 ULONG lHashVal, 3249 ITypeInfo **ppTInfo, 3250 MEMBERID *rgMemId, 3251 UINT16 *pcFound) 2330 3252 { 2331 3253 ICOM_THIS( ITypeLibImpl, iface); … … 2334 3256 TLBVarDesc *pVInfo; 2335 3257 int i,j = 0; 2336 3258 2337 3259 UINT nNameBufLen = SysStringLen(szNameBuf); 2338 3260 … … 2357 3279 2358 3280 *pcFound=j; 2359 3281 2360 3282 return S_OK; 2361 3283 } … … 2367 3289 */ 2368 3290 static VOID WINAPI ITypeLib2_fnReleaseTLibAttr( 2369 2370 3291 ITypeLib2 *iface, 3292 TLIBATTR *pTLibAttr) 2371 3293 { 2372 3294 ICOM_THIS( ITypeLibImpl, iface); … … 2380 3302 */ 2381 3303 static HRESULT WINAPI ITypeLib2_fnGetCustData( 2382 2383 REFGUID guid, 3304 ITypeLib2 * iface, 3305 REFGUID guid, 2384 3306 VARIANT *pVarVal) 2385 3307 { … … 2391 3313 if( IsEqualIID(guid, &pCData->guid)) break; 2392 3314 } 2393 3315 2394 3316 TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT"); 2395 3317 … … 2410 3332 */ 2411 3333 static HRESULT WINAPI ITypeLib2_fnGetLibStatistics( 2412 ITypeLib2 * iface, 3334 ITypeLib2 * iface, 2413 3335 ULONG *pcUniqueNames, 2414 3336 ULONG *pcchUniqueNames) 2415 3337 { 2416 3338 ICOM_THIS( ITypeLibImpl, iface); … … 2431 3353 */ 2432 3354 static HRESULT WINAPI ITypeLib2_fnGetDocumentation2( 2433 ITypeLib2 * iface, 3355 ITypeLib2 * iface, 2434 3356 INT index, 2435 2436 3357 LCID lcid, 3358 BSTR *pbstrHelpString, 2437 3359 DWORD *pdwHelpStringContext, 2438 3360 BSTR *pbstrHelpStringDll) 2439 3361 { 2440 3362 ICOM_THIS( ITypeLibImpl, iface); … … 2464 3386 /* for a typeinfo */ 2465 3387 result=ITypeLib2_GetTypeInfo(iface, index, &pTInfo); 2466 3388 2467 3389 if(SUCCEEDED(result)) 2468 { 3390 { 2469 3391 ITypeInfo2 * pTInfo2; 2470 result = ITypeInfo_QueryInterface(pTInfo, 2471 &IID_ITypeInfo2, 3392 result = ITypeInfo_QueryInterface(pTInfo, 3393 &IID_ITypeInfo2, 2472 3394 (LPVOID*) &pTInfo2); 2473 3395 2474 3396 if(SUCCEEDED(result)) 2475 3397 { 2476 result = ITypeInfo2_GetDocumentation2(pTInfo2, 2477 MEMBERID_NIL, 3398 result = ITypeInfo2_GetDocumentation2(pTInfo2, 3399 MEMBERID_NIL, 2478 3400 lcid, 2479 pbstrHelpString, 2480 pdwHelpStringContext, 3401 pbstrHelpString, 3402 pdwHelpStringContext, 2481 3403 pbstrHelpStringDll); 2482 3404 2483 3405 ITypeInfo2_Release(pTInfo2); 2484 3406 } 2485 3407 2486 3408 ITypeInfo_Release(pTInfo); 2487 3409 } … … 2492 3414 /* ITypeLib2::GetAllCustData 2493 3415 * 2494 * Gets all custom data items for the library. 3416 * Gets all custom data items for the library. 2495 3417 * 2496 3418 */ 2497 3419 static HRESULT WINAPI ITypeLib2_fnGetAllCustData( 2498 3420 ITypeLib2 * iface, 2499 3421 CUSTDATA *pCustData) 2500 3422 { … … 2502 3424 TLBCustData *pCData; 2503 3425 int i; 2504 TRACE("(%p) returning %d items\n", This, This->ctCustData); 3426 TRACE("(%p) returning %d items\n", This, This->ctCustData); 2505 3427 pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM)); 2506 3428 if(pCustData->prgCustData ){ … … 2557 3479 */ 2558 3480 static HRESULT WINAPI ITypeInfo_fnQueryInterface( 2559 2560 2561 3481 ITypeInfo2 *iface, 3482 REFIID riid, 3483 VOID **ppvObject) 2562 3484 { 2563 3485 ICOM_THIS( ITypeLibImpl, iface); … … 2566 3488 2567 3489 *ppvObject=NULL; 2568 if(IsEqualIID(riid, &IID_IUnknown) || 3490 if(IsEqualIID(riid, &IID_IUnknown) || 2569 3491 IsEqualIID(riid,&IID_ITypeInfo)|| 2570 3492 IsEqualIID(riid,&IID_ITypeInfo2)) … … 2599 3521 2600 3522 --(This->ref); 2601 3523 2602 3524 TRACE("(%p)->(%u)\n",This, This->ref); 2603 3525 … … 2606 3528 FIXME("destroy child objects\n"); 2607 3529 2608 TRACE("destroying ITypeInfo(%p)\n",This); 3530 TRACE("destroying ITypeInfo(%p)\n",This); 2609 3531 if (This->Name) 2610 3532 { … … 2612 3534 This->Name = 0; 2613 3535 } 2614 3536 2615 3537 if (This->DocString) 2616 3538 { … … 2671 3593 ICOM_THIS( ITypeInfoImpl, iface); 2672 3594 int i; 2673 TLBFuncDesc * pFDesc; 3595 TLBFuncDesc * pFDesc; 2674 3596 TRACE("(%p) index %d\n", This, index); 2675 3597 for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next) … … 2685 3607 /* ITypeInfo::GetVarDesc 2686 3608 * 2687 * Retrieves a VARDESC structure that describes the specified variable. 3609 * Retrieves a VARDESC structure that describes the specified variable. 2688 3610 * 2689 3611 */ … … 2693 3615 ICOM_THIS( ITypeInfoImpl, iface); 2694 3616 int i; 2695 TLBVarDesc * pVDesc; 3617 TLBVarDesc * pVDesc; 2696 3618 TRACE("(%p) index %d\n", This, index); 2697 3619 for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, pVDesc=pVDesc->next) … … 2715 3637 { 2716 3638 ICOM_THIS( ITypeInfoImpl, iface); 2717 TLBFuncDesc * pFDesc; 2718 TLBVarDesc * pVDesc; 3639 TLBFuncDesc * pFDesc; 3640 TLBVarDesc * pVDesc; 2719 3641 int i; 2720 3642 TRACE("(%p) memid=0x%08lx Maxname=%d\n", This, memid, cMaxNames); … … 2726 3648 { 2727 3649 if(!i) 2728 3650 *rgBstrNames=SysAllocString(pFDesc->Name); 2729 3651 else 2730 3652 rgBstrNames[i]=SysAllocString(pFDesc->pParamDesc[i-1].Name); … … 2747 3669 ITypeInfo *pTInfo; 2748 3670 HRESULT result; 2749 result=ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->reference, &pTInfo); 3671 result=ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, 3672 &pTInfo); 2750 3673 if(SUCCEEDED(result)) 2751 3674 { 2752 3675 result=ITypeInfo_GetNames(pTInfo, memid, rgBstrNames, cMaxNames, pcNames); 2753 3676 ITypeInfo_Release(pTInfo); … … 2757 3680 } 2758 3681 else 2759 3682 { 2760 3683 WARN("no names found\n"); 2761 3684 } 2762 3685 *pcNames=0; 2763 3686 return TYPE_E_ELEMENTNOTFOUND; … … 2777 3700 */ 2778 3701 static HRESULT WINAPI ITypeInfo_fnGetRefTypeOfImplType( 2779 3702 ITypeInfo2 *iface, 2780 3703 UINT index, 2781 3704 HREFTYPE *pRefType) 2782 3705 { 2783 3706 ICOM_THIS( ITypeInfoImpl, iface); 2784 3707 int(i); 2785 TLB RefType *pIref= This->impltypelist;3708 TLBImplType *pImpl = This->impltypelist; 2786 3709 2787 3710 TRACE("(%p) index %d\n", This, index); … … 2794 3717 */ 2795 3718 if( This->TypeAttr.typekind != TKIND_DISPATCH) return E_INVALIDARG; 2796 3719 2797 3720 if (This->TypeAttr.wTypeFlags & TYPEFLAG_FDISPATCHABLE && 2798 3721 This->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL ) … … 2802 3725 else 2803 3726 { 2804 if (!pI ref) return TYPE_E_ELEMENTNOTFOUND;2805 *pRefType = pI ref->reference;3727 if (!pImpl) return TYPE_E_ELEMENTNOTFOUND; 3728 *pRefType = pImpl->hRef; 2806 3729 } 2807 3730 } … … 2809 3732 { 2810 3733 /* get element n from linked list */ 2811 for(i=0; pI ref&& i<index; i++)3734 for(i=0; pImpl && i<index; i++) 2812 3735 { 2813 pI ref = pIref->next;3736 pImpl = pImpl->next; 2814 3737 } 2815 2816 if (!pI ref) return TYPE_E_ELEMENTNOTFOUND;2817 2818 *pRefType = pI ref->reference;2819 2820 TRACE("-- 0x%08lx %s\n",pIref->reference, debugstr_guid(&pIref->guid));2821 } 2822 3738 3739 if (!pImpl) return TYPE_E_ELEMENTNOTFOUND; 3740 3741 *pRefType = pImpl->hRef; 3742 3743 TRACE("-- 0x%08lx\n", pImpl->hRef ); 3744 } 3745 2823 3746 return S_OK; 2824 3747 2825 3748 } 2826 3749 2827 3750 /* ITypeInfo::GetImplTypeFlags 2828 * 2829 * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface 3751 * 3752 * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface 2830 3753 * or base interface in a type description. 2831 3754 */ … … 2834 3757 { 2835 3758 ICOM_THIS( ITypeInfoImpl, iface); 2836 int(i); 2837 TLBRefType *pIref; 3759 int i; 3760 TLBImplType *pImpl; 3761 2838 3762 TRACE("(%p) index %d\n", This, index); 2839 for(i=0, pIref=This->impltypelist; i<index && pIref; i++, pIref=pIref->next) 3763 for(i=0, pImpl=This->impltypelist; i<index && pImpl; 3764 i++, pImpl=pImpl->next) 2840 3765 ; 2841 if(i==index && pI ref){2842 *pImplTypeFlags=pI ref->flags;3766 if(i==index && pImpl){ 3767 *pImplTypeFlags=pImpl->implflags; 2843 3768 return S_OK; 2844 3769 } … … 2855 3780 { 2856 3781 ICOM_THIS( ITypeInfoImpl, iface); 2857 TLBFuncDesc * pFDesc; 2858 TLBVarDesc * pVDesc; 3782 TLBFuncDesc * pFDesc; 3783 TLBVarDesc * pVDesc; 2859 3784 HRESULT ret=S_OK; 2860 2861 3785 UINT nNameLen = SysStringLen(*rgszNames); 3786 2862 3787 TRACE("(%p) Name %s cNames %d\n", This, debugstr_w(*rgszNames), 2863 3788 cNames); … … 2867 3792 if(cNames) *pMemId=pFDesc->funcdesc.memid; 2868 3793 for(i=1; i < cNames; i++){ 2869 3794 UINT nParamLen = SysStringLen(rgszNames[i]); 2870 3795 for(j=0; j<pFDesc->funcdesc.cParams; j++) 2871 3796 if(memcmp(rgszNames[i],pFDesc->pParamDesc[j].Name, nParamLen)) … … 2878 3803 return ret; 2879 3804 } 2880 } 3805 } 2881 3806 for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) { 2882 3807 if( !memcmp(*rgszNames, pVDesc->Name, nNameLen)) { … … 2885 3810 } 2886 3811 } 2887 /* not found, see if this is and interface with an inheritance */ 2888 if(This->TypeAttr.typekind==TKIND_INTERFACE && 3812 /* not found, see if this is and interface with an inheritance */ 3813 if(This->TypeAttr.typekind==TKIND_INTERFACE && 2889 3814 This->TypeAttr.cImplTypes ){ 2890 3815 /* recursive search */ 2891 3816 ITypeInfo *pTInfo; 2892 ret=ITypeInfo_GetRefTypeInfo(iface, 2893 This->impltypelist-> reference, &pTInfo);3817 ret=ITypeInfo_GetRefTypeInfo(iface, 3818 This->impltypelist->hRef, &pTInfo); 2894 3819 if(SUCCEEDED(ret)){ 2895 3820 ret=ITypeInfo_GetIDsOfNames(pTInfo, rgszNames, cNames, pMemId ); … … 2904 3829 2905 3830 /* ITypeInfo::Invoke 2906 * 3831 * 2907 3832 * Invokes a method, or accesses a property of an object, that implements the 2908 3833 * interface described by the type description. … … 2912 3837 2913 3838 if (TRACE_ON(ole)) { 2914 2915 2916 2917 3839 int i; 3840 MESSAGE("Calling %p(",func); 3841 for (i=0;i<nrargs;i++) MESSAGE("%08lx,",args[i]); 3842 MESSAGE(")\n"); 2918 3843 } 2919 3844 … … 2921 3846 case CC_STDCALL: 2922 3847 2923 2924 3848 switch (nrargs) { 3849 case 0: { 2925 3850 #ifdef __WIN32OS2__ 2926 3851 DWORD (* WINAPI xfunc)() = func; 2927 3852 #else 2928 3853 DWORD (WINAPI *xfunc)() = func; 2929 3854 #endif 2930 2931 2932 2933 3855 res = xfunc(); 3856 break; 3857 } 3858 case 1: { 2934 3859 #ifdef __WIN32OS2__ 2935 3860 DWORD (* WINAPI xfunc)(DWORD) = func; 2936 3861 #else 2937 3862 DWORD (WINAPI *xfunc)(DWORD) = func; 2938 3863 #endif 2939 2940 2941 2942 3864 res = xfunc(args[0]); 3865 break; 3866 } 3867 case 2: { 2943 3868 #ifdef __WIN32OS2__ 2944 3869 DWORD (* WINAPI xfunc)(DWORD,DWORD) = func; 2945 3870 #else 2946 3871 DWORD (WINAPI *xfunc)(DWORD,DWORD) = func; 2947 3872 #endif 2948 2949 2950 2951 3873 res = xfunc(args[0],args[1]); 3874 break; 3875 } 3876 case 3: { 2952 3877 #ifdef __WIN32OS2__ 2953 3878 DWORD (* WINAPI xfunc)(DWORD,DWORD,DWORD) = func; 2954 3879 #else 2955 3880 DWORD (WINAPI *xfunc)(DWORD,DWORD,DWORD) = func; 2956 3881 #endif 2957 res = xfunc(args[0],args[1],args[2]); 2958 break; 2959 } 3882 res = xfunc(args[0],args[1],args[2]); 3883 break; 3884 } 3885 default: 3886 FIXME("unsupported number of arguments %d in stdcall\n",nrargs); 3887 res = -1; 3888 break; 3889 } 3890 break; 2960 3891 default: 2961 FIXME("unsupported number of arguments %d in stdcall\n",nrargs); 2962 res = -1; 2963 break; 2964 } 2965 break; 2966 default: 2967 FIXME("unsupported calling convention %d\n",callconv); 2968 res = -1; 2969 break; 3892 FIXME("unsupported calling convention %d\n",callconv); 3893 res = -1; 3894 break; 2970 3895 } 2971 3896 TRACE("returns %08lx\n",res); … … 2984 3909 { 2985 3910 ICOM_THIS( ITypeInfoImpl, iface); 2986 TLBFuncDesc * pFDesc; 2987 TLBVarDesc * pVDesc; 3911 TLBFuncDesc * pFDesc; 3912 TLBVarDesc * pVDesc; 2988 3913 int i; 2989 3914 … … 2994 3919 2995 3920 for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) 2996 2997 2998 2999 3921 if (pFDesc->funcdesc.memid == memid) { 3922 if (pFDesc->funcdesc.invkind & (dwFlags & ~DISPATCH_METHOD)) 3923 break; 3924 } 3000 3925 if (pFDesc) { 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3926 dump_TLBFuncDescOne(pFDesc); 3927 switch (pFDesc->funcdesc.funckind) { 3928 case FUNC_PUREVIRTUAL: 3929 case FUNC_VIRTUAL: { 3930 DWORD res; 3931 DWORD *args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*(pFDesc->funcdesc.cParams+1)); 3932 DWORD *args2 = (DWORD*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DWORD)*(pFDesc->funcdesc.cParams)); 3933 args[0] = (DWORD)pIUnk; 3934 3935 for (i=0;i<pFDesc->funcdesc.cParams;i++) { 3936 if (i<pDispParams->cArgs) { 3937 TRACE("set %d to disparg type %d vs %d\n",i, 3938 V_VT(pDispParams->rgvarg+i), 3939 pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt 3940 ); 3941 args[i+1] = V_UNION(pDispParams->rgvarg+i,lVal); 3942 } else { 3943 TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i].tdesc); 3944 TRACE("set %d to pointer for get (type is %d)\n",i,tdesc->vt); 3945 /*FIXME: give pointers for the rest, so propertyget works*/ 3946 args[i+1] = (DWORD)&args2[i]; 3947 3948 /* If pointer to variant, pass reference to variant 3949 * in result variant array. 3950 */ 3951 if ((tdesc->vt == VT_PTR) && 3952 (tdesc->u.lptdesc->vt == VT_VARIANT) && 3953 pVarResult 3954 ) 3955 args[i+1] = (DWORD)(pVarResult+(i-pDispParams->cArgs)); 3956 } 3957 } 3958 if (pFDesc->funcdesc.cParamsOpt) 3959 FIXME("Does not support optional parameters (%d)\n", 3960 pFDesc->funcdesc.cParamsOpt 3961 ); 3962 3963 res = _invoke((*(DWORD***)pIUnk)[pFDesc->funcdesc.oVft/4], 3964 pFDesc->funcdesc.callconv, 3965 pFDesc->funcdesc.cParams+1, 3966 args 3967 ); 3968 if (pVarResult && (dwFlags & (DISPATCH_PROPERTYGET))) { 3969 for (i=0;i<pFDesc->funcdesc.cParams-pDispParams->cArgs;i++) { 3970 TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i].tdesc); 3971 /* If we are a pointer to a variant, we are done already */ 3972 if ((tdesc->vt==VT_PTR)&&(tdesc->u.lptdesc->vt==VT_VARIANT)) 3973 continue; 3974 3975 VariantInit(&pVarResult[i]); 3976 V_UNION(pVarResult+i,intVal) = args2[i]; 3977 3978 if (tdesc->vt == VT_PTR) 3979 tdesc = tdesc->u.lptdesc; 3980 V_VT(pVarResult+i) = tdesc->vt; 3981 3982 /* HACK: VB5 likes this. 3983 * I do not know why. There is 1 example in MSDN which uses 3984 * this which appears broken (mixes int vals and 3985 * IDispatch*.). 3986 */ 3987 if ((tdesc->vt == VT_PTR) && (dwFlags & DISPATCH_METHOD)) 3988 V_VT(pVarResult+i) = VT_DISPATCH; 3989 TRACE("storing into variant: [%d] type %d, val %08x\n", 3990 i,V_VT(pVarResult+i),V_UNION(pVarResult+i,intVal) 3991 ); 3992 } 3993 } 3994 HeapFree(GetProcessHeap(),0,args2); 3995 HeapFree(GetProcessHeap(),0,args); 3996 return S_OK; 3997 } 3998 case FUNC_DISPATCH: { 3999 IDispatch *disp; 4000 HRESULT hr; 4001 4002 hr = IUnknown_QueryInterface((LPUNKNOWN)pIUnk,&IID_IDispatch,(LPVOID*)&disp); 4003 if (hr) { 4004 FIXME("FUNC_DISPATCH used on object without IDispatch iface?\n"); 4005 return hr; 4006 } 4007 FIXME("Calling Invoke in IDispatch iface. untested!\n"); 4008 hr = IDispatch_Invoke( 4009 disp,memid,&IID_NULL,LOCALE_USER_DEFAULT,dwFlags,pDispParams, 4010 pVarResult,pExcepInfo,pArgErr 4011 ); 4012 if (hr) 4013 FIXME("IDispatch::Invoke failed with %08lx. (Could be not a real error?)\n",hr); 4014 IDispatch_Release(disp); 4015 return hr; 4016 } 4017 default: 4018 FIXME("Unknown function invocation type %d\n",pFDesc->funcdesc.funckind); 4019 return E_FAIL; 4020 } 3096 4021 } else { 3097 3098 3099 3100 3101 3102 3103 3104 4022 FIXME("variable based invoking not supported yet.\n"); 4023 for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) { 4024 if (pVDesc->vardesc.memid == memid) { 4025 FIXME("varseek: Found memid name %s\n",debugstr_w(((LPWSTR)pVDesc->Name))); 4026 dump_TLBVarDesc(pVDesc); 4027 break; 4028 } 4029 } 3105 4030 } 3106 4031 FIXME("Did not find member id %d!\n",(int)memid); … … 3109 4034 3110 4035 /* ITypeInfo::GetDocumentation 3111 * 4036 * 3112 4037 * Retrieves the documentation string, the complete Help file name and path, 3113 4038 * and the context ID for the Help topic for a specified type description. … … 3118 4043 { 3119 4044 ICOM_THIS( ITypeInfoImpl, iface); 3120 TLBFuncDesc * pFDesc; 3121 TLBVarDesc * pVDesc; 4045 TLBFuncDesc * pFDesc; 4046 TLBVarDesc * pVDesc; 3122 4047 TRACE("(%p) memid %ld Name(%p) DocString(%p)" 3123 4048 " HelpContext(%p) HelpFile(%p)\n", … … 3136 4061 for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) 3137 4062 if(pFDesc->funcdesc.memid==memid){ 3138 return S_OK; 4063 if(pBstrName) 4064 *pBstrName = SysAllocString(pFDesc->Name); 4065 if(pBstrDocString) 4066 *pBstrDocString=SysAllocString(pFDesc->HelpString); 4067 if(pdwHelpContext) 4068 *pdwHelpContext=pFDesc->helpcontext; 4069 return S_OK; 3139 4070 } 3140 4071 for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) 3141 4072 if(pVDesc->vardesc.memid==memid){ 4073 FIXME("Not implemented\n"); 3142 4074 return S_OK; 3143 4075 } … … 3147 4079 3148 4080 /* ITypeInfo::GetDllEntry 3149 * 4081 * 3150 4082 * Retrieves a description or specification of an entry point for a function 3151 4083 * in a DLL. … … 3161 4093 3162 4094 /* ITypeInfo::GetRefTypeInfo 3163 * 4095 * 3164 4096 * If a type description references other type descriptions, it retrieves 3165 4097 * the referenced type descriptions. 3166 4098 */ 3167 4099 static HRESULT WINAPI ITypeInfo_fnGetRefTypeInfo( 3168 4100 ITypeInfo2 *iface, 3169 4101 HREFTYPE hRefType, 3170 4102 ITypeInfo **ppTInfo) 3171 4103 { 3172 4104 ICOM_THIS( ITypeInfoImpl, iface); 3173 4105 HRESULT result = E_FAIL; 3174 4106 3175 if(HREFTYPE_INTHISFILE(hRefType)) 4107 4108 if (hRefType == -1 && 4109 (((ITypeInfoImpl*) This)->TypeAttr.typekind == TKIND_DISPATCH) && 4110 (((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL)) 3176 4111 { 3177 ITypeLib *pTLib; 3178 int Index; 3179 result = ITypeInfo_GetContainingTypeLib(iface, &pTLib, &Index); 3180 if(SUCCEEDED( result )) 3181 { 3182 result=ITypeLib2_GetTypeInfo(pTLib, HREFTYPE_INDEX(hRefType), ppTInfo); 3183 ITypeLib2_Release(pTLib ); 3184 } 3185 } 3186 else if (hRefType == -1 && 3187 (((ITypeInfoImpl*) This)->TypeAttr.typekind == TKIND_DISPATCH) && 3188 (((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL)) 3189 { 3190 /* when we meet a DUAL dispinterface, we must create the interface 3191 * version of it. 3192 */ 3193 ITypeInfoImpl* pTypeInfoImpl = (ITypeInfoImpl*) ITypeInfo_Constructor(); 3194 3195 3196 /* the interface version contains the same information as the dispinterface 3197 * copy the contents of the structs. 3198 */ 3199 *pTypeInfoImpl = *This; 3200 pTypeInfoImpl->ref = 1; 3201 3202 /* change the type to interface */ 3203 pTypeInfoImpl->TypeAttr.typekind = TKIND_INTERFACE; 3204 3205 *ppTInfo = (ITypeInfo*) pTypeInfoImpl; 3206 3207 ITypeInfo_AddRef((ITypeInfo*) pTypeInfoImpl); 3208 3209 result = S_OK; 3210 } 3211 else 3212 { 3213 /* imported type lib */ 3214 TLBRefType *pRefType = NULL; 3215 3216 /* search in implemented types */ 3217 for( pRefType = This->impltypelist; 3218 pRefType && (pRefType->reference != hRefType); 3219 pRefType = pRefType->next); 3220 3221 if(!pRefType) 3222 { 3223 TYPEATTR* pMyTypeAttr = &This->TypeAttr; 3224 unsigned short cFuncs = pMyTypeAttr->cFuncs; 3225 unsigned short cVars = pMyTypeAttr->cVars; 3226 3227 /* search in arguments */ 3228 if (cFuncs > 0) 3229 { 3230 unsigned short cFuncIndex = 0; 3231 3232 TLBFuncDesc* pCurrFunc = This->funclist; 3233 3234 for (cFuncIndex = 0; !pRefType && cFuncIndex < cFuncs ; ++cFuncIndex) 3235 { 3236 FUNCDESC* pCurrFuncDesc = &pCurrFunc->funcdesc; 3237 3238 short cParams = pCurrFuncDesc->cParams; 3239 short cParamIndex = 0; 3240 3241 for (cParamIndex = 0 ; 3242 !pRefType && cParamIndex < cParams ; 3243 ++cParamIndex) 3244 { 3245 TLBParDesc* pCurrParamDesc = &(pCurrFunc->pParamDesc[cParamIndex]); 3246 3247 if ( pCurrParamDesc->pRefType && pCurrParamDesc->pRefType->reference == hRefType) 3248 { 3249 pRefType = pCurrParamDesc->pRefType; 3250 break; /* also break from outer loop since pRefType != 0 */ 3251 } 3252 } 3253 3254 pCurrFunc = pCurrFunc->next; 3255 } 3256 } 3257 /* search in variables */ 3258 else if (cVars > 0) 3259 { 3260 FIXME("search hreftype in variables, if any\n"); 3261 result = E_INVALIDARG; // FIXME : correct? 3262 } 3263 } 3264 3265 /* href-referenced typeinfo found! */ 3266 if (pRefType || hRefType == -1) 3267 { 3268 ITypeLibImpl *pTypeLib = pRefType->pImpTLInfo->pImpTypeLib; 3269 3270 if(pTypeLib) 3271 { 3272 TRACE("typeinfo in imported typelib that is already loaded\n"); 3273 3274 result = ITypeLib2_GetTypeInfoOfGuid((LPTYPELIB)pTypeLib, 3275 &pRefType->guid, 3276 ppTInfo); 3277 } 3278 else 3279 { 3280 result = LoadRegTypeLib( &pRefType->pImpTLInfo->guid, 3281 pRefType->pImpTLInfo->wVersionMajor, 3282 pRefType->pImpTLInfo->wVersionMinor, 3283 pRefType->pImpTLInfo->lcid, 3284 (LPTYPELIB *)&pTypeLib); 3285 3286 if(!SUCCEEDED(result)) 3287 { 3288 BSTR libnam=SysAllocString(pRefType->pImpTLInfo->name); 3289 TRACE("typeinfo in imported typelib that isn't already loaded\n"); 3290 result=LoadTypeLib(libnam, (LPTYPELIB *)&pTypeLib); 3291 SysFreeString(libnam); 3292 } 3293 if(SUCCEEDED(result)) 3294 { 3295 result=ITypeLib2_GetTypeInfoOfGuid((LPTYPELIB)pTypeLib, &pRefType->guid, ppTInfo); 3296 pRefType->pImpTLInfo->pImpTypeLib = pTypeLib; 3297 ITypeLib2_AddRef((ITypeLib*) pTypeLib); 3298 } 3299 } 3300 } 4112 /* when we meet a DUAL dispinterface, we must create the interface 4113 * version of it. 4114 */ 4115 ITypeInfoImpl* pTypeInfoImpl = (ITypeInfoImpl*) ITypeInfo_Constructor(); 4116 4117 4118 /* the interface version contains the same information as the dispinterface 4119 * copy the contents of the structs. 4120 */ 4121 *pTypeInfoImpl = *This; 4122 pTypeInfoImpl->ref = 1; 4123 4124 /* change the type to interface */ 4125 pTypeInfoImpl->TypeAttr.typekind = TKIND_INTERFACE; 4126 4127 *ppTInfo = (ITypeInfo*) pTypeInfoImpl; 4128 4129 ITypeInfo_AddRef((ITypeInfo*) pTypeInfoImpl); 4130 4131 result = S_OK; 4132 4133 } else { 4134 TLBRefType *pRefType; 4135 for(pRefType = This->reflist; pRefType; pRefType = pRefType->next) { 4136 if(pRefType->reference == hRefType) 4137 break; 4138 } 4139 if(!pRefType) 4140 FIXME("Can't find pRefType for ref %lx\n", hRefType); 4141 if(pRefType && hRefType != -1) { 4142 ITypeLib *pTLib; 4143 4144 if(pRefType->pImpTLInfo == TLB_REF_INTERNAL) { 4145 int Index; 4146 result = ITypeInfo_GetContainingTypeLib(iface, &pTLib, &Index); 4147 } else { 4148 if(pRefType->pImpTLInfo->pImpTypeLib) { 4149 TRACE("typeinfo in imported typelib that is already loaded\n"); 4150 pTLib = (ITypeLib*)pRefType->pImpTLInfo->pImpTypeLib; 4151 ITypeLib2_AddRef((ITypeLib*) pTLib); 4152 result = S_OK; 4153 } else { 4154 TRACE("typeinfo in imported typelib that isn't already loaded\n"); 4155 result = LoadRegTypeLib( &pRefType->pImpTLInfo->guid, 4156 pRefType->pImpTLInfo->wVersionMajor, 4157 pRefType->pImpTLInfo->wVersionMinor, 4158 pRefType->pImpTLInfo->lcid, 4159 &pTLib); 4160 4161 if(!SUCCEEDED(result)) { 4162 BSTR libnam=SysAllocString(pRefType->pImpTLInfo->name); 4163 result=LoadTypeLib(libnam, &pTLib); 4164 SysFreeString(libnam); 4165 } 4166 if(SUCCEEDED(result)) { 4167 pRefType->pImpTLInfo->pImpTypeLib = (ITypeLibImpl*)pTLib; 4168 ITypeLib2_AddRef(pTLib); 4169 } 4170 } 4171 } 4172 if(SUCCEEDED(result)) { 4173 if(pRefType->index == TLB_REF_USE_GUID) 4174 result = ITypeLib2_GetTypeInfoOfGuid(pTLib, 4175 &pRefType->guid, 4176 ppTInfo); 4177 else 4178 result = ITypeLib2_GetTypeInfo(pTLib, pRefType->index, 4179 ppTInfo); 4180 } 4181 } 3301 4182 } 3302 4183 … … 3307 4188 3308 4189 /* ITypeInfo::AddressOfMember 3309 * 4190 * 3310 4191 * Retrieves the addresses of static functions or variables, such as those 3311 4192 * defined in a DLL. … … 3320 4201 3321 4202 /* ITypeInfo::CreateInstance 3322 * 3323 * Creates a new instance of a type that describes a component object class 4203 * 4204 * Creates a new instance of a type that describes a component object class 3324 4205 * (coclass). 3325 4206 */ 3326 static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, 3327 IUnknown *pUnk, REFIID riid, VOID **ppvObj) 4207 static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, 4208 IUnknown *pUnk, REFIID riid, VOID **ppvObj) 3328 4209 { 3329 4210 ICOM_THIS( ITypeInfoImpl, iface); … … 3337 4218 */ 3338 4219 static HRESULT WINAPI ITypeInfo_fnGetMops( ITypeInfo2 *iface, MEMBERID memid, 3339 4220 BSTR *pBstrMops) 3340 4221 { 3341 4222 ICOM_THIS( ITypeInfoImpl, iface); … … 3345 4226 3346 4227 /* ITypeInfo::GetContainingTypeLib 3347 * 4228 * 3348 4229 * Retrieves the containing type library and the index of the type description 3349 4230 * within that type library. … … 3380 4261 */ 3381 4262 static HRESULT WINAPI ITypeInfo_fnReleaseFuncDesc( 3382 4263 ITypeInfo2 *iface, 3383 4264 FUNCDESC *pFuncDesc) 3384 4265 { … … 3418 4299 * Returns the type flags without any allocations. This returns a DWORD type 3419 4300 * flag, which expands the type flags without growing the TYPEATTR (type 3420 * attribute). 4301 * attribute). 3421 4302 * 3422 4303 */ … … 3443 4324 HRESULT result; 3444 4325 /* FIXME: should check for invKind??? */ 3445 for(i=0, pFuncInfo=This->funclist;pFuncInfo && 4326 for(i=0, pFuncInfo=This->funclist;pFuncInfo && 3446 4327 memid != pFuncInfo->funcdesc.memid; i++, pFuncInfo=pFuncInfo->next); 3447 4328 if(pFuncInfo){ … … 3460 4341 * 3461 4342 * Binds to a specific member based on a known DISPID, where the member name 3462 * is not known (for example, when binding to a default member). 4343 * is not known (for example, when binding to a default member). 3463 4344 * 3464 4345 */ … … 3470 4351 int i; 3471 4352 HRESULT result; 3472 for(i=0, pVarInfo=This->varlist; pVarInfo && 4353 for(i=0, pVarInfo=This->varlist; pVarInfo && 3473 4354 memid != pVarInfo->vardesc.memid; i++, pVarInfo=pVarInfo->next) 3474 4355 ; … … 3490 4371 */ 3491 4372 static HRESULT WINAPI ITypeInfo2_fnGetCustData( 3492 3493 3494 4373 ITypeInfo2 * iface, 4374 REFGUID guid, 4375 VARIANT *pVarVal) 3495 4376 { 3496 4377 ICOM_THIS( ITypeInfoImpl, iface); … … 3516 4397 */ 3517 4398 static HRESULT WINAPI ITypeInfo2_fnGetFuncCustData( 3518 3519 3520 3521 4399 ITypeInfo2 * iface, 4400 UINT index, 4401 REFGUID guid, 4402 VARIANT *pVarVal) 3522 4403 { 3523 4404 ICOM_THIS( ITypeInfoImpl, iface); 3524 4405 TLBCustData *pCData=NULL; 3525 TLBFuncDesc * pFDesc; 4406 TLBFuncDesc * pFDesc; 3526 4407 int i; 3527 4408 for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, … … 3547 4428 */ 3548 4429 static HRESULT WINAPI ITypeInfo2_fnGetParamCustData( 3549 3550 3551 3552 3553 3554 { 4430 ITypeInfo2 * iface, 4431 UINT indexFunc, 4432 UINT indexParam, 4433 REFGUID guid, 4434 VARIANT *pVarVal) 4435 { 3555 4436 ICOM_THIS( ITypeInfoImpl, iface); 3556 4437 TLBCustData *pCData=NULL; 3557 TLBFuncDesc * pFDesc; 4438 TLBFuncDesc * pFDesc; 3558 4439 int i; 3559 4440 … … 3561 4442 3562 4443 if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams) 3563 for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; 4444 for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; 3564 4445 pCData = pCData->next) 3565 4446 if( IsEqualIID(guid, &pCData->guid)) break; … … 3576 4457 } 3577 4458 3578 /* ITypeInfo2::GetVar cCustData4459 /* ITypeInfo2::GetVarCustData 3579 4460 * 3580 4461 * Gets the custom data 3581 4462 */ 3582 4463 static HRESULT WINAPI ITypeInfo2_fnGetVarCustData( 3583 3584 3585 3586 3587 { 4464 ITypeInfo2 * iface, 4465 UINT index, 4466 REFGUID guid, 4467 VARIANT *pVarVal) 4468 { 3588 4469 ICOM_THIS( ITypeInfoImpl, iface); 3589 4470 TLBCustData *pCData=NULL; 3590 TLBVarDesc * pVDesc; 4471 TLBVarDesc * pVDesc; 3591 4472 int i; 3592 4473 … … 3612 4493 } 3613 4494 3614 /* ITypeInfo2::GetImpl cCustData4495 /* ITypeInfo2::GetImplCustData 3615 4496 * 3616 4497 * Gets the custom data 3617 4498 */ 3618 4499 static HRESULT WINAPI ITypeInfo2_fnGetImplTypeCustData( 3619 3620 3621 3622 3623 { 4500 ITypeInfo2 * iface, 4501 UINT index, 4502 REFGUID guid, 4503 VARIANT *pVarVal) 4504 { 3624 4505 ICOM_THIS( ITypeInfoImpl, iface); 3625 4506 TLBCustData *pCData=NULL; 3626 TLB RefType * pRDesc;4507 TLBImplType * pRDesc; 3627 4508 int i; 3628 4509 … … 3636 4517 } 3637 4518 } 3638 4519 3639 4520 TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT"); 3640 4521 … … 3649 4530 3650 4531 /* ITypeInfo2::GetDocumentation2 3651 * 4532 * 3652 4533 * Retrieves the documentation string, the complete Help file name and path, 3653 4534 * the localization context to use, and the context ID for the library Help … … 3656 4537 */ 3657 4538 static HRESULT WINAPI ITypeInfo2_fnGetDocumentation2( 3658 3659 3660 3661 3662 3663 4539 ITypeInfo2 * iface, 4540 MEMBERID memid, 4541 LCID lcid, 4542 BSTR *pbstrHelpString, 4543 DWORD *pdwHelpStringContext, 4544 BSTR *pbstrHelpStringDll) 3664 4545 { 3665 4546 ICOM_THIS( ITypeInfoImpl, iface); 3666 TLBFuncDesc * pFDesc; 3667 TLBVarDesc * pVDesc; 4547 TLBFuncDesc * pFDesc; 4548 TLBVarDesc * pVDesc; 3668 4549 TRACE("(%p) memid %ld lcid(0x%lx) HelpString(%p) " 3669 4550 "HelpStringContext(%p) HelpStringDll(%p)\n", … … 3712 4593 /* ITypeInfo2::GetAllCustData 3713 4594 * 3714 * Gets all custom data items for the Type info. 4595 * Gets all custom data items for the Type info. 3715 4596 * 3716 4597 */ 3717 4598 static HRESULT WINAPI ITypeInfo2_fnGetAllCustData( 3718 3719 4599 ITypeInfo2 * iface, 4600 CUSTDATA *pCustData) 3720 4601 { 3721 4602 ICOM_THIS( ITypeInfoImpl, iface); … … 3723 4604 int i; 3724 4605 3725 TRACE("(%p) returning %d items\n", This, This->ctCustData); 4606 TRACE("(%p) returning %d items\n", This, This->ctCustData); 3726 4607 3727 4608 pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM)); … … 3745 4626 */ 3746 4627 static HRESULT WINAPI ITypeInfo2_fnGetAllFuncCustData( 3747 3748 3749 4628 ITypeInfo2 * iface, 4629 UINT index, 4630 CUSTDATA *pCustData) 3750 4631 { 3751 4632 ICOM_THIS( ITypeInfoImpl, iface); 3752 4633 TLBCustData *pCData; 3753 TLBFuncDesc * pFDesc; 4634 TLBFuncDesc * pFDesc; 3754 4635 int i; 3755 TRACE("(%p) index %d\n", This, index); 4636 TRACE("(%p) index %d\n", This, index); 3756 4637 for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, 3757 4638 pFDesc=pFDesc->next) … … 3787 4668 ICOM_THIS( ITypeInfoImpl, iface); 3788 4669 TLBCustData *pCData=NULL; 3789 TLBFuncDesc * pFDesc; 4670 TLBFuncDesc * pFDesc; 3790 4671 int i; 3791 TRACE("(%p) index %d\n", This, indexFunc); 4672 TRACE("(%p) index %d\n", This, indexFunc); 3792 4673 for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++, 3793 4674 pFDesc=pFDesc->next) 3794 4675 ; 3795 4676 if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams){ 3796 pCustData->prgCustData = 4677 pCustData->prgCustData = 3797 4678 TLB_Alloc(pFDesc->pParamDesc[indexParam].ctCustData * 3798 4679 sizeof(CUSTDATAITEM)); … … 3824 4705 ICOM_THIS( ITypeInfoImpl, iface); 3825 4706 TLBCustData *pCData; 3826 TLBVarDesc * pVDesc; 4707 TLBVarDesc * pVDesc; 3827 4708 int i; 3828 TRACE("(%p) index %d\n", This, index); 4709 TRACE("(%p) index %d\n", This, index); 3829 4710 for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, 3830 4711 pVDesc=pVDesc->next) … … 3856 4737 */ 3857 4738 static HRESULT WINAPI ITypeInfo2_fnGetAllImplTypeCustData( 3858 3859 3860 4739 ITypeInfo2 * iface, 4740 UINT index, 4741 CUSTDATA *pCustData) 3861 4742 { 3862 4743 ICOM_THIS( ITypeInfoImpl, iface); 3863 4744 TLBCustData *pCData; 3864 TLB RefType * pRDesc;4745 TLBImplType * pRDesc; 3865 4746 int i; 3866 TRACE("(%p) index %d\n", This, index); 4747 TRACE("(%p) index %d\n", This, index); 3867 4748 for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++, 3868 4749 pRDesc=pRDesc->next) … … 3888 4769 } 3889 4770 3890 static ICOM_VTABLE(ITypeInfo2) tinfvt = 4771 static ICOM_VTABLE(ITypeInfo2) tinfvt = 3891 4772 { 3892 4773 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE -
trunk/src/oleaut32/typelib.h
r6507 r6689 17 17 #define DO_NOT_SEEK (-1) 18 18 19 #define HREFTYPE_INTHISFILE(href) (!((href) & 3))20 #define HREFTYPE_INDEX(href) ((href) /sizeof(TLBTypeInfoBase))19 #define MSFT_HREFTYPE_INTHISFILE(href) (!((href) & 3)) 20 #define MSFT_HREFTYPE_INDEX(href) ((href) /sizeof(MSFT_TypeInfoBase)) 21 21 22 22 /*-------------------------FILE STRUCTURES-----------------------------------*/ 23 23 24 /* There are two known file formats, those created with ICreateTypeLib 25 * have the signature "SLGT" as their first four bytes, while those created 26 * with ICreateTypeLib2 have "MSFT". 27 */ 28 29 /***************************************************** 30 * MSFT typelibs 31 * 32 * These are TypeLibs created with ICreateTypeLib2 33 * 34 */ 24 35 25 36 /* … … 28 39 * 29 40 */ 30 typedef struct tag TLB2Header {41 typedef struct tagMSFT_Header { 31 42 /*0x00*/INT magic1; /* 0x5446534D "MSFT" */ 32 43 INT magic2; /* 0x00010002 version nr? */ … … 37 48 INT varflags; /* (largely) unknown flags ,seems to be always 41 */ 38 49 /* becomes 0x51 with a helpfile defined */ 39 /* if help dll defined it s 0x151 */50 /* if help dll defined it's 0x151 */ 40 51 /* update : the lower nibble is syskind */ 41 52 INT version; /* set with SetVersion() */ … … 55 66 INT dispatchpos; /* gets a value (1+n*0x0c) with Idispatch interfaces */ 56 67 /*0x50*/INT res50; /* is zero becomes one when an interface is derived */ 57 } TLB2Header;68 } MSFT_Header; 58 69 59 70 /* segments in the type lib file have a structure like this: */ 60 typedef struct _tptag {71 typedef struct tagMSFT_pSeg { 61 72 INT offset; /* absolute offset in file */ 62 73 INT length; /* length of segment */ … … 64 75 INT res0c; /* unknown always 0x0f in the header */ 65 76 /* 0x03 in the typeinfo_data */ 66 } pSeg;77 } MSFT_pSeg; 67 78 68 79 /* layout of the main segment directory */ 69 typedef struct tagTLBSegDir { 70 /*1*/pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */ 71 /* (25 ints) */ 72 /*2*/pSeg pImpInfo; /* table with info for imported types */ 73 /*3*/pSeg pImpFiles; /* import libaries */ 74 /*4*/pSeg pRefTab; /* References table */ 75 /*5*/pSeg pLibtab; /* always exists, alway same size (0x80) */ 76 /* hash table w offsets to guid????? */ 77 /*6*/pSeg pGuidTab; /* all guids are stored here together with */ 78 /* offset in some table???? */ 79 /*7*/pSeg res07; /* always created, alway same size (0x200) */ 80 /* purpose largely unknown */ 81 /*8*/pSeg pNametab; /* name tables */ 82 /*9*/pSeg pStringtab; /*string table */ 83 /*A*/pSeg pTypdescTab; /* table with type descriptors */ 84 /*B*/pSeg pArrayDescriptions; 85 /*C*/pSeg pCustData; /* data table, used for custom data and default */ 86 /* parameter values */ 87 /*D*/pSeg pCDGuids; /* table with offsets for the guids and into the customer data table */ 88 /*E*/pSeg res0e; /* unknown */ 89 /*F*/pSeg res0f; /* unknown */ 90 } TLBSegDir; 80 typedef struct tagMSFT_SegDir { 81 /*1*/MSFT_pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */ 82 /* (25 ints) */ 83 /*2*/MSFT_pSeg pImpInfo; /* table with info for imported types */ 84 /*3*/MSFT_pSeg pImpFiles; /* import libaries */ 85 /*4*/MSFT_pSeg pRefTab; /* References table */ 86 /*5*/MSFT_pSeg pLibtab; /* always exists, alway same size (0x80) */ 87 /* hash table w offsets to guid????? */ 88 /*6*/MSFT_pSeg pGuidTab; /* all guids are stored here together with */ 89 /* offset in some table???? */ 90 /*7*/MSFT_pSeg res07; /* always created, alway same size (0x200) */ 91 /* purpose largely unknown */ 92 /*8*/MSFT_pSeg pNametab; /* name tables */ 93 /*9*/MSFT_pSeg pStringtab; /* string table */ 94 /*A*/MSFT_pSeg pTypdescTab; /* table with type descriptors */ 95 /*B*/MSFT_pSeg pArrayDescriptions; 96 /*C*/MSFT_pSeg pCustData; /* data table, used for custom data and default */ 97 /* parameter values */ 98 /*D*/MSFT_pSeg pCDGuids; /* table with offsets for the guids and into */ 99 /* the customer data table */ 100 /*E*/MSFT_pSeg res0e; /* unknown */ 101 /*F*/MSFT_pSeg res0f; /* unknown */ 102 } MSFT_SegDir; 91 103 92 104 93 105 /* base type info data */ 94 typedef struct tag TLBTypeInfoBase {106 typedef struct tagMSFT_TypeInfoBase { 95 107 /*000*/ INT typekind; /* it is the TKIND_xxx */ 96 108 /* some byte alignment stuf */ … … 126 138 INT res18; /* always? 0 */ 127 139 /*060*/ INT res19; /* always? -1 */ 128 } TLBTypeInfoBase;140 } MSFT_TypeInfoBase; 129 141 130 142 /* layout of an entry with information on imported types */ 131 typedef struct tag TLBImpInfo {143 typedef struct tagMSFT_ImpInfo { 132 144 INT res0; /* unknown */ 133 145 INT oImpFile; /* offset inthe Import File table */ 134 146 INT oGuid; /* offset in Guid table */ 135 } TLBImpInfo;147 } MSFT_ImpInfo; 136 148 137 149 /* function description data */ … … 165 177 7* INT oArgCustData[1]; // custom data per argument // 166 178 */ 167 } TLBFuncRecord;179 } MSFT_FuncRecord; 168 180 169 181 /* after this may follow an array with default value pointers if the … … 177 189 INT oName; 178 190 INT Flags; 179 } TLBParameterInfo;191 } MSFT_ParameterInfo; 180 192 181 193 /* Variable description data */ … … 196 208 INT HelpStringContext; 197 209 198 } TLBVarRecord;210 } MSFT_VarRecord; 199 211 200 212 /* Structure of the reference data */ 201 213 typedef struct { 202 INT reftype; /* either offset in type info table, then it s */214 INT reftype; /* either offset in type info table, then it's */ 203 215 /* a multiple of 64 */ 204 216 /* or offset in the external reference table */ … … 207 219 INT oCustData; /* custom data */ 208 220 INT onext; /* next offset, -1 if last */ 209 } TLBRefRecord;221 } MSFT_RefRecord; 210 222 211 223 /* this is how a guid is stored */ … … 213 225 GUID guid; 214 226 INT unk10; /* differntiate with libid, classid etc? */ 215 /* it s -2 for a libary */227 /* it's -2 for a libary */ 216 228 /* it's 0 for an interface */ 217 229 INT unk14; /* always? -1 */ 218 } TLBGuidEntry;230 } MSFT_GuidEntry; 219 231 /* some data preceding entries in the name table */ 220 232 typedef struct { … … 222 234 sometimes 0 (interface, func) */ 223 235 INT unk10; /* sometimes -1 (lib) , sometimes 0 (interface, func), 224 sometime 0x10 (par) */236 sometimes 0x10 (par) */ 225 237 INT namelen; /* only lower 8 bits are valid */ 226 } TLBNameIntro;238 } MSFT_NameIntro; 227 239 /* the custom data table directory has enties like this */ 228 240 typedef struct { 229 241 INT GuidOffset; 230 242 INT DataOffset; 231 INT next; /* next offset in the table, -1 if its the last */ 232 } TLBCDGuid; 233 234 243 INT next; /* next offset in the table, -1 if it's the last */ 244 } MSFT_CDGuid; 245 246 247 /*********************************************************** 248 * 249 * SLTG typelibs. 250 * 251 * These are created with ICreateTypeLib 252 * 253 */ 254 255 #include "pshpack1.h" 256 257 typedef struct { 258 /*00*/ DWORD SLTG_magic; /* 0x47544c53 == "SLTG" */ 259 /*04*/ WORD nrOfFileBlks; /* no of SLTG_BlkEntry's + 1 */ 260 /*06*/ WORD res06; /* ?? always 9 */ 261 /*08*/ WORD res08; /* some kind of len/offset ?? */ 262 /*0a*/ WORD first_blk; /* 1 based index into blk entries that 263 corresponds to first block in file */ 264 /*0c*/ DWORD res0c; /* always 0x000204ff */ 265 /*10*/ DWORD res10; /* always 0x00000000 */ 266 /*14*/ DWORD res14; /* always 0x000000c0 */ 267 /*18*/ DWORD res18; /* always 0x46000000 */ 268 /*1c*/ DWORD res1c; /* always 0x00000044 */ 269 /*20*/ DWORD res20; /* always 0xffff0000 */ 270 } SLTG_Header; 271 272 /* This gets followed by a list of block entries */ 273 typedef struct { 274 /*00*/ DWORD len; 275 /*04*/ WORD index_string; /* offs from start of SLTG_Magic to index string */ 276 /*06*/ WORD next; 277 } SLTG_BlkEntry; 278 279 /* The order of the blocks in the file is given by starting at Block 280 entry firt_blk and stepping through using the next pointer */ 281 282 /* These then get followed by this magic */ 283 typedef struct { 284 /*00*/ BYTE res00; /* always 0x01 */ 285 /*01*/ CHAR CompObj_magic[8]; /* always "CompObj" */ 286 /*09*/ CHAR dir_magic[4]; /* always "dir" */ 287 } SLTG_Magic; 288 289 #define SLTG_COMPOBJ_MAGIC "CompObj" 290 #define SLTG_DIR_MAGIC "dir" 291 292 /* Next we have SLTG_Header.nrOfFileBlks - 2 of Index strings. These 293 are persumbably unique to within the file and look something like 294 "AAAAAAAAAA" with the first character incremented from 'A' to ensure 295 uniqueness. I guess successive chars increment when we need to wrap 296 the first one. */ 297 298 typedef struct { 299 /*00*/ CHAR string[11]; 300 } SLTG_Index; 301 302 303 /* This is followed by SLTG_pad9 */ 304 typedef struct { 305 /*00*/ CHAR pad[9]; /* 9 '\0's */ 306 } SLTG_Pad9; 307 308 309 /* Now we have the noOfFileBlks - 1 worth of blocks. The length of 310 each block is given by its entry in SLTG_BlkEntry. */ 311 312 /* type SLTG_NAME in rather like a BSTR except that the length in 313 bytes is given by the first WORD and the string contains 8bit chars */ 314 315 typedef WORD SLTG_Name; 316 317 /* The main library block looks like this. This one seems to come last */ 318 319 typedef struct { 320 /*00*/ WORD magic; /* 0x51cc */ 321 /*02*/ WORD res02; /* 0x0003, 0x0004 */ 322 /*04*/ WORD name; /* offset to name in name table */ 323 /*06*/ SLTG_Name res06; /* maybe this is just WORD == 0xffff */ 324 SLTG_Name helpstring; 325 SLTG_Name helpfile; 326 DWORD helpcontext; 327 WORD syskind; /* == 1 for win32, 0 for win16 */ 328 WORD lcid; /* == 0x409, 0x809 etc */ 329 DWORD res12; /* == 0 */ 330 WORD libflags; /* LIBFLAG_* */ 331 WORD maj_vers; 332 WORD min_vers; 333 GUID uuid; 334 } SLTG_LibBlk; 335 336 #define SLTG_LIBBLK_MAGIC 0x51cc 337 338 /* we then get 0x40 bytes worth of 0xffff or small numbers followed by 339 nrOfFileBlks - 2 of these */ 340 typedef struct { 341 WORD small_no; 342 SLTG_Name index_name; /* This refers to a name in the directory */ 343 SLTG_Name other_name; /* Another one of these weird names */ 344 WORD res1a; /* 0xffff */ 345 WORD name_offs; /* offset to name in name table */ 346 WORD more_bytes; /* if this is non-zero we get this many 347 bytes before the next element, which seem 348 to reference the docstring of the type ? */ 349 WORD res20; /* 0xffff */ 350 DWORD helpcontext; 351 WORD res26; /* 0xffff */ 352 GUID uuid; 353 } SLTG_OtherTypeInfo; 354 355 /* Next we get WORD 0x0003 followed by a DWORD which if we add to 356 0x216 gives the offset to the name table from the start of the LibBlk 357 struct */ 358 359 typedef struct { 360 /*00*/ WORD magic; /* 0x0501 */ 361 /*02*/ DWORD href_table; /* if not 0xffffffff, then byte offset from 362 beginning of struct to href table */ 363 /*06*/ DWORD res06; /* 0xffffffff */ 364 /*0a*/ DWORD elem_table; /* offset to members */ 365 /*0e*/ DWORD res0e; /* 0xffffffff */ 366 /*12*/ WORD major_version; /* major version number */ 367 /*14*/ WORD minor_version; /* minor version number */ 368 /*16*/ DWORD res16; /* 0xfffe0000 */ 369 /*1a*/ BYTE typeflags1;/* 0x02 | top 5 bits hold l5sbs of TYPEFLAGS */ 370 /*1b*/ BYTE typeflags2;/* TYPEFLAGS >> 5 */ 371 /*1c*/ BYTE typeflags3;/* 0x02*/ 372 /*1d*/ BYTE typekind; /* 0x03 == TKIND_INTERFACE etc. */ 373 /*1e*/ DWORD res1e; /* 0x00000000 or 0xffffffff */ 374 } SLTG_TypeInfoHeader; 375 376 #define SLTG_TIHEADER_MAGIC 0x0501 377 378 typedef struct { 379 /*00*/ WORD res00; /* 0x0001 sometimes 0x0003 ?? */ 380 /*02*/ WORD res02; /* 0xffff */ 381 /*04*/ BYTE res04; /* 0x01 */ 382 /*05*/ DWORD cbExtra; /* No of bytes that follow */ 383 } SLTG_MemberHeader; 384 385 typedef struct { 386 /*00*/ WORD magic; /* 0x120a */ 387 /*02*/ WORD next; /* offset in bytes to next block from start of block 388 group, 0xffff if last item */ 389 /*04*/ WORD name; /* offset to name within name table */ 390 /*06*/ WORD value; /* offset to value from start of block group */ 391 /*08*/ WORD res08; /* 0x56 */ 392 /*0a*/ DWORD memid; /* memid */ 393 /*0e*/ WORD helpcontext;/* 0xfffe == no context, 0x0001 == stored in EnumInfo struct, else offset 394 to value from start of block group */ 395 /*10*/ WORD helpstring;/* offset from start of block group to string offset */ 396 } SLTG_EnumItem; 397 398 #define SLTG_ENUMITEM_MAGIC 0x120a 399 400 401 typedef struct { 402 BYTE magic; /* 0x4c or 0x6c */ 403 BYTE inv; /* high nibble is INVOKE_KIND, low nibble = 2 */ 404 WORD next; /* byte offset from beginning of group to next fn */ 405 WORD name; /* Offset within name table to name */ 406 DWORD dispid; /* dispid */ 407 WORD helpcontext; /* helpcontext (again 1 is special) */ 408 WORD helpstring;/* helpstring offset to offset */ 409 WORD arg_off; /* offset to args from start of block */ 410 BYTE nacc; /* lowest 3bits are CALLCONV, rest are no of args */ 411 BYTE retnextopt;/* if 0x80 bit set ret type follows else next WORD 412 is offset to ret type. No of optional args is 413 middle 6 bits */ 414 WORD rettype; /* return type VT_?? or offset to ret type */ 415 WORD vtblpos; /* position in vtbl? */ 416 WORD funcflags; /* present if magic == 0x6c */ 417 /* Param list starts, repeat next two as required */ 418 #if 0 419 WORD name; /* offset to 2nd letter of name */ 420 WORD+ type; /* VT_ of param */ 421 #endif 422 } SLTG_Function; 423 424 #define SLTG_FUNCTION_MAGIC 0x4c 425 #define SLTG_FUNCTION_WITH_FLAGS_MAGIC 0x6c 426 427 typedef struct { 428 /*00*/ BYTE magic; /* 0xdf */ 429 /*01*/ BYTE res01; /* 0x00 */ 430 /*02*/ DWORD res02; /* 0xffffffff */ 431 /*06*/ DWORD res06; /* 0xffffffff */ 432 /*0a*/ DWORD res0a; /* 0xffffffff */ 433 /*0e*/ DWORD res0e; /* 0xffffffff */ 434 /*12*/ DWORD res12; /* 0xffffffff */ 435 /*16*/ DWORD res16; /* 0xffffffff */ 436 /*1a*/ DWORD res1a; /* 0xffffffff */ 437 /*1e*/ DWORD res1e; /* 0xffffffff */ 438 /*22*/ DWORD res22; /* 0xffffffff */ 439 /*26*/ DWORD res26; /* 0xffffffff */ 440 /*2a*/ DWORD res2a; /* 0xffffffff */ 441 /*2e*/ DWORD res2e; /* 0xffffffff */ 442 /*32*/ DWORD res32; /* 0xffffffff */ 443 /*36*/ DWORD res36; /* 0xffffffff */ 444 /*3a*/ DWORD res3a; /* 0xffffffff */ 445 /*3e*/ DWORD res3e; /* 0xffffffff */ 446 /*42*/ WORD res42; /* 0xffff */ 447 /*44*/ DWORD number; /* this is 8 times the number of refs */ 448 /*48*/ /* Now we have number bytes (8 for each ref) of SLTG_UnknownRefInfo */ 449 450 /*50*/ WORD res50; /* 0xffff */ 451 /*52*/ BYTE res52; /* 0x01 */ 452 /*53*/ DWORD res53; /* 0x00000000 */ 453 /*57*/ SLTG_Name names[1]; 454 /* Now we have number/8 SLTG_Names (first WORD is no of bytes in the ascii 455 * string). Strings look like "*\Rxxxx*#n". If xxxx == ffff then the 456 * ref refers to the nth type listed in this library (0 based). Else 457 * the xxxx (which maybe fewer than 4 digits) is the offset into the name 458 * table to a string "*\G{<guid>}#1.0#0#C:\WINNT\System32\stdole32.tlb#" 459 * The guid is the typelib guid; the ref again refers to the nth type of 460 * the imported typelib. 461 */ 462 463 /*xx*/ BYTE resxx; /* 0xdf */ 464 465 } SLTG_RefInfo; 466 467 #define SLTG_REF_MAGIC 0xdf 468 469 typedef struct { 470 WORD res00; /* 0x0001 */ 471 BYTE res02; /* 0x02 */ 472 BYTE res03; /* 0x40 if internal ref, 0x00 if external ? */ 473 WORD res04; /* 0xffff */ 474 WORD res06; /* 0x0000, 0x0013 or 0xffff ?? */ 475 } SLTG_UnknownRefInfo; 476 477 typedef struct { 478 WORD res00; /* 0x004a */ 479 WORD next; /* byte offs to next interface */ 480 WORD res04; /* 0xffff */ 481 BYTE impltypeflags; /* IMPLTYPEFLAG_* */ 482 BYTE res07; /* 0x80 */ 483 WORD res08; /* 0x0012, 0x0028 ?? */ 484 WORD ref; /* number in ref table ? */ 485 WORD res0c; /* 0x4000 */ 486 WORD res0e; /* 0xfffe */ 487 WORD res10; /* 0xffff */ 488 WORD res12; /* 0x001d */ 489 WORD pos_in_table; /* 0x0, 0x4, ? */ 490 } SLTG_ImplInfo; 491 492 #define SLTG_IMPL_MAGIC 0x004a 493 494 typedef struct { 495 BYTE magic; /* 0x0a */ 496 BYTE typepos; 497 WORD next; 498 WORD name; 499 WORD byte_offs; /* pos in struct */ 500 WORD type; /* if typepos == 0x02 this is the type, else offset to type */ 501 DWORD memid; 502 WORD helpcontext; /* ?? */ 503 WORD helpstring; /* ?? */ 504 } SLTG_RecordItem; 505 506 #define SLTG_RECORD_MAGIC 0x0a 507 508 509 /* CARRAYs look like this 510 WORD type == VT_CARRAY 511 WORD offset from start of block to SAFEARRAY 512 WORD typeofarray 513 */ 514 515 #include "poppack.h" 235 516 236 517 /*---------------------------END--------------------------------------------*/ 237 518 #endif 519 520 -
trunk/src/oleaut32/variant.c
r6648 r6689 1 /* $Id: variant.c,v 1.5 2001-09-05 13:19:02 bird Exp $ */2 1 /* 3 2 * VARIANT
Note:
See TracChangeset
for help on using the changeset viewer.