Do not allow creation of not aligned EMF records by GDI code

Dmitry Timoshkov dmitry at baikal.ru
Fri Jun 18 04:39:45 CDT 2004


Hello,

Wine (like Windows) refuses to load unaligned EMF files. This patch
makes sure that EMF generating code in Wine will not suffer a breakage
in that area in future.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Do not allow creation of not aligned EMF records by GDI code.

--- cvs/hq/wine/dlls/gdi/enhmfdrv/init.c	2004-01-16 17:47:19.000000000 +0800
+++ wine/dlls/gdi/enhmfdrv/init.c	2004-02-05 16:01:40.000000000 +0800
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <assert.h>
 #include <stdarg.h>
 #include <string.h>
 
@@ -186,11 +187,19 @@ BOOL EMFDRV_WriteRecord( PHYSDEV dev, EM
     ENHMETAHEADER *emh;
     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
 
+    TRACE("record %ld, size %ld %s\n",
+          emr->iType, emr->nSize, physDev->hFile ? "(to disk)" : "");
+
+    if (emr->nSize & 3)
+    {
+        ERR("EMF record %ld breaks file alignment!\n", emr->iType);
+        assert(0);
+    }
+
     physDev->emh->nBytes += emr->nSize;
     physDev->emh->nRecords++;
 
     if(physDev->hFile) {
-        TRACE("Writing record to disk\n");
 	if (!WriteFile(physDev->hFile, (char *)emr, emr->nSize, NULL, NULL))
 	    return FALSE;
     } else {






More information about the wine-patches mailing list