Merged msacm and msacm32 dlls.
[wine] / dlls / oleaut32 / typelib.h
1 /*
2  * typelib.h  internal wine data structures
3  * used to decode typelib's
4  *
5  * Copyright 1999 Rein KLazes
6  *  
7  */
8 #ifndef _WINE_TYPELIB_H
9 #define _WINE_TYPELIB_H
10
11
12 #include "oleauto.h"
13
14
15 #define TLBMAGIC2 "MSFT"
16 #define TLBMAGIC1 "SLTG"
17 #define HELPDLLFLAG (0x0100)
18 #define DO_NOT_SEEK (-1)
19
20 #define HREFTYPE_INTHISFILE(href) (!((href) & 3))
21 #define HREFTYPE_INDEX(href) ((href) /sizeof(TLBTypeInfoBase))
22
23 /*-------------------------FILE STRUCTURES-----------------------------------*/
24
25
26 /*
27  * structure of the typelib type2 header
28  * it is at the beginning of a type lib file
29  *  
30  */
31 typedef struct tagTLB2Header {
32 /*0x00*/INT magic1;       /* 0x5446534D "MSFT" */
33         INT   magic2;       /* 0x00010002 version nr? */
34         INT   posguid;      /* position of libid in guid table  */
35                             /* (should be,  else -1) */
36         INT   lcid;         /* locale id */
37 /*0x10*/INT   lcid2;
38         INT   varflags;     /* (largely) unknown flags ,seems to be always 41 */
39                             /* becomes 0x51 with a helpfile defined */
40                             /* if help dll defined its 0x151 */
41                             /* update : the lower nibble is syskind */
42         INT   version;      /* set with SetVersion() */
43         INT   flags;        /* set with SetFlags() */
44 /*0x20*/INT   nrtypeinfos;  /* number of typeinfo's (till so far) */
45         INT   helpstring;   /* position of help string in stringtable */
46         INT   helpstringcontext;
47         INT   helpcontext;
48 /*0x30*/INT   nametablecount;   /* number of names in name table */
49         INT   nametablechars;   /* nr of characters in name table */
50         INT   NameOffset;       /* offset of name in name table */
51         INT   helpfile;         /* position of helpfile in stringtable */
52 /*0x40*/INT   CustomDataOffset; /* if -1 no custom data, else it is offset */
53                                 /* in customer data/guid offset table */
54         INT   res44;            /* unknown always: 0x20 */
55         INT   res48;            /* unknown always: 0x80 */
56         INT   dispatchpos;      /* gets a value (1+n*0x0c) with Idispatch interfaces */
57 /*0x50*/INT   res50;            /* is zero becomes one when an interface is derived */
58 } TLB2Header;
59
60 /* segments in the type lib file have a structure like this: */
61 typedef struct _tptag {
62         INT   offset;       /* absolute offset in file */
63         INT   length;       /* length of segment */
64         INT   res08;        /* unknown always -1 */
65         INT   res0c;        /* unknown always 0x0f in the header */
66                             /* 0x03 in the typeinfo_data */
67 } pSeg;
68
69 /* layout of the main segment directory */
70 typedef struct tagTLBSegDir {
71 /*1*/pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
72                         /* (25 ints) */
73 /*2*/pSeg pImpInfo;     /* table with info for imported types */
74 /*3*/pSeg pImpFiles;    /* import libaries */
75 /*4*/pSeg pRefTab;      /* References table */
76 /*5*/pSeg pLibtab;      /* always exists, alway same size (0x80) */
77                         /* hash table w offsets to guid????? */
78 /*6*/pSeg pGuidTab;     /* all guids are stored here together with  */
79                         /* offset in some table???? */
80 /*7*/pSeg res07;        /* always created, alway same size (0x200) */
81                         /* purpose largely unknown */
82 /*8*/pSeg pNametab;     /* name tables */
83 /*9*/pSeg pStringtab;   /*string table */
84 /*A*/pSeg pTypdescTab;  /* table with type descriptors */
85 /*B*/pSeg pArrayDescriptions;
86 /*C*/pSeg pCustData;    /*  data table, used for custom data and default */
87                         /* parameter values */
88 /*D*/pSeg pCDGuids;     /* table with offsets for the guids and into the customer data table */
89 /*E*/pSeg res0e;            /* unknown */
90 /*F*/pSeg res0f;            /* unknown  */
91 } TLBSegDir;
92
93
94 /* base type info data */
95 typedef struct tagTLBTypeInfoBase {
96 /*000*/ INT   typekind;             /*  it is the TKIND_xxx */
97                                     /* some byte alignment stuf */
98         INT     memoffset;          /* points past the file, if no elements */
99         INT     res2;               /* zero if no element, N*0x40 */
100         INT     res3;               /* -1 if no lement, (N-1)*0x38 */
101 /*010*/ INT     res4;               /* always? 3 */
102         INT     res5;               /* always? zero */
103         INT     cElement;           /* counts elements, HI=cVars, LO=cFuncs */
104         INT     res7;               /* always? zero */
105 /*020*/ INT     res8;               /* always? zero */
106         INT     res9;               /* always? zero */
107         INT     resA;               /* always? zero */
108         INT     posguid;            /* position in guid table */
109 /*030*/ INT     flags;              /* Typeflags */
110         INT     NameOffset;         /* offset in name table */
111         INT     version;            /* element version */
112         INT     docstringoffs;      /* offset of docstring in string tab */
113 /*040*/ INT     helpstringcontext;  /*  */
114         INT     helpcontext;    /* */
115         INT     oCustData;          /* offset in customer data table */
116         INT16   cImplTypes;     /* nr of implemented interfaces */
117         INT16   cbSizeVft;      /* virtual table size, not including inherits */
118 /*050*/ INT     size;           /* size in bytes, at least for structures */
119         /* fixme: name of this field */
120         INT     datatype1;      /* position in type description table */
121                                 /* or in base intefaces */
122                                 /* if coclass: offset in reftable */
123                                 /* if interface: reference to inherited if */
124         INT     datatype2;      /* if 0x8000, entry above is valid */
125                                 /* actually dunno */
126                                 /* else it is zero? */
127         INT     res18;          /* always? 0 */
128 /*060*/ INT     res19;          /* always? -1 */
129     } TLBTypeInfoBase;
130
131 /* layout of an entry with information on imported types */
132 typedef struct tagTLBImpInfo {
133     INT     res0;           /* unknown */
134     INT     oImpFile;       /* offset inthe Import File table */
135     INT     oGuid;          /* offset in Guid table */
136     } TLBImpInfo;
137
138 /* function description data */
139 typedef struct {
140 /*  INT   recsize;       record size including some xtra stuff */
141     INT   DataType;     /* data type of the memeber, eg return of function */
142     INT   Flags;        /* something to do with attribute flags (LOWORD) */
143     INT16 VtableOffset; /* offset in vtable */
144     INT16 res3;         /* some offset into dunno what */
145     INT   FKCCIC;       /* bit string with the following  */
146                         /* meaning (bit 0 is the msb): */
147                         /* bit 2 indicates that oEntry is numeric */
148                         /* bit 3 that parameter has default values */
149                         /* calling convention (bits 4-7 ) */
150                         /* bit 8 indicates that custom data is present */
151                         /* Invokation kind (bits 9-12 ) */
152                         /* function kind (eg virtual), bits 13-15  */
153     INT16 nrargs;       /* number of arguments (including optional ????) */
154     INT16 nroargs;      /* nr of optional arguments */
155     /* optional attribute fields, the number of them is variable */
156     INT   OptAttr[1];
157 /*
158 0*  INT   helpcontext;
159 1*  INT   oHelpString;
160 2*  INT   oEntry;       // either offset in string table or numeric as it is //
161 3*  INT   res9;         // unknown (-1) //
162 4*  INT   resA;         // unknown (-1) //
163 5*  INT   HelpStringContext;
164     // these are controlled by a bit set in the FKCCIC field  //
165 6*  INT   oCustData;        // custom data for function //
166 7*  INT   oArgCustData[1];  // custom data per argument //
167 */
168 } TLBFuncRecord;
169
170 /* after this may follow an array with default value pointers if the 
171  * appropriate bit in the FKCCIC field has been set: 
172  * INT   oDefautlValue[nrargs];
173  */
174
175     /* Parameter info one per argument*/
176 typedef struct {
177         INT   DataType;
178         INT   oName;
179         INT   Flags;
180     } TLBParameterInfo;
181
182 /* Variable description data */
183 typedef struct {
184 /*  INT   recsize;      // record size including some xtra stuff */
185     INT   DataType;     /* data type of the variable */
186     INT   Flags;        /* VarFlags (LOWORD) */
187     INT16 VarKind;      /* VarKind */
188     INT16 res3;         /* some offset into dunno what */
189     INT   OffsValue;    /* value of the variable or the offset  */
190                         /* in the data structure */
191     /* optional attribute fields, the number of them is variable */
192     /* controlled by record length */
193     INT   HelpContext;
194     INT   oHelpString;
195     INT   res9;         /* unknown (-1) */
196     INT   oCustData;        /* custom data for variable */
197     INT   HelpStringContext;
198
199 } TLBVarRecord;
200
201 /* Structure of the reference data  */
202 typedef struct {
203     INT   reftype;  /* either offset in type info table, then its */
204                     /* a multiple of 64 */
205                     /* or offset in the external reference table */
206                     /* with an offset of 1 */
207     INT   flags;
208     INT   oCustData;    /* custom data */
209     INT   onext;    /* next offset, -1 if last */
210 } TLBRefRecord;
211
212 /* this is how a guid is stored */
213 typedef struct {
214     GUID guid;
215     INT   unk10;        /* differntiate with libid, classid etc? */
216                         /* its -2 for a libary */
217                         /* it's 0 for an interface */
218     INT   unk14;        /* always? -1 */
219 } TLBGuidEntry;
220 /* some data preceding entries in the name table */
221 typedef struct {
222     INT   unk00;        /* sometimes -1 (lib, parameter) ,
223                            sometimes 0 (interface, func) */
224     INT   unk10;        /* sometimes -1 (lib) , sometimes 0 (interface, func),
225                            sometime 0x10 (par) */
226     INT   namelen;      /* only lower 8 bits are valid */
227 } TLBNameIntro;
228 /* the custom data table directory has enties like this */
229 typedef struct {
230     INT   GuidOffset;
231     INT   DataOffset;
232     INT   next;     /* next offset in the table, -1 if its the last */
233 } TLBCDGuid;
234
235
236
237 /*---------------------------END--------------------------------------------*/
238 #endif