2 * typelib.h internal wine data structures
3 * used to decode typelib's
5 * Copyright 1999 Rein KLazes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _WINE_TYPELIB_H
22 #define _WINE_TYPELIB_H
25 #include "wine/windef16.h"
27 #define HELPDLLFLAG (0x0100)
28 #define DO_NOT_SEEK (-1)
30 #define MSFT_HREFTYPE_INTHISFILE(href) (!((href) & 3))
31 #define MSFT_HREFTYPE_INDEX(href) ((href) /sizeof(MSFT_TypeInfoBase))
33 /*-------------------------FILE STRUCTURES-----------------------------------*/
35 /* There are two known file formats, those created with ICreateTypeLib
36 * have the signature "SLTG" as their first four bytes, while those created
37 * with ICreateTypeLib2 have "MSFT".
40 /*****************************************************
43 * These are TypeLibs created with ICreateTypeLib2
48 * structure of the typelib type2 header
49 * it is at the beginning of a type lib file
52 typedef struct tagMSFT_Header {
53 /*0x00*/INT magic1; /* 0x5446534D "MSFT" */
54 INT magic2; /* 0x00010002 version nr? */
55 INT posguid; /* position of libid in guid table */
56 /* (should be, else -1) */
57 INT lcid; /* locale id */
59 INT varflags; /* (largely) unknown flags ,seems to be always 41 */
60 /* becomes 0x51 with a helpfile defined */
61 /* if help dll defined it's 0x151 */
62 /* update : the lower nibble is syskind */
63 INT version; /* set with SetVersion() */
64 INT flags; /* set with SetFlags() */
65 /*0x20*/INT nrtypeinfos; /* number of typeinfo's (till so far) */
66 INT helpstring; /* position of help string in stringtable */
67 INT helpstringcontext;
69 /*0x30*/INT nametablecount; /* number of names in name table */
70 INT nametablechars; /* nr of characters in name table */
71 INT NameOffset; /* offset of name in name table */
72 INT helpfile; /* position of helpfile in stringtable */
73 /*0x40*/INT CustomDataOffset; /* if -1 no custom data, else it is offset */
74 /* in customer data/guid offset table */
75 INT res44; /* unknown always: 0x20 */
76 INT res48; /* unknown always: 0x80 */
77 INT dispatchpos; /* gets a value (1+n*0x0c) with Idispatch interfaces */
78 /*0x50*/INT res50; /* is zero becomes one when an interface is derived */
81 /* segments in the type lib file have a structure like this: */
82 typedef struct tagMSFT_pSeg {
83 INT offset; /* absolute offset in file */
84 INT length; /* length of segment */
85 INT res08; /* unknown always -1 */
86 INT res0c; /* unknown always 0x0f in the header */
87 /* 0x03 in the typeinfo_data */
90 /* layout of the main segment directory */
91 typedef struct tagMSFT_SegDir {
92 /*1*/MSFT_pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
94 /*2*/MSFT_pSeg pImpInfo; /* table with info for imported types */
95 /*3*/MSFT_pSeg pImpFiles; /* import libaries */
96 /*4*/MSFT_pSeg pRefTab; /* References table */
97 /*5*/MSFT_pSeg pLibtab; /* always exists, alway same size (0x80) */
98 /* hash table w offsets to guid????? */
99 /*6*/MSFT_pSeg pGuidTab; /* all guids are stored here together with */
100 /* offset in some table???? */
101 /*7*/MSFT_pSeg res07; /* always created, alway same size (0x200) */
102 /* purpose largely unknown */
103 /*8*/MSFT_pSeg pNametab; /* name tables */
104 /*9*/MSFT_pSeg pStringtab; /* string table */
105 /*A*/MSFT_pSeg pTypdescTab; /* table with type descriptors */
106 /*B*/MSFT_pSeg pArrayDescriptions;
107 /*C*/MSFT_pSeg pCustData; /* data table, used for custom data and default */
108 /* parameter values */
109 /*D*/MSFT_pSeg pCDGuids; /* table with offsets for the guids and into */
110 /* the customer data table */
111 /*E*/MSFT_pSeg res0e; /* unknown */
112 /*F*/MSFT_pSeg res0f; /* unknown */
116 /* base type info data */
117 typedef struct tagMSFT_TypeInfoBase {
118 /*000*/ INT typekind; /* it is the TKIND_xxx */
119 /* some byte alignment stuf */
120 INT memoffset; /* points past the file, if no elements */
121 INT res2; /* zero if no element, N*0x40 */
122 INT res3; /* -1 if no lement, (N-1)*0x38 */
123 /*010*/ INT res4; /* always? 3 */
124 INT res5; /* always? zero */
125 INT cElement; /* counts elements, HI=cVars, LO=cFuncs */
126 INT res7; /* always? zero */
127 /*020*/ INT res8; /* always? zero */
128 INT res9; /* always? zero */
129 INT resA; /* always? zero */
130 INT posguid; /* position in guid table */
131 /*030*/ INT flags; /* Typeflags */
132 INT NameOffset; /* offset in name table */
133 INT version; /* element version */
134 INT docstringoffs; /* offset of docstring in string tab */
135 /*040*/ INT helpstringcontext; /* */
136 INT helpcontext; /* */
137 INT oCustData; /* offset in customer data table */
138 #ifdef WORDS_BIGENDIAN
139 INT16 cbSizeVft; /* virtual table size, not including inherits */
140 INT16 cImplTypes; /* nr of implemented interfaces */
142 INT16 cImplTypes; /* nr of implemented interfaces */
143 INT16 cbSizeVft; /* virtual table size, not including inherits */
145 /*050*/ INT size; /* size in bytes, at least for structures */
146 /* FIXME: name of this field */
147 INT datatype1; /* position in type description table */
148 /* or in base intefaces */
149 /* if coclass: offset in reftable */
150 /* if interface: reference to inherited if */
151 INT datatype2; /* if 0x8000, entry above is valid */
153 /* else it is zero? */
154 INT res18; /* always? 0 */
155 /*060*/ INT res19; /* always? -1 */
158 /* layout of an entry with information on imported types */
159 typedef struct tagMSFT_ImpInfo {
160 INT res0; /* unknown */
161 INT oImpFile; /* offset inthe Import File table */
162 INT oGuid; /* offset in Guid table */
165 /* function description data */
167 /* INT recsize; record size including some xtra stuff */
168 INT DataType; /* data type of the memeber, eg return of function */
169 INT Flags; /* something to do with attribute flags (LOWORD) */
170 #ifdef WORDS_BIGENDIAN
171 INT16 res3; /* some offset into dunno what */
172 INT16 VtableOffset; /* offset in vtable */
174 INT16 VtableOffset; /* offset in vtable */
175 INT16 res3; /* some offset into dunno what */
177 INT FKCCIC; /* bit string with the following */
178 /* meaning (bit 0 is the msb): */
179 /* bit 2 indicates that oEntry is numeric */
180 /* bit 3 that parameter has default values */
181 /* calling convention (bits 4-7 ) */
182 /* bit 8 indicates that custom data is present */
183 /* Invokation kind (bits 9-12 ) */
184 /* function kind (eg virtual), bits 13-15 */
185 #ifdef WORDS_BIGENDIAN
186 INT16 nroargs; /* nr of optional arguments */
187 INT16 nrargs; /* number of arguments (including optional ????) */
189 INT16 nrargs; /* number of arguments (including optional ????) */
190 INT16 nroargs; /* nr of optional arguments */
192 /* optional attribute fields, the number of them is variable */
197 2* INT oEntry; // either offset in string table or numeric as it is //
198 3* INT res9; // unknown (-1) //
199 4* INT resA; // unknown (-1) //
200 5* INT HelpStringContext;
201 // these are controlled by a bit set in the FKCCIC field //
202 6* INT oCustData; // custom data for function //
203 7* INT oArgCustData[1]; // custom data per argument //
207 /* after this may follow an array with default value pointers if the
208 * appropriate bit in the FKCCIC field has been set:
209 * INT oDefautlValue[nrargs];
212 /* Parameter info one per argument*/
217 } MSFT_ParameterInfo;
219 /* Variable description data */
221 /* INT recsize; // record size including some xtra stuff */
222 INT DataType; /* data type of the variable */
223 INT Flags; /* VarFlags (LOWORD) */
224 #ifdef WORDS_BIGENDIAN
225 INT16 res3; /* some offset into dunno what */
226 INT16 VarKind; /* VarKind */
228 INT16 VarKind; /* VarKind */
229 INT16 res3; /* some offset into dunno what */
231 INT OffsValue; /* value of the variable or the offset */
232 /* in the data structure */
233 /* optional attribute fields, the number of them is variable */
234 /* controlled by record length */
237 INT res9; /* unknown (-1) */
238 INT oCustData; /* custom data for variable */
239 INT HelpStringContext;
243 /* Structure of the reference data */
245 INT reftype; /* either offset in type info table, then it's */
246 /* a multiple of 64 */
247 /* or offset in the external reference table */
248 /* with an offset of 1 */
250 INT oCustData; /* custom data */
251 INT onext; /* next offset, -1 if last */
254 /* this is how a guid is stored */
257 INT unk10; /* differntiate with libid, classid etc? */
258 /* it's -2 for a libary */
259 /* it's 0 for an interface */
260 INT unk14; /* always? -1 */
262 /* some data preceding entries in the name table */
264 INT unk00; /* sometimes -1 (lib, parameter) ,
265 sometimes 0 (interface, func) */
266 INT unk10; /* sometimes -1 (lib) , sometimes 0 (interface, func),
267 sometimes 0x10 (par) */
268 INT namelen; /* only lower 8 bits are valid */
270 /* the custom data table directory has enties like this */
274 INT next; /* next offset in the table, -1 if it's the last */
278 /***********************************************************
282 * These are created with ICreateTypeLib
286 #include "pshpack1.h"
289 /*00*/ DWORD SLTG_magic; /* 0x47544c53 == "SLTG" */
290 /*04*/ WORD nrOfFileBlks; /* no of SLTG_BlkEntry's + 1 */
291 /*06*/ WORD res06; /* ?? always 9 */
292 /*08*/ WORD res08; /* some kind of len/offset ?? */
293 /*0a*/ WORD first_blk; /* 1 based index into blk entries that
294 corresponds to first block in file */
295 /*0c*/ DWORD res0c; /* always 0x000204ff */
296 /*10*/ DWORD res10; /* always 0x00000000 */
297 /*14*/ DWORD res14; /* always 0x000000c0 */
298 /*18*/ DWORD res18; /* always 0x46000000 */
299 /*1c*/ DWORD res1c; /* always 0x00000044 */
300 /*20*/ DWORD res20; /* always 0xffff0000 */
303 /* This gets followed by a list of block entries */
306 /*04*/ WORD index_string; /* offs from start of SLTG_Magic to index string */
310 /* The order of the blocks in the file is given by starting at Block
311 entry firt_blk and stepping through using the next pointer */
313 /* These then get followed by this magic */
315 /*00*/ BYTE res00; /* always 0x01 */
316 /*01*/ CHAR CompObj_magic[8]; /* always "CompObj" */
317 /*09*/ CHAR dir_magic[4]; /* always "dir" */
320 #define SLTG_COMPOBJ_MAGIC "CompObj"
321 #define SLTG_DIR_MAGIC "dir"
323 /* Next we have SLTG_Header.nrOfFileBlks - 2 of Index strings. These
324 are presumably unique to within the file and look something like
325 "AAAAAAAAAA" with the first character incremented from 'A' to ensure
326 uniqueness. I guess successive chars increment when we need to wrap
330 /*00*/ CHAR string[11];
334 /* This is followed by SLTG_pad9 */
336 /*00*/ CHAR pad[9]; /* 9 '\0's */
340 /* Now we have the noOfFileBlks - 1 worth of blocks. The length of
341 each block is given by its entry in SLTG_BlkEntry. */
343 /* type SLTG_NAME in rather like a BSTR except that the length in
344 bytes is given by the first WORD and the string contains 8bit chars */
346 typedef WORD SLTG_Name;
348 /* The main library block looks like this. This one seems to come last */
351 /*00*/ WORD magic; /* 0x51cc */
352 /*02*/ WORD res02; /* 0x0003, 0x0004 */
353 /*04*/ WORD name; /* offset to name in name table */
354 /*06*/ SLTG_Name res06; /* maybe this is just WORD == 0xffff */
355 SLTG_Name helpstring;
358 WORD syskind; /* == 1 for win32, 0 for win16 */
359 WORD lcid; /* == 0x409, 0x809 etc */
360 DWORD res12; /* == 0 */
361 WORD libflags; /* LIBFLAG_* */
367 #define SLTG_LIBBLK_MAGIC 0x51cc
369 /* we then get 0x40 bytes worth of 0xffff or small numbers followed by
370 nrOfFileBlks - 2 of these */
373 SLTG_Name index_name; /* This refers to a name in the directory */
374 SLTG_Name other_name; /* Another one of these weird names */
375 WORD res1a; /* 0xffff */
376 WORD name_offs; /* offset to name in name table */
377 WORD more_bytes; /* if this is non-zero we get this many
378 bytes before the next element, which seem
379 to reference the docstring of the type ? */
380 WORD res20; /* 0xffff */
382 WORD res26; /* 0xffff */
384 } SLTG_OtherTypeInfo;
386 /* Next we get WORD 0x0003 followed by a DWORD which if we add to
387 0x216 gives the offset to the name table from the start of the LibBlk
391 /*00*/ WORD magic; /* 0x0501 */
392 /*02*/ DWORD href_table; /* if not 0xffffffff, then byte offset from
393 beginning of struct to href table */
394 /*06*/ DWORD res06; /* 0xffffffff */
395 /*0a*/ DWORD elem_table; /* offset to members */
396 /*0e*/ DWORD res0e; /* 0xffffffff */
397 /*12*/ WORD major_version; /* major version number */
398 /*14*/ WORD minor_version; /* minor version number */
399 /*16*/ DWORD res16; /* 0xfffe0000 */
400 /*1a*/ BYTE typeflags1;/* 0x02 | top 5 bits hold l5sbs of TYPEFLAGS */
401 /*1b*/ BYTE typeflags2;/* TYPEFLAGS >> 5 */
402 /*1c*/ BYTE typeflags3;/* 0x02*/
403 /*1d*/ BYTE typekind; /* 0x03 == TKIND_INTERFACE etc. */
404 /*1e*/ DWORD res1e; /* 0x00000000 or 0xffffffff */
405 } SLTG_TypeInfoHeader;
407 #define SLTG_TIHEADER_MAGIC 0x0501
412 /*04*/ WORD cImplTypes;
420 /*14*/ WORD tdescalias_vt; /* for TKIND_ALIAS */
426 /*20*/ WORD cbSizeInstance;
427 /*22*/ WORD cbAlignment;
430 /*28*/ WORD cbSizeVft;
440 /*00*/ WORD res00; /* 0x0001 sometimes 0x0003 ?? */
441 /*02*/ WORD res02; /* 0xffff */
442 /*04*/ BYTE res04; /* 0x01 */
443 /*05*/ DWORD cbExtra; /* No of bytes that follow */
447 /*00*/ WORD magic; /* 0x120a */
448 /*02*/ WORD next; /* offset in bytes to next block from start of block
449 group, 0xffff if last item */
450 /*04*/ WORD name; /* offset to name within name table */
451 /*06*/ WORD value; /* offset to value from start of block group */
452 /*08*/ WORD res08; /* 0x56 */
453 /*0a*/ DWORD memid; /* memid */
454 /*0e*/ WORD helpcontext;/* 0xfffe == no context, 0x0001 == stored in EnumInfo struct, else offset
455 to value from start of block group */
456 /*10*/ WORD helpstring;/* offset from start of block group to string offset */
459 #define SLTG_ENUMITEM_MAGIC 0x120a
462 /*00*/ WORD vt; /* vartype, 0xffff marks end. */
463 /*02*/ WORD res02; /* ?, 0xffff marks end */
466 #define SLTG_ALIASITEM_MAGIC 0x001d
470 BYTE magic; /* 0x4c or 0x6c */
471 BYTE inv; /* high nibble is INVOKE_KIND, low nibble = 2 */
472 WORD next; /* byte offset from beginning of group to next fn */
473 WORD name; /* Offset within name table to name */
474 DWORD dispid; /* dispid */
475 WORD helpcontext; /* helpcontext (again 1 is special) */
476 WORD helpstring;/* helpstring offset to offset */
477 WORD arg_off; /* offset to args from start of block */
478 BYTE nacc; /* lowest 3bits are CALLCONV, rest are no of args */
479 BYTE retnextopt;/* if 0x80 bit set ret type follows else next WORD
480 is offset to ret type. No of optional args is
482 WORD rettype; /* return type VT_?? or offset to ret type */
483 WORD vtblpos; /* position in vtbl? */
484 WORD funcflags; /* present if magic == 0x6c */
485 /* Param list starts, repeat next two as required */
487 WORD name; /* offset to 2nd letter of name */
488 WORD+ type; /* VT_ of param */
492 #define SLTG_FUNCTION_MAGIC 0x4c
493 #define SLTG_FUNCTION_WITH_FLAGS_MAGIC 0x6c
496 /*00*/ BYTE magic; /* 0xdf */
497 /*01*/ BYTE res01; /* 0x00 */
498 /*02*/ DWORD res02; /* 0xffffffff */
499 /*06*/ DWORD res06; /* 0xffffffff */
500 /*0a*/ DWORD res0a; /* 0xffffffff */
501 /*0e*/ DWORD res0e; /* 0xffffffff */
502 /*12*/ DWORD res12; /* 0xffffffff */
503 /*16*/ DWORD res16; /* 0xffffffff */
504 /*1a*/ DWORD res1a; /* 0xffffffff */
505 /*1e*/ DWORD res1e; /* 0xffffffff */
506 /*22*/ DWORD res22; /* 0xffffffff */
507 /*26*/ DWORD res26; /* 0xffffffff */
508 /*2a*/ DWORD res2a; /* 0xffffffff */
509 /*2e*/ DWORD res2e; /* 0xffffffff */
510 /*32*/ DWORD res32; /* 0xffffffff */
511 /*36*/ DWORD res36; /* 0xffffffff */
512 /*3a*/ DWORD res3a; /* 0xffffffff */
513 /*3e*/ DWORD res3e; /* 0xffffffff */
514 /*42*/ WORD res42; /* 0xffff */
515 /*44*/ DWORD number; /* this is 8 times the number of refs */
516 /*48*/ /* Now we have number bytes (8 for each ref) of SLTG_UnknownRefInfo */
518 /*50*/ WORD res50; /* 0xffff */
519 /*52*/ BYTE res52; /* 0x01 */
520 /*53*/ DWORD res53; /* 0x00000000 */
521 /*57*/ SLTG_Name names[1];
522 /* Now we have number/8 SLTG_Names (first WORD is no of bytes in the ascii
523 * string). Strings look like "*\Rxxxx*#n". If xxxx == ffff then the
524 * ref refers to the nth type listed in this library (0 based). Else
525 * the xxxx (which maybe fewer than 4 digits) is the offset into the name
526 * table to a string "*\G{<guid>}#1.0#0#C:\WINNT\System32\stdole32.tlb#"
527 * The guid is the typelib guid; the ref again refers to the nth type of
528 * the imported typelib.
531 /*xx*/ BYTE resxx; /* 0xdf */
535 #define SLTG_REF_MAGIC 0xdf
538 WORD res00; /* 0x0001 */
539 BYTE res02; /* 0x02 */
540 BYTE res03; /* 0x40 if internal ref, 0x00 if external ? */
541 WORD res04; /* 0xffff */
542 WORD res06; /* 0x0000, 0x0013 or 0xffff ?? */
543 } SLTG_UnknownRefInfo;
546 WORD res00; /* 0x004a */
547 WORD next; /* byte offs to next interface */
548 WORD res04; /* 0xffff */
549 BYTE impltypeflags; /* IMPLTYPEFLAG_* */
550 BYTE res07; /* 0x80 */
551 WORD res08; /* 0x0012, 0x0028 ?? */
552 WORD ref; /* number in ref table ? */
553 WORD res0c; /* 0x4000 */
554 WORD res0e; /* 0xfffe */
555 WORD res10; /* 0xffff */
556 WORD res12; /* 0x001d */
557 WORD pos_in_table; /* 0x0, 0x4, ? */
560 #define SLTG_IMPL_MAGIC 0x004a
563 BYTE magic; /* 0x0a */
567 WORD byte_offs; /* pos in struct */
568 WORD type; /* if typepos == 0x02 this is the type, else offset to type */
570 WORD helpcontext; /* ?? */
571 WORD helpstring; /* ?? */
574 #define SLTG_RECORD_MAGIC 0x0a
577 /* CARRAYs look like this
578 WORD type == VT_CARRAY
579 WORD offset from start of block to SAFEARRAY
583 extern DWORD _invoke(FARPROC func,CALLCONV callconv, int nrargs, DWORD *args);
584 extern void dump_Variant(VARIANT * pvar);
587 /*---------------------------END--------------------------------------------*/