Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Windows dialog template resource (RT_DIALOG)

From ReverseEngineering.wiki
Format
Platforms Platform:Windows
Magic first u16 pair 01 00 FF FF for DLGTEMPLATEEX
Extensions RT_DIALOG (5) resource
Endianness little
On this wiki Facts · Code · Notes · Topics

The binary layout of a dialog box in a PE resource (type 5, RT_DIALOG): the classic DLGTEMPLATE and the extended DLGTEMPLATEEX header, then one DLGITEMTEMPLATE or DLGITEMTEMPLATEEX per control, all strings UTF-16 and every control DWORD-aligned.

Where it lives

Dialogs are RT_DIALOG (5) entries in the resource tree, see Format:PE (Portable Executable)/Resource directory. The same blob is what DialogBoxIndirectParam and CreateDialogIndirectParam take in memory. Frameworks such as Library:MFC and Library:wxWidgets load the same resources; WTL/ATL dialogs use them too (Library:ATL).

Telling the two headers apart

Read the first two u16. If they are 0x0001, 0xFFFF the template is DLGTEMPLATEEX (DIALOGEX in .rc files); otherwise the first dword is the style of a classic DLGTEMPLATE. (Wine DIALOG_ParseTemplate32 tests dlgver == 1 && signature == 0xffff.)

Header

Classic DLGTEMPLATE (18 bytes, packed, from the MinGW-w64 winuser.h): u32 style, u32 dwExtendedStyle, u16 cdit, i16 x, y, cx, cy.

DLGTEMPLATEEX: u16 dlgVer (1), u16 signature (0xFFFF), u32 helpID, u32 exStyle, u32 style, u16 cDlgItems, i16 x, y, cx, cy. Note that exStyle comes before style here, the opposite of the classic header.

Then, in both formats, three variable parts:

  1. menu: u16 0 none; u16 0xFFFF, u16 id a menu resource id; otherwise a NUL-terminated UTF-16 name.
  2. window class: same three forms (0 = the default dialog class).
  3. title: NUL-terminated UTF-16 (just a single 0 when empty).
  4. font, only when style & DS_SETFONT (0x40) (DS_SHELLFONT is DS_SETFONT|DS_FIXEDSYS 0x48): u16 pointSize; in the EX form also u16 weight, u8 italic, u8 charset; then the UTF-16 face name. A pointSize of 0x7FFF means "use the system message-box font" and Wine then reads no weight/italic/face from the template.

The first control starts at the next DWORD boundary.

Controls

Classic DLGITEMTEMPLATE: u32 style, u32 exStyle, i16 x, y, cx, cy, u16 id. DLGITEMTEMPLATEEX: u32 helpID, u32 exStyle, u32 style, i16 x, y, cx, cy, u32 id (the id is 32-bit here).

After the fixed part, for both:

  • class: either u16 0xFFFF, u16 atom for a predefined class, or a UTF-16 string. Atoms 0x0080 Button, 0x0081 Edit, 0x0082 Static, 0x0083 ListBox, 0x0084 ScrollBar, 0x0085 ComboBox (Wine also accepts 0 to 5 as the same classes).
  • text: u16 0xFFFF, u16 resource id (for example an icon or bitmap id in a static control) or a UTF-16 string.
  • creation data: u16 cbExtra followed by that many bytes (passed as lParam of WM_CREATE); 0 when none.
  • padding up to the next DWORD boundary before the next control.

Control class strings other than the six atoms (SysListView32, msctls_progress32, RichEdit20W, a custom class registered by the program) tell an analyst which common controls or custom windows the dialog needs.

Using it when reversing

  • Control ids in the dialog tie to handlers: in an MFC program to the message map (Library:MFC#Message maps), otherwise to the WM_COMMAND switch in the dialog procedure.
  • Dialog styles (WS_*, DS_*) and the font tell the toolkit era: DS_SHELLFONT with "MS Shell Dlg" or "MS Sans Serif" is typical of Win9x/2000-era .rc files.
  • Resource editors and wrestool/pefile extract the blob; do not run the program to see the dialog.

Code & repositories

  • Wine dlls/user32/dialog.c (LGPL-2.1+): DIALOG_ParseTemplate32 and DIALOG_GetControl32 implement exactly this parse.
  • MinGW-w64 mingw-w64-headers/include/winuser.h: DLGTEMPLATE, DLGITEMTEMPLATE, DS_* flags.
  • https://github.com/mirror/mingw-w64 @ 93f3505a758fe70e56678f00e753af3bc4f640bb · license: BSD-2-Clause (read from COPYING; GitHub's detector did not classify it)
    MinGW-w64 headers: winuser.h has DLGTEMPLATE, DLGITEMTEMPLATE, ACCEL and the DS_*/FVIRTKEY constants.
    Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2024-09-25
  • https://github.com/wine-mirror/wine @ 7298a818b79446bae153b8d5aa27235ab3703bf9 · license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize COPYING.LIB)
    Wine (LGPL-2.1+): user32 dialog.c, menu.c, resource.c parse the dialog, menu and accelerator resource formats; include/atlbase.h has the ATL object/interface map structs.
    Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2026-10-16

Evidence & references

  • Read in Wine commit 7298a818b7 and MinGW-w64 commit 93f3505a75, see the attached facts. Unverified: the charset byte after italic in DLGTEMPLATEEX is taken from Microsoft's documentation of DLGTEMPLATEEX (Wine reads the italic from the low byte of that word and skips the high byte).