Hubbry Logo
Windows MetafileWindows MetafileMain
Open search
Windows Metafile
Community hub
Windows Metafile
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Windows Metafile
Windows Metafile
from Wikipedia

Windows Metafile (WMF) is an image file format originally designed for Microsoft Windows in the 1990s. The original Windows Metafile format was not device-independent (though could be made more so with placement headers) and may contain both vector graphics and bitmap components. It acts in a similar manner to SVG files. WMF files were later superseded by Enhanced Metafiles (EMF files) which did provide for device-independence. EMF files were then themselves enhanced via EMF+ files.

Essentially, a metafile stores a list of records consisting of drawing commands, property definitions and graphics objects to display an image on screen.[1] The drawing commands used are closely related to the commands of the Graphics Device Interface (GDI) API used for drawing in Microsoft Windows.

There are three major types of metafiles – a WMF is a 16-bit format introduced in Windows 3.0. It is the native vector format for Microsoft Office applications such as Word, PowerPoint, and Publisher. As of April 2024, revision 18 of the Windows Metafile Format specification is available.[2] EMF files, which replaced WMF files, work on the same principle only it is a 32-bit file format that also allows for the embedding of private data within "comment" records.[3] EMF+ is an extension to EMF files and embedded in these comment records, allowing for images and text using commands, objects and properties that are similar to Windows GDI+.[4]

History

[edit]

The original 16 bit WMF file format was fully specified in volume 4 of the 1992 Windows 3.1 SDK documentation[5] (at least if combined with the descriptions of the individual functions and structures in the other volumes), but that specification was vague about a few details. These manuals were published as printed books available in bookstores with no click through EULA or other unusual licensing restrictions (just a general warning that if purchased as part of a software bundle, the software would be subject to one).

Over time the existence of that historic specification was largely forgotten and some alternative implementations resorted to reverse engineering to figure out the file format from existing WMF files, which was difficult and error prone.[6] In September 2006, Microsoft again published the WMF file format specification in a more complete form[7] in the context of the Microsoft Open Specification Promise, promising to not assert patent rights to file format implementors.[8]

Microsoft later deprecated WMF files in favour of 32-bit EMF files as WMF files had real issues with device independence, despite the use of a "placeable" file header which provided basic device independence. Microsoft found that developers who use the format were "[embedding] application, location, or scaling comments in the metafiles... Others added headers to the metafile that provided various application-specific information", causing major compatibility issues.[9] Thus, in 1992 with Windows NT 3.1, Microsoft introduced the Enhanced Metafile format (EMF)[10] — a format which was based on the Win32 API and with which they built-in device independence.[11][9] — these were also known as NT metafiles.[12] With the release of Windows XP and GDI+, the set of records had to be significantly increased and so Microsoft released EMF+ as an extension to the existing EMF file format.[10][13]

Metafile structure

[edit]
Comparison of Windows Metafiles – WMF files can include EMF+ records

WMF, EMF and EMF+ files all consist of a series of records that are played back to produce graphical output. Some records define objects which can specify graphical objects used to determine how graphics should be drawn (e.g. pens specify the color and width of lines). Each of these objects are stored in metafiles and are placed into an object table, which tracks the usage of graphic objects while processing the metafile. The object table is an associative array of indexes to graphical object structures defined within the metafile.

WMF and EMF files handle object processing differently to EMF+ records in EMF files. As a WMF and EMF file is being processed, the records are read into an object table once an object is defined. If an object is deleted then the object is released from the table and the identifier can be reused. Notably an object will not be used until it is specifically selected during record playback.[14][15] This differs for EMF+ files, which also use an associative array via a hashmap which records the object along with an object identifier. However, unlike WMF and EMF files which can delete an object, when a new object is created that has the same index as an existing object, the entry in the table is replaced with the new object. An EMF file also does not need to specifically select an object before it is used.[16]

WMF

[edit]
Windows Metafile
Filename extension
.wmf
Internet media type
image/wmf[10]
Uniform Type Identifier (UTI)com.microsoft.wmf[10]
Type of formatVector graphics
Extended toEMF
Structures of original and placeable Windows metafiles[17]

WMF files were not originally designed to be device independent, meaning that a file could not be played back on output devices that differed from the original device on which the file was recorded. A partial solution to this issue was invented by Aldus Corporation, who added an additional "placeable" header, called the "APM header",[18] which added a bounding rectangle, a metafile version, metafile size, number of objects in the metafile and the size of the largest single record in the metafile.[19][20] This was later incorporated into the WMF format by Microsoft, starting in Windows 2000.[21]

WMF files are structured by a series of records, starting with a number of control records: the header record,[19][22] the aforementioned optional placeable record,[23] and finished by an end of file record.[19][24]

Encapsulated by the control records are the records that make up the image itself. These records work within what is known as the playback device context, which is the collection of properties and objects that make up a device's graphical environment as the metafile is being "played back" onto this output device.[25]

Records other than control records can be largely grouped into bitmap records, drawing records, object records, state records and escape records.

Bitmap records

[edit]

Bitmap records manage and output bitmap images.

Name Description
META_BITBLT Specifies how to do a bit block transfer. These records can specify a bitmap to use as the source, or a region.[26]
META_DIBBITBLT Specifies how to do a bit block transfer of a device-independent bitmap image. These records can specify a bitmap to use as the source, or a region.[27]
META_DIBSTRETCHBITBLT Specifies how to do a bit block transfer of a device-independent bitmap image, but allows for expansion or contraction of the image. These records can specify a bitmap to use as the source, or a region.[28]
META_SETDIBTODEV Specifies color to set a block of pixels in a device-independent bitmap image. These records can specify a bitmap to use as the source, or a region.[29]
META_STRETCHBLT Specifies how to do a bit block transfer, but allows for expansion or contraction of the image.[30]
META_STRETCHDIB Specifies how to do a bit block transfer of a device-independent bitmap image, but allows for expansion or contraction of the image. These records can specify a bitmap to use as the source, or a region.[31]

Drawing records

[edit]

Drawing records produce graphics output.

Name Description
META_ARC Draws an elliptical arc.[32]
META_CHORD Draws a chord.[33]
META_ELLIPSE Draws an elliptical arc.[34]
META_EXTFLOODFILL Fills an area with a brush.[35]
META_EXTTEXTOUT Draw text with font, background color and text color of the playback device context.[36]
META_FILLREGION Fills a region with a specified brush.[37]
META_FLOODFILL Fills an area with a brush.[38]
META_FRAMEREGION Draws a border around a region of the page with a brush.[39]
META_INVERTREGION Paints a region of the graphic with inverted colors.[40]
META_LINETO Draws a half-open line from the drawing position defined in the playback device context to a specified point.[41]
META_PAINTREGION Paint a region with the current brush specified in the playback device context.[42]
META_PATBLT Paint a region with the current brush specified in the playback device context and then combine the brush color and surface color(s) using a raster operation.[43]
META_PIE Draw a pie-shaped wedge bounded by the intersection of an ellipse and two radials — the line is set via the pen set via the playback device context, and the area bounded by the pie shape is filled in by the current brush of the playback device context.[44]
META_POLYLINE Draws a series of line segnments by connecting the points in a specified array.[45]
META_POLYGON Paints a polygon consisting of two or more vertices connected by straight lines. The polygon is outlined by using the pen and filled by using the brush and polygon fill mode that are defined in the playback device context.[46]
META_POLYPOLYGON Paints a series of closed polygons, which may overlap. Each polygon is outlined by using the pen and filled by using the brush and polygon fill mode that are defined in the playback device context.[47]
META_RECTANGLE Paints a rectangle, which is outlined by using the pen and filled by using the brush and is filled by using the brush that is defined in the playback device context.[48]
META_ROUNDRECT Paints a rectangle with rounded corners. The rectangle is outlined by using the pen and filled by using the brush and is filled by using the brush that is defined in the playback device context.[49]
META_SETPIXEL Sets the pixel at the specified coordinates to the specified color.[50]
META_TEXTOUT Outputs a character string at the specified location by using the font, background color, and text color that are defined in the playback device context.[51]

Object records

[edit]

Object records create and manage graphics objects. In WMF files there are two broad categories of objects – graphics objects and structure objects. Structure objects are not explicitly created or deleted in a WMF, they are instead of complex structures. For example, the BitmapCoreHeader contains information about the dimensions and color format of a device-independent bitmap,[52] which is itself part of a DeviceIndependentBitmap object.[53] A graphics object, however, specifies parameters for graphics output and during playback of the WMF it sets up the playback device context.[54]

Graphics objects can be brushes (defines the style, color and pattern of a brush which defines how to paint an area of the graphic), fonts (defines properties that affect how text is displayed), palettes (specifies colors as device-independent values, defined by an application), pens (specifies the graphical attributes of a line), and regions (which specify line and curve segments that define a shape).[54]

Name Description
META_CREATEBRUSHINDIRECT Creates a brush object from a LogBrush (logical brush) object.[55]
META_CREATEFONTINDIRECT Creates a brush object from a font object.[56]
META_CREATEPALETTE Creates a palette object.
META_CREATEPATTERNBRUSH[57] Creates a brush object from a LogBrush (logical brush) object.[58]
META_CREATEPENINDIRECT Creates a pen object.[59]
META_CREATEREGION Creates a region object.[60]
META_DELETEOBJECT Delete an object.[61]
META_CREATEBRUSHINDIRECT Creates a brush object from a LogBrush (logical brush) object.[62]
META_DIBCREATEPATTERNBRUSH Creates a brush object from a device-independent bitmap.[63]
META_SELECTCLIPREGION Specifies the region object that will be the current clipping region.[64]
META_SELECTOBJECT Selects the object that will be the current object for the playback device context, which works on all graphics objects except palette objects, which must be set with META_SELECTPALETTE.[65]
META_SELECTPALETTE Selects the logical palette for the playback device context.[66]

State records

[edit]

State records manage the graphics properties of the playback device context.[67]

Name Description
META_ANIMATEPALETTE Redefines entries in the logical palette that is defined in the playback device context with a specified Palette Object.[68]
META_EXCLUDECLIPRECT Sets the clipping region that is defined in the playback device context to the existing clipping region minus a specified rectangle.[69]
META_INTERSECTCLIPRECT Sets the clipping region that is defined in the playback device context to the intersection of the existing clipping region and a specified rectangle.[70]
META_MOVETO Sets the output position in the playback device context to a specified point.[71]
META_OFFSETCLIPRGN Moves the clipping region that is defined in the playback device context by specified offsets.[72]
META_OFFSETVIEWPORTORG Moves the viewport origin in the playback device context by specified horizontal and vertical offsets.[73]
META_OFFSETWINDOWORG Moves the output window origin in the playback device context by specified horizontal and vertical offsets.[74]
META_REALIZEPALETTE Maps entries from the logical palette that is defined in the playback device context to the system palette.[75]
META_RESIZEPALETTE Redefines the size of the logical palette that is defined in the playback device context.[76]
META_RESTOREDC Restores the playback device context from a previously saved device context.[77]
META_SAVEDC Saves the playback device context for later retrieval.[78]
META_SCALEVIEWPORTEXT Scales the horizontal and vertical extents of the viewport that is defined in the playback device context using the ratios formed by specified multiplicands and divisors.[79]
META_SCALEWINDOWEXT Scales the horizontal and vertical extents of the output window that is defined in the playback device context using the ratios formed by specified multiplicands and divisors.[80]
META_SETBKCOLOR Sets the background color in the playback device context to a specified color.[81]
META_SETBKMODE Sets the background mix mode in the playback device context.[82]
META_SETLAYOUT Defines the layout orientation in the playback device context.[83]
META_SETMAPMODE Defines the mapping mode in the playback device context.[84]
META_SETMAPPERFLAGS Defines the algorithm that the font mapper uses when it maps logical fonts to physical fonts.[85]
META_SETPALENTRIES Defines RGB color values in a range of entries in the logical palette that is defined in the playback device context.[86]
META_SETPOLYFILLMODE Defines polygon fill mode in the playback device context for graphics operations that fill polygons.[87]
META_SETRELABS Unused record.[88]
META_SETROP2 Defines the foreground raster operation mixing mode in the playback device context.[89]
META_SETSTRETCHBLTMODE Defines the bitmap stretching mode in the playback device context.[90]
META_SETTEXTALIGN Defines text-alignment values in the playback device context.[91]
META_SETTEXTCHAREXTRA Defines inter-character spacing for text justification in the playback device context.[92]
META_SETTEXTCOLOR Defines the text foreground color in the playback device context.[93]
META_SETTEXTJUSTIFICATION Defines the amount of space to add to break characters in a string of justified text.[94]
META_SETVIEWPORTEXT Defines the horizontal and vertical extents of the viewport in the playback device context.[95]
META_SETVIEWPORTORG Defines the viewport origin in the playback device context.[96]
META_SETWINDOWEXT Defines the horizontal and vertical extents of the output window in the playback device context.[97]
META_SETWINDOWORG Defines the output window origin in the playback device context.[98]

Escape records

[edit]
WMF generic escape record

Escape records are a means to extend metafile functionality via records that are not otherwise defined as a WMF record type. Each escape record contains a record function, an escape function and potentially escape data.

The following escape records make up a WMF file.

Name Description
ABORTDOC Stops processing the current document.[99]
BEGIN_PATH Opens a path.[100]
CHECK_JPEGFORMAT Determines whether it can handle the given JPEG image.[101]
CHECK_PNGFORMAT Determines whether it can handle the given PNG image.[102]
CLIP_TO_PATH Applies a function to the current PostScript clipping path.[103]
CLOSE_CHANNEL Same as ENDDOC.[104]
DOWNLOAD_FACE Sets the font face name on the output device.[105]
DOWNLOAD_HEADER Downloads sets of PostScript procedures.[106]
DRAW_PATTERNRECT Draws a rectangle with a defined pattern.[107]
ENCAPSULATED_POSTSCRIPT Sends arbitrary encapsulated PostScript (EPS) data directly to the printer driver.[108]
END_PATH Ends a path.[109]
ENDDOC Notifies the printer driver that a new print job is ending.[110]
EPS_PRINTING Indicates the start and end of EPS printing.[111]
EXTTEXTOUT Draws text using the currently selected font, background color, and text color.[112]
GET_COLORTABLE Gets color table values from the printer driver.[113]
GET_DEVICEUNITS Gets the device units currently configured on the output device.[114]
GET_EXTENDED_TEXTMETRICS Gets the extended text metrics that are currently configured on the printer driver.[115]
GET_FACENAME Gets the font face name currently configured on the output device.[116]
GET_PAIRKERNTABLE Gets the font kern table currently defined on the output device.[117]
GET_PHYSPAGESIZE Retrieves the physical page size currently selected on the output device.[118]
GET_PRINTINGOFFSET Retrieves the offset from the upper-left corner of the physical page where the actual printing or drawing begins.[119]
GET_PS_FEATURESETTING Queries the printer driver for information about PostScript features supported on the output device.[120]
GET_SCALINGFACTOR Retrieves the scaling factors for the x-axis and the y-axis of a printer.[121]
META_ESCAPE_ENHANCED_METAFILE Used to embed an EMF metafile within a WMF metafile.[122]
METAFILE_DRIVER Queries the printer driver about its support for metafiles on the output device.[123]
NEWFRAME Notifies the printer driver that the application has finished writing to a page.[124]
NEXTBAND Notifies the printer driver that the application has finished writing to a band.[125]
PASSTHROUGH Passes through arbitrary data to the printer driver.[126]
POSTSCRIPT_DATA Sends arbitrary PostScript data to the output device.[127]
POSTSCRIPT_IDENTIFY Sets the printer driver to either PostScript-centric or GDI-centric mode.[128]
POSTSCRIPT_IGNORE Notifies the output device to ignore PostScript data.[129]
POSTSCRIPT_INJECTION Inserts a block of raw data into a PostScript stream.[130]
POSTSCRIPT_PASSTHROUGH Sends arbitrary data directly to a printer driver, which is expected to process this data only when in PostScript mode.[131]
OPEN_CHANNEL Acts the same as STARTDOC, with a NULL document and output filename, and data in raw mode.[132]
QUERY_DIBSUPPORT Queries the printer driver about its support for DIBs on the output device.[133]
QUERY_ESCSUPPORT Queries the printer driver to determine whether a specific WMF escape function is supported on the output device.[134]
SET_COLORTABLE Sets color table values.[135]
SET_COPYCOUNT Sets the number of copies.[136]
SET_LINECAP Specifies the line-ending mode to use in drawing to the output device.[137]
SET_LINEJOIN Specifies the line-joining mode to use in drawing to the output device.[138]
SET_MITERLIMIT Sets the limit for the length of miter joins to use in drawing to the output device.[139]
SPCLPASSTHROUGH2 Enables documents to include private procedures and other arbitrary data in documents.[140]
STARTDOC Notifies the printer driver that a new print job is starting.[141]

There was a major vulnerability found in escape records around the Abort escape record, which stores the abort procedure code within the record itself. This affected Windows systems (see CVE-2005-4560) and the Wine project (see CVE-2006-0106). According to Secunia, "The vulnerability is caused due to an error in the handling of Windows Metafile files ('.wmf') containing specially crafted SETABORTPROC 'Escape' records. Such records allow arbitrary user-defined function to be executed when the rendering of a WMF file fails."[142] According to the Windows 3.1 SDK documentation, the SETABORTPROC escape was obsoleted and replaced by the function of the same name in Windows 3.1, long before the WMF vulnerability was discovered.[143] However the obsoleted escape code was retained for compatibility with 16 bit programs written for (or at least backwards compatible with) Windows 3.0. This change happened at approximately the same time as Microsoft was creating the 32 bit reimplementation of GDI for Windows NT, and it is likely that the vulnerability occurred during this effort.

After Steve Gibson accused Microsoft of deliberately implementing a backdoor into their code,[144][145] Mark Russinovich provided a rebuttal, and stated that:

...things were different when the format was architected. In the Windows 3.1 “large” memory model code is inherently location-independent and Windows was never patched, so both Windows and an application could simply copy an application function into the WMF file and assume it would work when played back by the same application in a later run session. In any case, its not clear that the developers envisioned applications creating on-disk metafiles with abort procedures. Also, as Microsoft’s Stephen Toulouse pointed out in Microsoft’s rebuttal to Steve’s claims, the security landscape in the early 1990s was very different than today and all code, including that stored in a WMF file, was inherently trusted.[146]

Peter Ferrie of Symantec Security Response, USA also disagreed with Gibson, noting that:

Gibson claimed that a thread is created to run the SetAbortProc handler. In fact, no thread is created to run the handler – it is a callback, which is called by the parser, and the parser has to wait until the callback returns, otherwise the whole point of the function (to abort the printing) is lost. By his own admission, Gibson did not read the documentation (in fact, he claimed that he couldn’t find it, although it is freely available on Microsoft’s Web site), and he claimed that the device context is not available to the function handler. Of course the device context is available to the function handler — it is one of the two parameters that is passed to it (see above), and it is required in order to abort the printing. Finally, Gibson claimed that the control flow could not return to Windows. It is simply a matter of the function returning and discarding the parameters that were passed on the stack. If the record is well formed, Windows will continue to parse the file, as before. ... Gibson admits that he was guessing about a number of things. Unfortunately, he guessed poorly. I guess we know better now.[147]

EMF

[edit]
Enhanced Metafile
Filename extension
.emf
Internet media type
image/emf[10]
Uniform Type Identifier (UTI)com.microsoft.emf[10]
Type of formatVector graphics
Extended fromWMF
Extended toEMF+
Windows Enhanced Metafile headers

EMF files have three possible versions of headers. The original headers is just a container for images, the second and third version encapsulates the original header and contains a pixel format record and support for OpenGL records, and the third version encapsulates the second header extension and increases EMF accuracy and scalability of EMFs as it adds the ability to measure distances of device surfaces using the metric system.[148]

Each EMF header starts with an EMR_HEADER record, and records the relevant properties of the device on which the metafile image was recorded. The original EMF header has an 80 byte header and an optional variable length description string.[149] Other metafiles contain extension fields, which encapsulate the original header. EmfMetafileHeaderExtension1 is a record that is inserted directly after the original EMF header, specifies whether there is a pixel format descriptor and the offset to the descriptor object within the header, as well as a field that specifies if OpenGL records exist in the metafile.[150] The pixel format descriptor specifies the capabilities of the drawing surface and whether a pixel is encoded in RGBA or is an index into a color table.[151] EmfMetafileHeaderExtension2 is a record that is inserted directly after the EmfMetafileHeaderExtension1 record, and it contains two fields with the X and Y values to measure the device surface in micrometers.[152]

Like WMF files, records can be classified by function, however there are more record types in EMF files than there are in WMF files. Records can be classified as control, bitmap, clipping, comment, drawing, escape, object creation, object manipulation, OpenGL, path bracket, state and transform records.

EMF+

[edit]

With the release of Windows XP, the Enhanced Metafile Format Plus Extensions (EMF+) format was introduced. EMF+ provides a way to serialize calls to the GDI+ API in the same way that WMF/EMF stores calls to GDI.

There are also compressed versions of Windows Metafiles known as Compressed Windows Metafile (WMZ) and Compressed Windows Enhanced Metafile (EMZ),[153] which are basically gzip compressed WMF and EMF files correspondingly.

Implementations

[edit]

The WMF format was designed to be executed by the Windows GDI layer in order to restore the image, but as the WMF binary files contain the definition of the GDI graphic primitives that constitute this image, it is possible to design alternative libraries that render WMF binary files or convert them into other graphic formats.

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The Windows Metafile (WMF) is a vector and graphics developed by for storing images in a device-independent manner within Windows operating systems, consisting of a header followed by an of variable-length records that encode drawing commands and graphics objects. Introduced in the early versions of Windows to support 16-bit applications, WMF enables the recording and playback of graphical output from the Windows (GDI), facilitating tasks such as transfers, printing, and document portability. WMF files are structured as a sequence of metafile , each representing GDI function calls like line drawing, filling, text rendering, and handling, which collectively define the image content without embedding pixel data directly. The format includes an optional placeable header for additional metadata, such as bounding coordinates and checksums, but lacks comprehensive details on device resolution, palettes, or text descriptions compared to later formats. Due to its origins in 16-bit environments, WMF is - and application-dependent, with playback influenced by mapping modes and resolutions, and it does not support advanced features like curves, paths, or transformations. To address WMF's limitations, introduced the Enhanced Metafile (EMF) format in the 32-bit era, which extends WMF with improved device independence, scalable records, and support for modern GDI functions; WMF files can be converted to EMF using API calls like SetWinMetaFileBits. Despite its age, WMF remains relevant for in Windows applications, legacy document processing, and interoperability with tools that handle for plotting or archiving. The specification has undergone multiple revisions, with the latest documented version (18.0) updated as of April 2024, ensuring ongoing support for core functionality in contemporary systems.

Overview

Definition and Purpose

The Windows Metafile (WMF) is a format developed by for storing graphical images as a sequence of variable-length records containing (GDI) drawing commands. These records capture instructions for rendering vector elements, such as lines, polygons, and basic shapes, alongside support for embedded raster bitmaps, aiming for scalable output in a device-independent format, though playback can be influenced by device resolution and mapping modes. In essence, a WMF functions as a of an image, which can be played back to reproduce the original graphics on compatible devices. The primary purpose of the Windows Metafile format is to facilitate device-independent rendering in Windows environments, particularly for output to printers and displays, by allowing applications to record and spool drawing operations without embedding hardware-specific details. This portability ensures that the same set of GDI commands can be executed consistently across varied output contexts, simplifying the transfer of graphical content between applications and systems. Metafiles emerged as a key solution to portability challenges in early GDI-based APIs, where direct device calls risked incompatibility and limited reuse of visual data. The original WMF uses the .wmf file extension, while the enhanced version employs .emf; the standard MIME type for WMF files is image/x-wmf. Over time, the format has evolved into Enhanced Metafile (EMF) and further extensions to enhance device independence and feature support.

Key Formats and Evolution

The Windows Metafile (WMF) format, introduced in 1987 with , serves as the original 16-bit format designed for storing sequences of (GDI) commands in a device-independent manner. It employs 16-bit signed integer coordinates, which restrict the drawable area to a range of -32,768 to 32,767 units, potentially limiting precision and scalability for larger or more detailed images. This format was pivotal in early Windows applications for operations and but suffered from device dependencies and limited color support. To address these shortcomings, developed the Enhanced Metafile (EMF) format in the early 1990s, debuting with in 1993 and via extensions. EMF upgrades to a 32-bit structure, utilizing signed 32-bit integer coordinates for vastly improved precision and a larger addressable space, enabling better scalability across devices. It also incorporates enhanced device independence through bounding rectangles and reference device contexts, while supporting text via records like EMR_EXTTEXTOUTW, facilitating international character handling. Building further on EMF, the Enhanced Metafile Plus (EMF+) format emerged in 2001 with the introduction of GDI+ in , extending the EMF spool to embed GDI+ calls for richer capabilities. EMF+ introduces support for alpha channels in bitmaps and brushes, allowing transparency and effects, as well as fills, texture brushes, and path-based rendering that emulate advanced features akin to those in modern s. Available in EMF+ Only mode for GDI+-exclusive content or Dual mode for with standard EMF records, it enables high-fidelity playback on systems supporting GDI+. This progression reflects the evolution of Windows graphics: from the rudimentary WMF in the 1980s, constrained by 16-bit architecture; to EMF in the , prioritizing 32-bit scalability and portability; and culminating in EMF+ during the 2000s, which integrates sophisticated rendering for contemporary applications while maintaining .

History

Development of Original WMF

The original Windows Metafile (WMF) format appeared with the release of on December 9, 1987, as a core component of Microsoft's 16-bit Windows operating systems. Developed during the mid-1980s, it formed an integral part of the (GDI), Microsoft's foundational for handling graphics output. The primary design goals centered on enabling device-independent graphics operations, particularly for printing and transfers, by capturing graphical content in a portable manner that minimized information loss during scaling or device changes. At its core, the WMF format was engineered by to record sequences of GDI function calls, such as line drawing, shape filling, and text rendering, into a compact binary structure for later replay on any compatible . This approach allowed applications to store vector-based images and bitmaps in a single file, supporting without and facilitating across Windows environments. The format used the METAFILEPICT structure for integration, enabling seamless copy-paste operations of between programs while preserving editability through GDI playback. An extension known as the placeable metafile header, developed by Aldus Corporation around 1988 for use in PageMaker, added metadata like bounding rectangles and became widely adopted for improved portability. Despite its innovations, the original WMF suffered from key limitations inherent to its 16-bit architecture, including the use of 16-bit integer coordinates that restricted image dimensions to a maximum of 16,383 units in each direction, leading to precision loss and distortion when scaling to high-resolution displays or printers. Additionally, the initial version (METAVERSION100) lacked support for device-independent bitmaps (DIBs) and advanced font technologies, such as TrueType fonts—which were not introduced until 1991—resulting in reliance on device-specific rasterization for text and limited portability across font environments. These constraints made WMF suitable primarily for simple 2D graphics but inadequate for complex or high-fidelity applications, prompting later enhancements like the Enhanced Metafile (EMF) to address such shortcomings. With Windows 3.0 in 1990, the format was updated to METAVERSION300, adding DIB support for better device independence. Early adoption of WMF was driven by its native integration into Windows applications, particularly Microsoft's productivity tools, where it served as a standard format for embedding and exchanging in documents. This widespread use in early Windows ecosystems solidified WMF's role, despite its technical constraints.

Introduction of Enhanced Formats

The Enhanced Metafile (EMF) format was introduced in 1993 as part of the Win32 API with the release of , serving as a 32-bit successor to the original Windows Metafile (WMF) to overcome its 16-bit limitations in coordinate precision and device independence. EMF employs 32-bit fixed-point coordinates for improved accuracy in rendering scalable graphics across diverse display resolutions and devices, while also supporting long filenames through its enhanced file structure. This format played a central role in the Win32 (GDI), enabling developers to create portable, device-independent pictures that could be played back consistently via functions like CreateEnhMetaFile. Building on EMF, the Enhanced Metafile Plus (EMF+) format emerged in 2001 alongside the GDI+ library in , extending the EMF structure to incorporate advanced graphics features not feasible in the base format. EMF+ introduced support for cubic Bézier curves through records like EmfPlusDrawBeziers, enabling smoother vector path rendering, along with variable transparency (alpha blending) for more realistic compositions and optional compression of records to reduce file sizes and improve efficiency. These enhancements addressed WMF's scalability challenges, such as imprecise rendering on high-DPI displays, by leveraging EMF's foundation for better vector fidelity and extensibility. EMF+ achieved deeper integration with the .NET Framework by embedding GDI+ commands as private data within EMF comment records (e.g., EMR_COMMENT_EMFPLUS), allowing seamless playback in managed code environments without disrupting legacy EMF compatibility. This milestone facilitated the transition to modern graphics programming in Windows applications, prioritizing device independence and performance for evolving display technologies.

Technical Structure

WMF Format Details

The original Windows Metafile (WMF) format is a structure consisting of a fixed header followed by a sequence of variable-length records that encode graphics commands and objects. The core header, known as the META_HEADER record, spans 9 words (18 bytes) and provides essential metadata about the file. This header begins immediately after any optional placeable extension and is always the first required record in the metafile. The META_HEADER structure is defined as follows:
FieldSize (bytes)TypeDescription
Type2WORD (16-bit unsigned)Specifies the metafile type; value 0x0001 indicates a standard WMF.
HeaderSize2WORD (16-bit unsigned)Number of words in the header; always 9 for standard WMFs.
Version2WORD (16-bit unsigned)Metafile version; for example, 0x0300 corresponds to the implementation.
SizeLow2WORD (16-bit unsigned)Low-order word of the total file size in words.
SizeHigh2WORD (16-bit unsigned)High-order word of the total file size in words (combined with SizeLow to form a 32-bit value).
NumberOfObjects2WORD (16-bit unsigned)Number of objects (such as brushes or pens) defined in the metafile.
MaxRecord4DWORD (32-bit unsigned)Size of the largest record in the file, measured in words.
NumberOfMembers2WORD (16-bit unsigned)Reserved field; must be 0x0000 and is unused.
Following the META_HEADER, the metafile may include a logical palette defined through dedicated records, such as META_CREATEPALETTE or META_SETPALENTRIES, which map colors using RGB values and flags for device-independent rendering. The body of the WMF consists of variable-length records, each beginning with a 4-byte RecordSize field (specifying the total size in words, including headers) followed by a 2-byte RecordFunction field that identifies the operation (e.g., drawing or object creation). The remaining bytes contain parameters specific to the function, often padded to align on word boundaries, with the sequence of records bounded by the META_EOF record (RecordFunction 0x0000, RecordSize 3 words). Coordinates in WMF records use 16-bit signed integers (SHORT type) to represent positions in device units, with the origin at the upper-left corner of the and the positive y-axis directed downward; this system defaults to MM_TEXT mapping mode, where one logical unit equals one device pixel. For improved portability, an optional 18-byte META_PLACEABLE header may precede the META_HEADER, extending the format with a (0x9AC6CDD7), a metafile (0x0000 on disk), an 8-byte bounding box in logical units (left, top, right, bottom as 16-bit signed integers), logical inches per physical inch (typically 1440 for twips), reserved bytes (0x00000000), and a 2-byte computed as the XOR of the prior ten 16-bit words to validate integrity. This placeable extension enhances device-independent placement without altering the core WMF structure, which later evolved into the 32-bit Enhanced Metafile (EMF) format for broader capabilities.

EMF Format Details

The Enhanced Metafile (EMF) format represents a significant advancement over its predecessor, the Windows Metafile (WMF), by adopting a 32-bit that enables greater precision and portability in graphical representations. Unlike the 16-bit WMF, EMF records utilize 32-bit integer coordinates for logical units, supporting larger canvases and finer detail without device-specific dependencies. This structure facilitates device-independent rendering, making EMF suitable for applications ranging from screen display to high-resolution printing. The EMF file commences with the EMR_HEADER record (type 1), which establishes the metafile's foundational parameters in a structured binary format. The record begins with an 8-byte prefix common to all EMF records: a 32-bit unsigned integer for the type (EMR_HEADER = 0x00000001) and a 32-bit unsigned integer for the total record size in bytes. Following this prefix, the core header includes the rclBounds field (a RECTL structure specifying the smallest rectangle enclosing the image in logical units, inclusive-inclusive coordinates) and the rclFrame field (a RECTL structure specifying the reference device frame in 0.01 mm units, inclusive-inclusive coordinates), the device frame dimensions via the szlDevice field (a SIZEL structure in pixels), the millimeter units via the szlMillimeters field (a SIZEL structure also in 0.01 mm units, equivalent to 100 units per millimeter), and the RecordSignature field (a 32-bit value, ENHMETA_SIGNATURE = 0x464D4520 for standard EMF files). This initial segment culminates at the file offset where the ASCII signature " EMF" (with leading space) appears, confirming the format. The full EMR_HEADER record extends beyond this core with additional fixed fields (such as metafile version, total bytes, and record count) and optional variable-length elements like a description string, totaling up to 108 bytes for the fixed ENHMETAHEADER plus extensions.
FieldTypeSize (bytes)Description
TypeULONG4Record type identifier (1 for EMR_HEADER).
SizeULONG4Total size of the EMR_HEADER record in bytes.
rclBounds (image bounds)RECTL16Smallest rectangle enclosing the metafile picture, in logical units (inclusive-inclusive coordinates).
rclFrame (reference frame)RECTL16Reference device frame enclosing the metafile picture, in 0.01 mm units (inclusive-inclusive coordinates).
szlDevice (device frame)SIZEL8Dimensions of the reference device in pixels (width and height).
szlMillimetersSIZEL8Dimensions of the reference device in 0.01 mm units (width and height, providing 100 units per millimeter for metric scaling).
RecordSignatureULONG4Signature identifying the format (e.g., 0x464D4520).
Subsequent records in the EMF follow the same 8-byte prefix format, with the type indicating the operation (e.g., or state change) and the size specifying the length of the ensuing parameters, which can reach up to 2^32 - 1 bytes to accommodate complex graphics. Parameters are tightly packed tailored to the record type, ensuring efficient without beyond necessary alignment. This design allows for a variable number of records, each self-describing its extent, enabling incremental processing during playback or . EMF incorporates several enhancements for robustness and interoperability, including 32-bit signed integer coordinates for logical positions (via structures like POINTL and RECTL), which support extensive ranges far exceeding 16-bit limitations. Text-related records utilize (UTF-16) encoding for strings, promoting global language support over the ANSI limitations of earlier formats. The reference device data in the header—encompassing pixel and millimeter dimensions—enables precise scaling and rendering in modes like MM_TEXT, where output aligns to device-specific metrics without recomputation. An EMF file concludes with the EMR_EOF record (type 1), a minimal 8-byte entry signaling the end of records and validating the metafile's integrity; its size field is typically 8 bytes, containing no parameters. The total file size is predetermined by the nBytes field in the EMR_HEADER, allowing verification by summing individual record sizes during . This closure ensures complete playback without trailing data. EMF's emphasizes compatibility with printer spoolers, permitting direct transmission of records to output devices for interpretation without requiring full GDI emulation on the client side, thus optimizing print workflows in Windows environments. This spooler-friendly approach reduces latency in rendering pipelines while maintaining the format's device independence.

EMF+ Format Details

EMF+ metafiles maintain compatibility with the EMF format by beginning with a standard EMF header record, immediately followed by an EMR_COMMENT_EMFPLUS record that signals the presence of embedded EMF+ data. This comment record uses the identifier 0x2B464D45, representing the ASCII string "EMF+" in little-endian format, to identify the subsequent data as EMF+ private content. The EMF+ private records reside within the CommentRecordBuffer of the EMR_COMMENT_EMFPLUS record, starting directly after the 4-byte CommentIdentifier and typically beginning at an offset of 40 bytes from the end of the EMF header in practice due to the fixed structure of initial fields. The first such record is the EmfPlusHeader, which defines key metadata for the EMF+ section, including the version (an EmfPlusGraphicsVersion value such as 0xDBC01002, corresponding to GraphicsVersion1_1 for GDI+ version 1.1), EmfPlusFlags (for example, 0x00000001 indicating no or video display reference), and the total size of the EMF+ data in bytes. The EMF+ portion optionally employs compression for its data payload, often via embedded structures like the EMR_COMMENT_EMFPLUSHEADER mechanism, which allows compact representation while supporting native 32-bit floating-point coordinates for precise positioning and transformations in drawing operations. Subsequent EMF+ records are enumerated in a sequential description table within the private data buffer, where each entry specifies the record type, offsets from the buffer start, data sizes, and processing flags to enable selective rendering—such as skipping unsupported records based on size fields or processing only essential EMF fallback commands. Overall, EMF+ integrates with EMF by encapsulating GDI+ commands and objects within these comment records, enabling enhanced graphics features like alpha blending and gradients while providing a complete EMF subset for fallback rendering on systems lacking GDI+ support.

Records and Operations

Bitmap and Drawing Records

In Windows Metafile (WMF) format, bitmap records such as BITMAP16 (record function number 0x000B) enable the loading and definition of device-independent bitmaps (DIBs) using 16-bit parameters, including fields for bitmap type, width, height, planes, bits per pixel, and raw pixel data, which can also create pattern brushes for subsequent drawing operations. In contrast, the Enhanced Metafile (EMF) format uses records like EMR_STRETCHDIBITS (type 0x00000051) to transfer and scale DIB pixels to a destination rectangle, supporting optional stretching, compression, and integration with brush patterns for more precise raster output. These bitmap records in both formats incorporate raster operations to combine source data with the destination surface, such as SRCCOPY (0x00CC0020), which directly copies the source bitmap, and PATCOPY (0x00F00021), which applies the current brush pattern, often with clipping to the current device context bounds. Drawing records in WMF and EMF handle vector primitives by rendering lines, polylines, and arcs using the current for outlines, with fills implicitly applied via the selected where applicable, such as in closed shapes. In WMF, the LINETO record (0x0079) draws a straight line from the current position to specified 16-bit coordinates using the current , updating the position accordingly. The POLYLINE record (0x0325) extends this to multiple connected segments defined by a count of points and their 16-bit X-Y coordinates, again relying on the for rendering without filling. For curves, the ARC record (0x0817) draws an elliptical arc within a bounding specified by 16-bit coordinates, using start and end radial points to define the sweep angle in device units, with the for the outline and for any chord or fill if selected. EMF improves precision in these operations with 32-bit integer coordinates and floating-point support for angles. The EMR_LINETO record (type 0x00000036) performs a similar line draw to its WMF counterpart but uses a single 32-bit point for the endpoint. EMR_POLYLINE (type 0x00000024) renders connected lines from an of 32-bit points, maintaining compatibility with WMF while enhancing scalability for higher resolutions. Likewise, EMR_ARC (type 0x0000002D) defines arcs via a 32-bit bounding and start/end angles in logical units, applying the current pen for the and supporting fills for enclosed regions like sectors. Across both formats, these records assume prior selection of pen and states, ensuring that line styles, widths, colors, and fill patterns are applied consistently during playback without explicit recreation in the primitive itself.

Object, State, and Escape Records

In Windows Metafile (WMF) and its enhanced variants, object records manage the creation and selection of graphics resources such as , pens, and fonts, which are stored in an object table for reuse during playback. The CREATEBRUSHINDIRECT record in WMF, identified by function number 0x02FC, creates a logical defined by a specifying the brush style (e.g., solid, hatched), color reference, and optional hatch pattern. This record includes a fixed-size header with the record size and function identifier, followed by the LogBrush data, enabling device-independent definitions. In the Metafile (EMF) format, the equivalent is the EMR_CREATEBRUSHINDIRECT record (type 0x00000027), which uses a LogBrushEx to support additional attributes like texture bitmaps and for more precise rendering. Selection of these objects into the active device context is handled by the SELECTOBJECT record, common to both formats with function/type 0x012E in WMF and type 0x00000025 in EMF. This record specifies an object index from the metafile's object table or a stock object identifier (e.g., NULL_BRUSH), activating it for subsequent drawing operations without recreating resources. The ihObject field in EMF provides a 32-bit index, supporting up to 64K objects, while WMF uses a 16-bit for efficiency in older systems. State records preserve and restore the device context configuration, allowing complex drawing sequences to revert changes without reapplying all prior settings. In WMF, the SAVE_DC record (0x001E) pushes the current state onto a stack limited to 16 levels, capturing attributes like transformation matrices and clipping regions. The corresponding RESTORE_DC record (0x0127) pops states from this stack using a signed 16-bit offset (nSavedDC), where negative values indicate relative restoration and positive ones absolute levels. EMF mirrors this with EMR_SAVEDC (type 0x00000021), which has no parameters and appends the state to an unbounded array, and EMR_RESTOREDC (type 0x00000022), which uses a 32-bit integer for the saved state index to enable deeper nesting. Mapping modes, which define how logical coordinates map to device coordinates, are set via dedicated state records to support anisotropic scaling and orientation. The WMF SETMAPMODE record (0x0103) accepts a 16-bit mode value, such as MM_ANISOTROPIC for arbitrary X/Y scaling or MM_ISOTROPIC for equal units, influencing subsequent coordinate interpretations. EMF's EMR_SETMAPMODE (type 0x00000011) uses the same enumeration but integrates with floating-point world transformations for higher precision in modern graphics pipelines. Escape records provide a mechanism for vendor-specific or device-dependent extensions, bypassing standard GDI operations. In WMF, the ESCAPE record (0x0626) includes a 16-bit escape function code (e.g., NEWFRAME for page ejection) followed by a byte count and variable data payload, allowing printer-specific commands like aborting jobs. EMF extends this with EMR_EXTESCAPE (type 0x0000006A), supporting enhanced functions such as EXTTEXTOUT for advanced text output, where the EscapeFunction field identifies the operation and cbEscData specifies the data length. Resource management is completed by deletion records to prevent memory leaks during playback. The WMF DELETEOBJECT record (0x01F0) removes a specified object from the table using its 16-bit handle, freeing associated resources like memory. In EMF, EMR_DELETEOBJECT (type 0x00000028) uses a 32-bit index for the same purpose, ensuring compatibility with larger object tables and supporting selective cleanup in nested contexts.
Record CategoryWMF Record (Function)EMF Record (Type)Key Purpose
Object CreationCREATEBRUSHINDIRECT (0x02FC)EMR_CREATEBRUSHINDIRECT (0x00000027)Define brushes with style, color, and patterns
Object SelectionSELECTOBJECT (0x012E)EMR_SELECTOBJECT (0x00000025)Activate object in device context
State Save/RestoreSAVE_DC (0x001E) / RESTORE_DC (0x0127)EMR_SAVEDC (0x00000021) / EMR_RESTOREDC (0x00000022)Stack-based context preservation
Mapping ModeSETMAPMODE (0x0103)EMR_SETMAPMODE (0x00000011)Set coordinate transformation mode
EscapeESCAPE (0x0626)EMR_EXTESCAPE (0x0000006A)Device-specific extensions
Object DeletionDELETEOBJECT (0x01F0)EMR_DELETEOBJECT (0x00000028)Free graphics resources

Implementations and Support

Native Windows Integration

Windows Metafiles are created within the Windows operating system using Graphics Device Interface (GDI) functions provided by the Win32 API. For Windows-format metafiles (WMF), applications invoke the CreateMetaFile function to obtain a device context suitable for recording GDI drawing operations, followed by calls to standard GDI functions such as LineTo or Ellipse to capture the graphics sequence, and finally CloseMetaFile to finalize the metafile handle. Enhanced metafiles (EMF) are recorded similarly using CreateEnhMetaFile, which supports a broader range of GDI operations including advanced features like alpha blending, and the resulting handle is retrieved via CloseEnhMetaFile. To retrieve or convert metafile data, functions like GetMetaFileBitsEx allow extraction of WMF contents into a buffer, facilitating conversion to EMF format for improved fidelity. Playback of metafiles occurs through dedicated GDI functions integrated into the Windows graphics subsystem. The PlayMetaFile function renders a WMF by enumerating and executing its records on a specified device context, ensuring device-independent reproduction of the captured graphics. For EMF files, introduced with (with enhancements in ), the PlayEnhMetaFile function maps the metafile contents onto a target rectangle in the device context, supporting playback since and later versions. These functions are implemented in the GDI32.dll library, enabling seamless integration in native Windows applications. Metafiles serve as standard formats in Windows clipboard operations and (OLE) mechanisms for exchanging . WMF and EMF are registered clipboard formats (CF_METAFILEPICT for WMF and CF_ENHMETAFILE for EMF), allowing applications like and the Office suite to copy and paste graphics as device-independent pictures without loss of scalability. In OLE scenarios, embedded or linked objects from applications such as Word or Excel utilize metafiles to store and render graphical content, ensuring consistent display across documents and supporting inter-application data transfer. In the Windows printing pipeline, EMF plays a central role in for Win32 applications via the Print API. When , GDI operations are recorded into an EMF spool file by the spooler, which the print processor then converts to a printer-specific format, optimizing for device independence and reducing bandwidth in networked environments. Starting with , the XPS print path incorporates EMF+ records—extensions to EMF supporting advanced features like gradients—for in XML Paper Specification (XPS) documents, enabling higher-fidelity output in modern print drivers while maintaining compatibility with legacy GDI-based . The evolution of the GDI API reflects the transition from 16-bit Windows environments to the 32-bit Win32 architecture, with metafile support migrating to GDI32.dll for enhanced stability and functionality. In 16-bit Windows (e.g., Windows 3.1), metafile operations were handled directly in the GDI subsystem, but Win32 introduced 32-bit handles and improved error handling in functions like those in wingdi.h. Key enhancements include the SetMetaRgn function, which intersects the current clipping region with a metaregion during metafile recording or playback, allowing precise control over visible areas in vector graphics. Backward compatibility ensures that WMF playback remains supported in and 11 through the core GDI functions, allowing legacy applications and files to render correctly without modification. While direct WMF creation is deprecated in favor of EMF, the system maintains playback via PlayMetaFile, and conversion tools can bridge formats if needed for . This ongoing support in GDI32.dll preserves the utility of older metafiles in contemporary Windows environments.

Third-Party and Cross-Platform Support

Third-party libraries have extended Windows Metafile (WMF) support to non-Windows environments, enabling rendering and conversion on and Unix systems. The libwmf library, developed as part of the wvWare project, provides functionality for interpreting WMF files and converting them to standard formats such as , , (PS), (EPS), and . This library is commonly integrated into tools like , where it facilitates WMF rendering by default using the dimensions specified in the metafile header, with options like -density for resolution adjustments during rasterization. UniConvertor, an open-source universal translator from the sK1 Project, supports importing WMF files for and conversion within applications like . It uses the sK1 engine to handle WMF alongside other formats such as , CDR, and CGM, allowing export to vector formats like for cross-platform vector workflows. While primarily focused on WMF, UniConvertor integrates with extensions to enable batch processing of legacy metafiles in open-source vector graphics pipelines. Commercial applications maintain compatibility with WMF and Enhanced Metafile (EMF) formats to handle legacy files from Windows ecosystems. Adobe supports importing and exporting both WMF and EMF via its Open and Place commands, preserving vector data for editing in cross-platform design projects. Similarly, CorelDRAW provides import and export capabilities for WMF, storing both vector and information in 24-bit RGB color, and extends support to EMF for enhanced metafile interchange in professional graphics workflows. These features ensure without native Windows dependencies, though users may encounter limitations with complex EMF+ records. ImageMagick's convert tool offers rasterization of WMF files on Unix-like systems, leveraging libwmf for accurate rendering to formats like PNG or JPEG. This command-line utility processes metafiles by translating GDI commands into pixel-based output, making it suitable for server-side image processing in web applications. Cross-platform runtime environments have implemented partial support for metafile playback to enable Windows application portability. Wine, a compatibility layer for running Windows software on Linux, includes a GDI implementation that handles WMF and EMF through its gdi32 module, allowing apps to render metafiles via translated API calls. Mono, the open-source .NET implementation, provides partial EMF+ support via its libgdiplus library, which emulates GDI+ APIs using Cairo for rendering on non-Windows platforms, though some advanced records may not be fully compatible. Conversion utilities bridge metafile formats across ecosystems. Online services like provide web-based conversion of WMF to or PDF without software installation, processing files through cloud-based rasterization and vector extraction for quick cross-format access. Open-source libraries support metafile parsing in web and enterprise contexts. Batik, a toolkit for manipulation, includes a WMFTranscoder for converting WMF files to , enabling embedding in Java-based web applications while handling basic metafile records.

Limitations and Security

Known Vulnerabilities

Windows Metafile (WMF) parsing and rendering have been associated with critical vulnerabilities primarily in the mid-2000s, enabling remote code execution through malformed records. A prominent exploit targeted the SETABORTPROC function within META_ESCAPE records, allowing attackers to execute arbitrary code by leveraging the (GDI) library in and Server 2003. This issue was addressed in Microsoft Security Bulletin MS06-001, released in January 2006, which modified WMF handling to remove support for the vulnerable record type. Enhanced Metafile (EMF) formats exhibited buffer overflow vulnerabilities in specific records, such as EMR_STRETCHDIBITS for bitmap stretching and font-related records processed via GDI+. These defects allowed heap-based overflows during rendering, potentially resulting in remote code execution when processing malicious files. Microsoft Security Bulletin MS05-053 addressed a buffer overflow in EMF rendering routines. Additional patches like MS07-017 addressed elevation-of-privilege issues in EMF rendering. EMF+ extensions in GDI+ introduced risks from compressed records, where improper decompression led to heap corruption and . Vulnerabilities in GDI+ handling of EMF+ were addressed in bulletins such as MS09-062. Microsoft provided registry-based disabling options for broader WMF/EMF support in bulletin MS09-062, referencing article 941835 for implementation, with options available since around 2008. Office 2007 incorporated enhanced safeguards against EMF rendering exploits through improved file validation in the Graphics Rendering Engine. These vulnerabilities predominantly impacted users via attachments containing malicious images or web pages embedding exploitable metafiles, facilitating widespread attacks in 2005–2006. Vulnerabilities have continued post-2010, including remote code execution flaws in EMF rendering patched in MS11-029 (2011) and MS15-035 (2015). As recently as November 2025, Research disclosed three critical vulnerabilities in the Windows (GDI), such as CVE-2025-53766, enabling remote code execution that could affect metafile processing. Mitigations like browser sandboxing, deprecated rendering in modern applications, and comprehensive patching have reduced but not eliminated the attack surface.

Modern Alternatives and Deprecation

The Windows Metafile (WMF) format was largely phased out in favor of the Enhanced Metafile (EMF) starting with , as EMF provided improved device independence and 32-bit support for better scalability in graphics rendering. EMF+ further extended EMF to incorporate GDI+ features but remains limited to legacy applications relying on the GDI+ library, with shifting primary 2D graphics development to beginning in for hardware-accelerated performance. Key reasons for the decline of WMF and EMF include the base EMF's lack of native support for alpha channel opacity, restricting it to binary transparency and causing rendering issues in layered compositions. Additionally, these formats exhibit poor compatibility with mobile platforms due to their Windows-centric design and dependence on GDI, which lacks optimization for touch interfaces and cross-device portability. The rise of hardware-accelerated APIs like , underpinning , has further diminished their relevance by enabling faster, GPU-accelerated vector and raster operations without the overhead of metafile playback. Modern alternatives emphasize scalability and interoperability: (SVG) serves as a primary substitute for web-based , offering XML-based structure for resolution-independent rendering across browsers and devices. For print workflows, Portable Document Format (PDF) provides robust portability with embedded vectors and fonts, while and handle raster needs in user interfaces with better compression and transparency support. WMF and EMF persist for backward compatibility in Microsoft Office 365, particularly for legacy printing and document insertion. Microsoft recommends modern APIs like or web standards for new development. Migration tools include GDI+ APIs for converting WMF to EMF+, such as the Metafile::ConvertToEmfPlus method, and broader .NET paths from GDI+-based WinForms to Windows Presentation Foundation (WPF), which leverages for modern vector handling.

References

  1. https://wiki.inkscape.org/wiki/Uniconvertor
Add your contribution
Related Hubs
User Avatar
No comments yet.