ANI (file format)
| ANI | |
|---|---|
| Filename extension |
.ani |
| Internet media type | application/x-navi-animation |
| Magic number | ACON (4 bytes, ASCII) |
| Developed by | Microsoft |
| Type of format | animated raster image format for mouse cursors[1] |
| Container for | CUR frames |
The ANI file format is a graphics file format used for animated mouse cursors on the Microsoft Windows operating system.[2]
The format is based on the Microsoft Resource Interchange File Format,[3] which is used as a container for storing the individual frames (which are standard Windows cursors) of the animation.
History
[edit]The concept of an animated mouse pointer originated on OS/2 Presentation Manager, whose animated pointers were produced by an early Microsoft animation tool later ported to Windows NT.[citation needed] The RIFF/ACON container was not part of the original 1991 RIFF specification;[3] the ACON form type was registered by Microsoft in April 1993.[4] Early third-party documentation described the AF_ICON flag in the anih header as selecting between two frame formats: with the flag set, each frame is a complete icon or cursor resource; without it, frames would be raw device-independent bitmaps described by the cx, cy, cBitCount and cPlanes header fields.[5] This raw-bitmap mode did not appear in Microsoft's own published specification, however, and no version of Windows accepts a frame with the flag unset; in every animated cursor shipped with Windows the flag is set and those four header fields are zero.[citation needed]
The Animated Cursor Editor for Windows NT (ANIEDIT) provides a reference implementation of the ANI format. Its source code was distributed as a sample in the Windows SDK — as source only, with compiled binaries provided instead in the Windows 95 and Windows NT Resource Kits[5] — and is preserved in the MSDN October 2001 Library.[6]
The 16-bit Windows 3.x line had no animated cursor support of any kind.[citation needed] Windows NT 3.5 was the first version to load and display animated cursors, and shipped a set of ANI files — such as the animated hourglass — as part of its default cursor scheme; these early frames were 16-color (4 bpp) 32×32 images, some using a reversing "ping-pong" playback sequence.[citation needed] Windows 95 brought animated cursor support to the consumer line, adding a monochrome (1 bpp) fallback image to the first frame for display adapters running in 16 colors.[citation needed] On Windows 9x, animating a cursor required a protected-mode disk driver together with a suitable display driver; on systems lacking them the pointer was shown in color but did not animate.[7]
Windows Vista introduced 32-bit color cursors with its Aero theme, and its animated cursors were the first to store several sizes within each frame so that a larger pointer could be drawn at higher display scaling — the built-in aero_busy.ani, for example, carries 32×32, 48×48 and 64×64 variants in every frame, for 100%, 150% and 200% scaling respectively.[citation needed]
File structure
[edit]An ANI file is a RIFF container with the chunk identifier ACON. It contains a mandatory animation header chunk (anih), a mandatory list of frame chunks (fram), and optional chunks for per-step timing (rate), frame sequencing (seq), and metadata (INFO).
#define AF_ICON 0x1
typedef struct {
DWORD cbSizeof; // 36
DWORD cFrames; // unique frame count
DWORD cSteps; // animation step count
DWORD cx, cy; // unused (legacy)
DWORD cBitCount, cPlanes; // unused (legacy)
DWORD jifRate; // default rate in jiffies (1/60 s)
DWORD fl; // AF_ICON (required); see Sequence and playback
} ANIHEADER;
RIFF('ACON'
[LIST('INFO'
[INAM(<ZSTR>)] // title (optional)
[IART(<ZSTR>)] // author (optional)
)]
[DISP(<DWORD> <data>)] // display preview (optional, defined in spec; unused in practice)
'anih'(<ANIHEADER>)
['rate'(<DWORD[cSteps]>)] // per-step rates in jiffies; see Timing
['seq '(<DWORD[cSteps]>)] // per-step frame indices (0-based); see Sequence and playback
LIST('fram' // cFrames icon chunks
'icon'(<icon_data_1>)
'icon'(<icon_data_2>)
...
)
)
The cbSizeof field must be exactly 36; any other value causes the file to fail to load.[citation needed] The anih chunk must appear before rate, seq , and the fram list; this is the only strict ordering constraint defined in the specification.[4] The INFO list may contain standard RIFF metadata sub-chunks, including INAM (title) and IART (author). All are null-terminated strings encoded in ASCII or the system ANSI code page; the original RIFF specification defines ISO 8859/1 as the default.[3] Windows ignores all INFO sub-chunks when loading a cursor; the metadata is only read by third-party editors.
Frames
[edit]The AF_ICON flag in anih is required and marks each frame in the fram list as a complete CUR-format resource.[4] Because the frame format is identical to a standalone CUR file, a frame may contain images at multiple sizes within a single chunk — this capability is part of the original 1993 specification. Within each icon chunk, the dwImageOffset field of each directory entry is relative to the start of the chunk content and must fit within 16 bits.
cFrames must be at least 1; a value of 1 is treated as a static cursor. Both cFrames and cSteps are effectively 16-bit on modern Windows: non-zero upper bits cause the file to fail to load.[citation needed] Without a seq chunk, cSteps must not exceed cFrames; with one, every frame index in the table must be less than cFrames.
Because frames use the ICO/CUR image format, they may also contain PNG-compressed images since Windows Vista (see PNG format). PNG compression can reduce file size by around 40× compared to uncompressed BMP for typical semi-transparent cursors; existing Windows cursor tools only emit uncompressed BMP frames.
Timing
[edit]Frame rates are measured in jiffies, with one jiffy equal to 1/60 of a second, or approximately 16.7 ms.[8] The anih header specifies a default rate (jifRate) applied to all steps. The optional rate chunk overrides this with a per-entry rate table, allowing individual frames to be held for different durations. The table must contain exactly cSteps entries.
Sequence and playback
[edit]The optional seq chunk contains a table of cSteps frame indices, mapping each animation step to a frame index and allowing frames to be played in any order and reused across multiple steps. For example, an animation with three unique images and the step sequence 0–1–2–1–0 only needs to store three frames while playing five steps, saving storage space. The fl field also carries a 0x2 bit, not part of Microsoft's own published specification but described in early third-party documentation as a sequence flag — conventionally referred to as AF_SEQUENCE — set when a seq chunk is present.[5] It is informational only: Windows parses the seq chunk unconditionally whenever it appears, regardless of whether the bit is set.[citation needed]
When an ANI file is used as a Windows cursor, the sequence loops continuously; the fl field defines no play-once or other playback-control bits.[9] An application can also draw a chosen animation step directly with the Win32 DrawIconEx function, whose istepIfAniCur parameter selects the frame index to render when the handle refers to an animated cursor.[10]
Animated cursor resources
[edit]ANI files stored in Portable Executable binaries use the resource type RT_ANICURSOR (21) for animated cursors and RT_ANIICON (22) for animated icons.[11] Unlike static icons and cursors, an animated cursor is embedded as a single unmodified RIFF/ACON blob rather than split into a group resource and individual frame resources.[12] The Win32 LoadImage, LoadCursor, and CreateIconFromResource functions detect the RIFF/ACON signature automatically and route it to the ANI loader. In a resource-definition script, an animated cursor or icon is declared with the ordinary CURSOR or ICON statement pointing at the .ani file; the resource compiler recognises the animated format and emits an RT_ANICURSOR or RT_ANIICON resource rather than the static RT_CURSOR/RT_ICON group-and-image pair.[13][14]
Security
[edit]Because Windows renders animated cursors automatically from files that may come from untrusted sources, the ANI parser has been the target of several remote-code-execution vulnerabilities. On January 11, 2005, Microsoft's security bulletin MS05-002 fixed three such flaws: insufficient validation of cursor, animated-cursor, and icon files could allow remote code execution (CVE-2004-1049) or crash the kernel (CVE-2004-1305) from a malformed file, and a specific stack-based buffer overflow in the animation-header length field of an ANI file could allow code execution (CVE-2005-0416); affected systems ranged from Windows NT through Windows Server 2003.[15][16] In late March 2007, a further animated-cursor parsing flaw (CVE-2007-0038) — discovered by Alexander Sotirov of Determina Security Research — was disclosed and was already being exploited in the wild. It was a recurrence of the MS05-002 class of bug: the validation added in 2005 checked the length of only the first animation header, so a file carrying a second, malformed anih header bypassed the check and overflowed a fixed-size buffer.[17] Microsoft released bulletin MS07-017 the following week, covering Windows 2000, Windows XP, Windows Server 2003, and Windows Vista.[18][19] Later that year, a buffer overflow in the ANI handling of the third-party image viewer IrfanView 3.99 — showing the risk was not limited to Microsoft's own code — was assigned CVE-2007-1867.[20]
See also
[edit]References
[edit]- ↑ "Details for: Microsoft Animated Cursor Format". The National Archives. Retrieved April 1, 2025.
- ↑ "ANI File - What is an .ani file and how do I open it?". fileinfo.com. Retrieved 2024-04-27.
- 1 2 3 Multimedia Programming Interface and Data Specifications 1.0 (PDF). IBM Corporation and Microsoft Corporation. August 1991.
- 1 2 3 Multimedia Standards Update, New Multimedia Data Types and Data Techniques (PDF). Microsoft Corporation. April 15, 1994.
- 1 2 3 Murray, James D.; vanRyper, William (1996). "Microsoft RIFF". Encyclopedia of Graphics File Formats (2nd ed.). O'Reilly & Associates. ISBN 1-56592-161-5.
- ↑ "MSDN Library October 2001 - Internet Archive". archive.org. Retrieved 2025-05-03.
- ↑ "Animated Mouse Pointers May Not Work in Windows". Microsoft Knowledge Base. Microsoft Corporation. KB123334. Archived from the original on 2007-01-06. Retrieved 2026-07-29.
{{cite web}}: CS1 maint: bot: original URL status unknown (link) - ↑ "Description of the ani file format". AniTuner. GDGSoft. Retrieved 2026-07-30.
- ↑ "file-format-ani". www.daubnet.com. Retrieved 2025-05-03.
- ↑ "DrawIconEx function (winuser.h) - Win32 apps". Microsoft Learn. Microsoft Corporation. 2018-12-05. Retrieved 2026-08-03.
- ↑ "Resource Types (Winuser.h) - Win32 apps". Microsoft Learn. Microsoft Corporation. 2018-05-31. Retrieved 2026-07-30.
- ↑ "Resource File Formats - Win32 apps". Microsoft Learn. Microsoft Corporation. 2018-05-31. Retrieved 2026-07-30.
- ↑ "Resource-Definition Statements - Win32 apps". Microsoft Learn. Microsoft Corporation. 2018-05-31. Retrieved 2026-08-03.
- ↑ "CURSOR resource - Win32 apps". Microsoft Learn. Microsoft Corporation. 2018-05-31. Retrieved 2026-08-03.
- ↑ "Microsoft Security Bulletin MS05-002 – Critical: Vulnerability in Cursor and Icon Format Handling Could Allow Remote Code Execution (891711)". Microsoft Corporation. January 11, 2005. Retrieved 2026-07-29.
- ↑ eEye Digital Security (January 11, 2005). "Windows ANI File Parsing Buffer Overflow". Retrieved 2026-07-29.
- ↑ Gonchigar, Shashank (October 19, 2007). "ANI vulnerability: History repeats". SANS Institute (GIAC GCIH Gold Certification). Retrieved 2026-07-29.
- ↑ Frantzen, Swa (March 30, 2007). "Windows Animated Cursor Handling vulnerability - CVE-2007-0038". SANS Internet Storm Center. Retrieved 2026-07-29.
- ↑ "Microsoft Security Bulletin MS07-017 – Critical: Vulnerabilities in GDI Could Allow Remote Code Execution (925902)". Microsoft Corporation. April 3, 2007. Retrieved 2026-07-29.
- ↑ "CVE-2007-1867". CVE. MITRE Corporation. Retrieved 2026-07-29.
