1 /* windres.h -- header file for windres program.
2 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support.
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 /* This is the header file for the windres program. It defines
26 structures and declares functions used within the program. */
30 /* We represent resources internally as a tree, similar to the tree
31 used in the .rsrc section of a COFF file. The root is a
32 res_directory structure. */
36 /* Resource flags. According to the MS docs, this is currently
38 unsigned long characteristics
;
39 /* Time/date stamp. */
41 /* Major version number. */
43 /* Minor version number. */
45 /* Directory entries. */
46 struct res_entry
*entries
;
49 /* A resource ID is stored in a res_id structure. */
53 /* Non-zero if this entry has a name rather than an ID. */
54 unsigned int named
: 1;
57 /* If the named field is non-zero, this is the name. */
60 /* Length of the name. */
62 /* Pointer to the name, which is a Unicode string. */
65 /* If the named field is zero, this is the ID. */
70 /* Each entry in the tree is a res_entry structure. We mix
71 directories and resources because in a COFF file all entries in a
72 directory are sorted together, whether the entries are
73 subdirectories or resources. */
78 struct res_entry
*next
;
81 /* Non-zero if this entry is a subdirectory rather than a leaf. */
82 unsigned int subdir
: 1;
85 /* If the subdir field is non-zero, this is a pointer to the
87 struct res_directory
*dir
;
88 /* If the subdir field is zero, this is a pointer to the resource
90 struct res_resource
*res
;
94 /* Types of resources. */
98 RES_TYPE_UNINITIALIZED
,
102 RES_TYPE_GROUP_CURSOR
,
109 RES_TYPE_MESSAGETABLE
,
111 RES_TYPE_STRINGTABLE
,
116 /* A res file and a COFF file store information differently. The
117 res_info structures holds data which in a res file is stored with
118 each resource, but in a COFF file is stored elsewhere. */
122 /* Language. In a COFF file, the third level of the directory is
123 keyed by the language, so the language of a resource is defined
124 by its location in the resource tree. */
125 unsigned short language
;
126 /* Characteristics of the resource. Entirely user defined. In a
127 COFF file, the res_directory structure has a characteristics
128 field, but I don't know if it's related to the one in the res
130 unsigned long characteristics
;
131 /* Version of the resource. Entirely user defined. In a COFF file,
132 the res_directory structure has a characteristics field, but I
133 don't know if it's related to the one in the res file. */
134 unsigned long version
;
135 /* Memory flags. This is a combination of the MEMFLAG values
136 defined below. Most of these values are historical, and are not
137 meaningful for win32. I don't think there is any way to store
138 this information in a COFF file. */
139 unsigned short memflags
;
142 /* Each resource in a COFF file has some information which can does
143 not appear in a res file. */
147 /* The code page used for the data. I don't really know what this
149 unsigned long codepage
;
150 /* A resource entry in a COFF file has a reserved field, which we
151 record here when reading a COFF file. When writing a COFF file,
152 we set this field to zero. */
153 unsigned long reserved
;
156 /* Resource data is stored in a res_resource structure. */
160 /* The type of resource. */
162 /* The data for the resource. */
167 unsigned long length
;
168 const unsigned char *data
;
170 struct accelerator
*acc
;
171 struct cursor
*cursor
;
172 struct group_cursor
*group_cursor
;
173 struct dialog
*dialog
;
174 struct fontdir
*fontdir
;
175 struct group_icon
*group_icon
;
177 struct rcdata_item
*rcdata
;
178 struct stringtable
*stringtable
;
179 struct rcdata_item
*userdata
;
180 struct versioninfo
*versioninfo
;
182 /* Information from a res file. */
183 struct res_res_info res_info
;
184 /* Information from a COFF file. */
185 struct res_coff_info coff_info
;
188 #define SUBLANG_SHIFT 10
190 /* Memory flags in the memflags field of a struct res_resource. */
192 #define MEMFLAG_MOVEABLE 0x10
193 #define MEMFLAG_PURE 0x20
194 #define MEMFLAG_PRELOAD 0x40
195 #define MEMFLAG_DISCARDABLE 0x1000
197 /* Standard resource type codes. These are used in the ID field of a
198 res_entry structure. */
208 #define RT_ACCELERATOR 9
210 #define RT_MESSAGETABLE 11
211 #define RT_GROUP_CURSOR 12
212 #define RT_GROUP_ICON 14
213 #define RT_VERSION 16
214 #define RT_DLGINCLUDE 17
215 #define RT_PLUGPLAY 19
217 #define RT_ANICURSOR 21
218 #define RT_ANIICON 22
220 /* An accelerator resource is a linked list of these structures. */
224 /* Next accelerator. */
225 struct accelerator
*next
;
226 /* Flags. A combination of the ACC values defined below. */
227 unsigned short flags
;
234 /* Accelerator flags in the flags field of a struct accelerator.
235 These are the same values that appear in a res file. I hope. */
237 #define ACC_VIRTKEY 0x01
238 #define ACC_NOINVERT 0x02
239 #define ACC_SHIFT 0x04
240 #define ACC_CONTROL 0x08
242 #define ACC_LAST 0x80
244 /* A cursor resource. */
248 /* X coordinate of hotspot. */
250 /* Y coordinate of hotspot. */
252 /* Length of bitmap data. */
253 unsigned long length
;
255 const unsigned char *data
;
258 /* A group_cursor resource is a list of group_cursor structures. */
262 /* Next cursor in group. */
263 struct group_cursor
*next
;
265 unsigned short width
;
267 unsigned short height
;
269 unsigned short planes
;
270 /* Bits per pixel. */
272 /* Number of bytes in cursor resource. */
274 /* Index of cursor resource. */
275 unsigned short index
;
278 /* A dialog resource. */
282 /* Basic window style. */
284 /* Extended window style. */
285 unsigned long exstyle
;
291 unsigned short width
;
293 unsigned short height
;
300 /* Font point size. */
301 unsigned short pointsize
;
304 /* Extended information for a dialogex. */
305 struct dialog_ex
*ex
;
307 struct dialog_control
*controls
;
310 /* An extended dialog has additional information. */
317 unsigned short weight
;
318 /* Whether the font is italic. */
319 unsigned char italic
;
321 unsigned char charset
;
324 /* Window style flags, from the winsup Defines.h header file. These
325 can appear in the style field of a struct dialog or a struct
328 #define CW_USEDEFAULT (0x80000000)
329 #define WS_BORDER (0x800000L)
330 #define WS_CAPTION (0xc00000L)
331 #define WS_CHILD (0x40000000L)
332 #define WS_CHILDWINDOW (0x40000000L)
333 #define WS_CLIPCHILDREN (0x2000000L)
334 #define WS_CLIPSIBLINGS (0x4000000L)
335 #define WS_DISABLED (0x8000000L)
336 #define WS_DLGFRAME (0x400000L)
337 #define WS_GROUP (0x20000L)
338 #define WS_HSCROLL (0x100000L)
339 #define WS_ICONIC (0x20000000L)
340 #define WS_MAXIMIZE (0x1000000L)
341 #define WS_MAXIMIZEBOX (0x10000L)
342 #define WS_MINIMIZE (0x20000000L)
343 #define WS_MINIMIZEBOX (0x20000L)
344 #define WS_OVERLAPPED (0L)
345 #define WS_OVERLAPPEDWINDOW (0xcf0000L)
346 #define WS_POPUP (0x80000000L)
347 #define WS_POPUPWINDOW (0x80880000L)
348 #define WS_SIZEBOX (0x40000L)
349 #define WS_SYSMENU (0x80000L)
350 #define WS_TABSTOP (0x10000L)
351 #define WS_THICKFRAME (0x40000L)
352 #define WS_TILED (0L)
353 #define WS_TILEDWINDOW (0xcf0000L)
354 #define WS_VISIBLE (0x10000000L)
355 #define WS_VSCROLL (0x200000L)
356 #define MDIS_ALLCHILDSTYLES (0x1)
357 #define BS_3STATE (0x5L)
358 #define BS_AUTO3STATE (0x6L)
359 #define BS_AUTOCHECKBOX (0x3L)
360 #define BS_AUTORADIOBUTTON (0x9L)
361 #define BS_BITMAP (0x80L)
362 #define BS_BOTTOM (0x800L)
363 #define BS_CENTER (0x300L)
364 #define BS_CHECKBOX (0x2L)
365 #define BS_DEFPUSHBUTTON (0x1L)
366 #define BS_GROUPBOX (0x7L)
367 #define BS_ICON (0x40L)
368 #define BS_LEFT (0x100L)
369 #define BS_LEFTTEXT (0x20L)
370 #define BS_MULTILINE (0x2000L)
371 #define BS_NOTIFY (0x4000L)
372 #define BS_OWNERDRAW (0xbL)
373 #define BS_PUSHBOX (0xcL) /* FIXME! What should this be? */
374 #define BS_PUSHBUTTON (0L)
375 #define BS_PUSHLIKE (0x1000L)
376 #define BS_RADIOBUTTON (0x4L)
377 #define BS_RIGHT (0x200L)
378 #define BS_RIGHTBUTTON (0x20L)
380 #define BS_TOP (0x400L)
381 #define BS_USERBUTTON (0x8L)
382 #define BS_VCENTER (0xc00L)
383 #define CBS_AUTOHSCROLL (0x40L)
384 #define CBS_DISABLENOSCROLL (0x800L)
385 #define CBS_DROPDOWN (0x2L)
386 #define CBS_DROPDOWNLIST (0x3L)
387 #define CBS_HASSTRINGS (0x200L)
388 #define CBS_LOWERCASE (0x4000L)
389 #define CBS_NOINTEGRALHEIGHT (0x400L)
390 #define CBS_OEMCONVERT (0x80L)
391 #define CBS_OWNERDRAWFIXED (0x10L)
392 #define CBS_OWNERDRAWVARIABLE (0x20L)
393 #define CBS_SIMPLE (0x1L)
394 #define CBS_SORT (0x100L)
395 #define CBS_UPPERCASE (0x2000L)
396 #define ES_AUTOHSCROLL (0x80L)
397 #define ES_AUTOVSCROLL (0x40L)
398 #define ES_CENTER (0x1L)
400 #define ES_LOWERCASE (0x10L)
401 #define ES_MULTILINE (0x4L)
402 #define ES_NOHIDESEL (0x100L)
403 #define ES_NUMBER (0x2000L)
404 #define ES_OEMCONVERT (0x400L)
405 #define ES_PASSWORD (0x20L)
406 #define ES_READONLY (0x800L)
407 #define ES_RIGHT (0x2L)
408 #define ES_UPPERCASE (0x8L)
409 #define ES_WANTRETURN (0x1000L)
410 #define LBS_DISABLENOSCROLL (0x1000L)
411 #define LBS_EXTENDEDSEL (0x800L)
412 #define LBS_HASSTRINGS (0x40L)
413 #define LBS_MULTICOLUMN (0x200L)
414 #define LBS_MULTIPLESEL (0x8L)
415 #define LBS_NODATA (0x2000L)
416 #define LBS_NOINTEGRALHEIGHT (0x100L)
417 #define LBS_NOREDRAW (0x4L)
418 #define LBS_NOSEL (0x4000L)
419 #define LBS_NOTIFY (0x1L)
420 #define LBS_OWNERDRAWFIXED (0x10L)
421 #define LBS_OWNERDRAWVARIABLE (0x20L)
422 #define LBS_SORT (0x2L)
423 #define LBS_STANDARD (0xa00003L)
424 #define LBS_USETABSTOPS (0x80L)
425 #define LBS_WANTKEYBOARDINPUT (0x400L)
426 #define SBS_BOTTOMALIGN (0x4L)
427 #define SBS_HORZ (0L)
428 #define SBS_LEFTALIGN (0x2L)
429 #define SBS_RIGHTALIGN (0x4L)
430 #define SBS_SIZEBOX (0x8L)
431 #define SBS_SIZEBOXBOTTOMRIGHTALIGN (0x4L)
432 #define SBS_SIZEBOXTOPLEFTALIGN (0x2L)
433 #define SBS_SIZEGRIP (0x10L)
434 #define SBS_TOPALIGN (0x2L)
435 #define SBS_VERT (0x1L)
436 #define SS_BITMAP (0xeL)
437 #define SS_BLACKFRAME (0x7L)
438 #define SS_BLACKRECT (0x4L)
439 #define SS_CENTER (0x1L)
440 #define SS_CENTERIMAGE (0x200L)
441 #define SS_ENHMETAFILE (0xfL)
442 #define SS_ETCHEDFRAME (0x12L)
443 #define SS_ETCHEDHORZ (0x10L)
444 #define SS_ETCHEDVERT (0x11L)
445 #define SS_GRAYFRAME (0x8L)
446 #define SS_GRAYRECT (0x5L)
447 #define SS_ICON (0x3L)
449 #define SS_LEFTNOWORDWRAP (0xcL)
450 #define SS_NOPREFIX (0x80L)
451 #define SS_NOTIFY (0x100L)
452 #define SS_OWNERDRAW (0xdL)
453 #define SS_REALSIZEIMAGE (0x800L)
454 #define SS_RIGHT (0x2L)
455 #define SS_RIGHTJUST (0x400L)
456 #define SS_SIMPLE (0xbL)
457 #define SS_SUNKEN (0x1000L)
458 #define SS_USERITEM (0xaL)
459 #define SS_WHITEFRAME (0x9L)
460 #define SS_WHITERECT (0x6L)
461 #define DS_3DLOOK (0x4L)
462 #define DS_ABSALIGN (0x1L)
463 #define DS_CENTER (0x800L)
464 #define DS_CENTERMOUSE (0x1000L)
465 #define DS_CONTEXTHELP (0x2000L)
466 #define DS_CONTROL (0x400L)
467 #define DS_FIXEDSYS (0x8L)
468 #define DS_LOCALEDIT (0x20L)
469 #define DS_MODALFRAME (0x80L)
470 #define DS_NOFAILCREATE (0x10L)
471 #define DS_NOIDLEMSG (0x100L)
472 #define DS_SETFONT (0x40L)
473 #define DS_SETFOREGROUND (0x200L)
474 #define DS_SYSMODAL (0x2L)
476 /* A dialog control. */
478 struct dialog_control
481 struct dialog_control
*next
;
486 /* Extended style. */
487 unsigned long exstyle
;
493 unsigned short width
;
495 unsigned short height
;
498 /* Associated text. */
500 /* Extra data for the window procedure. */
501 struct rcdata_item
*data
;
502 /* Help ID. Only used in an extended dialog. */
506 /* Control classes. These can be used as the ID field in a struct
509 #define CTL_BUTTON 0x80
510 #define CTL_EDIT 0x81
511 #define CTL_STATIC 0x82
512 #define CTL_LISTBOX 0x83
513 #define CTL_SCROLLBAR 0x84
514 #define CTL_COMBOBOX 0x85
516 /* A fontdir resource is a list of fontdir structures. */
520 struct fontdir
*next
;
521 /* Index of font entry. */
523 /* Length of font information. */
524 unsigned long length
;
525 /* Font information. */
526 const unsigned char *data
;
529 /* A group_icon resource is a list of group_icon structures. */
533 /* Next icon in group. */
534 struct group_icon
*next
;
538 unsigned char height
;
540 unsigned char colors
;
542 unsigned short planes
;
543 /* Bits per pixel. */
545 /* Number of bytes in cursor resource. */
547 /* Index of cursor resource. */
548 unsigned short index
;
551 /* A menu resource. */
555 /* List of menuitems. */
556 struct menuitem
*items
;
557 /* Help ID. I don't think there is any way to set this in an rc
558 file, but it can appear in the binary format. */
562 /* A menu resource is a list of menuitem structures. */
567 struct menuitem
*next
;
568 /* Type. In a normal menu, rather than a menuex, this is the flags
571 /* State. This is only used in a menuex. */
577 /* Popup menu items for a popup. */
578 struct menuitem
*popup
;
579 /* Help ID. This is only used in a menuex. */
583 /* Menu item flags. These can appear in the flags field of a struct
586 #define MENUITEM_GRAYED 0x001
587 #define MENUITEM_INACTIVE 0x002
588 #define MENUITEM_BITMAP 0x004
589 #define MENUITEM_OWNERDRAW 0x100
590 #define MENUITEM_CHECKED 0x008
591 #define MENUITEM_POPUP 0x010
592 #define MENUITEM_MENUBARBREAK 0x020
593 #define MENUITEM_MENUBREAK 0x040
594 #define MENUITEM_ENDMENU 0x080
595 #define MENUITEM_HELP 0x4000
597 /* An rcdata resource is a pointer to a list of rcdata_item
602 /* Next data item. */
603 struct rcdata_item
*next
;
619 unsigned long length
;
624 unsigned long length
;
629 unsigned long length
;
630 const unsigned char *data
;
635 /* A stringtable resource is a pointer to a stringtable structure. */
639 /* Each stringtable resource is a list of 16 unicode strings. */
642 /* Length of string. */
644 /* String data if length > 0. */
649 /* A versioninfo resource points to a versioninfo structure. */
653 /* Fixed version information. */
654 struct fixed_versioninfo
*fixed
;
655 /* Variable version information. */
656 struct ver_info
*var
;
659 /* The fixed portion of a versioninfo resource. */
661 struct fixed_versioninfo
663 /* The file version, which is two 32 bit integers. */
664 unsigned long file_version_ms
;
665 unsigned long file_version_ls
;
666 /* The product version, which is two 32 bit integers. */
667 unsigned long product_version_ms
;
668 unsigned long product_version_ls
;
669 /* The file flags mask. */
670 unsigned long file_flags_mask
;
671 /* The file flags. */
672 unsigned long file_flags
;
674 unsigned long file_os
;
676 unsigned long file_type
;
677 /* The file subtype. */
678 unsigned long file_subtype
;
679 /* The date, which in Windows is two 32 bit integers. */
680 unsigned long file_date_ms
;
681 unsigned long file_date_ls
;
684 /* A list of variable version information. */
689 struct ver_info
*next
;
691 enum { VERINFO_STRING
, VERINFO_VAR
} type
;
694 /* StringFileInfo data. */
700 struct ver_stringinfo
*strings
;
702 /* VarFileInfo data. */
708 struct ver_varinfo
*var
;
713 /* A list of string version information. */
715 struct ver_stringinfo
718 struct ver_stringinfo
*next
;
725 /* A list of variable version information. */
730 struct ver_varinfo
*next
;
732 unsigned short language
;
733 /* Character set ID. */
734 unsigned short charset
;
737 /* This structure is used when converting resource information to
743 struct bindata
*next
;
744 /* Length of data. */
745 unsigned long length
;
752 /* Function declarations. */
754 extern struct res_directory
*read_rc_file
755 (const char *, const char *, const char *, int, int);
756 extern struct res_directory
*read_res_file (const char *);
757 extern struct res_directory
*read_coff_rsrc (const char *, const char *);
758 extern void write_rc_file (const char *, const struct res_directory
*);
759 extern void write_res_file (const char *, const struct res_directory
*);
760 extern void write_coff_file
761 (const char *, const char *, const struct res_directory
*);
763 extern struct res_resource
*bin_to_res
764 (struct res_id
, const unsigned char *, unsigned long, int);
765 extern struct bindata
*res_to_bin (const struct res_resource
*, int);
767 extern FILE *open_file_search
768 (const char *, const char *, const char *, char **);
770 extern void *res_alloc (size_t);
771 extern void *reswr_alloc (size_t);
773 /* Resource ID handling. */
775 extern int res_id_cmp (struct res_id
, struct res_id
);
776 extern void res_id_print (FILE *, struct res_id
, int);
777 extern void res_ids_print (FILE *, int, const struct res_id
*);
778 extern void res_string_to_id (struct res_id
*, const char *);
780 /* Manipulation of the resource tree. */
782 extern struct res_resource
*define_resource
783 (struct res_directory
**, int, const struct res_id
*, int);
784 extern struct res_resource
*define_standard_resource
785 (struct res_directory
**, int, struct res_id
, int, int);
787 extern int extended_dialog (const struct dialog
*);
788 extern int extended_menu (const struct menu
*);
790 /* Communication between the rc file support and the parser and lexer. */
794 extern char *rc_filename
;
795 extern int rc_lineno
;
797 extern int yyparse (void);
798 extern int yylex (void);
799 extern void yyerror (const char *);
800 extern void rcparse_warning (const char *);
801 extern void rcparse_set_language (int);
802 extern void rcparse_discard_strings (void);
803 extern void rcparse_rcdata (void);
804 extern void rcparse_normal (void);
806 extern void define_accelerator
807 (struct res_id
, const struct res_res_info
*, struct accelerator
*);
808 extern void define_bitmap
809 (struct res_id
, const struct res_res_info
*, const char *);
810 extern void define_cursor
811 (struct res_id
, const struct res_res_info
*, const char *);
812 extern void define_dialog
813 (struct res_id
, const struct res_res_info
*, const struct dialog
*);
814 extern struct dialog_control
*define_control
815 (const struct res_id
, unsigned long, unsigned long, unsigned long,
816 unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
817 extern struct dialog_control
*define_icon_control
818 (struct res_id
, unsigned long, unsigned long, unsigned long, unsigned long,
819 unsigned long, unsigned long, struct rcdata_item
*, struct dialog_ex
*);
820 extern void define_font
821 (struct res_id
, const struct res_res_info
*, const char *);
822 extern void define_icon
823 (struct res_id
, const struct res_res_info
*, const char *);
824 extern void define_menu
825 (struct res_id
, const struct res_res_info
*, struct menuitem
*);
826 extern struct menuitem
*define_menuitem
827 (const char *, int, unsigned long, unsigned long, unsigned long,
829 extern void define_messagetable
830 (struct res_id
, const struct res_res_info
*, const char *);
831 extern void define_rcdata
832 (struct res_id
, const struct res_res_info
*, struct rcdata_item
*);
833 extern void define_rcdata_file
834 (struct res_id
, const struct res_res_info
*, const char *);
835 extern struct rcdata_item
*define_rcdata_string
836 (const char *, unsigned long);
837 extern struct rcdata_item
*define_rcdata_number (unsigned long, int);
838 extern void define_stringtable
839 (const struct res_res_info
*, unsigned long, const char *);
840 extern void define_user_data
841 (struct res_id
, struct res_id
, const struct res_res_info
*,
842 struct rcdata_item
*);
843 extern void define_user_file
844 (struct res_id
, struct res_id
, const struct res_res_info
*, const char *);
845 extern void define_versioninfo
846 (struct res_id
, int, struct fixed_versioninfo
*, struct ver_info
*);
847 extern struct ver_info
*append_ver_stringfileinfo
848 (struct ver_info
*, const char *, struct ver_stringinfo
*);
849 extern struct ver_info
*append_ver_varfileinfo
850 (struct ver_info
*, const char *, struct ver_varinfo
*);
851 extern struct ver_stringinfo
*append_verval
852 (struct ver_stringinfo
*, const char *, const char *);
853 extern struct ver_varinfo
*append_vertrans
854 (struct ver_varinfo
*, unsigned long, unsigned long);