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
15 #define TLBMAGIC2 "MSFT"
16 #define TLBMAGIC1 "SLTG"
17 #define HELPDLLFLAG (0x0100)
18 #define DO_NOT_SEEK (-1)
20 #define HREFTYPE_INTHISFILE(href) (!((href) & 3))
21 #define HREFTYPE_INDEX(href) ((href) /sizeof(TLBTypeInfoBase))
23 typedef struct tagTLBCustData
{
26 struct tagTLBCustData
* next
;
29 /* internal Parameter data */
30 typedef struct tagTLBParDesc
{
33 TLBCustData
* pCustData
; /* linked list to cust data; */
37 /* internal Function data */
38 typedef struct tagTLBFuncDesc
{
39 FUNCDESC funcdesc
; /* lots of info on the function and its attributes. */
40 PCHAR Name
; /* the name of this function */
41 TLBParDesc
*pParamDesc
; /* array with name and custom data */
43 int HelpStringContext
;
45 PCHAR Entry
; /* if its Hiword==0, it numeric; -1 is not present*/
47 TLBCustData
* pCustData
; /* linked list to cust data; */
48 struct tagTLBFuncDesc
* next
;
51 /* internal Variable data */
52 typedef struct tagTLBVarDesc
{
53 VARDESC vardesc
; /* lots of info on the variable and its attributes. */
54 PCHAR Name
; /* the name of this variable */
56 int HelpStringContext
; /* fixme: where? */
59 TLBCustData
* pCustData
;/* linked list to cust data; */
60 struct tagTLBVarDesc
* next
;
63 /* data for refernced types in a coclass, or an inherited interface */
64 typedef struct tagTLBRefType
{
65 GUID guid
; /* guid of the referenced type */
66 /* (important if its a imported type) */
70 TLBCustData
* pCustData
;/* linked list to custom data; */
71 struct tagTLBImpLib
*pImpTLInfo
;
72 struct tagTLBRefType
* next
;
75 /* internal TypeInfo data */
76 typedef struct tagTYPEINFO
{
77 LPTYPEINFO_VTABLE lpvtbl
;
79 TYPEATTR TypeAttr
; /* _lots_ of type information. */
80 struct tagTYPELIB
* pTypeLib
; /* back pointer to typelib */
81 int index
; /* index in this typelib; */
82 /* type libs seem to store the doc strings in ascii
83 * so why should we do it in unicode?
87 unsigned long dwHelpContext
;
88 unsigned long dwHelpStringContext
;
91 TLBFuncDesc
* funclist
; /* linked list with function descriptions */
93 TLBVarDesc
* varlist
; /* linked list with variable descriptions */
94 /* Implemented Interfaces */
95 TLBRefType
* impltypelist
;
97 TLBCustData
* pCustData
; /* linked list to cust data; */
98 struct tagTYPEINFO
* next
;
101 /* data structure for import typelibs */
102 typedef struct tagTLBImpLib
{
103 int offset
; /* offset in the file */
104 GUID guid
; /* libid */
105 PCHAR name
; /* name; */
106 struct tagTYPELIB
*pImpTypeLib
; /* pointer to loaded typelib */
107 struct tagTLBImpLib
* next
;
110 /* internal TypeLib data */
111 typedef struct tagTYPELIB
{
112 LPTYPELIB_VTABLE lpvtbl
;
114 TLIBATTR LibAttr
; /* guid,lcid,syskind,version,flags */
115 /* type libs seem to store the doc strings in ascii
116 * so why should we do it in unicode?
122 unsigned long dwHelpContext
;
123 int TypeInfoCount
; /* nr of typeinfo's in librarry */
124 TLBTypeInfo
*pTypeInfo
; /* linked list of type info data */
125 int ctCustData
; /* number of items in cust data list */
126 TLBCustData
* pCustData
; /* linked list to cust data; */
127 TLBImpLib
* pImpLibs
; /* linked list to all imported typelibs */
128 TYPEDESC
* pTypeDesc
; /* array of TypeDescriptions found in the libary */
131 /*-------------------------FILE STRUCTURES-----------------------------------*/
135 * structure of the typelib type2 header
136 * it is at the beginning of a type lib file
139 typedef struct tagTLB2Header
{
140 /*0x00*/INT magic1
; /* 0x5446534D "MSFT" */
141 INT magic2
; /* 0x00010002 version nr? */
142 INT posguid
; /* position of libid in guid table */
143 /* (should be, else -1) */
144 INT lcid
; /* locale id */
146 INT varflags
; /* (largely) unknown flags ,seems to be always 41 */
147 /* becomes 0x51 with a helpfile defined */
148 /* if help dll defined its 0x151 */
149 /* update : the lower nibble is syskind */
150 INT version
; /* set with SetVersion() */
151 INT flags
; /* set with SetFlags() */
152 /*0x20*/INT nrtypeinfos
; /* number of typeinfo's (till so far) */
153 INT helpstring
; /* position of help string in stringtable */
154 INT helpstringcontext
;
156 /*0x30*/INT nametablecount
; /* number of names in name table */
157 INT nametablechars
; /* nr of characters in name table */
158 INT NameOffset
; /* offset of name in name table */
159 INT helpfile
; /* position of helpfile in stringtable */
160 /*0x40*/INT CustomDataOffset
; /* if -1 no custom data, else it is offset */
161 /* in customer data/guid offset table */
162 INT res44
; /* unknown always: 0x20 */
163 INT res48
; /* unknown always: 0x80 */
164 INT dispatchpos
; /* gets a value (1+n*0x0c) with Idispatch interfaces */
165 /*0x50*/INT res50
; /* is zero becomes one when an interface is derived */
168 /* segments in the type lib file have a structure like this: */
169 typedef struct _tptag
{
170 INT offset
; /* absolute offset in file */
171 INT length
; /* length of segment */
172 INT res08
; /* unknown always -1 */
173 INT res0c
; /* unknown always 0x0f in the header */
174 /* 0x03 in the typeinfo_data */
177 /* layout of the main segment directory */
178 typedef struct tagTLBSegDir
{
179 /*1*/pSeg pTypeInfoTab
; /* each type info get an entry of 0x64 bytes */
181 /*2*/pSeg pImpInfo
; /* table with info for imported types */
182 /*3*/pSeg pImpFiles
; /* import libaries */
183 /*4*/pSeg pRefTab
; /* References table */
184 /*5*/pSeg pLibtab
; /* always exists, alway same size (0x80) */
185 /* hash table w offsets to guid????? */
186 /*6*/pSeg pGuidTab
; /* all guids are stored here together with */
187 /* offset in some table???? */
188 /*7*/pSeg res07
; /* always created, alway same size (0x200) */
189 /* purpose largely unknown */
190 /*8*/pSeg pNametab
; /* name tables */
191 /*9*/pSeg pStringtab
; /*string table */
192 /*A*/pSeg pTypdescTab
; /* table with type descriptors */
193 /*B*/pSeg pArrayDescriptions
;
194 /*C*/pSeg pCustData
; /* data table, used for custom data and default */
195 /* parameter values */
196 /*D*/pSeg pCDGuids
; /* table with offsets for the guids and into the customer data table */
197 /*E*/pSeg res0e
; /* unknown */
198 /*F*/pSeg res0f
; /* unknown */
202 /* base type info data */
203 typedef struct tagTLBTypeInfoBase
{
204 /*000*/ INT typekind
; /* it is the TKIND_xxx */
205 /* some byte alignment stuf */
206 INT memoffset
; /* points past the file, if no elements */
207 INT res2
; /* zero if no element, N*0x40 */
208 INT res3
; /* -1 if no lement, (N-1)*0x38 */
209 /*010*/ INT res4
; /* always? 3 */
210 INT res5
; /* always? zero */
211 INT cElement
; /* counts elements, HI=cVars, LO=cFuncs */
212 INT res7
; /* always? zero */
213 /*020*/ INT res8
; /* always? zero */
214 INT res9
; /* always? zero */
215 INT resA
; /* always? zero */
216 INT posguid
; /* position in guid table */
217 /*030*/ INT flags
; /* Typeflags */
218 INT NameOffset
; /* offset in name table */
219 INT version
; /* element version */
220 INT docstringoffs
; /* offset of docstring in string tab */
221 /*040*/ INT helpstringcontext
; /* */
222 INT helpcontext
; /* */
223 INT oCustData
; /* offset in customer data table */
224 INT16 cImplTypes
; /* nr of implemented interfaces */
225 INT16 cbSizeVft
; /* virtual table size, not including inherits */
226 /*050*/ INT size
; /* size in bytes, at least for structures */
227 /* fixme: name of this field */
228 INT datatype1
; /* position in type description table */
229 /* or in base intefaces */
230 /* if coclass: offset in reftable */
231 /* if interface: reference to inherited if */
232 INT datatype2
; /* if 0x8000, entry above is valid */
234 /* else it is zero? */
235 INT res18
; /* always? 0 */
236 /*060*/ INT res19
; /* always? -1 */
239 /* layout of an entry with information on imported types */
240 typedef struct tagTLBImpInfo
{
241 INT res0
; /* unknown */
242 INT oImpFile
; /* offset inthe Import File table */
243 INT oGuid
; /* offset in Guid table */
246 /* function description data */
248 /* INT recsize; record size including some xtra stuff */
249 INT DataType
; /* data type of the memeber, eg return of function */
250 INT Flags
; /* something to do with attribute flags (LOWORD) */
251 INT16 VtableOffset
; /* offset in vtable */
252 INT16 res3
; /* some offset into dunno what */
253 INT FKCCIC
; /* bit string with the following */
254 /* meaning (bit 0 is the msb): */
255 /* bit 2 indicates that oEntry is numeric */
256 /* bit 3 that parameter has default values */
257 /* calling convention (bits 4-7 ) */
258 /* bit 8 indicates that custom data is present */
259 /* Invokation kind (bits 9-12 ) */
260 /* function kind (eg virtual), bits 13-15 */
261 INT16 nrargs
; /* number of arguments (including optional ????) */
262 INT16 nroargs
; /* nr of optional arguments */
263 /* optional attribute fields, the number of them is variable */
268 2* INT oEntry; // either offset in string table or numeric as it is //
269 3* INT res9; // unknown (-1) //
270 4* INT resA; // unknown (-1) //
271 5* INT HelpStringContext;
272 // these are controlled by a bit set in the FKCCIC field //
273 6* INT oCustData; // custom data for function //
274 7* INT oArgCustData[1]; // custom data per argument //
278 /* after this may follow an array with default value pointers if the
279 * appropriate bit in the FKCCIC field has been set:
280 * INT oDefautlValue[nrargs];
283 /* Parameter info one per argument*/
290 /* Variable description data */
292 /* INT recsize; // record size including some xtra stuff */
293 INT DataType
; /* data type of the variable */
294 INT Flags
; /* VarFlags (LOWORD) */
295 INT16 VarKind
; /* VarKind */
296 INT16 res3
; /* some offset into dunno what */
297 INT OffsValue
; /* value of the variable or the offset */
298 /* in the data structure */
299 /* optional attribute fields, the number of them is variable */
300 /* controlled by record length */
303 INT res9
; /* unknown (-1) */
304 INT oCustData
; /* custom data for variable */
305 INT HelpStringContext
;
309 /* Structure of the reference data */
311 INT reftype
; /* either offset in type info table, then its */
312 /* a multiple of 64 */
313 /* or offset in the external reference table */
314 /* with an offset of 1 */
316 INT oCustData
; /* custom data */
317 INT onext
; /* next offset, -1 if last */
320 /* this is how a guid is stored */
323 INT unk10
; /* differntiate with libid, classid etc? */
324 /* its -2 for a libary */
325 /* it's 0 for an interface */
326 INT unk14
; /* always? -1 */
328 /* some data preceding entries in the name table */
330 INT unk00
; /* sometimes -1 (lib, parameter) ,
331 sometimes 0 (interface, func) */
332 INT unk10
; /* sometimes -1 (lib) , sometimes 0 (interface, func),
333 sometime 0x10 (par) */
334 INT namelen
; /* only lower 8 bits are valid */
336 /* the custom data table directory has enties like this */
340 INT next
; /* next offset in the table, -1 if its the last */
345 /*---------------------------END--------------------------------------------*/