windint.h revision 225736
1228063Sbapt/* windint.h -- internal header file for windres program.
295060Sjmallett   Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007
31590Srgrimes   Free Software Foundation, Inc.
41590Srgrimes   Written by Kai Tietz, Onevision.
51590Srgrimes
61590Srgrimes   This file is part of GNU Binutils.
71590Srgrimes
81590Srgrimes   This program is free software; you can redistribute it and/or modify
91590Srgrimes   it under the terms of the GNU General Public License as published by
101590Srgrimes   the Free Software Foundation; either version 2 of the License, or
111590Srgrimes   (at your option) any later version.
121590Srgrimes
131590Srgrimes   This program is distributed in the hope that it will be useful,
141590Srgrimes   but WITHOUT ANY WARRANTY; without even the implied warranty of
151590Srgrimes   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161590Srgrimes   GNU General Public License for more details.
171590Srgrimes
18228063Sbapt   You should have received a copy of the GNU General Public License
191590Srgrimes   along with this program; if not, write to the Free Software
201590Srgrimes   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
211590Srgrimes   02110-1301, USA.  */
221590Srgrimes
231590Srgrimes#include "winduni.h"
241590Srgrimes
251590Srgrimes#ifndef WINDINT_H
261590Srgrimes#define WINDINT_H
271590Srgrimes
281590Srgrimes/* Use bfd_size_type to ensure a sufficient number of bits.  */
291590Srgrimes#ifndef DEFINED_RC_UINT_TYPE
301590Srgrimes#define DEFINED_RC_UINT_TYPE
311590Srgrimestypedef bfd_size_type rc_uint_type;
321590Srgrimes#endif
331590Srgrimes
3495060Sjmallett/* Resource directory structure.  */
3595060Sjmallett
361590Srgrimestypedef struct res_hdr
371590Srgrimes{
381590Srgrimes  rc_uint_type data_size;
391590Srgrimes  rc_uint_type header_size;
401590Srgrimes} res_hdr;
411590Srgrimes
421590Srgrimesstruct __attribute__ ((__packed__)) bin_res_hdr
431590Srgrimes{
441590Srgrimes  bfd_byte data_size[4];
451590Srgrimes  bfd_byte header_size[4];
46228063Sbapt};
4795060Sjmallett#define BIN_RES_HDR_SIZE 8
481590Srgrimes
49228063Sbaptstruct __attribute__ ((__packed__)) bin_res_id
501590Srgrimes{
511590Srgrimes  bfd_byte sig[2]; /* Has to be 0xffff for unnamed ids.  */
521590Srgrimes  bfd_byte id[2];
531590Srgrimes};
54228063Sbapt#define BIN_RES_ID  4
55228063Sbapt
56228063Sbapt/* This structure is used when converting resource information to
57228063Sbapt   binary.  */
58228063Sbapt
5995060Sjmalletttypedef struct bindata
60228063Sbapt{
61228063Sbapt  /* Next data.  */
62228063Sbapt  struct bindata *next;
63228063Sbapt  /* Length of data.  */
64228063Sbapt  rc_uint_type length;
65228063Sbapt  /* Data.  */
66228063Sbapt  bfd_byte *data;
67228063Sbapt} bindata;
68228063Sbapt
691590Srgrimes/* This structure is used when converting resource information to
70228063Sbapt   coff.  */
71228063Sbapttypedef struct coff_res_data
72228063Sbapt{
73228063Sbapt  /* Next data.  */
741590Srgrimes  struct coff_res_data *next;
751590Srgrimes  /* Length of data.  */
76228063Sbapt  rc_uint_type length;
77228063Sbapt  /* Data.  */
78228063Sbapt  const struct rc_res_resource *res;
79228063Sbapt} coff_res_data;
80228063Sbapt
81228063Sbapt/* We represent resources internally as a tree, similar to the tree
82228063Sbapt   used in the .rsrc section of a COFF file.  The root is a
83228063Sbapt   rc_res_directory structure.  */
84228063Sbapt
85228063Sbapttypedef struct rc_res_directory
86228063Sbapt{
87228063Sbapt  /* Resource flags.  According to the MS docs, this is currently
88228063Sbapt     always zero.  */
89228063Sbapt  rc_uint_type characteristics;
90228063Sbapt  /* Time/date stamp.  */
91228063Sbapt  rc_uint_type time;
92228063Sbapt  /* Major version number.  */
93228063Sbapt  rc_uint_type major;
941590Srgrimes  /* Minor version number.  */
951590Srgrimes  rc_uint_type minor;
961590Srgrimes  /* Directory entries.  */
97100014Sjmallett  struct rc_res_entry *entries;
9895887Sjmallett} rc_res_directory;
991590Srgrimes
100228063Sbapt/* A resource ID is stored in a rc_res_id structure.  */
101228063Sbapt
102228063Sbapttypedef struct rc_res_id
103228063Sbapt{
104228063Sbapt  /* Non-zero if this entry has a name rather than an ID.  */
105228063Sbapt  rc_uint_type named : 1;
10695060Sjmallett  union
1071590Srgrimes  {
108228063Sbapt    /* If the named field is non-zero, this is the name.  */
109228063Sbapt    struct
110228063Sbapt    {
111228063Sbapt      /* Length of the name.  */
112228063Sbapt      rc_uint_type length;
1131590Srgrimes      /* Pointer to the name, which is a Unicode string.  */
1141590Srgrimes      unichar *name;
115228063Sbapt    } n;
116228063Sbapt    /* If the named field is zero, this is the ID.  */
1171590Srgrimes    rc_uint_type id;
1181590Srgrimes  } u;
1191590Srgrimes} rc_res_id;
120228063Sbapt
121228063Sbapt/* Each entry in the tree is a rc_res_entry structure.  We mix
122228063Sbapt   directories and resources because in a COFF file all entries in a
123228063Sbapt   directory are sorted together, whether the entries are
124228063Sbapt   subdirectories or resources.  */
125228063Sbapt
126228063Sbapttypedef struct rc_res_entry
127228063Sbapt{
128228063Sbapt  /* Next entry.  */
129228063Sbapt  struct rc_res_entry *next;
130228063Sbapt  /* Resource ID.  */
131228063Sbapt  rc_res_id id;
132228063Sbapt  /* Non-zero if this entry is a subdirectory rather than a leaf.  */
1331590Srgrimes  rc_uint_type subdir : 1;
1341590Srgrimes  union
135228063Sbapt  {
136228063Sbapt    /* If the subdir field is non-zero, this is a pointer to the
1371590Srgrimes       subdirectory.  */
138228063Sbapt    rc_res_directory *dir;
139228063Sbapt    /* If the subdir field is zero, this is a pointer to the resource
140228063Sbapt       data.  */
141228063Sbapt    struct rc_res_resource *res;
142228063Sbapt  } u;
143228063Sbapt} rc_res_entry;
144228063Sbapt
145228063Sbapt/* Types of resources.  */
146228063Sbapt
147228063Sbaptenum rc_res_type
148228063Sbapt{
149228063Sbapt  RES_TYPE_UNINITIALIZED,
150228063Sbapt  RES_TYPE_ACCELERATOR,
151228063Sbapt  RES_TYPE_BITMAP,
1521590Srgrimes  RES_TYPE_CURSOR,
1531590Srgrimes  RES_TYPE_GROUP_CURSOR,
1541590Srgrimes  RES_TYPE_DIALOG,
155228063Sbapt  RES_TYPE_FONT,
1561590Srgrimes  RES_TYPE_FONTDIR,
157228063Sbapt  RES_TYPE_ICON,
158228063Sbapt  RES_TYPE_GROUP_ICON,
159228063Sbapt  RES_TYPE_MENU,
160228063Sbapt  RES_TYPE_MESSAGETABLE,
161228063Sbapt  RES_TYPE_RCDATA,
162228063Sbapt  RES_TYPE_STRINGTABLE,
163228063Sbapt  RES_TYPE_USERDATA,
164228063Sbapt  RES_TYPE_VERSIONINFO,
165228063Sbapt  RES_TYPE_DLGINCLUDE,
166228063Sbapt  RES_TYPE_PLUGPLAY,
1671590Srgrimes  RES_TYPE_VXD,
168228063Sbapt  RES_TYPE_ANICURSOR,
169228063Sbapt  RES_TYPE_ANIICON,
170228063Sbapt  RES_TYPE_DLGINIT,
171228063Sbapt  RES_TYPE_TOOLBAR
172228063Sbapt};
173228063Sbapt
174228063Sbapt/* A res file and a COFF file store information differently.  The
175228063Sbapt   res_info structures holds data which in a res file is stored with
176228063Sbapt   each resource, but in a COFF file is stored elsewhere.  */
177228063Sbapt
178228063Sbapttypedef struct rc_res_res_info
179228063Sbapt{
180228063Sbapt  /* Language.  In a COFF file, the third level of the directory is
181228063Sbapt     keyed by the language, so the language of a resource is defined
182228063Sbapt     by its location in the resource tree.  */
183228063Sbapt  rc_uint_type language;
184228063Sbapt  /* Characteristics of the resource.  Entirely user defined.  In a
185228063Sbapt     COFF file, the rc_res_directory structure has a characteristics
186228063Sbapt     field, but I don't know if it's related to the one in the res
187228063Sbapt     file.  */
188228063Sbapt  rc_uint_type characteristics;
189228063Sbapt  /* Version of the resource.  Entirely user defined.  In a COFF file,
190228063Sbapt     the rc_res_directory structure has a characteristics field, but I
191228063Sbapt     don't know if it's related to the one in the res file.  */
192228063Sbapt  rc_uint_type version;
1931590Srgrimes  /* Memory flags.  This is a combination of the MEMFLAG values
194228063Sbapt     defined below.  Most of these values are historical, and are not
195228063Sbapt     meaningful for win32.  I don't think there is any way to store
196228063Sbapt     this information in a COFF file.  */
197228063Sbapt  rc_uint_type memflags;
198228063Sbapt} rc_res_res_info;
199228063Sbapt
200228063Sbapt/* Binary layout of rc_res_info.  */
201228063Sbapt
202228063Sbaptstruct __attribute__ ((__packed__)) bin_res_info
203228063Sbapt{
204228063Sbapt  bfd_byte version[4];
205228063Sbapt  bfd_byte memflags[2];
206228063Sbapt  bfd_byte language[2];
207228063Sbapt  bfd_byte version2[4];
208228063Sbapt  bfd_byte characteristics[4];
209228063Sbapt};
2101590Srgrimes#define BIN_RES_INFO_SIZE 16
2111590Srgrimes
2121590Srgrimes/* Each resource in a COFF file has some information which can does
213228063Sbapt   not appear in a res file.  */
214228063Sbapt
215228063Sbapttypedef struct rc_res_coff_info
216228063Sbapt{
217228063Sbapt  /* The code page used for the data.  I don't really know what this
218228063Sbapt     should be.  It has something todo with ASCII to Unicode encoding.  */
219228063Sbapt  rc_uint_type codepage;
220228063Sbapt  /* A resource entry in a COFF file has a reserved field, which we
221228063Sbapt     record here when reading a COFF file.  When writing a COFF file,
222228063Sbapt     we set this field to zero.  */
223228063Sbapt  rc_uint_type reserved;
224228063Sbapt} rc_res_coff_info;
225228063Sbapt
226228063Sbapt/* Resource data is stored in a rc_res_resource structure.  */
227228063Sbapt
228228063Sbapttypedef struct rc_res_resource
229228063Sbapt{
230228063Sbapt  /* The type of resource.  */
231228063Sbapt  enum rc_res_type type;
232228063Sbapt  /* The data for the resource.  */
233228063Sbapt  union
234228063Sbapt  {
235228063Sbapt    struct
236228063Sbapt    {
237228063Sbapt      rc_uint_type length;
238228063Sbapt      const bfd_byte *data;
239228063Sbapt    } data;
240228063Sbapt    struct rc_accelerator *acc;
241228063Sbapt    struct rc_cursor *cursor;
242228063Sbapt    struct rc_group_cursor *group_cursor;
243228063Sbapt    struct rc_dialog *dialog;
244228063Sbapt    struct rc_fontdir *fontdir;
245228063Sbapt    struct rc_group_icon *group_icon;
246228063Sbapt    struct rc_menu *menu;
247228063Sbapt    struct rc_rcdata_item *rcdata;
248228063Sbapt    struct rc_stringtable *stringtable;
249228063Sbapt    struct rc_rcdata_item *userdata;
250228063Sbapt    struct rc_versioninfo *versioninfo;
251228063Sbapt    struct rc_toolbar *toolbar;
252228063Sbapt  } u;
253228063Sbapt  /* Information from a res file.  */
254228063Sbapt  struct rc_res_res_info res_info;
255228063Sbapt  /* Information from a COFF file.  */
256228063Sbapt  rc_res_coff_info coff_info;
257228063Sbapt} rc_res_resource;
258228063Sbapt
259228063Sbapt#define SUBLANG_SHIFT 10
260228063Sbapt
261228063Sbapt/* Memory flags in the memflags field of a rc_res_resource.  */
262228063Sbapt
263228063Sbapt#define MEMFLAG_MOVEABLE	0x10
264228063Sbapt#define MEMFLAG_PURE		0x20
265228063Sbapt#define MEMFLAG_PRELOAD		0x40
266228063Sbapt#define MEMFLAG_DISCARDABLE	0x1000
267228063Sbapt
268228063Sbapt/* Standard resource type codes.  These are used in the ID field of a
269228063Sbapt   rc_res_entry structure.  */
270228063Sbapt
271228063Sbapt#define RT_CURSOR		 1
272228063Sbapt#define RT_BITMAP		 2
273228063Sbapt#define RT_ICON			 3
274228063Sbapt#define RT_MENU			 4
275228063Sbapt#define RT_DIALOG		 5
276228063Sbapt#define RT_STRING		 6
277228063Sbapt#define RT_FONTDIR		 7
278#define RT_FONT			 8
279#define RT_ACCELERATOR		 9
280#define RT_RCDATA		10
281#define RT_MESSAGETABLE		11
282#define RT_GROUP_CURSOR		12
283#define RT_GROUP_ICON		14
284#define RT_VERSION		16
285#define RT_DLGINCLUDE		17
286#define RT_PLUGPLAY		19
287#define RT_VXD			20
288#define RT_ANICURSOR		21
289#define RT_ANIICON		22
290#define RT_HTML			23
291#define RT_MANIFEST		24
292#define RT_DLGINIT		240
293#define RT_TOOLBAR		241
294
295/* An accelerator resource is a linked list of these structures.  */
296
297typedef struct rc_accelerator
298{
299  /* Next accelerator.  */
300  struct rc_accelerator *next;
301  /* Flags.  A combination of the ACC values defined below.  */
302  rc_uint_type flags;
303  /* Key value.  */
304  rc_uint_type key;
305  /* Resource ID.  */
306  rc_uint_type id;
307} rc_accelerator;
308
309struct __attribute__ ((__packed__)) bin_accelerator
310{
311  bfd_byte flags[2];
312  bfd_byte key[2];
313  bfd_byte id[2];
314  bfd_byte pad[2];
315};
316#define BIN_ACCELERATOR_SIZE  8
317
318/* Accelerator flags in the flags field of a rc_accelerator.
319   These are the same values that appear in a res file.  I hope.  */
320
321#define ACC_VIRTKEY	0x01
322#define ACC_NOINVERT	0x02
323#define ACC_SHIFT	0x04
324#define ACC_CONTROL	0x08
325#define ACC_ALT		0x10
326#define ACC_LAST	0x80
327
328/* A cursor resource.  */
329
330typedef struct rc_cursor
331{
332  /* X coordinate of hotspot.  */
333  bfd_signed_vma xhotspot;
334  /* Y coordinate of hotspot.  */
335  bfd_signed_vma yhotspot;
336  /* Length of bitmap data.  */
337  rc_uint_type length;
338  /* Data.  */
339  const bfd_byte *data;
340} rc_cursor;
341
342struct __attribute__ ((__packed__)) bin_cursor
343{
344  bfd_byte xhotspot[2];
345  bfd_byte yhotspot[2];
346};
347#define BIN_CURSOR_SIZE 4
348
349/* A group_cursor resource is a list of rc_i_group_cursor structures.  */
350
351typedef struct rc_group_cursor
352{
353  /* Next cursor in group.  */
354  struct rc_group_cursor *next;
355  /* Width.  */
356  rc_uint_type width;
357  /* Height.  */
358  rc_uint_type height;
359  /* Planes.  */
360  rc_uint_type planes;
361  /* Bits per pixel.  */
362  rc_uint_type bits;
363  /* Number of bytes in cursor resource.  */
364  rc_uint_type bytes;
365  /* Index of cursor resource.  */
366  rc_uint_type index;
367} rc_group_cursor;
368
369struct __attribute__ ((__packed__)) bin_group_cursor_item
370{
371  bfd_byte width[2];
372  bfd_byte height[2];
373  bfd_byte planes[2];
374  bfd_byte bits[2];
375  bfd_byte bytes[4];
376  bfd_byte index[2];
377};
378#define BIN_GROUP_CURSOR_ITEM_SIZE 14
379
380struct __attribute__ ((__packed__)) bin_group_cursor
381{
382  bfd_byte sig1[2];
383  bfd_byte sig2[2];
384  bfd_byte nitems[2];
385  /* struct bin_group_cursor_item item[nitems]; */
386};
387#define BIN_GROUP_CURSOR_SIZE 6
388
389/* A dialog resource.  */
390
391typedef struct rc_dialog
392{
393  /* Basic window style.  */
394  unsigned int style;
395  /* Extended window style.  */
396  rc_uint_type exstyle;
397  /* X coordinate.  */
398  rc_uint_type x;
399  /* Y coordinate.  */
400  rc_uint_type y;
401  /* Width.  */
402  rc_uint_type width;
403  /* Height.  */
404  rc_uint_type height;
405  /* Menu name.  */
406  rc_res_id menu;
407  /* Class name.  */
408  rc_res_id class;
409  /* Caption.  */
410  unichar *caption;
411  /* Font point size.  */
412  rc_uint_type pointsize;
413  /* Font name.  */
414  unichar *font;
415  /* Extended information for a dialogex.  */
416  struct rc_dialog_ex *ex;
417  /* Controls.  */
418  struct rc_dialog_control *controls;
419} rc_dialog;
420
421struct __attribute__ ((__packed__)) bin_dialog
422{
423  bfd_byte style[4];
424  bfd_byte exstyle[4];
425  bfd_byte off[2];
426  bfd_byte x[2];
427  bfd_byte y[2];
428  bfd_byte width[2];
429  bfd_byte height[2];
430};
431#define BIN_DIALOG_SIZE 18
432
433/* An extended dialog has additional information.  */
434
435typedef struct rc_dialog_ex
436{
437  /* Help ID.  */
438  rc_uint_type help;
439  /* Font weight.  */
440  rc_uint_type weight;
441  /* Whether the font is italic.  */
442  bfd_byte italic;
443  /* Character set.  */
444  bfd_byte charset;
445} rc_dialog_ex;
446
447struct __attribute__ ((__packed__)) bin_dialogex
448{
449  bfd_byte sig1[2];
450  bfd_byte sig2[2];
451  bfd_byte help[4];
452  bfd_byte exstyle[4];
453  bfd_byte style[4];
454  bfd_byte off[2];
455  bfd_byte x[2];
456  bfd_byte y[2];
457  bfd_byte width[2];
458  bfd_byte height[2];
459};
460#define BIN_DIALOGEX_SIZE 26
461
462struct __attribute__ ((__packed__)) bin_dialogfont
463{
464  bfd_byte pointsize[2];
465};
466#define BIN_DIALOGFONT_SIZE 2
467
468struct __attribute__ ((__packed__)) bin_dialogexfont
469{
470  bfd_byte pointsize[2];
471  bfd_byte weight[2];
472  bfd_byte italic[1];
473  bfd_byte charset[1];
474};
475#define BIN_DIALOGEXFONT_SIZE 6
476
477/* Window style flags, from the winsup Defines.h header file.  These
478   can appear in the style field of a rc_dialog or a rc_dialog_control.  */
479
480#define CW_USEDEFAULT	0x80000000
481#define WS_BORDER	0x800000L
482#define WS_CAPTION	0xc00000L
483#define WS_CHILD	0x40000000L
484#define WS_CHILDWINDOW	0x40000000L
485#define WS_CLIPCHILDREN	0x2000000L
486#define WS_CLIPSIBLINGS	0x4000000L
487#define WS_DISABLED	0x8000000L
488#define WS_DLGFRAME	0x400000L
489#define WS_GROUP	0x20000L
490#define WS_HSCROLL	0x100000L
491#define WS_ICONIC	0x20000000L
492#define WS_MAXIMIZE	0x1000000L
493#define WS_MAXIMIZEBOX	0x10000L
494#define WS_MINIMIZE	0x20000000L
495#define WS_MINIMIZEBOX	0x20000L
496#define WS_OVERLAPPED	0L
497#define WS_OVERLAPPEDWINDOW	0xcf0000L
498#define WS_POPUP	0x80000000L
499#define WS_POPUPWINDOW	0x80880000L
500#define WS_SIZEBOX	0x40000L
501#define WS_SYSMENU	0x80000L
502#define WS_TABSTOP	0x10000L
503#define WS_THICKFRAME	0x40000L
504#define WS_TILED	0L
505#define WS_TILEDWINDOW	0xcf0000L
506#define WS_VISIBLE	0x10000000L
507#define WS_VSCROLL	0x200000L
508#define MDIS_ALLCHILDSTYLES	0x1
509#define BS_3STATE	0x5L
510#define BS_AUTO3STATE	0x6L
511#define BS_AUTOCHECKBOX	0x3L
512#define BS_AUTORADIOBUTTON	0x9L
513#define BS_BITMAP	0x80L
514#define BS_BOTTOM	0x800L
515#define BS_CENTER	0x300L
516#define BS_CHECKBOX	0x2L
517#define BS_DEFPUSHBUTTON	0x1L
518#define BS_GROUPBOX	0x7L
519#define BS_ICON		0x40L
520#define BS_LEFT		0x100L
521#define BS_LEFTTEXT	0x20L
522#define BS_MULTILINE	0x2000L
523#define BS_NOTIFY	0x4000L
524#define BS_OWNERDRAW	0xbL
525#define BS_PUSHBOX	0xcL		/* FIXME!  What should this be?  */
526#define BS_PUSHBUTTON	0L
527#define BS_PUSHLIKE	0x1000L
528#define BS_RADIOBUTTON	0x4L
529#define BS_RIGHT	0x200L
530#define BS_RIGHTBUTTON	0x20L
531#define BS_TEXT		0L
532#define BS_TOP		0x400L
533#define BS_USERBUTTON	0x8L
534#define BS_VCENTER	0xc00L
535#define CBS_AUTOHSCROLL	0x40L
536#define CBS_DISABLENOSCROLL	0x800L
537#define CBS_DROPDOWN	0x2L
538#define CBS_DROPDOWNLIST	0x3L
539#define CBS_HASSTRINGS	0x200L
540#define CBS_LOWERCASE	0x4000L
541#define CBS_NOINTEGRALHEIGHT	0x400L
542#define CBS_OEMCONVERT	0x80L
543#define CBS_OWNERDRAWFIXED	0x10L
544#define CBS_OWNERDRAWVARIABLE	0x20L
545#define CBS_SIMPLE	0x1L
546#define CBS_SORT	0x100L
547#define CBS_UPPERCASE	0x2000L
548#define ES_AUTOHSCROLL	0x80L
549#define ES_AUTOVSCROLL	0x40L
550#define ES_CENTER	0x1L
551#define ES_LEFT		0L
552#define ES_LOWERCASE	0x10L
553#define ES_MULTILINE	0x4L
554#define ES_NOHIDESEL	0x100L
555#define ES_NUMBER	0x2000L
556#define ES_OEMCONVERT	0x400L
557#define ES_PASSWORD	0x20L
558#define ES_READONLY	0x800L
559#define ES_RIGHT	0x2L
560#define ES_UPPERCASE	0x8L
561#define ES_WANTRETURN	0x1000L
562#define LBS_DISABLENOSCROLL	0x1000L
563#define LBS_EXTENDEDSEL	0x800L
564#define LBS_HASSTRINGS	0x40L
565#define LBS_MULTICOLUMN	0x200L
566#define LBS_MULTIPLESEL	0x8L
567#define LBS_NODATA	0x2000L
568#define LBS_NOINTEGRALHEIGHT	0x100L
569#define LBS_NOREDRAW	0x4L
570#define LBS_NOSEL	0x4000L
571#define LBS_NOTIFY	0x1L
572#define LBS_OWNERDRAWFIXED	0x10L
573#define LBS_OWNERDRAWVARIABLE	0x20L
574#define LBS_SORT	0x2L
575#define LBS_STANDARD	0xa00003L
576#define LBS_USETABSTOPS	0x80L
577#define LBS_WANTKEYBOARDINPUT	0x400L
578#define SBS_BOTTOMALIGN	0x4L
579#define SBS_HORZ	0L
580#define SBS_LEFTALIGN	0x2L
581#define SBS_RIGHTALIGN	0x4L
582#define SBS_SIZEBOX	0x8L
583#define SBS_SIZEBOXBOTTOMRIGHTALIGN	0x4L
584#define SBS_SIZEBOXTOPLEFTALIGN	0x2L
585#define SBS_SIZEGRIP	0x10L
586#define SBS_TOPALIGN	0x2L
587#define SBS_VERT	0x1L
588#define SS_BITMAP	0xeL
589#define SS_BLACKFRAME	0x7L
590#define SS_BLACKRECT	0x4L
591#define SS_CENTER	0x1L
592#define SS_CENTERIMAGE	0x200L
593#define SS_ENHMETAFILE	0xfL
594#define SS_ETCHEDFRAME	0x12L
595#define SS_ETCHEDHORZ	0x10L
596#define SS_ETCHEDVERT	0x11L
597#define SS_GRAYFRAME	0x8L
598#define SS_GRAYRECT	0x5L
599#define SS_ICON		0x3L
600#define SS_LEFT		0L
601#define SS_LEFTNOWORDWRAP	0xcL
602#define SS_NOPREFIX	0x80L
603#define SS_NOTIFY	0x100L
604#define SS_OWNERDRAW	0xdL
605#define SS_REALSIZEIMAGE	0x800L
606#define SS_RIGHT	0x2L
607#define SS_RIGHTJUST	0x400L
608#define SS_SIMPLE	0xbL
609#define SS_SUNKEN	0x1000L
610#define SS_USERITEM     0xaL
611#define SS_WHITEFRAME	0x9L
612#define SS_WHITERECT	0x6L
613#define DS_3DLOOK	0x4L
614#define DS_ABSALIGN	0x1L
615#define DS_CENTER	0x800L
616#define DS_CENTERMOUSE	0x1000L
617#define DS_CONTEXTHELP	0x2000L
618#define DS_CONTROL	0x400L
619#define DS_FIXEDSYS	0x8L
620#define DS_LOCALEDIT	0x20L
621#define DS_MODALFRAME	0x80L
622#define DS_NOFAILCREATE	0x10L
623#define DS_NOIDLEMSG	0x100L
624#define DS_SETFONT	0x40L
625#define DS_SETFOREGROUND	0x200L
626#define DS_SYSMODAL	0x2L
627
628/* A dialog control.  */
629
630typedef struct rc_dialog_control
631{
632  /* Next control.  */
633  struct rc_dialog_control *next;
634  /* ID.  */
635  rc_uint_type id;
636  /* Style.  */
637  rc_uint_type style;
638  /* Extended style.  */
639  rc_uint_type exstyle;
640  /* X coordinate.  */
641  rc_uint_type x;
642  /* Y coordinate.  */
643  rc_uint_type y;
644  /* Width.  */
645  rc_uint_type width;
646  /* Height.  */
647  rc_uint_type height;
648  /* Class name.  */
649  rc_res_id class;
650  /* Associated text.  */
651  rc_res_id text;
652  /* Extra data for the window procedure.  */
653  struct rc_rcdata_item *data;
654  /* Help ID.  Only used in an extended dialog.  */
655  rc_uint_type help;
656} rc_dialog_control;
657
658struct __attribute__ ((__packed__)) bin_dialog_control
659{
660  bfd_byte style[4];
661  bfd_byte exstyle[4];
662  bfd_byte x[2];
663  bfd_byte y[2];
664  bfd_byte width[2];
665  bfd_byte height[2];
666  bfd_byte id[2];
667};
668#define BIN_DIALOG_CONTROL_SIZE 18
669
670struct __attribute__ ((__packed__)) bin_dialogex_control
671{
672  bfd_byte help[4];
673  bfd_byte exstyle[4];
674  bfd_byte style[4];
675  bfd_byte x[2];
676  bfd_byte y[2];
677  bfd_byte width[2];
678  bfd_byte height[2];
679  bfd_byte id[4];
680};
681#define BIN_DIALOGEX_CONTROL_SIZE 24
682
683/* Control classes.  These can be used as the ID field in a rc_dialog_control.  */
684
685#define CTL_BUTTON	0x80
686#define CTL_EDIT	0x81
687#define CTL_STATIC	0x82
688#define CTL_LISTBOX	0x83
689#define CTL_SCROLLBAR	0x84
690#define CTL_COMBOBOX	0x85
691
692/* A fontdir resource is a list of rc_fontdir.  */
693
694typedef struct rc_fontdir
695{
696  struct rc_fontdir *next;
697  /* Index of font entry.  */
698  rc_uint_type index;
699  /* Length of font information.  */
700  rc_uint_type length;
701  /* Font information.  */
702  const bfd_byte *data;
703} rc_fontdir;
704
705struct __attribute__ ((__packed__)) bin_fontdir_item
706{
707  bfd_byte index[2];
708  bfd_byte header[54];
709  bfd_byte device_name[1];
710  /* bfd_byte face_name[]; */
711};
712
713/* A group_icon resource is a list of rc_group_icon.  */
714
715typedef struct rc_group_icon
716{
717  /* Next icon in group.  */
718  struct rc_group_icon *next;
719  /* Width.  */
720  bfd_byte width;
721  /* Height.  */
722  bfd_byte height;
723  /* Color count.  */
724  bfd_byte colors;
725  /* Planes.  */
726  rc_uint_type planes;
727  /* Bits per pixel.  */
728  rc_uint_type bits;
729  /* Number of bytes in cursor resource.  */
730  rc_uint_type bytes;
731  /* Index of cursor resource.  */
732  rc_uint_type index;
733} rc_group_icon;
734
735struct __attribute__ ((__packed__)) bin_group_icon
736{
737  bfd_byte sig1[2];
738  bfd_byte sig2[2];
739  bfd_byte count[2];
740};
741#define BIN_GROUP_ICON_SIZE 6
742
743struct __attribute__ ((__packed__)) bin_group_icon_item
744{
745  bfd_byte width[1];
746  bfd_byte height[1];
747  bfd_byte colors[1];
748  bfd_byte pad[1];
749  bfd_byte planes[2];
750  bfd_byte bits[2];
751  bfd_byte bytes[4];
752  bfd_byte index[2];
753};
754#define BIN_GROUP_ICON_ITEM_SIZE 14
755
756/* A menu resource.  */
757
758typedef struct rc_menu
759{
760  /* List of menuitems.  */
761  struct rc_menuitem *items;
762  /* Help ID.  I don't think there is any way to set this in an rc
763     file, but it can appear in the binary format.  */
764  rc_uint_type help;
765} rc_menu;
766
767struct __attribute__ ((__packed__)) bin_menu
768{
769  bfd_byte sig1[2];
770  bfd_byte sig2[2];
771};
772#define BIN_MENU_SIZE 4
773
774struct __attribute__ ((__packed__)) bin_menuex
775{
776  bfd_byte sig1[2];
777  bfd_byte sig2[2];
778  bfd_byte help[4];
779};
780#define BIN_MENUEX_SIZE 8
781
782/* A menu resource is a list of rc_menuitem.  */
783
784typedef struct rc_menuitem
785{
786  /* Next menu item.  */
787  struct rc_menuitem *next;
788  /* Type.  In a normal menu, rather than a menuex, this is the flags
789     field.  */
790  rc_uint_type type;
791  /* State.  This is only used in a menuex.  */
792  rc_uint_type state;
793  /* Id.  */
794  rc_uint_type id;
795  /* Unicode text.  */
796  unichar *text;
797  /* Popup menu items for a popup.  */
798  struct rc_menuitem *popup;
799  /* Help ID.  This is only used in a menuex.  */
800  rc_uint_type help;
801} rc_menuitem;
802
803struct __attribute__ ((__packed__)) bin_menuitem
804{
805  bfd_byte flags[2];
806  bfd_byte id[2];
807};
808#define BIN_MENUITEM_SIZE  4
809#define BIN_MENUITEM_POPUP_SIZE  2
810
811struct __attribute__ ((__packed__)) bin_menuitemex
812{
813  bfd_byte type[4];
814  bfd_byte state[4];
815  bfd_byte id[4];
816  bfd_byte flags[2];
817  /* unicode text */
818  /* if popup: align, bfd_byte help[4], align, bin_menuitemex[]; */
819};
820#define BIN_MENUITEMEX_SIZE 14
821
822/* Menu item flags.  These can appear in the flags field of a rc_menuitem.  */
823
824#define MENUITEM_GRAYED		0x001
825#define MENUITEM_INACTIVE	0x002
826#define MENUITEM_BITMAP		0x004
827#define MENUITEM_OWNERDRAW	0x100
828#define MENUITEM_CHECKED	0x008
829#define MENUITEM_POPUP		0x010
830#define MENUITEM_MENUBARBREAK	0x020
831#define MENUITEM_MENUBREAK	0x040
832#define MENUITEM_ENDMENU	0x080
833#define MENUITEM_HELP	       0x4000
834
835/* An rcdata resource is a pointer to a list of rc_rcdata_item.  */
836
837typedef struct rc_rcdata_item
838{
839  /* Next data item.  */
840  struct rc_rcdata_item *next;
841  /* Type of data.  */
842  enum
843  {
844    RCDATA_WORD,
845    RCDATA_DWORD,
846    RCDATA_STRING,
847    RCDATA_WSTRING,
848    RCDATA_BUFFER
849  } type;
850  union
851  {
852    rc_uint_type word;
853    rc_uint_type dword;
854    struct
855    {
856      rc_uint_type length;
857      const char *s;
858    } string;
859    struct
860    {
861      rc_uint_type length;
862      const unichar *w;
863    } wstring;
864    struct
865    {
866      rc_uint_type length;
867      const bfd_byte *data;
868    } buffer;
869  } u;
870} rc_rcdata_item;
871
872/* A stringtable resource is a pointer to a rc_stringtable.  */
873
874typedef struct rc_stringtable
875{
876  /* Each stringtable resource is a list of 16 unicode strings.  */
877  struct
878  {
879    /* Length of string.  */
880    rc_uint_type length;
881    /* String data if length > 0.  */
882    unichar *string;
883  } strings[16];
884} rc_stringtable;
885
886/* A versioninfo resource points to a rc_versioninfo.  */
887
888typedef struct rc_versioninfo
889{
890  /* Fixed version information.  */
891  struct rc_fixed_versioninfo *fixed;
892  /* Variable version information.  */
893  struct rc_ver_info *var;
894} rc_versioninfo;
895
896struct __attribute__ ((__packed__)) bin_versioninfo
897{
898  bfd_byte size[2];
899  bfd_byte fixed_size[2];
900  bfd_byte sig2[2];
901};
902#define BIN_VERSIONINFO_SIZE 6
903
904/* The fixed portion of a versioninfo resource.  */
905
906typedef struct rc_fixed_versioninfo
907{
908  /* The file version, which is two 32 bit integers.  */
909  rc_uint_type file_version_ms;
910  rc_uint_type file_version_ls;
911  /* The product version, which is two 32 bit integers.  */
912  rc_uint_type product_version_ms;
913  rc_uint_type product_version_ls;
914  /* The file flags mask.  */
915  rc_uint_type file_flags_mask;
916  /* The file flags.  */
917  rc_uint_type file_flags;
918  /* The OS type.  */
919  rc_uint_type file_os;
920  /* The file type.  */
921  rc_uint_type file_type;
922  /* The file subtype.  */
923  rc_uint_type file_subtype;
924  /* The date, which in Windows is two 32 bit integers.  */
925  rc_uint_type file_date_ms;
926  rc_uint_type file_date_ls;
927} rc_fixed_versioninfo;
928
929struct __attribute__ ((__packed__)) bin_fixed_versioninfo
930{
931  bfd_byte sig1[4];
932  bfd_byte sig2[4];
933  bfd_byte file_version[4];
934  bfd_byte file_version_ls[4];
935  bfd_byte product_version_ms[4];
936  bfd_byte product_version_ls[4];
937  bfd_byte file_flags_mask[4];
938  bfd_byte file_flags[4];
939  bfd_byte file_os[4];
940  bfd_byte file_type[4];
941  bfd_byte file_subtype[4];
942  bfd_byte file_date_ms[4];
943  bfd_byte file_date_ls[4];
944};
945#define BIN_FIXED_VERSIONINFO_SIZE 52
946
947/* A list of variable version information.  */
948
949typedef struct rc_ver_info
950{
951  /* Next item.  */
952  struct rc_ver_info *next;
953  /* Type of data.  */
954  enum { VERINFO_STRING, VERINFO_VAR } type;
955  union
956  {
957    /* StringFileInfo data.  */
958    struct
959    {
960      /* Language.  */
961      unichar *language;
962      /* Strings.  */
963      struct rc_ver_stringinfo *strings;
964    } string;
965    /* VarFileInfo data.  */
966    struct
967    {
968      /* Key.  */
969      unichar *key;
970      /* Values.  */
971      struct rc_ver_varinfo *var;
972    } var;
973  } u;
974} rc_ver_info;
975
976struct __attribute__ ((__packed__)) bin_ver_info
977{
978  bfd_byte size[2];
979  bfd_byte sig1[2];
980  bfd_byte sig2[2];
981};
982#define BIN_VER_INFO_SIZE 6
983
984/* A list of string version information.  */
985
986typedef struct rc_ver_stringinfo
987{
988  /* Next string.  */
989  struct rc_ver_stringinfo *next;
990  /* Key.  */
991  unichar *key;
992  /* Value.  */
993  unichar *value;
994} rc_ver_stringinfo;
995
996/* A list of variable version information.  */
997
998typedef struct rc_ver_varinfo
999{
1000  /* Next item.  */
1001  struct rc_ver_varinfo *next;
1002  /* Language ID.  */
1003  rc_uint_type language;
1004  /* Character set ID.  */
1005  rc_uint_type charset;
1006} rc_ver_varinfo;
1007
1008typedef struct rc_toolbar_item
1009{
1010  struct rc_toolbar_item *next;
1011  struct rc_toolbar_item *prev;
1012  rc_res_id id;
1013} rc_toolbar_item;
1014
1015struct __attribute__ ((__packed__)) bin_messagetable_item
1016{
1017  bfd_byte length[2];
1018  bfd_byte flags[2];
1019  bfd_byte data[1];
1020};
1021#define BIN_MESSAGETABLE_ITEM_SIZE  4
1022
1023#define MESSAGE_RESOURCE_UNICODE  0x0001
1024
1025struct __attribute__ ((__packed__)) bin_messagetable_block
1026{
1027  bfd_byte lowid[4];
1028  bfd_byte highid[4];
1029  bfd_byte offset[4];
1030};
1031#define BIN_MESSAGETABLE_BLOCK_SIZE 12
1032
1033struct __attribute__ ((__packed__)) bin_messagetable
1034{
1035  bfd_byte cblocks[4];
1036  struct bin_messagetable_block items[1];
1037};
1038#define BIN_MESSAGETABLE_SIZE 8
1039
1040typedef struct rc_toolbar
1041{
1042  rc_uint_type button_width;
1043  rc_uint_type button_height;
1044  rc_uint_type nitems;
1045  rc_toolbar_item *items;
1046} rc_toolbar;
1047
1048struct __attribute__ ((__packed__)) bin_toolbar
1049{
1050  bfd_byte button_width[4];
1051  bfd_byte button_height[4];
1052  bfd_byte nitems[4];
1053  /* { bfd_byte id[4]; } * nitems; */
1054};
1055#define BIN_TOOLBAR_SIZE 12
1056
1057extern int target_is_bigendian;
1058
1059typedef struct windres_bfd
1060{
1061  bfd *abfd;
1062  asection *sec;
1063  rc_uint_type kind : 4;
1064} windres_bfd;
1065
1066#define WR_KIND_TARGET	  0
1067#define WR_KIND_BFD	  1
1068#define WR_KIND_BFD_BIN_L 2
1069#define WR_KIND_BFD_BIN_B 3
1070
1071#define WR_KIND(PTR)  (PTR)->kind
1072#define WR_SECTION(PTR)	(PTR)->sec
1073#define WR_BFD(PTR) (PTR)->abfd
1074
1075extern void set_windres_bfd_content (windres_bfd *, const void *, rc_uint_type, rc_uint_type);
1076extern void get_windres_bfd_content (windres_bfd *, void *, rc_uint_type, rc_uint_type);
1077
1078extern void windres_put_8 (windres_bfd *, void *, rc_uint_type);
1079extern void windres_put_16 (windres_bfd *, void *, rc_uint_type);
1080extern void windres_put_32 (windres_bfd *, void *, rc_uint_type);
1081extern rc_uint_type windres_get_8 (windres_bfd *, const void *, rc_uint_type);
1082extern rc_uint_type windres_get_16 (windres_bfd *, const void *, rc_uint_type);
1083extern rc_uint_type windres_get_32 (windres_bfd *, const void *, rc_uint_type);
1084
1085extern void set_windres_bfd (windres_bfd *, bfd *, asection *, rc_uint_type);
1086extern void set_windres_bfd_endianess (windres_bfd *, int);
1087
1088#endif
1089