Format:Windows menu resource (RT_MENU)
| Platforms | Platform:Windows |
|---|---|
| Extensions | RT_MENU (4) resource |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
RT_MENU (type 4) resources: a version word (0 classic MENUITEMTEMPLATE, 1 extended MENUEX) and a flat list of items with an MF_END flag marking the last item of each (sub)menu.
Where it lives
Menus are RT_MENU (4) entries of the resource tree (Format:PE (Portable Executable)/Resource directory); LoadMenuIndirect takes the same blob. The item ids are the WM_COMMAND ids that a program (or its Library:MFC#Message maps) dispatches on.
Header
u16 wVersion (0 = classic, 1 = extended) and u16 cbHeaderSize (extra header bytes to skip: 0 for classic; the extended form uses 4, a help id dword, in the header). The items start cbHeaderSize bytes after these four bytes. Any other version fails to load (Wine: "version %d not supported").
Classic items (version 0)
u16 mtOption (flags), then if not MF_POPUP: u16 mtID; then a NUL-terminated UTF-16 text. A popup item (MF_POPUP 0x0010) has no id and is directly followed by its child items, ended by an item with MF_END (0x0080). A separator is an item with empty text and id 0. Flags are the MF_* values: 0x0001 GRAYED, 0x0002 DISABLED, 0x0008 CHECKED, 0x0010 POPUP, 0x0040 MENUBARBREAK, 0x0020 MENUBREAK, 0x0080 END. The top-level list also ends with MF_END.
Extended items (version 1, MENUEX)
Each item: u32 fType (MFT_), u32 fState (MFS_), u32 wID, u16 resInfo (bit 0 set = popup, 0x80 = last item of this menu), then the UTF-16 text starting on a WORD boundary, then padding to a DWORD boundary. A popup item is followed by a u32 helpId, then its child items. Wine converts an empty text without MFT_SEPARATOR to a separator.
Reversing notes
- Menu strings are the quickest list of a program's features; ids are the command numbers.
- A menu shown through
TrackPopupMenuis often built from a resource menu whose first item is a popup (the program loads it and callsGetSubMenu(menu, 0)). - The accelerator table (Format:Windows accelerator table resource (RT_ACCELERATOR)) uses the same command ids.
Code & repositories
- Wine
dlls/user32/menu.c:MENU_ParseResource,MENUEX_ParseResource,LoadMenuIndirectW. - 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
- Wine commit 7298a818b7, see the attached fact. Unverified: the MF_* flag values other than MF_END and MF_POPUP are quoted from the Win32 headers from memory.