Removed global variable pCurrentTeb.
[wine/wine-kai.git] / ole / typelib.h
blobe328ce9682cd749445fedce9f9a87da4674427e9
1 /*
2 * typelib.h internal wine data structures
3 * used to decode typelib's
5 * Copyright 1999 Rein KLazes
6 *
7 */
8 #ifndef _WINE_TYPELIB_H
9 #define _WINE_TYPELIB_H
12 #include "oleauto.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 {
24 GUID guid;
25 VARIANT data;
26 struct tagTLBCustData* next;
27 } TLBCustData;
29 /* internal Parameter data */
30 typedef struct tagTLBParDesc{
31 PCHAR Name;
32 int ctCustData;
33 TLBCustData * pCustData; /* linked list to cust data; */
34 } TLBParDesc;
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 */
42 int helpcontext;
43 int HelpStringContext;
44 PCHAR HelpString;
45 PCHAR Entry; /* if its Hiword==0, it numeric; -1 is not present*/
46 int ctCustData;
47 TLBCustData * pCustData; /* linked list to cust data; */
48 struct tagTLBFuncDesc * next;
49 } TLBFuncDesc;
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 */
55 int HelpContext;
56 int HelpStringContext; /* fixme: where? */
57 PCHAR HelpString;
58 int ctCustData;
59 TLBCustData * pCustData;/* linked list to cust data; */
60 struct tagTLBVarDesc * next;
61 } TLBVarDesc;
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) */
67 HREFTYPE reference;
68 int flags;
69 int ctCustData;
70 TLBCustData * pCustData;/* linked list to custom data; */
71 struct tagTLBImpLib *pImpTLInfo;
72 struct tagTLBRefType * next;
73 }TLBRefType;
75 /* internal TypeInfo data */
76 typedef struct tagTYPEINFO {
77 LPTYPEINFO_VTABLE lpvtbl;
78 UINT ref;
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?
85 PCHAR Name;
86 PCHAR DocString;
87 unsigned long dwHelpContext;
88 unsigned long dwHelpStringContext;
90 /* functions */
91 TLBFuncDesc * funclist; /* linked list with function descriptions */
92 /* variables */
93 TLBVarDesc * varlist; /* linked list with variable descriptions */
94 /* Implemented Interfaces */
95 TLBRefType * impltypelist;
96 int ctCustData;
97 TLBCustData * pCustData; /* linked list to cust data; */
98 struct tagTYPEINFO * next;
99 } TLBTypeInfo;
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;
108 } TLBImpLib;
110 /* internal TypeLib data */
111 typedef struct tagTYPELIB {
112 LPTYPELIB_VTABLE lpvtbl;
113 UINT ref;
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?
118 PCHAR Name;
119 PCHAR DocString;
120 PCHAR HelpFile;
121 PCHAR HelpStringDll;
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 */
129 } TLBLibInfo;
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 */
145 /*0x10*/INT lcid2;
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;
155 INT helpcontext;
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 */
166 } TLB2Header;
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 */
175 } pSeg;
177 /* layout of the main segment directory */
178 typedef struct tagTLBSegDir {
179 /*1*/pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
180 /* (25 ints) */
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 */
199 } TLBSegDir;
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 */
233 /* actually dunno */
234 /* else it is zero? */
235 INT res18; /* always? 0 */
236 /*060*/ INT res19; /* always? -1 */
237 } TLBTypeInfoBase;
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 */
244 } TLBImpInfo;
246 /* function description data */
247 typedef struct {
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 */
264 INT OptAttr[1];
266 0* INT helpcontext;
267 1* INT oHelpString;
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 //
276 } TLBFuncRecord;
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*/
284 typedef struct {
285 INT DataType;
286 INT oName;
287 INT Flags;
288 } TLBParameterInfo;
290 /* Variable description data */
291 typedef struct {
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 */
301 INT HelpContext;
302 INT oHelpString;
303 INT res9; /* unknown (-1) */
304 INT oCustData; /* custom data for variable */
305 INT HelpStringContext;
307 } TLBVarRecord;
309 /* Structure of the reference data */
310 typedef struct {
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 */
315 INT flags;
316 INT oCustData; /* custom data */
317 INT onext; /* next offset, -1 if last */
318 } TLBRefRecord;
320 /* this is how a guid is stored */
321 typedef struct {
322 GUID guid;
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 */
327 } TLBGuidEntry;
328 /* some data preceding entries in the name table */
329 typedef struct {
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 */
335 } TLBNameIntro;
336 /* the custom data table directory has enties like this */
337 typedef struct {
338 INT GuidOffset;
339 INT DataOffset;
340 INT next; /* next offset in the table, -1 if its the last */
341 } TLBCDGuid;
345 /*---------------------------END--------------------------------------------*/
347 typedef struct tagTLBContext {
348 HANDLE hFile; /* open typelib file */
349 long oStart; /* start of TLB in file */
350 TLBSegDir * pTblDir;
351 TLBLibInfo* pLibInfo;
352 } TLBContext;
355 #endif