Debian Codegraph @

mingw-w64-tools/genidl/src/genidl_typeinfo.h

raw
1 /*
2 genidl - Generate interface defintion language listing from a
3 Portable Executable.
4 Copyright (C) 2009-2016 mingw-w64 project
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _GENIDL_TYPEINFO_H
21 #define _GENIDL_TYPEINFO_H
22
23 #define TYPELIB_MSFT_MAGIC 0x5446534d /**< MSFT */
24 #define TYPELIB_NO_INDEX (-1)
25
26 #pragma pack(push,1)
27
28 typedef struct sTypeLibMSFT {
29 uint32_t magic1;
30 uint16_t ver_major;
31 uint16_t ver_minor;
32 int32_t pos_guid; /* references into guid table. */
33 int32_t lcid; /* locale id */
34 int32_t lcid2;
35 uint32_t var_flags; /* syskind, 0x10:if helpfile defined, 0x100:if helpstringdll defined. */
36 int32_t version; /* set with SetVersion() */
37 int32_t flags; /* set with SetFlags() */
38 int32_t nr_typeinfos;
39 int32_t helpstring; /* position of help string in stringtable. */
40 int32_t helpstringcontext;
41 int32_t helpcontext;
42 int32_t nametable_count; /* number of names in name table. */
43 uint32_t nametable_size; /* nr of characters in name table */
44 int32_t name_offset; /* offset of name in name table. */
45 int32_t helpfile; /* position of helpfile in stringtable */
46 int32_t custom_data_offset; /* if -1 no custom data, else it is offset in customer data/guid offset table */
47 uint32_t res44; /* unknown always: 0x20 (guid hash size?) */
48 uint32_t res48; /* unknown always: 0x80 (name hash size?) */
49 int32_t dispatchpos; /* HREFTYPE to IDispatch, or -1 if no IDispatch */
50 int32_t nr_impinfos; /* number of impinfos */
51 int32_t dta[1];
52 } sTypeLibMSFT;
53 /* 0x100 set with a helpstringdll defined - in this
54 case the offset to the name in the stringtable
55 appears right after this struct, before the
56 typeinfo offsets */
57
58 typedef struct sSegMSFT {
59 uint32_t offset; /* absolute offset in file */
60 uint32_t length; /* length of segment */
61 int32_t res08; /* unknown always -1 */
62 int32_t res0c; /* unknown always 0x0f in the header 0x03 in the typeinfo_data */
63 } sSegMSFT;
64
65 typedef enum eSegMSFT {
66 eSegMSFT_TYPEINFO = 0, /* type information */
67 eSegMSFT_IMPORTINFO, /* import information */
68 eSegMSFT_IMPORTFILES, /* import filenames */
69 eSegMSFT_REFERENCES, /* references (?) */
70 eSegMSFT_GUIDHASH, /* hash table for guids? */
71 eSegMSFT_GUID, /* guid storage */
72 eSegMSFT_NAMEHASH, /* hash table for names */
73 eSegMSFT_NAME, /* name storage */
74 eSegMSFT_STRING, /* string storage */
75 eSegMSFT_TYPEDESC, /* type descriptions */
76 eSegMSFT_ARRAYDESC, /* array descriptions */
77 eSegMSFT_CUSTDATA, /* custom data */
78 eSegMSFT_CUSTDATAGUID, /* custom data guids */
79 eSegMSFT_UNKNOWN, /* ??? */
80 eSegMSFT_UNKNOWN2, /* ??? */
81 eSegMSFT_MAX
82 } eSegMSFT;
83
84 typedef struct sMSFT_TypeInfoBase {
85 int32_t typekind; /* it is the TKIND_xxx */
86 /* some byte alignment stuff */
87 uint32_t memoffset; /* points past the file, if no elements */
88 int32_t res2; /* zero if no element, N*0x40 */
89 int32_t res3; /* -1 if no element, (N-1)*0x38 */
90 int32_t res4; /* always? 3 */
91 int32_t res5; /* always? zero */
92 int32_t cElement; /* counts elements, HI=cVars, LO=cFuncs */
93 int32_t res7; /* always? zero */
94 int32_t res8; /* always? zero */
95 int32_t res9; /* always? zero */
96 int32_t resA; /* always? zero */
97 int32_t posguid; /* position in guid table */
98 int32_t flags; /* Typeflags */
99 int32_t NameOffset; /* offset in name table */
100 int32_t version; /* element version */
101 int32_t docstringoffs; /* offset of docstring in string tab */
102 int32_t helpstringcontext; /* */
103 int32_t helpcontext; /* */
104 int32_t oCustData; /* offset in customer data table */
105 int16_t cImplTypes; /* nr of implemented interfaces */
106 int16_t cbSizeVft; /* virtual table size, including inherits */
107 int32_t size; /* size in bytes, at least for structures */
108 /* FIXME: name of this field */
109 int32_t datatype1; /* position in type description table */
110 /* or in base interfaces */
111 /* if coclass: offset in reftable */
112 /* if interface: reference to inherited if */
113 int32_t datatype2; /* for interfaces: hiword is num of inherited funcs */
114 /* loword is num of inherited interfaces */
115 int32_t res18; /* always? 0 */
116 int32_t res19; /* always? -1 */
117 } sMSFT_TypeInfoBase;
118
119 typedef struct sMSFT_TypeDesc {
120 uint16_t kind;
121 uint16_t flag;
122 #ifdef __GNUC__
123 __extension__
124 #endif
125 union {
126 int32_t oTypeB;
127 int32_t oTypeD;
128 int32_t oArrayD;
129 uint32_t vt;
130 };
131 } sMSFT_TypeDesc;
132
133 typedef struct sMSFT_RefTab {
134 int32_t oData1;
135 int32_t no;
136 int32_t data2;
137 int32_t oNextRef;
138 } sMSFT_RefTab;
139
140 typedef struct sMSFT_CustomData {
141 uint16_t vt;
142 unsigned char dta[1];
143 } sMSFT_CustomData;
144
145 typedef struct sMSFT_CDGuid {
146 int32_t oGuid;
147 int32_t oData;
148 int32_t next; /* next offset in the table, -1 if it's the last */
149 } sMSFT_CDGuid;
150
151 typedef struct sMSFT_FuncParam {
152 uint32_t dataType;
153 int32_t oName;
154 int32_t flags;
155 } sMSFT_FuncParam;
156
157 typedef struct sMSFT_var {
158 uint16_t rlen;
159 uint16_t id;
160 uint32_t datatype;
161 uint32_t flags;
162 uint16_t varKind;
163 uint16_t vardescSize;
164 int32_t oValue;
165 } sMSFT_var;
166
167 typedef struct sMSFT_func {
168 uint16_t rlen;
169 uint16_t id;
170 uint32_t datatype;
171 uint32_t flags;
172 uint16_t vtableOffset;
173 uint16_t funcdescSize;
174 #ifdef __GNUC__
175 __extension__
176 #endif
177 union {
178 int32_t fkccic;
179 #ifdef __GNUC__
180 __extension__
181 #endif
182 struct {
183 uint32_t funcKind : 3;
184 uint32_t invokeKind : 4;
185 uint32_t hasCustomData : 1;
186 uint32_t callconv : 4;
187 uint32_t hasParamDefValue : 1;
188 uint32_t isOEntryNumeric : 1;
189 uint32_t hasRetvalParam : 1;
190 uint32_t reserved1 : 1;
191 uint32_t nextIndexWithSameID : 16;
192 } f;
193 };
194 uint16_t nrArgs;
195 uint16_t nrOptArgs;
196 uint32_t data[1];
197 /* sMSFT_FuncParam params[1]; */
198 } sMSFT_func;
199
200 typedef struct sMSFT_ImpFiles {
201 int32_t res1;
202 int32_t res2;
203 int32_t res3;
204 uint16_t flag;
205 unsigned char dta[1];
206 } sMSFT_ImpFiles;
207
208 typedef struct sMSFT_memblob {
209 uint32_t size;
210 #ifdef __GNUC__
211 __extension__
212 #endif
213 union {
214 unsigned char dta[1];
215 };
216 } sMSFT_memblob;
217
218 typedef struct sMSFT_ArrayDesc {
219 uint32_t vt;
220 uint16_t count;
221 uint16_t size;
222 uint32_t vt_offset[1];
223 } sMSFT_ArrayDesc;
224
225 typedef struct tagMSFT_ImpInfo {
226 uint16_t count;
227 unsigned char flags;
228 unsigned char tkind;
229 int32_t oImpFile; /* offset in the Import File table */
230 int32_t oGuid; /* offset in Guid table or typeinfo index (see bit 16 of flags) */
231 } MSFT_ImpInfo;
232
233 #pragma pack(pop)
234
235 #ifndef IMPLTYPEFLAG_FDEFAULT
236 #define IMPLTYPEFLAG_FDEFAULT 1
237 #define IMPLTYPEFLAG_FSOURCE 2
238 #define IMPLTYPEFLAG_FRESTRICTED 4
239 #define IMPLTYPEFLAG_FDEFAULTVTABLE 8
240 #endif
241
242 #ifndef LIBFLAG_FRESTRICTED
243 #define LIBFLAG_FRESTRICTED 1
244 #define LIBFLAG_FCONTROL 2
245 #define LIBFLAG_FHIDDEN 4
246 #define LIBFLAG_FHASDISKIMAGE 0x8
247 #endif
248
249 #define VARKIND_PERINSTANCE 0
250 #define VARKIND_STATIC 1
251 #define VARKIND_CONST 2
252 #define VARKIND_DISPATCH 3
253
254 #define SYSKIND_WIN16 0
255 #define SYSKIND_WIN32 1
256 #define SYSKIND_MAC 2
257 #define SYSKIND_WIN64 3
258
259 /* Function Kind */
260 #define FUNCTKIND_VIRTUAL 0
261 #define FUNCTKIND_PUREVIRTUAL 1
262 #define FUNCTKIND_NONVIRTUAL 2
263 #define FUNCTKIND_STATIC 3
264 #define FUNCTKIND_DISPATCH 4
265
266 /* Invoke Kind */
267 #define INVOKIND_FUNC 1
268 #define INVOKIND_PROPERTYGET 2
269 #define INVOKIND_PROPERTYPUT 4
270 #define INVOKIND_PROPERTYPUTREF 8
271
272 /* Calling convention */
273 #define CALLCONV_FASTCALL 0 /**< fastcall call convention */
274 #define CALLCONV_CDECL 1 /**< cdecl call convention */
275 #define CALLCONV_PASCAL 2 /**< pascal call convention */
276 #define CALLCONV_MACPASCAL 3
277 #define CALLCONV_STDCALL 4 /**< stdcall call convention */
278 #define CALLCONV_FPFASTCALL 5
279 #define CALLCONV_SYSCALL 6
280 #define CALLCONV_MPWCDECL 7
281 #define CALLCONV_MPWPASCAL 8
282 #define CALLCONV_MAX 9
283
284 #define DESCKIND_NONE 0
285 #define DESCKIND_FUNCDESC 1
286 #define DESCKIND_VARDESC 2
287 #define DESCKIND_TYPECOMP 3
288 #define DESCKIND_IMPLICITAPPOBJECT 4
289 #define DESCKIND_MAX 5
290
291 #define TKIND_ENUM 0
292 #define TKIND_RECORD 1
293 #define TKIND_MODULE 2
294 #define TKIND_INTERFACE 3
295 #define TKIND_DISPATCH 4
296 #define TKIND_COCLASS 5
297 #define TKIND_ALIAS 6
298 #define TKIND_UNION 7
299 #define TKIND_MAX 8
300
301 #define TYPEFLAG_FAPPOBJECT 1
302 #define TYPEFLAG_FCANCREATE 2
303 #define TYPEFLAG_FLICENSED 4
304 #define TYPEFLAG_FPREDECLID 8
305 #define TYPEFLAG_FHIDDEN 0x10
306 #define TYPEFLAG_FCONTROL 0x20
307 #define TYPEFLAG_FDUAL 0x40
308 #define TYPEFLAG_FNONEXTENSIBLE 0x80
309 #define TYPEFLAG_FOLEAUTOMATION 0x100
310 #define TYPEFLAG_FRESTRICTED 0x200
311 #define TYPEFLAG_FAGGREGATABLE 0x400
312 #define TYPEFLAG_FREPLACEABLE 0x800
313 #define TYPEFLAG_FDISPATCHABLE 0x1000
314 #define TYPEFLAG_FREVERSEBIND 0x2000
315 #define TYPEFLAG_FPROXY 0x4000
316
317
318 #define TYPE_KIND_STRUCT_EXTERN 0x10a1
319 #define TYPE_KIND_ENUM 0x2120
320 #define TYPE_KIND_STRUCT 0x2121
321 #define TYPE_KIND_TYPEDEF 0x2126
322 #define TYPE_KIND_FORWARD_STRUCT 0x2225
323 #define TYPE_KIND_INTERFACE 0x2234
324 #define TYPE_KIND_UNION 0x4221
325 #define TYPE_KIND_UNION_INSTRUCT 0x4227
326
327 #ifndef PARAMFLAG_FIN
328 #define PARAMFLAG_FIN 1
329 #define PARAMFLAG_FOUT 2
330 #define PARAMFLAG_FLCID 4
331 #define PARAMFLAG_FRETVAL 8
332 #define PARAMFLAG_FOPT 0x10
333 #define PARAMFLAG_FHASDEFAULT 0x20
334 #define PARAMFLAG_FHASCUSTDATA 0x40
335 #endif
336
337 #define FUNCFLAG_FRESTRICTED 0x1
338 #define FUNCFLAG_FSOURCE 0x2
339 #define FUNCFLAG_FBINDABLE 0x4
340 #define FUNCFLAG_FREQUESTEDIT 0x8
341 #define FUNCFLAG_FDISPLAYBIND 0x10
342 #define FUNCFLAG_FDEFAULTBIND 0x20
343 #define FUNCFLAG_FHIDDEN 0x40
344 #define FUNCFLAG_FUSESGETLASTERROR 0x80
345 #define FUNCFLAG_FDEFAULTCOLLELEM 0x100
346 #define FUNCFLAG_FUIDEFAULT 0x200
347 #define FUNCFLAG_FNONBROWSABLE 0x400
348 #define FUNCFLAG_FREPLACEABLE 0x800
349 #define FUNCFLAG_FIMMEDIATEBIND 0x1000
350
351 #define VARFLAG_FREADONLY 0x1
352 #define VARFLAG_FSOURCE 0x2
353 #define VARFLAG_FBINDABLE 0x4
354 #define VARFLAG_FREQUESTEDIT 0x8
355 #define VARFLAG_FDISPLAYBIND 0x10
356 #define VARFLAG_FDEFAULTBIND 0x20
357 #define VARFLAG_FHIDDEN 0x40
358 #define VARFLAG_FRESTRICTED 0x80
359 #define VARFLAG_FDEFAULTCOLLELEM 0x100
360 #define VARFLAG_FUIDEFAULT 0x200
361 #define VARFLAG_FNONBROWSABLE 0x400
362 #define VARFLAG_FREPLACEABLE 0x800
363 #define VARFLAG_FIMMEDIATEBIND 0x1000
364
365 /**
366 * Dumps typelib info to file
367 * @param[in] fp File to print to
368 * @param[in] dta raw typelib info
369 * @param[in] size size of raw typelib information
370 */
371 void dumpInfo (FILE *fp, unsigned char *dta, size_t size);
372
373 #endif