By Ray Lischner, Tempest Software
A Windows resource file (.RES) contains a series of packed resource entries, with no other structure, that is no headers, footers, padding, etc. The format of a resource entry is different for Windows 3.x (16-bit) and Win32, that is, Windows 95 and Windows NT (32-bit).
A 32-bit .RES file starts with an empty resource entry of 32 bytes:
00000000 20000000 FFFF0000 FFFF0000 00000000 00000000 00000000 00000000
After that comes the real resource entries, packed into the file with no padding or other structure--just a series of resource entries.
Each resource entry has a header followed immediately by the resource data. Immediately after the data for one entry comes the header for the next entry. Each header has the following format:
Field |
Size (bytes) |
Description |
---|---|---|
Data Size |
|
Size of the resource data that follow the header |
Header Size |
|
Size of the resource header (always at least 16) |
Type |
| |
Name |
|
Resource name or identifier |
Data Version |
|
Version number for resource data format, usually 0 |
Flags |
|
Most flags are for backward compability with Win16. Discardable (100016) is the only Win32 flag. |
Language |
|
Primary and secondary language identifiers. Zero for language-neutral, or look up your Windows documentation for a full list of identifiers. Form a language identifier from a primary and sublanguage as follows: (sublanguage << 10 | primary). |
Version |
|
Version number for the resource entry |
Characteristics |
|
Anything you want |
Each resource entry has a header followed immediately by the resource data. Immediately after the data for one entry comes the header for the next entry. Each header has the following format:
Field |
Size |
Description |
---|---|---|
Type |
| |
Name |
|
Resource name or identifier |
Flags |
|
Discardable=100016, Moveable=001016, Pure=002016, Preload=004016 |
Size |
|
Size of the resource data that immediately follow the header |
Windows reserves numeric resource types under 256 for its own use. In this range are several predefined resource types:
Type |
Value |
Description |
---|---|---|
RT_CURSOR |
|
Cursor image (one entry in a cursor group) |
RT_BITMAP |
|
Bitmap (Windows or OS/2 BMP format) |
RT_ICON |
|
Icon image (one entry in an icon group) |
RT_MENU |
|
Menu |
RT_DIALOG |
|
Dialog box |
RT_STRING |
|
String table (must have numeric identifier, not textual) |
RT_FONTDIR |
|
Font directory |
RT_FONT |
|
Font entry |
RT_ACCELERATOR |
|
Keyboard accelerator table |
RT_RCDATA |
|
Application-defined data |
RT_GROUP_CURSOR |
|
Group header for a cursor |
RT_GROUP_ICON |
|
Group header for an icon |
Win32 defines additional resource types:
Type |
Value |
Description |
---|---|---|
RT_MESSAGETABLE |
|
Message table |
RT_VERSION |
|
Version information |
RT_DLGINCLUDE |
|
Dialog include |
RT_PLUGPLAY |
|
Plug and play |
RT_VXD |
|
VxD |
RT_ANICURSOR |
|
Animated cursor |