Recent from talks
Nothing was collected or created yet.
Windows Metafile
View on WikipediaWindows 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[update], 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]
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 format | Vector graphics |
| Extended to | EMF |

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]
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 format | Vector graphics |
| Extended from | WMF |
| Extended to | EMF+ |

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]- PostScript
- Vector Markup Language (VML)
- Scalable Vector Graphics (SVG)
References
[edit]- ^ Windows Metafile Format (PDF), Microsoft, p. 16
- ^ "[MS-WMF]: Windows Metafile Format". MSDN. 2021-04-26. Retrieved 2023-09-13.
- ^ [MS-EMF]: Enhanced Metafile Format (PDF), Microsoft, p. 17
- ^ [MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions (PDF), Microsoft, p. 19
- ^ Microsoft Windows 3.1 Programmers Reference, Volume 4 Resources, Microsoft Press 1992, ISBN 1-55615-494-1, chapter 3 pp. 21-45
- ^ Caolan McNamara. "Window Metafile (wmf) Reference". Retrieved 2008-06-01.
These opcodes are unimplemented, for the reason that i dont know what they are, no known documentation
- ^ "[MS-WMF]: Windows Metafile Format Specification". Retrieved 2008-06-01.
- ^ "Microsoft Open Specification Promise". Microsoft. Retrieved 2008-06-01.
- ^ a b Enhanced Metafiles in Win32, Microsoft Developer Network Technology Group, June 10, 1993
- ^ a b c d e f Leonard, Sean (September 2016). "Windows Metafiles". Windows Image Media Types. IETF. p. 1. doi:10.17487/RFC7903. ISSN 2070-1721. RFC 7903. Retrieved February 8, 2020.
- ^ "EMF", FileFormat, Aspose Pty Ltd, 11 October 2019, retrieved 2020-01-20
- ^ Petzold, Charles (October 11, 1994), "NT Metafiles and GDI Objects", PC Magazine, pp. 343–347
- ^ Polyakov, Alex; Brusentsev, Vitaly (2005). Graphics Programming with GDI+ & DirectX. A-List Publishing. p. 68. ISBN 1-931769-39-7.
- ^ "3.1.4.1 WMF Object Table", [MS-WMF]: Enhanced Metafile Format (PDF), Microsoft, p. 187
- ^ "3.1.1.1 EMF Object Table", [MS-EMF]: Windows Metafile Format Specification (PDF), Microsoft, pp. 212–214
- ^ [MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions (PDF), Microsoft, pp. 204–205
- ^ "Figure 1: Structures of original and placeable Windows metafiles", Windows Metafile Format (PDF), Microsoft, p. 17
- ^ Q66949: INFO: Windows Metafile Functions & Aldus Placeable Metafiles, Microsoft – via KnowledgeBase Archive: An Archive of Early Microsoft KnowledgeBase
- ^ a b c "1.3.1 Metafile Structure", Windows Metafile Format (PDF), Microsoft, p. 17
- ^ "2.3.2.3 META_PLACEABLE Record", Windows Metafile Format (PDF), Microsoft, p. 115
- ^ Windows Metafile Format (PDF), Microsoft, p. 55,
<55> Section 2.3.2.3: Windows NT 3.1, Windows NT 3.5, Windows NT 3.51, and Windows 95: This feature is not supported.
- ^ "2.3.2.2 MTF_HEADERRECORD Record", Windows Metafile Format (PDF), Microsoft, p. 114
- ^ "2.3.2.2 MTF_HEADERRECORD Record", Windows Metafile Format (PDF), Microsoft, p. 114
- ^ "2.3.2.1 MTF_EOF Record", Windows Metafile Format (PDF), Microsoft, p. 114
- ^ "1.1 Glossary", [MS-WMF]: Windows Metafile Format Specification (PDF), Microsoft, p. 13, retrieved 2020-01-24
- ^ "2.3.1.1 META_BITBLT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 101–103, retrieved 2020-01-24
- ^ "2.3.1.2 META_DIBBITBLT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), Microsoft, pp. 103–106, retrieved 2020-01-24
- ^ "2.3.1.3 META_DIBSTRETCHBITBLT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), Microsoft, pp. 106–108, retrieved 2020-01-24
- ^ "2.3.1.4 META_SETDIBTODEV Record", [MS-WMF]: Windows Metafile Format Specification (PDF), Microsoft, pp. 108–109, retrieved 2020-01-24
- ^ "2.3.1.5 META_STRETCHBLT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), Microsoft, pp. 109–110, retrieved 2020-01-24
- ^ "2.3.1.6 META_STRETCHDIB Record", [MS-WMF]: Windows Metafile Format Specification (PDF), Microsoft, pp. 103–106, retrieved 2020-01-24
- ^ "2.3.3.1 META_ARC Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 101–103, retrieved 2020-01-24
- ^ "2.3.3.2 META_CHORD Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 117–118, retrieved 2020-01-24
- ^ "2.3.3.3 META_ELLIPSE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 119, retrieved 2020-01-24
- ^ "2.3.3.4 META_EXTFLOODFILL Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 119–120, retrieved 2020-01-24
- ^ "2.3.3.5 META_EXTTEXTOUT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 119–120, retrieved 2020-01-24
- ^ "2.3.3.6 META_FILLREGION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 121, retrieved 2020-01-24
- ^ "2.3.3.7 META_FLOODFILL Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 119–120, retrieved 2020-01-24
- ^ "2.3.3.8 META_FRAMEREGION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 122–123, retrieved 2020-01-24
- ^ "2.3.3.9 META_INVERTREGION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 123, retrieved 2020-01-24
- ^ "2.3.3.10 META_LINETO Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 123–124, retrieved 2020-01-24
- ^ "2.3.3.11 META_PAINTREGION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 124, retrieved 2020-01-24
- ^ "2.3.3.12 META_PATBLT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 124–125, retrieved 2020-01-24
- ^ "2.3.3.13 META_PIE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 125–126, retrieved 2020-01-24
- ^ "2.3.3.14 META_POLYLINE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 126, retrieved 2020-01-24
- ^ "2.3.3.15 META_POLYGON Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 127, retrieved 2020-01-24
- ^ "2.3.3.16 META_POLYPOLYGON Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 127–128, retrieved 2020-01-24
- ^ "2.3.3.17 META_RECTANGLE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 127–128, retrieved 2020-01-24
- ^ "2.3.3.18 META_ROUNDRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 128–129, retrieved 2020-01-24
- ^ "2.3.3.19 META_SETPIXEL Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 129–130, retrieved 2020-01-24
- ^ "2.3.3.20 META_TEXTOUT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 130, retrieved 2020-01-24
- ^ "2.2.2.2. BitmapCoreHeader Object", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 85, retrieved 2020-01-25
- ^ "2.2.2.9. DeviceIndependentBitmap Object", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 91, retrieved 2020-01-25
- ^ a b "2.2.1. Graphics Objects", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 79, retrieved 2020-01-25
- ^ "2.3.4.1 META_CREATEBRUSHINDIRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 131–132, retrieved 2020-01-25
- ^ "2.3.4.2 META_CREATEFONTINDIRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 132, retrieved 2020-01-25
- ^ "2.3.4.4 META_CREATEPATTERNBRUSH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 133–135, retrieved 2020-01-25
- ^ "2.3.4.3 META_CREATEPALETTE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 132–133, retrieved 2020-01-25
- ^ "2.3.4.5 META_CREATEPENINDIRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 134–135, retrieved 2020-01-25
- ^ "2.3.4.6 META_CREATEREGION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 135, retrieved 2020-01-25
- ^ "2.3.4.7 META_DELETEOBJECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 135, retrieved 2020-01-25
- ^ "2.3.4.8 META_CREATEBRUSHINDIRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 135–136, retrieved 2020-01-25
- ^ "2.3.4.9 META_DIBCREATEPATTERNBRUSH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 136–137, retrieved 2020-01-25
- ^ "2.3.4.10 META_SELECTCLIPREGION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 137, retrieved 2020-01-25
- ^ "2.3.4.11 META_SELECTOBJECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 137–138, retrieved 2020-01-25
- ^ "2.3.4.11 META_SELECTPALETTE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 139, retrieved 2020-01-25
- ^ "2.3.5 State Record Types", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 138, retrieved 2020-01-28
- ^ "2.3.5.1 META_ANIMATEPALETTE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 140, retrieved 2020-01-28
- ^ "2.3.5.2 META_EXCLUDECLIPRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 140–141, retrieved 2020-01-28
- ^ "2.3.5.3 META_INTERSECTCLIPRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 141–142, retrieved 2020-01-28
- ^ "2.3.5.1 META_MOVETO Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 142, retrieved 2020-01-28
- ^ "2.3.5.4 META_OFFSETCLIPRGN Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 142–143, retrieved 2020-01-28
- ^ "2.3.5.5 META_OFFSETVIEWPORTORG Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 143, retrieved 2020-01-28
- ^ "2.3.5.6 META_OFFSETWINDOWORG Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 131–132, retrieved 2020-01-28
- ^ "2.3.5.7 META_REALIZEPALETTE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 143–144, retrieved 2020-01-28
- ^ "2.3.5.8 META_RESIZEPALETTE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 144, retrieved 2020-01-28
- ^ "2.3.5.9 META_RESTOREDC Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 145, retrieved 2020-01-28
- ^ "2.3.5.10 META_SAVEDC Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 145, retrieved 2020-01-28
- ^ "2.3.5.11 META_SCALEVIEWPORTEXT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 145–146, retrieved 2020-01-28
- ^ "2.3.5.12 META_SCALEWINDOWEXT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 146–147, retrieved 2020-01-28
- ^ "2.3.5.13 META_SETBKCOLOR Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 147, retrieved 2020-01-28
- ^ "2.3.5.14 META_SETBKMODE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 147–148, retrieved 2020-01-28
- ^ "2.3.5.15 META_SETLAYOUT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 148, retrieved 2020-01-28
- ^ "2.3.5.16 META_SETMAPMODE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 148–149, retrieved 2020-01-28
- ^ "2.3.5.17 META_SETMAPPERFLAGS Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 131–132, retrieved 2020-01-28
- ^ "2.3.5.18 META_ANIMATEPALETTE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 149, retrieved 2020-01-28
- ^ "2.3.5.19 META_SETPALENTRIES Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 149–150, retrieved 2020-01-28
- ^ "2.3.5.20 META_SETRELABS Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 150, retrieved 2020-01-28
- ^ "2.3.5.21 META_SETROP2 Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 151, retrieved 2020-01-28
- ^ "2.3.5.1 META_SETSTRETCHBLTMODE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 151–152, retrieved 2020-01-28
- ^ "2.3.5.22 META_SETTEXTALIGN Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 152, retrieved 2020-01-28
- ^ "2.3.5.1 META_SETTEXTCHAREXTRA Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 152–153, retrieved 2020-01-28
- ^ "2.3.5.23 META_SETTEXTCOLOR Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 153, retrieved 2020-01-28
- ^ "2.3.5.24 META_SETTEXTJUSTIFICATION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 153–154, retrieved 2020-01-28
- ^ "2.3.5.25 META_SETVIEWPORTEXT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 154, retrieved 2020-01-28
- ^ "2.3.5.26 META_SETVIEWPORTORG Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 154–155, retrieved 2020-01-28
- ^ "2.3.5.27 META_SETWINDOWEXT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 155, retrieved 2020-01-28
- ^ "2.3.5.28 META_SETWINDOWORG Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 155, retrieved 2020-01-28
- ^ "2.3.6.2. ABORTDOC Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 158–159, retrieved 2020-01-28
- ^ "2.3.6.3. BEGIN_PATH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 159, retrieved 2020-01-28
- ^ "2.3.6.4. CHECK_JPEGFORMAT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 159–160, retrieved 2020-01-28
- ^ "2.3.6.5. CHECK_PNGFORMAT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 160, retrieved 2020-01-28
- ^ "2.3.6.6. CLIP_TO_PATH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 160, retrieved 2020-01-28
- ^ "2.3.6.7. CLOSE_CHANNEL Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 162, retrieved 2020-01-28
- ^ "2.3.6.8. DOWNLOAD_FACE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 162–163, retrieved 2020-01-28
- ^ "2.3.6.9. DOWNLOAD_HEADER Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 158–159, retrieved 2020-01-28
- ^ "2.3.6.10. DRAW_PATTERNRECT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 163–164, retrieved 2020-01-28
- ^ "2.3.6.11. ENCAPSULATED_POSTSCRIPT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 164, retrieved 2020-01-28
- ^ "2.3.6.12. END_PATH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 164–165, retrieved 2020-01-28
- ^ "2.3.6.13. ENDDOC Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 165, retrieved 2020-01-28
- ^ "2.3.6.14. EPS_PRINTING Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 165–166, retrieved 2020-01-28
- ^ "2.3.6.15. EXTTEXTOUT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 166–167, retrieved 2020-01-28
- ^ "2.3.6.16. GET_COLORTABLE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 167–168, retrieved 2020-01-28
- ^ "2.3.6.17. GET_DEVICEUNITS Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 168, retrieved 2020-01-28
- ^ "2.3.6.18. GET_EXTENDED_TEXTMETRICS Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 168–169, retrieved 2020-01-28
- ^ "2.3.6.19. GET_FACENAME Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 169, retrieved 2020-01-28
- ^ "2.3.6.20. GET_PAIRKERNTABLE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 169–170, retrieved 2020-01-28
- ^ "2.3.6.21. GET_PHYSPAGESIZE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 170, retrieved 2020-01-28
- ^ "2.3.6.22. GET_PRINTINGOFFSET Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 170–171, retrieved 2020-01-28
- ^ "2.3.6.23. GET_PS_FEATURESETTING Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 171, retrieved 2020-01-28
- ^ "2.3.6.24. GET_SCALINGFACTOR Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 171–172, retrieved 2020-01-28
- ^ "2.3.6.25. META_ESCAPE_ENHANCED_METAFILE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 172–173, retrieved 2020-01-28
- ^ "2.3.6.26. METAFILE_DRIVER Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 173–174, retrieved 2020-01-28
- ^ "2.3.6.27. NEWFRAME Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 174–175, retrieved 2020-01-28
- ^ "2.3.6.28. NEXTBAND Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 174–175, retrieved 2020-01-28
- ^ "2.3.6.29. PASSTHROUGH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 175, retrieved 2020-01-28
- ^ "2.3.6.30. POSTSCRIPT_DATA Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 176, retrieved 2020-01-28
- ^ "2.3.6.31. POSTSCRIPT_IDENTIFY Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 176–177, retrieved 2020-01-28
- ^ "2.3.6.32. POSTSCRIPT_IGNORE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 177, retrieved 2020-01-28
- ^ "2.3.6.33. POSTSCRIPT_INJECTION Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 177–178, retrieved 2020-01-28
- ^ "2.3.6.34. POSTSCRIPT_PASSTHROUGH Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 178, retrieved 2020-01-28
- ^ "2.3.6.35. OPEN_CHANNEL Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 179, retrieved 2020-01-28
- ^ "2.3.6.36. QUERY_DIBSUPPORT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 179–180, retrieved 2020-01-28
- ^ "2.3.6.37. QUERY_ESCSUPPORT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 180, retrieved 2020-01-28
- ^ "2.3.6.38. SET_COLORTABLE Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 180–181, retrieved 2020-01-28
- ^ "2.3.6.39. SET_COPYCOUNT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 181, retrieved 2020-01-28
- ^ "2.3.6.40. SET_LINECAP Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 181–182, retrieved 2020-01-28
- ^ "2.3.6.41. SET_LINEJOIN Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 182–183, retrieved 2020-01-28
- ^ "2.3.6.42. SET_MITERLIMIT Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 183, retrieved 2020-01-28
- ^ "2.3.6.43. SPCLPASSTHROUGH2 Record", [MS-WMF]: Windows Metafile Format Specification (PDF), pp. 183–184, retrieved 2020-01-28
- ^ "2.3.6.44. STARTDOC Record", [MS-WMF]: Windows Metafile Format Specification (PDF), p. 184, retrieved 2020-01-28
- ^ "Microsoft Windows WMF "SETABORTPROC" Arbitrary Code Execution". Secunia. Secunia Advisory: SA18255. Archived from the original on January 2, 2006.
- ^ Pscript-Supported Escapes, Microsoft, retrieved 2020-01-28
- ^ "The Windows MetaFile Backdoor?". GRC Security Now! (Podcast). Gibson Research Corporation. January 12, 2006. Retrieved 2020-01-28.
- ^ Gibson, Steve (January 12, 2006), "Re: You won't want to miss tonight's Security Now!, #22", grc.news.feedback, retrieved 2020-01-28
- ^ Russinovich, Mark (January 18, 2006), "Inside the WMF Backdoor", TechNet, Microsoft – via Microsoft Tech Community
- ^ Ferrie, Peter (February 2, 2006), Inside the Windows Meta File Format (PDF), Virus Bulletin, archived from the original (PDF) on May 16, 2008, retrieved 2020-01-24 – via Symantec
- ^ "1.3.1. Metafile Structure", [MS-EMF]: Enhanced Metafile Format (PDF), Microsoft, pp. 17–18
- ^ "2.3.4.2.1 EmfMetafileHeader Record", [MS-EMF]: Enhanced Metafile Format (PDF), Microsoft, p. 120
- ^ "2.2.10 HeaderExtension1 Object", [MS-EMF]: Enhanced Metafile Format (PDF), Microsoft, pp. 57–58
- ^ "2.2.22 PixelFormatDescriptor Object", [MS-EMF]: Enhanced Metafile Format (PDF), Microsoft, pp. 68–71
- ^ "2.3.4.2.3 EmfMetafileHeaderExtension2 Record", [MS-EMF]: Enhanced Metafile Format (PDF), Microsoft, pp. 122–124
- ^ "You receive a "This file is an unsupported graphic format" error message when you try to insert a picture into a PowerPoint for Mac presentation". Microsoft. Archived from the original on 2014-04-19. Retrieved 2014-04-19.
External links
[edit]Windows Metafile
View on GrokipediaSetWinMetaFileBits.[2] Despite its age, WMF remains relevant for backward compatibility in Windows applications, legacy document processing, and interoperability with tools that handle vector graphics for plotting or archiving.[1] 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.[1]
Overview
Definition and Purpose
The Windows Metafile (WMF) is a binary file format developed by Microsoft for storing graphical images as a sequence of variable-length records containing Graphics Device Interface (GDI) drawing commands.[1] 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.[4] In essence, a WMF functions as a digital recording of an image, which can be played back to reproduce the original graphics on compatible devices.[3] The primary purpose of the Windows Metafile format is to facilitate device-independent graphics 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.[4] 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.[5] Metafiles emerged as a key solution to portability challenges in early GDI-based graphics APIs, where direct device calls risked incompatibility and limited reuse of visual data.[4] 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.[6]Key Formats and Evolution
The Windows Metafile (WMF) format, introduced in 1987 with Windows 2.0, serves as the original 16-bit vector graphics format designed for storing sequences of Graphics Device Interface (GDI) commands in a device-independent manner.[1] 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.[3] This format was pivotal in early Windows applications for clipboard operations and printing but suffered from device dependencies and limited color support. To address these shortcomings, Microsoft developed the Enhanced Metafile (EMF) format in the early 1990s, debuting with Windows NT 3.1 in 1993 and Windows 3.1 via Win32s extensions.[7] 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 Unicode text via records like EMR_EXTTEXTOUTW, facilitating international character handling.[6] Building further on EMF, the Enhanced Metafile Plus (EMF+) format emerged in 2001 with the introduction of GDI+ in Windows XP, extending the EMF spool to embed GDI+ API calls for richer graphics capabilities.[8] EMF+ introduces support for alpha channels in bitmaps and brushes, allowing transparency and compositing effects, as well as gradient fills, texture brushes, and path-based rendering that emulate advanced features akin to those in modern graphics APIs.[9] Available in EMF+ Only mode for GDI+-exclusive content or Dual mode for backward compatibility with standard EMF records, it enables high-fidelity playback on systems supporting GDI+.[8] This progression reflects the evolution of Windows graphics: from the rudimentary WMF in the 1980s, constrained by 16-bit architecture; to EMF in the 1990s, prioritizing 32-bit scalability and portability; and culminating in EMF+ during the 2000s, which integrates sophisticated rendering for contemporary applications while maintaining interoperability.[5][6][8]History
Development of Original WMF
The original Windows Metafile (WMF) format appeared with the release of Windows 2.0 on December 9, 1987, as a core component of Microsoft's 16-bit Windows operating systems.[10] Developed during the mid-1980s, it formed an integral part of the Graphics Device Interface (GDI), Microsoft's foundational API for handling graphics output.[3] The primary design goals centered on enabling device-independent graphics operations, particularly for printing and clipboard transfers, by capturing graphical content in a portable manner that minimized information loss during scaling or device changes.[11] At its core, the WMF format was engineered by Microsoft 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 output device.[1] This approach allowed applications to store vector-based images and bitmaps in a single file, supporting scalability without pixelation and facilitating interoperability across Windows environments.[11] The format used the METAFILEPICT structure for clipboard integration, enabling seamless copy-paste operations of graphics 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.[10] 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.[12] 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.[11] 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.[11] 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 vector graphics in documents. This widespread use in early Windows ecosystems solidified WMF's role, despite its technical constraints.[1]Introduction of Enhanced Formats
The Enhanced Metafile (EMF) format was introduced in 1993 as part of the Win32 API with the release of Windows NT 3.1, 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.[6] This format played a central role in the Win32 Graphics Device Interface (GDI), enabling developers to create portable, device-independent pictures that could be played back consistently via functions like CreateEnhMetaFile.[13] Building on EMF, the Enhanced Metafile Plus (EMF+) format emerged in 2001 alongside the GDI+ library in Windows XP, 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.[14] 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.[7] 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.[9] This milestone facilitated the transition to modern graphics programming in Windows applications, prioritizing device independence and performance for evolving display technologies.[15]Technical Structure
WMF Format Details
The original Windows Metafile (WMF) format is a binary file 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.[16] The META_HEADER structure is defined as follows:| Field | Size (bytes) | Type | Description |
|---|---|---|---|
| Type | 2 | WORD (16-bit unsigned) | Specifies the metafile type; value 0x0001 indicates a standard WMF.[16] |
| HeaderSize | 2 | WORD (16-bit unsigned) | Number of words in the header; always 9 for standard WMFs.[16] |
| Version | 2 | WORD (16-bit unsigned) | Metafile version; for example, 0x0300 corresponds to the Windows 3.0 implementation.[16] |
| SizeLow | 2 | WORD (16-bit unsigned) | Low-order word of the total file size in words.[16] |
| SizeHigh | 2 | WORD (16-bit unsigned) | High-order word of the total file size in words (combined with SizeLow to form a 32-bit value).[16] |
| NumberOfObjects | 2 | WORD (16-bit unsigned) | Number of graphics objects (such as brushes or pens) defined in the metafile.[16] |
| MaxRecord | 4 | DWORD (32-bit unsigned) | Size of the largest record in the file, measured in words.[16] |
| NumberOfMembers | 2 | WORD (16-bit unsigned) | Reserved field; must be 0x0000 and is unused.[16] |
EMF Format Details
The Enhanced Metafile (EMF) format represents a significant advancement over its predecessor, the Windows Metafile (WMF), by adopting a 32-bit architecture that enables greater precision and portability in graphical representations.[7] 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.[6] 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.[18] 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).[19] 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.[18]| Field | Type | Size (bytes) | Description |
|---|---|---|---|
| Type | ULONG | 4 | Record type identifier (1 for EMR_HEADER).[18] |
| Size | ULONG | 4 | Total size of the EMR_HEADER record in bytes.[18] |
| rclBounds (image bounds) | RECTL | 16 | Smallest rectangle enclosing the metafile picture, in logical units (inclusive-inclusive coordinates).[19] |
| rclFrame (reference frame) | RECTL | 16 | Reference device frame enclosing the metafile picture, in 0.01 mm units (inclusive-inclusive coordinates).[19] |
| szlDevice (device frame) | SIZEL | 8 | Dimensions of the reference device in pixels (width and height).[19] |
| szlMillimeters | SIZEL | 8 | Dimensions of the reference device in 0.01 mm units (width and height, providing 100 units per millimeter for metric scaling).[19] |
| RecordSignature | ULONG | 4 | Signature identifying the format (e.g., 0x464D4520).[19] |
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.[9][21] 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.[21] 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.[21][22] 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 color correction or video display reference), and the total size of the EMF+ data in bytes.[22][23] 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.[24] 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.[9][22] 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.[9][15]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.[11] 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.[25] 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.[26] Drawing records in WMF and EMF handle vector primitives by rendering lines, polylines, and arcs using the current pen for outlines, with fills implicitly applied via the selected brush 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 pen, updating the position accordingly.[11] 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 pen for rendering without filling.[11] For curves, the ARC record (0x0817) draws an elliptical arc within a bounding rectangle specified by 16-bit coordinates, using start and end radial points to define the sweep angle in device units, with the pen for the outline and brush for any chord or pie fill if selected.[11] 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.[27] EMR_POLYLINE (type 0x00000024) renders connected lines from an array of 32-bit points, maintaining compatibility with WMF while enhancing scalability for higher resolutions.[28] Likewise, EMR_ARC (type 0x0000002D) defines arcs via a 32-bit bounding rectangle and start/end angles in logical units, applying the current pen for the curve and supporting brush fills for enclosed regions like sectors.[29] Across both formats, these records assume prior selection of pen and brush states, ensuring that line styles, widths, colors, and fill patterns are applied consistently during playback without explicit recreation in the primitive itself.[3][20]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 brushes, 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 brush defined by a LogBrush structure specifying the brush style (e.g., solid, hatched), color reference, and optional hatch pattern.[11] This record includes a fixed-size header with the record size and function identifier, followed by the LogBrush data, enabling device-independent brush definitions.[11] In the Enhanced Metafile (EMF) format, the equivalent is the EMR_CREATEBRUSHINDIRECT record (type 0x00000027), which uses a LogBrushEx structure to support additional attributes like texture bitmaps and gamma correction for more precise rendering.[30] 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.[11][31] The ihObject field in EMF provides a 32-bit index, supporting up to 64K objects, while WMF uses a 16-bit handle for efficiency in older systems.[31][11] 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.[11] 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.[11] 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.[32] 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.[11] EMF's EMR_SETMAPMODE (type 0x00000011) uses the same enumeration but integrates with floating-point world transformations for higher precision in modern graphics pipelines.[32] 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.[11] 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.[33] 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 bitmap memory.[11] 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.[30]| Record Category | WMF Record (Function) | EMF Record (Type) | Key Purpose |
|---|---|---|---|
| Object Creation | CREATEBRUSHINDIRECT (0x02FC) | EMR_CREATEBRUSHINDIRECT (0x00000027) | Define brushes with style, color, and patterns |
| Object Selection | SELECTOBJECT (0x012E) | EMR_SELECTOBJECT (0x00000025) | Activate object in device context |
| State Save/Restore | SAVE_DC (0x001E) / RESTORE_DC (0x0127) | EMR_SAVEDC (0x00000021) / EMR_RESTOREDC (0x00000022) | Stack-based context preservation |
| Mapping Mode | SETMAPMODE (0x0103) | EMR_SETMAPMODE (0x00000011) | Set coordinate transformation mode |
| Escape | ESCAPE (0x0626) | EMR_EXTESCAPE (0x0000006A) | Device-specific extensions |
| Object Deletion | DELETEOBJECT (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.[34] 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.[35] 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.[36] 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.[37] For EMF files, introduced with Windows NT 3.1 (with enhancements in Windows 95), the PlayEnhMetaFile function maps the metafile contents onto a target rectangle in the device context, supporting playback since Windows 95 and later versions.[38] 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 Object Linking and Embedding (OLE) mechanisms for exchanging vector graphics. WMF and EMF are registered clipboard formats (CF_METAFILEPICT for WMF and CF_ENHMETAFILE for EMF), allowing applications like Microsoft Paint and the Office suite to copy and paste graphics as device-independent pictures without loss of scalability.[39] 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.[40] In the Windows printing pipeline, EMF plays a central role in spooling for Win32 applications via the Print API. When printing, 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.[41] Starting with Windows Vista, the XPS print path incorporates EMF+ records—extensions to EMF supporting advanced features like gradients—for spooling in XML Paper Specification (XPS) documents, enabling higher-fidelity output in modern print drivers while maintaining compatibility with legacy GDI-based printing.[42] 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.[2] 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.[43] Backward compatibility ensures that WMF playback remains supported in Windows 10 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 interoperability.[37] 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 Linux 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 PNG, JPEG, PostScript (PS), Encapsulated PostScript (EPS), and SVG.[44] This library is commonly integrated into tools like ImageMagick, where it facilitates WMF rendering by default using the dimensions specified in the metafile header, with options like -density for resolution adjustments during rasterization.[45] UniConvertor, an open-source universal vector graphics translator from the sK1 Project, supports importing WMF files for editing and conversion within applications like Inkscape.[46] It uses the sK1 engine to handle WMF alongside other formats such as SVG, CDR, and CGM, allowing export to vector formats like SVG for cross-platform vector editing workflows.[47] While primarily focused on WMF, UniConvertor integrates with Inkscape extensions to enable batch processing of legacy metafiles in open-source vector graphics pipelines.[48] Commercial applications maintain compatibility with WMF and Enhanced Metafile (EMF) formats to handle legacy files from Windows ecosystems. Adobe Illustrator supports importing and exporting both WMF and EMF via its Open and Place commands, preserving vector data for editing in cross-platform design projects.[49] Similarly, CorelDRAW provides import and export capabilities for WMF, storing both vector and bitmap information in 24-bit RGB color, and extends support to EMF for enhanced metafile interchange in professional graphics workflows.[50] These features ensure backward compatibility without native Windows dependencies, though users may encounter limitations with complex EMF+ records.[51] ImageMagick's convert tool offers rasterization of WMF files on Unix-like systems, leveraging libwmf for accurate rendering to formats like PNG or JPEG.[52] 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.[45] 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.[53] Conversion utilities bridge metafile formats across ecosystems. Online services like Zamzar provide web-based conversion of WMF to SVG or PDF without software installation, processing files through cloud-based rasterization and vector extraction for quick cross-format access. Open-source Java libraries support metafile parsing in web and enterprise contexts. Apache Batik, a toolkit for SVG manipulation, includes a WMFTranscoder for converting WMF files to SVG, enabling embedding in Java-based web applications while handling basic metafile records.[54]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 Graphics Device Interface (GDI) library in Windows XP 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.[55] 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.[56][57] EMF+ extensions in GDI+ introduced risks from compressed records, where improper decompression led to heap corruption and arbitrary code execution. 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 Knowledge Base 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.[58] These vulnerabilities predominantly impacted users via email 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, Check Point Research disclosed three critical vulnerabilities in the Windows Graphics Device Interface (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.[59][60][58][61]Modern Alternatives and Deprecation
The Windows Metafile (WMF) format was largely phased out in favor of the Enhanced Metafile (EMF) starting with Windows 2000, as EMF provided improved device independence and 32-bit support for better scalability in graphics rendering.[11] EMF+ further extended EMF to incorporate GDI+ features but remains limited to legacy applications relying on the GDI+ library, with Microsoft shifting primary 2D graphics development to Direct2D beginning in Windows 8 for hardware-accelerated performance.[62][63] 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.[64] 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.[65] The rise of hardware-accelerated APIs like DirectX, underpinning Direct2D, has further diminished their relevance by enabling faster, GPU-accelerated vector and raster operations without the overhead of metafile playback.[66] Modern alternatives emphasize scalability and interoperability: Scalable Vector Graphics (SVG) serves as a primary substitute for web-based vector graphics, offering XML-based structure for resolution-independent rendering across browsers and devices.[67] For print workflows, Portable Document Format (PDF) provides robust portability with embedded vectors and fonts, while PNG and JPEG handle raster needs in user interfaces with better compression and transparency support.[68] WMF and EMF persist for backward compatibility in Microsoft Office 365, particularly for legacy printing and document insertion. Microsoft recommends modern APIs like Direct2D or web standards for new development.[68][39] 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 DirectX for modern vector handling.[69][70]References
- https://wiki.inkscape.org/wiki/Uniconvertor
