2 * typelib.h internal wine data structures
3 * used to decode typelib's
5 * Copyright 1999 Rein KLazes
8 #ifndef _WINE_TYPELIB_H
9 #define _WINE_TYPELIB_H
17 #define TLBMAGIC2 "MSFT"
18 #define TLBMAGIC1 "SLTG"
19 #define HELPDLLFLAG (0x0100)
20 #define DO_NOT_SEEK (-1)
22 #define HREFTYPE_INTHISFILE(href) (!((href) & 3))
23 #define HREFTYPE_INDEX(href) ((href) /sizeof(TLBTypeInfoBase))
25 typedef struct tagTLBCustData {
28 struct tagTLBCustData* next;
31 /* internal Parameter data */
32 typedef struct tagTLBParDesc{
35 TLBCustData * pCustData; /* linked list to cust data; */
39 /* internal Function data */
40 typedef struct tagTLBFuncDesc{
41 FUNCDESC funcdesc; /* lots of info on the function and its attributes. */
42 PCHAR Name; /* the name of this function */
43 TLBParDesc *pParamDesc; /* array with name and custom data */
45 int HelpStringContext;
47 PCHAR Entry; /* if its Hiword==0, it numeric; -1 is not present*/
49 TLBCustData * pCustData; /* linked list to cust data; */
50 struct tagTLBFuncDesc * next;
53 /* internal Variable data */
54 typedef struct tagTLBVarDesc{
55 VARDESC vardesc; /* lots of info on the variable and its attributes. */
56 PCHAR Name; /* the name of this variable */
58 int HelpStringContext; /* fixme: where? */
61 TLBCustData * pCustData;/* linked list to cust data; */
62 struct tagTLBVarDesc * next;
65 /* data for refernced types in a coclass, or an inherited interface */
66 typedef struct tagTLBRefType {
67 GUID guid; /* guid of the referenced type */
68 /* (important if its a imported type) */
72 TLBCustData * pCustData;/* linked list to custom data; */
73 struct tagTLBImpLib *pImpTLInfo;
74 struct tagTLBRefType * next;
77 /* internal TypeInfo data */
78 typedef struct tagTYPEINFO {
79 LPTYPEINFO_VTABLE lpvtbl;
81 TYPEATTR TypeAttr ; /* _lots_ of type information. */
82 struct tagTYPELIB * pTypeLib; /* back pointer to typelib */
83 int index; /* index in this typelib; */
84 /* type libs seem to store the doc strings in ascii
85 * so why should we do it in unicode?
89 unsigned long dwHelpContext;
90 unsigned long dwHelpStringContext;
93 TLBFuncDesc * funclist; /* linked list with function descriptions */
95 TLBVarDesc * varlist; /* linked list with variable descriptions */
96 /* Implemented Interfaces */
97 TLBRefType * impltypelist;
99 TLBCustData * pCustData; /* linked list to cust data; */
100 struct tagTYPEINFO * next;
103 /* data structure for import typelibs */
104 typedef struct tagTLBImpLib {
105 int offset; /* offset in the file */
106 GUID guid; /* libid */
107 PCHAR name; /* name; */
108 struct tagTYPELIB *pImpTypeLib; /* pointer to loaded typelib */
109 struct tagTLBImpLib * next;
112 /* internal TypeLib data */
113 typedef struct tagTYPELIB {
114 LPTYPELIB_VTABLE lpvtbl;
116 TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */
117 /* type libs seem to store the doc strings in ascii
118 * so why should we do it in unicode?
124 unsigned long dwHelpContext;
125 int TypeInfoCount; /* nr of typeinfo's in librarry */
126 TLBTypeInfo *pTypeInfo; /* linked list of type info data */
127 int ctCustData; /* number of items in cust data list */
128 TLBCustData * pCustData; /* linked list to cust data; */
129 TLBImpLib * pImpLibs; /* linked list to all imported typelibs */
130 TYPEDESC * pTypeDesc; /* array of TypeDescriptions found in the libary */
133 /*-------------------------FILE STRUCTURES-----------------------------------*/
137 * structure of the typelib type2 header
138 * it is at the beginning of a type lib file
141 typedef struct tagTLB2Header {
142 /*0x00*/INT magic1; /* 0x5446534D "MSFT" */
143 INT magic2; /* 0x00010002 version nr? */
144 INT posguid; /* position of libid in guid table */
145 /* (should be, else -1) */
146 INT lcid; /* locale id */
148 INT varflags; /* (largely) unknown flags ,seems to be always 41 */
149 /* becomes 0x51 with a helpfile defined */
150 /* if help dll defined its 0x151 */
151 /* update : the lower nibble is syskind */
152 INT version; /* set with SetVersion() */
153 INT flags; /* set with SetFlags() */
154 /*0x20*/INT nrtypeinfos; /* number of typeinfo's (till so far) */
155 INT helpstring; /* position of help string in stringtable */
156 INT helpstringcontext;
158 /*0x30*/INT nametablecount; /* number of names in name table */
159 INT nametablechars; /* nr of characters in name table */
160 INT NameOffset; /* offset of name in name table */
161 INT helpfile; /* position of helpfile in stringtable */
162 /*0x40*/INT CustomDataOffset; /* if -1 no custom data, else it is offset */
163 /* in customer data/guid offset table */
164 INT res44; /* unknown always: 0x20 */
165 INT res48; /* unknown always: 0x80 */
166 INT dispatchpos; /* gets a value (1+n*0x0c) with Idispatch interfaces */
167 /*0x50*/INT res50; /* is zero becomes one when an interface is derived */
170 /* segments in the type lib file have a structure like this: */
171 typedef struct _tptag {
172 INT offset; /* absolute offset in file */
173 INT length; /* length of segment */
174 INT res08; /* unknown always -1 */
175 INT res0c; /* unknown always 0x0f in the header */
176 /* 0x03 in the typeinfo_data */
179 /* layout of the main segment directory */
180 typedef struct tagTLBSegDir {
181 /*1*/pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
183 /*2*/pSeg pImpInfo; /* table with info for imported types */
184 /*3*/pSeg pImpFiles; /* import libaries */
185 /*4*/pSeg pRefTab; /* References table */
186 /*5*/pSeg pLibtab; /* always exists, alway same size (0x80) */
187 /* hash table w offsets to guid????? */
188 /*6*/pSeg pGuidTab; /* all guids are stored here together with */
189 /* offset in some table???? */
190 /*7*/pSeg res07; /* always created, alway same size (0x200) */
191 /* purpose largely unknown */
192 /*8*/pSeg pNametab; /* name tables */
193 /*9*/pSeg pStringtab; /*string table */
194 /*A*/pSeg pTypdescTab; /* table with type descriptors */
195 /*B*/pSeg pArrayDescriptions;
196 /*C*/pSeg pCustData; /* data table, used for custom data and default */
197 /* parameter values */
198 /*D*/pSeg pCDGuids; /* table with offsets for the guids and into the customer data table */
199 /*E*/pSeg res0e; /* unknown */
200 /*F*/pSeg res0f; /* unknown */
204 /* base type info data */
205 typedef struct tagTLBTypeInfoBase {
206 /*000*/ INT typekind; /* it is the TKIND_xxx */
207 /* some byte alignment stuf */
208 INT memoffset; /* points past the file, if no elements */
209 INT res2; /* zero if no element, N*0x40 */
210 INT res3; /* -1 if no lement, (N-1)*0x38 */
211 /*010*/ INT res4; /* always? 3 */
212 INT res5; /* always? zero */
213 INT cElement; /* counts elements, HI=cVars, LO=cFuncs */
214 INT res7; /* always? zero */
215 /*020*/ INT res8; /* always? zero */
216 INT res9; /* always? zero */
217 INT resA; /* always? zero */
218 INT posguid; /* position in guid table */
219 /*030*/ INT flags; /* Typeflags */
220 INT NameOffset; /* offset in name table */
221 INT version; /* element version */
222 INT docstringoffs; /* offset of docstring in string tab */
223 /*040*/ INT helpstringcontext; /* */
224 INT helpcontext; /* */
225 INT oCustData; /* offset in customer data table */
226 INT16 cImplTypes; /* nr of implemented interfaces */
227 INT16 cbSizeVft; /* virtual table size, not including inherits */
228 /*050*/ INT size; /* size in bytes, at least for structures */
229 /* fixme: name of this field */
230 INT datatype1; /* position in type description table */
231 /* or in base intefaces */
232 /* if coclass: offset in reftable */
233 /* if interface: reference to inherited if */
234 INT datatype2; /* if 0x8000, entry above is valid */
236 /* else it is zero? */
237 INT res18; /* always? 0 */
238 /*060*/ INT res19; /* always? -1 */
241 /* layout of an entry with information on imported types */
242 typedef struct tagTLBImpInfo {
243 INT res0; /* unknown */
244 INT oImpFile; /* offset inthe Import File table */
245 INT oGuid; /* offset in Guid table */
248 /* function description data */
250 /* INT recsize; record size including some xtra stuff */
251 INT DataType; /* data type of the memeber, eg return of function */
252 INT Flags; /* something to do with attribute flags (LOWORD) */
253 INT16 VtableOffset; /* offset in vtable */
254 INT16 res3; /* some offset into dunno what */
255 INT FKCCIC; /* bit string with the following */
256 /* meaning (bit 0 is the msb): */
257 /* bit 2 indicates that oEntry is numeric */
258 /* bit 3 that parameter has default values */
259 /* calling convention (bits 4-7 ) */
260 /* bit 8 indicates that custom data is present */
261 /* Invokation kind (bits 9-12 ) */
262 /* function kind (eg virtual), bits 13-15 */
263 INT16 nrargs; /* number of arguments (including optional ????) */
264 INT16 nroargs; /* nr of optional arguments */
265 /* optional attribute fields, the number of them is variable */
270 2* INT oEntry; // either offset in string table or numeric as it is //
271 3* INT res9; // unknown (-1) //
272 4* INT resA; // unknown (-1) //
273 5* INT HelpStringContext;
274 // these are controlled by a bit set in the FKCCIC field //
275 6* INT oCustData; // custom data for function //
276 7* INT oArgCustData[1]; // custom data per argument //
280 /* after this may follow an array with default value pointers if the
281 * appropriate bit in the FKCCIC field has been set:
282 * INT oDefautlValue[nrargs];
285 /* Parameter info one per argument*/
292 /* Variable description data */
294 /* INT recsize; // record size including some xtra stuff */
295 INT DataType; /* data type of the variable */
296 INT Flags; /* VarFlags (LOWORD) */
297 INT16 VarKind; /* VarKind */
298 INT16 res3; /* some offset into dunno what */
299 INT OffsValue; /* value of the variable or the offset */
300 /* in the data structure */
301 /* optional attribute fields, the number of them is variable */
302 /* controlled by record length */
305 INT res9; /* unknown (-1) */
306 INT oCustData; /* custom data for variable */
307 INT HelpStringContext;
311 /* Structure of the reference data */
313 INT reftype; /* either offset in type info table, then its */
314 /* a multiple of 64 */
315 /* or offset in the external reference table */
316 /* with an offset of 1 */
318 INT oCustData; /* custom data */
319 INT onext; /* next offset, -1 if last */
322 /* this is how a guid is stored */
325 INT unk10; /* differntiate with libid, classid etc? */
326 /* its -2 for a libary */
327 /* it's 0 for an interface */
328 INT unk14; /* always? -1 */
330 /* some data preceding entries in the name table */
332 INT unk00; /* sometimes -1 (lib, parameter) ,
333 sometimes 0 (interface, func) */
334 INT unk10; /* sometimes -1 (lib) , sometimes 0 (interface, func),
335 sometime 0x10 (par) */
336 INT namelen; /* only lower 8 bits are valid */
338 /* the custom data table directory has enties like this */
342 INT next; /* next offset in the table, -1 if its the last */
347 /*---------------------------END--------------------------------------------*/
349 typedef struct tagTLBContext {
350 HANDLE hFile; /* open typelib file */
351 long oStart; /* start of TLB in file */
353 TLBLibInfo* pLibInfo;