Guides

How Windows Icons Are Stored in EXE Files

How Windows Icons Are Stored in EXE Files

Windows icons are embedded inside an executable’s Portable Executable (PE) .rsrc section as individual RT_ICON bitmap or PNG image frames linked together by an RT_GROUP_ICON directory structure. Windows reads the group directory to select and extract the optimal resolution and color depth variant for rendering across system UI components.

When you view a desktop shortcut or taskbar icon, the graphic displayed is not an external image file on disk. Instead, Windows binaries compile visual branding directly into the executable container. Understanding executable icons requires exploring PE file headers, resource tree hierarchies, and Win32 APIs.

This technical guide explains how Windows binaries structure icon resources, how resolution assets are reassembled into .ico files, and how to extract icons safely using a browser-based parser.

Key Definitions: PE Format, .rsrc, ICO Containers, and Icon Resources

To analyze how Windows binaries store embedded graphics, we must clarify the core system structures involved:

  • PE (Portable Executable) File Format: The binary format used by Windows for executables (.exe), DLLs (.dll), and drivers (.sys). Based on COFF, PE defines how code and data map in memory and on disk.
  • Resource Section (.rsrc): A read-only data section in a PE binary structured as a hierarchical directory tree. It holds non-code assets such as icons, cursors, dialog layouts, string tables, version manifests, and bitmaps.
  • ICO File Container: The standard Windows graphic format (.ico) designed to encapsulate multiple raster image frames at varying resolutions (16×16, 32×32, 48×48, 256×256 pixels) and color depths (4-bit, 8-bit, 24-bit, 32-bit ARGB) in one container.
  • RT_ICON (Resource Type 3): The binary resource type corresponding to a single raster image frame (a raw DIB header or PNG byte stream) stored within the .rsrc tree.
  • RT_GROUP_ICON (Resource Type 14): The directory resource entry acting as the master index for an icon family. It contains metadata descriptors for each icon size and color depth, mapping them to corresponding RT_ICON resource IDs.

Internal Structure of a Windows PE File

Every Windows executable follows a binary layout mandated by the Microsoft PE/COFF specification. The file topology consists of nested headers and section descriptors mapping file offsets into memory:

  1. MS-DOS Header (IMAGE_DOS_HEADER): A 64-byte header located at offset 0x00 starting with signature MZ (0x5A4D). Field e_lfanew at offset 0x3C points to the PE header offset.
  2. MS-DOS Stub: A legacy 16-bit program displaying "This program cannot be run in DOS mode" if executed under MS-DOS.
  3. PE Header / NT Headers (IMAGE_NT_HEADERS): Starts at offset e_lfanew with signature PE\0\0 (0x00004550). Encapsulates File Header (machine architecture, section counts, timestamp) and Optional Header (entry point, alignment, and Data Directories array where Index 2 points to IMAGE_DIRECTORY_ENTRY_RESOURCE).
  4. Section Table (IMAGE_SECTION_HEADER Array): Maps virtual memory addresses to physical raw file offsets for sections including .text (code), .data (data), .rdata (read-only data), and .rsrc (resources).
  5. The .rsrc Directory Tree: A 3-level hierarchical tree: Level 1 (Resource Type: Type 3 for RT_ICON, Type 14 for RT_GROUP_ICON), Level 2 (Resource Name / ID), and Level 3 (Language ID pointing to IMAGE_RESOURCE_DATA_ENTRY with RVA offset and size).

How Icons Are Stored Inside the .rsrc Section

A PE binary splits icon components into directory headers (RT_GROUP_ICON) and individual image payloads (RT_ICON).

The Disk ICO Header vs. RT_GROUP_ICON Header

On disk, an .ico file begins with a 6-byte ICONDIR header followed by 16-byte ICONDIRENTRY records containing image dimensions, color depth, image size, and a 4-byte dwImageOffset DWORD. Inside a PE binary, the RT_GROUP_ICON resource contains a GRPICONDIR header and 14-byte GRPICONDIRENTRY records. The structure comparison is shown below:

Field Name Data Type Disk ICO Entry (ICONDIRENTRY) PE Resource Entry (GRPICONDIRENTRY)
Width & Height BYTE × 2 Pixel width/height (0 = 256px) Pixel width/height (0 = 256px)
Color Count & Reserved BYTE × 2 Palette colors and reserved byte Palette colors and reserved byte
Planes & Bit Count WORD × 2 Planes and bits per pixel Planes and bits per pixel
Resource Size DWORD Payload size in bytes Payload size in bytes
Identifier / Offset WORD / DWORD dwImageOffset (4-byte offset) nID (2-byte RT_ICON Resource ID)

While a disk .ico file uses a 4-byte file pointer (dwImageOffset), the RT_GROUP_ICON structure replaces it with a 2-byte resource ID (nID) matching a child RT_ICON entry in the .rsrc tree.

Reassembling an ICO File from PE Resources

To rebuild a valid .ico file from an EXE binary, an extractor parser executes the following steps:

  1. Locate the target RT_GROUP_ICON entry in the Level 2 tree.
  2. Read the GRPICONDIR header to determine frame count (idCount).
  3. Iterate through each GRPICONDIRENTRY record in the group directory.
  4. Extract the 2-byte nID value and navigate to the matching RT_ICON node in the .rsrc tree.
  5. Read the raw image bytes referenced by the IMAGE_RESOURCE_DATA_ENTRY of that RT_ICON.
  6. Construct standard disk ICONDIR and ICONDIRENTRY headers, converting each 2-byte nID into a calculated 4-byte dwImageOffset pointer.
  7. Concatenate the headers with harvested RT_ICON byte streams to output a compliant .ico file.

Icon Resolution, Color Depth, and PNG Compression Standards

Windows desktop environments require applications to render crisp icons across diverse UI contexts and DPI scaling settings (100% to 500%). Consequently, an application main icon group embeds multiple image variants.

Standard Resolution Variants

A complete application icon group packages several standard dimension variants:

  • 16×16 pixels: Window title bar, taskbar small icons list, Explorer details view, system tray.
  • 24×24 & 20×20 pixels: High-DPI title bar buttons and context menus.
  • 32×32 pixels: Explorer list view, desktop shortcuts, taskbar medium icons.
  • 48×48 pixels: Explorer large icons view and control panel applets.
  • 64×64 & 96×96 pixels: High-DPI display scaling (200% and 300%).
  • 256×256 pixels: Explorer Extra Large icons, Jumbo view, Windows Search previews, Start Menu tiles.

Color Depths and Alpha Transparency

Legacy Windows versions relied on 4-bit (16-color) and 8-bit (256-color) palette bitmaps with 1-bit monochrome AND mask transparency. Since Windows XP, binaries use 32-bit ARGB color depth, combining 24 bits of true color with an 8-bit alpha channel providing 256 levels of translucent edge blending.

PNG Compression in 256×256 Icon Resources

An uncompressed 256×256 32-bit ARGB bitmap requires ~256 KB of pixel data. To prevent executable bloat, Microsoft added support in Windows Vista for 256×256 RT_ICON resources to be stored as PNG compressed streams.

When an icon frame is 256×256 pixels, the RT_ICON resource contains a PNG image—starting with the magic signature 89 50 4E 47 0D 0A 1A 0A—rather than a DIB header. This reduces frame footprint from 256 KB down to 10–40 KB. The Windows graphics subsystem (user32.dll and gdiplus.dll) automatically detects the PNG header signature and decompresses the image stream in memory.

How Windows Loads Application Icons via Win32 APIs

When Windows Explorer displays a file listing, the operating system invokes specific Win32 API functions to query and decode icon resources from target binary files:

Primary Win32 Resource and Shell APIs

  • LoadIconA / LoadIconW: Loads a specified icon resource from an executable module handle (e.g., IDI_APPLICATION).
  • ExtractIconExA / ExtractIconExW: A Shell API exported by shell32.dll that extracts arrays of large (32×32) and small (16×16) icon handles (HICON) from `.exe`, `.dll`, or `.ico` files.
  • SHGetFileInfoA / SHGetFileInfoW: The primary Shell API used by Windows Explorer. By specifying SHGFI_ICON with SHGFI_LARGEICON or SHGFI_SMALLICON, Explorer retrieves the system image list index and icon handle matching current display DPI and view modes.

Icon Group Precedence Rules

An executable binary can contain dozens of RT_GROUP_ICON directories for documents, toolbars, and settings. Windows Explorer determines which icon group represents the primary application icon by applying a strict numerical rule:

Windows Explorer automatically selects the RT_GROUP_ICON directory with the lowest numeric Resource ID (typically ID 1 or MAINICON) as the main application icon. Software developers assign Resource ID 1 to their primary branding icon in resource scripts (.rc) to ensure consistent Explorer display.

How to Extract High-Resolution ICO and PNG Icons from an EXE Without Running It

Executing an untrusted .exe file just to capture its icon graphic poses severe cybersecurity risks. Malicious binaries can execute background payloads or drop ransomware the moment they are launched on a desktop system.

To pull original high-resolution .ico files and 256×256 PNG graphics out of an executable binary safely without running the program, use a browser-based parser:

  1. Open the Icon Extractor tool in your web browser.
  2. Drag and drop your target .exe, .dll, .cpl, or .sys binary into the browser interface.
  3. The client-side JavaScript engine reads the file into an ArrayBuffer, parses the PE .rsrc directory tree, and resolves all RT_GROUP_ICON and RT_ICON resources.
  4. Select your target icon group and download the reassembled multi-resolution .ico container or export isolated 256×256 PNG master files directly to your device.

Because extraction runs locally in client-side memory, your executable file is never uploaded to an external server, preserving privacy. For deeper binary analysis, explore the EXE Extractor and our file extraction tools.

Security Benefits of Inspecting EXE Icon Resources

Inspecting the .rsrc directory of executable files provides valuable security analysis capabilities for malware analysts and system administrators:

1. Detecting Malware Icon Spoofing Attacks

Attackers frequently disguise malicious executable payloads as harmless documents (PDFs, Word documents). Cybercriminals attach a PDF icon to an .exe binary named Invoice_2026.pdf.exe, relying on Windows’ default hidden file extension setting to trick users into launching the file.

By inspecting the PE resource tree with an offline parser, analysts expose discrepancies between file extensions, binary headers, and resource entries.

2. Identifying Trojanized Installers

Threat actors regularly copy legitimate icon resources from popular software (such as Google Chrome or Zoom) into trojanized installers. Security tools compare embedded icon hashes and signatures against known binaries to flag impersonation.

3. Forensic Analysis of Hidden Payloads

Malware authors occasionally store payloads or shellcode inside non-standard RT_ICON or custom resource tables in .rsrc to bypass antivirus scanners. Auditing resource sizes reveals hidden anomalies.

Frequently Asked Questions

Where are application icons stored inside a Windows EXE file?
Application icons are stored directly inside the executable’s Portable Executable (PE) .rsrc (resource) section as individual raster image frames (RT_ICON, Resource Type 3) mapped to a group directory header (RT_GROUP_ICON, Resource Type 14).

What is the difference between RT_ICON and RT_GROUP_ICON?
RT_ICON represents an individual raster bitmap or PNG image stream at a specific resolution and color depth. RT_GROUP_ICON is a directory index resource that groups multiple RT_ICON child entries into a single logical icon family and specifies their dimensions and resource IDs.

How does an ICO file container differ from a standard PNG or BMP image?
A standard PNG or BMP file contains a single graphic image at a fixed resolution. An ICO file is a multi-resolution container format that encapsulates multiple image frames at different dimensions (16×16, 32×32, 48×48, 256×256 pixels) and color depths in one file header.

Why do EXE files contain multiple sizes and color depths of the same icon?
Windows displays icons in many UI contexts—including window title bars (16×16), taskbar buttons (32×32), desktop shortcuts (48×48), and Explorer jumbo views (256×256). Embedding multiple sizes ensures the operating system renders crisp graphics without scaling artifacts across different display DPI settings.

Can I extract icons from Windows DLL files like shell32.dll or imageres.dll?
Yes. Dynamic-Link Libraries (.dll) follow the exact same PE binary structure as .exe files and store icons in their .rsrc section. System DLLs like shell32.dll and imageres.dll contain hundreds of standard Windows system icons that can be extracted using an icon parser.

How does Windows Vista and newer compress 256×256 high-resolution icons?
To prevent large icons from ballooning binary file sizes, Windows Vista introduced PNG compression for 256×256 RT_ICON resources. Instead of uncompressed DIB bitmaps, 256×256 icon frames are stored as raw PNG streams starting with the magic header signature 89 50 4E 47, reducing file size by up to 80%.

Is it safe to extract icons from an unknown or untrusted EXE file online?
Yes, provided you use a browser-based parser like the Icon Extractor. Browser-based extraction parses PE binary structures entirely in client-side WebAssembly memory without executing the binary or uploading it to a remote server, eliminating malware execution risks.

Sources & References

Last updated: 18 September 2026.

Shah Abrar Ahmad - Founder & Lead Engineer
Lead Architect & Founder

Software architect and technical web engineer specializing in browser-based zero-knowledge file parsing, technical SEO, and data extraction security. Built EasyExtract to give users 100% private in-browser tools with zero cloud uploads.

Keep reading