1 /* windres.h -- header file for windres program.
2 Copyright 1997, 1998 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 /* This is the header file for the windres program. It defines
25 structures and declares functions used within the program. */
29 /* We represent resources internally as a tree, similar to the tree
30 used in the .rsrc section of a COFF file. The root is a
31 res_directory structure. */
35 /* Resource flags. According to the MS docs, this is currently
37 unsigned long characteristics
;
38 /* Time/date stamp. */
40 /* Major version number. */
42 /* Minor version number. */
44 /* Directory entries. */
45 struct res_entry
*entries
;
48 /* A resource ID is stored in a res_id structure. */
52 /* Non-zero if this entry has a name rather than an ID. */
53 unsigned int named
: 1;
56 /* If the named field is non-zero, this is the name. */
59 /* Length of the name. */
61 /* Pointer to the name, which is a Unicode string. */
64 /* If the named field is zero, this is the ID. */
69 /* Each entry in the tree is a res_entry structure. We mix
70 directories and resources because in a COFF file all entries in a
71 directory are sorted together, whether the entries are
72 subdirectories or resources. */
77 struct res_entry
*next
;
80 /* Non-zero if this entry is a subdirectory rather than a leaf. */
81 unsigned int subdir
: 1;
84 /* If the subdir field is non-zero, this is a pointer to the
86 struct res_directory
*dir
;
87 /* If the subdir field is zero, this is a pointer to the resource
89 struct res_resource
*res
;
93 /* Types of resources. */
97 RES_TYPE_UNINITIALIZED
,
101 RES_TYPE_GROUP_CURSOR
,
108 RES_TYPE_MESSAGETABLE
,
110 RES_TYPE_STRINGTABLE
,
115 /* A res file and a COFF file store information differently. The
116 res_info structures holds data which in a res file is stored with
117 each resource, but in a COFF file is stored elsewhere. */
121 /* Language. In a COFF file, the third level of the directory is
122 keyed by the language, so the language of a resource is defined
123 by its location in the resource tree. */
124 unsigned short language
;
125 /* Characteristics of the resource. Entirely user defined. In a
126 COFF file, the res_directory structure has a characteristics
127 field, but I don't know if it's related to the one in the res
129 unsigned long characteristics
;
130 /* Version of the resource. Entirely user defined. In a COFF file,
131 the res_directory structure has a characteristics field, but I
132 don't know if it's related to the one in the res file. */
133 unsigned long version
;
134 /* Memory flags. This is a combination of the MEMFLAG values
135 defined below. Most of these values are historical, and are not
136 meaningful for win32. I don't think there is any way to store
137 this information in a COFF file. */
138 unsigned short memflags
;
141 /* Each resource in a COFF file has some information which can does
142 not appear in a res file. */
146 /* The code page used for the data. I don't really know what this
148 unsigned long codepage
;
149 /* A resource entry in a COFF file has a reserved field, which we
150 record here when reading a COFF file. When writing a COFF file,
151 we set this field to zero. */
152 unsigned long reserved
;
155 /* Resource data is stored in a res_resource structure. */
159 /* The type of resource. */
161 /* The data for the resource. */
166 unsigned long length
;
167 const unsigned char *data
;
169 struct accelerator
*acc
;
170 struct cursor
*cursor
;
171 struct group_cursor
*group_cursor
;
172 struct dialog
*dialog
;
173 struct fontdir
*fontdir
;
174 struct group_icon
*group_icon
;
176 struct rcdata_item
*rcdata
;
177 struct stringtable
*stringtable
;
178 struct rcdata_item
*userdata
;
179 struct versioninfo
*versioninfo
;
181 /* Information from a res file. */
182 struct res_res_info res_info
;
183 /* Information from a COFF file. */
184 struct res_coff_info coff_info
;
187 /* Memory flags in the memflags field of a struct res_resource. */
189 #define MEMFLAG_MOVEABLE 0x10
190 #define MEMFLAG_PURE 0x20
191 #define MEMFLAG_PRELOAD 0x40
192 #define MEMFLAG_DISCARDABLE 0x1000
194 /* Standard resource type codes. These are used in the ID field of a
195 res_entry structure. */
205 #define RT_ACCELERATOR 9
207 #define RT_MESSAGETABLE 11
208 #define RT_GROUP_CURSOR 12
209 #define RT_GROUP_ICON 14
210 #define RT_VERSION 16
211 #define RT_DLGINCLUDE 17
212 #define RT_PLUGPLAY 19
214 #define RT_ANICURSOR 21
215 #define RT_ANIICON 22
217 /* An accelerator resource is a linked list of these structures. */
221 /* Next accelerator. */
222 struct accelerator
*next
;
223 /* Flags. A combination of the ACC values defined below. */
224 unsigned short flags
;
231 /* Accelerator flags in the flags field of a struct accelerator.
232 These are the same values that appear in a res file. I hope. */
234 #define ACC_VIRTKEY 0x01
235 #define ACC_NOINVERT 0x02
236 #define ACC_SHIFT 0x04
237 #define ACC_CONTROL 0x08
239 #define ACC_LAST 0x80
241 /* A cursor resource. */
245 /* X coordinate of hotspot. */
247 /* Y coordinate of hotspot. */
249 /* Length of bitmap data. */
250 unsigned long length
;
252 const unsigned char *data
;
255 /* A group_cursor resource is a list of group_cursor structures. */
259 /* Next cursor in group. */
260 struct group_cursor
*next
;
262 unsigned short width
;
264 unsigned short height
;
266 unsigned short planes
;
267 /* Bits per pixel. */
269 /* Number of bytes in cursor resource. */
271 /* Index of cursor resource. */
272 unsigned short index
;
275 /* A dialog resource. */
279 /* Basic window style. */
281 /* Extended window style. */
282 unsigned long exstyle
;
288 unsigned short width
;
290 unsigned short height
;
297 /* Font point size. */
298 unsigned short pointsize
;
301 /* Extended information for a dialogex. */
302 struct dialog_ex
*ex
;
304 struct dialog_control
*controls
;
307 /* An extended dialog has additional information. */
314 unsigned short weight
;
315 /* Whether the font is italic. */
316 unsigned short italic
;
319 /* Window style flags, from the winsup Defines.h header file. These
320 can appear in the style field of a struct dialog or a struct
323 #define CW_USEDEFAULT (0x80000000)
324 #define WS_BORDER (0x800000L)
325 #define WS_CAPTION (0xc00000L)
326 #define WS_CHILD (0x40000000L)
327 #define WS_CHILDWINDOW (0x40000000L)
328 #define WS_CLIPCHILDREN (0x2000000L)
329 #define WS_CLIPSIBLINGS (0x4000000L)
330 #define WS_DISABLED (0x8000000L)
331 #define WS_DLGFRAME (0x400000L)
332 #define WS_GROUP (0x20000L)
333 #define WS_HSCROLL (0x100000L)
334 #define WS_ICONIC (0x20000000L)
335 #define WS_MAXIMIZE (0x1000000L)
336 #define WS_MAXIMIZEBOX (0x10000L)
337 #define WS_MINIMIZE (0x20000000L)
338 #define WS_MINIMIZEBOX (0x20000L)
339 #define WS_OVERLAPPED (0L)
340 #define WS_OVERLAPPEDWINDOW (0xcf0000L)
341 #define WS_POPUP (0x80000000L)
342 #define WS_POPUPWINDOW (0x80880000L)
343 #define WS_SIZEBOX (0x40000L)
344 #define WS_SYSMENU (0x80000L)
345 #define WS_TABSTOP (0x10000L)
346 #define WS_THICKFRAME (0x40000L)
347 #define WS_TILED (0L)
348 #define WS_TILEDWINDOW (0xcf0000L)
349 #define WS_VISIBLE (0x10000000L)
350 #define WS_VSCROLL (0x200000L)
351 #define MDIS_ALLCHILDSTYLES (0x1)
352 #define BS_3STATE (0x5L)
353 #define BS_AUTO3STATE (0x6L)
354 #define BS_AUTOCHECKBOX (0x3L)
355 #define BS_AUTORADIOBUTTON (0x9L)
356 #define BS_BITMAP (0x80L)
357 #define BS_BOTTOM (0x800L)
358 #define BS_CENTER (0x300L)
359 #define BS_CHECKBOX (0x2L)
360 #define BS_DEFPUSHBUTTON (0x1L)
361 #define BS_GROUPBOX (0x7L)
362 #define BS_ICON (0x40L)
363 #define BS_LEFT (0x100L)
364 #define BS_LEFTTEXT (0x20L)
365 #define BS_MULTILINE (0x2000L)
366 #define BS_NOTIFY (0x4000L)
367 #define BS_OWNERDRAW (0xbL)
368 #define BS_PUSHBOX (0xcL) /* FIXME! What should this be? */
369 #define BS_PUSHBUTTON (0L)
370 #define BS_PUSHLIKE (0x1000L)
371 #define BS_RADIOBUTTON (0x4L)
372 #define BS_RIGHT (0x200L)
373 #define BS_RIGHTBUTTON (0x20L)
375 #define BS_TOP (0x400L)
376 #define BS_USERBUTTON (0x8L)
377 #define BS_VCENTER (0xc00L)
378 #define CBS_AUTOHSCROLL (0x40L)
379 #define CBS_DISABLENOSCROLL (0x800L)
380 #define CBS_DROPDOWN (0x2L)
381 #define CBS_DROPDOWNLIST (0x3L)
382 #define CBS_HASSTRINGS (0x200L)
383 #define CBS_LOWERCASE (0x4000L)
384 #define CBS_NOINTEGRALHEIGHT (0x400L)
385 #define CBS_OEMCONVERT (0x80L)
386 #define CBS_OWNERDRAWFIXED (0x10L)
387 #define CBS_OWNERDRAWVARIABLE (0x20L)
388 #define CBS_SIMPLE (0x1L)
389 #define CBS_SORT (0x100L)
390 #define CBS_UPPERCASE (0x2000L)
391 #define ES_AUTOHSCROLL (0x80L)
392 #define ES_AUTOVSCROLL (0x40L)
393 #define ES_CENTER (0x1L)
395 #define ES_LOWERCASE (0x10L)
396 #define ES_MULTILINE (0x4L)
397 #define ES_NOHIDESEL (0x100L)
398 #define ES_NUMBER (0x2000L)
399 #define ES_OEMCONVERT (0x400L)
400 #define ES_PASSWORD (0x20L)
401 #define ES_READONLY (0x800L)
402 #define ES_RIGHT (0x2L)
403 #define ES_UPPERCASE (0x8L)
404 #define ES_WANTRETURN (0x1000L)
405 #define LBS_DISABLENOSCROLL (0x1000L)
406 #define LBS_EXTENDEDSEL (0x800L)
407 #define LBS_HASSTRINGS (0x40L)
408 #define LBS_MULTICOLUMN (0x200L)
409 #define LBS_MULTIPLESEL (0x8L)
410 #define LBS_NODATA (0x2000L)
411 #define LBS_NOINTEGRALHEIGHT (0x100L)
412 #define LBS_NOREDRAW (0x4L)
413 #define LBS_NOSEL (0x4000L)
414 #define LBS_NOTIFY (0x1L)
415 #define LBS_OWNERDRAWFIXED (0x10L)
416 #define LBS_OWNERDRAWVARIABLE (0x20L)
417 #define LBS_SORT (0x2L)
418 #define LBS_STANDARD (0xa00003L)
419 #define LBS_USETABSTOPS (0x80L)
420 #define LBS_WANTKEYBOARDINPUT (0x400L)
421 #define SBS_BOTTOMALIGN (0x4L)
422 #define SBS_HORZ (0L)
423 #define SBS_LEFTALIGN (0x2L)
424 #define SBS_RIGHTALIGN (0x4L)
425 #define SBS_SIZEBOX (0x8L)
426 #define SBS_SIZEBOXBOTTOMRIGHTALIGN (0x4L)
427 #define SBS_SIZEBOXTOPLEFTALIGN (0x2L)
428 #define SBS_SIZEGRIP (0x10L)
429 #define SBS_TOPALIGN (0x2L)
430 #define SBS_VERT (0x1L)
431 #define SS_BITMAP (0xeL)
432 #define SS_BLACKFRAME (0x7L)
433 #define SS_BLACKRECT (0x4L)
434 #define SS_CENTER (0x1L)
435 #define SS_CENTERIMAGE (0x200L)
436 #define SS_ENHMETAFILE (0xfL)
437 #define SS_ETCHEDFRAME (0x12L)
438 #define SS_ETCHEDHORZ (0x10L)
439 #define SS_ETCHEDVERT (0x11L)
440 #define SS_GRAYFRAME (0x8L)
441 #define SS_GRAYRECT (0x5L)
442 #define SS_ICON (0x3L)
444 #define SS_LEFTNOWORDWRAP (0xcL)
445 #define SS_NOPREFIX (0x80L)
446 #define SS_NOTIFY (0x100L)
447 #define SS_OWNERDRAW (0xdL)
448 #define SS_REALSIZEIMAGE (0x800L)
449 #define SS_RIGHT (0x2L)
450 #define SS_RIGHTJUST (0x400L)
451 #define SS_SIMPLE (0xbL)
452 #define SS_SUNKEN (0x1000L)
453 #define SS_USERITEM (0xaL)
454 #define SS_WHITEFRAME (0x9L)
455 #define SS_WHITERECT (0x6L)
456 #define DS_3DLOOK (0x4L)
457 #define DS_ABSALIGN (0x1L)
458 #define DS_CENTER (0x800L)
459 #define DS_CENTERMOUSE (0x1000L)
460 #define DS_CONTEXTHELP (0x2000L)
461 #define DS_CONTROL (0x400L)
462 #define DS_FIXEDSYS (0x8L)
463 #define DS_LOCALEDIT (0x20L)
464 #define DS_MODALFRAME (0x80L)
465 #define DS_NOFAILCREATE (0x10L)
466 #define DS_NOIDLEMSG (0x100L)
467 #define DS_SETFONT (0x40L)
468 #define DS_SETFOREGROUND (0x200L)
469 #define DS_SYSMODAL (0x2L)
471 /* A dialog control. */
473 struct dialog_control
476 struct dialog_control
*next
;
481 /* Extended style. */
482 unsigned long exstyle
;
488 unsigned short width
;
490 unsigned short height
;
493 /* Associated text. */
495 /* Extra data for the window procedure. */
496 struct rcdata_item
*data
;
497 /* Help ID. Only used in an extended dialog. */
501 /* Control classes. These can be used as the ID field in a struct
504 #define CTL_BUTTON 0x80
505 #define CTL_EDIT 0x81
506 #define CTL_STATIC 0x82
507 #define CTL_LISTBOX 0x83
508 #define CTL_SCROLLBAR 0x84
509 #define CTL_COMBOBOX 0x85
511 /* A fontdir resource is a list of fontdir structures. */
515 struct fontdir
*next
;
516 /* Index of font entry. */
518 /* Length of font information. */
519 unsigned long length
;
520 /* Font information. */
521 const unsigned char *data
;
524 /* A group_icon resource is a list of group_icon structures. */
528 /* Next icon in group. */
529 struct group_icon
*next
;
533 unsigned char height
;
535 unsigned char colors
;
537 unsigned short planes
;
538 /* Bits per pixel. */
540 /* Number of bytes in cursor resource. */
542 /* Index of cursor resource. */
543 unsigned short index
;
546 /* A menu resource. */
550 /* List of menuitems. */
551 struct menuitem
*items
;
552 /* Help ID. I don't think there is any way to set this in an rc
553 file, but it can appear in the binary format. */
557 /* A menu resource is a list of menuitem structures. */
562 struct menuitem
*next
;
563 /* Type. In a normal menu, rather than a menuex, this is the flags
566 /* State. This is only used in a menuex. */
572 /* Popup menu items for a popup. */
573 struct menuitem
*popup
;
574 /* Help ID. This is only used in a menuex. */
578 /* Menu item flags. These can appear in the flags field of a struct
581 #define MENUITEM_GRAYED 0x001
582 #define MENUITEM_INACTIVE 0x002
583 #define MENUITEM_BITMAP 0x004
584 #define MENUITEM_OWNERDRAW 0x100
585 #define MENUITEM_CHECKED 0x008
586 #define MENUITEM_POPUP 0x010
587 #define MENUITEM_MENUBARBREAK 0x020
588 #define MENUITEM_MENUBREAK 0x040
589 #define MENUITEM_ENDMENU 0x080
590 #define MENUITEM_HELP 0x4000
592 /* An rcdata resource is a pointer to a list of rcdata_item
597 /* Next data item. */
598 struct rcdata_item
*next
;
614 unsigned long length
;
619 unsigned long length
;
624 unsigned long length
;
625 const unsigned char *data
;
630 /* A stringtable resource is a pointer to a stringtable structure. */
634 /* Each stringtable resource is a list of 16 unicode strings. */
637 /* Length of string. */
639 /* String data if length > 0. */
644 /* A versioninfo resource points to a versioninfo structure. */
648 /* Fixed version information. */
649 struct fixed_versioninfo
*fixed
;
650 /* Variable version information. */
651 struct ver_info
*var
;
654 /* The fixed portion of a versioninfo resource. */
656 struct fixed_versioninfo
658 /* The file version, which is two 32 bit integers. */
659 unsigned long file_version_ms
;
660 unsigned long file_version_ls
;
661 /* The product version, which is two 32 bit integers. */
662 unsigned long product_version_ms
;
663 unsigned long product_version_ls
;
664 /* The file flags mask. */
665 unsigned long file_flags_mask
;
666 /* The file flags. */
667 unsigned long file_flags
;
669 unsigned long file_os
;
671 unsigned long file_type
;
672 /* The file subtype. */
673 unsigned long file_subtype
;
674 /* The date, which in Windows is two 32 bit integers. */
675 unsigned long file_date_ms
;
676 unsigned long file_date_ls
;
679 /* A list of variable version information. */
684 struct ver_info
*next
;
686 enum { VERINFO_STRING
, VERINFO_VAR
} type
;
689 /* StringFileInfo data. */
695 struct ver_stringinfo
*strings
;
697 /* VarFileInfo data. */
703 struct ver_varinfo
*var
;
708 /* A list of string version information. */
710 struct ver_stringinfo
713 struct ver_stringinfo
*next
;
720 /* A list of variable version information. */
725 struct ver_varinfo
*next
;
727 unsigned short language
;
728 /* Character set ID. */
729 unsigned short charset
;
732 /* This structure is used when converting resource information to
738 struct bindata
*next
;
739 /* Length of data. */
740 unsigned long length
;
747 /* Function declarations. */
749 extern struct res_directory
*read_rc_file
750 PARAMS ((const char *, const char *, const char *, int, int));
751 extern struct res_directory
*read_res_file
PARAMS ((const char *));
752 extern struct res_directory
*read_coff_rsrc
753 PARAMS ((const char *, const char *));
754 extern void write_rc_file
755 PARAMS ((const char *, const struct res_directory
*));
756 extern void write_res_file
757 PARAMS ((const char *, const struct res_directory
*));
758 extern void write_coff_file
759 PARAMS ((const char *, const char *, const struct res_directory
*));
761 extern struct res_resource
*bin_to_res
762 PARAMS ((struct res_id
, const unsigned char *, unsigned long, int));
763 extern struct bindata
*res_to_bin
PARAMS ((const struct res_resource
*, int));
765 extern FILE *open_file_search
766 PARAMS ((const char *, const char *, const char *, char **));
768 extern PTR res_alloc
PARAMS ((size_t));
769 extern PTR reswr_alloc
PARAMS ((size_t));
771 /* Resource ID handling. */
773 extern int res_id_cmp
PARAMS ((struct res_id
, struct res_id
));
774 extern void res_id_print
PARAMS ((FILE *, struct res_id
, int));
775 extern void res_ids_print
PARAMS ((FILE *, int, const struct res_id
*));
776 extern void res_string_to_id
PARAMS ((struct res_id
*, const char *));
778 /* Manipulation of the resource tree. */
780 extern struct res_resource
*define_resource
781 PARAMS ((struct res_directory
**, int, const struct res_id
*, int));
782 extern struct res_resource
*define_standard_resource
783 PARAMS ((struct res_directory
**, int, struct res_id
, int, int));
785 extern int extended_dialog
PARAMS ((const struct dialog
*));
786 extern int extended_menu
PARAMS ((const struct menu
*));
788 /* Communication between the rc file support and the parser and lexer. */
792 extern char *rc_filename
;
793 extern int rc_lineno
;
794 extern int yyparse
PARAMS ((void));
795 extern int yylex
PARAMS ((void));
796 extern void yyerror
PARAMS ((const char *));
797 extern void rcparse_warning
PARAMS ((const char *));
798 extern void rcparse_set_language
PARAMS ((int));
799 extern void rcparse_discard_strings
PARAMS ((void));
800 extern void rcparse_rcdata
PARAMS ((void));
801 extern void rcparse_normal
PARAMS ((void));
803 extern void define_accelerator
804 PARAMS ((struct res_id
, const struct res_res_info
*, struct accelerator
*));
805 extern void define_bitmap
806 PARAMS ((struct res_id
, const struct res_res_info
*, const char *));
807 extern void define_cursor
808 PARAMS ((struct res_id
, const struct res_res_info
*, const char *));
809 extern void define_dialog
810 PARAMS ((struct res_id
, const struct res_res_info
*, const struct dialog
*));
811 extern struct dialog_control
*define_control
812 PARAMS ((const char *, unsigned long, unsigned long, unsigned long,
813 unsigned long, unsigned long, unsigned long, unsigned long,
815 extern struct dialog_control
*define_icon_control
816 PARAMS ((struct res_id
, unsigned long, unsigned long,
817 unsigned long, unsigned long, unsigned long, unsigned long,
818 struct rcdata_item
*, struct dialog_ex
*));
819 extern void define_font
820 PARAMS ((struct res_id
, const struct res_res_info
*, const char *));
821 extern void define_icon
822 PARAMS ((struct res_id
, const struct res_res_info
*, const char *));
823 extern void define_menu
824 PARAMS ((struct res_id
, const struct res_res_info
*, struct menuitem
*));
825 extern struct menuitem
*define_menuitem
826 PARAMS ((const char *, int, unsigned long, unsigned long, unsigned long,
828 extern void define_messagetable
829 PARAMS ((struct res_id
, const struct res_res_info
*, const char *));
830 extern void define_rcdata
831 PARAMS ((struct res_id
, const struct res_res_info
*, struct rcdata_item
*));
832 extern struct rcdata_item
*define_rcdata_string
833 PARAMS ((const char *, unsigned long));
834 extern struct rcdata_item
*define_rcdata_number
PARAMS ((unsigned long, int));
835 extern void define_stringtable
836 PARAMS ((const struct res_res_info
*, unsigned long, const char *));
837 extern void define_user_data
838 PARAMS ((struct res_id
, struct res_id
, const struct res_res_info
*,
839 struct rcdata_item
*));
840 extern void define_user_file
841 PARAMS ((struct res_id
, struct res_id
, const struct res_res_info
*,
843 extern void define_versioninfo
844 PARAMS ((struct res_id
, int, struct fixed_versioninfo
*,
846 extern struct ver_info
*append_ver_stringfileinfo
847 PARAMS ((struct ver_info
*, const char *, struct ver_stringinfo
*));
848 extern struct ver_info
*append_ver_varfileinfo
849 PARAMS ((struct ver_info
*, const char *, struct ver_varinfo
*));
850 extern struct ver_stringinfo
*append_verval
851 PARAMS ((struct ver_stringinfo
*, const char *, const char *));
852 extern struct ver_varinfo
*append_vertrans
853 PARAMS ((struct ver_varinfo
*, unsigned long, unsigned long));