[GDI32] Meta File Fix Ups
authorJames Tabor <james.tabor@reactos.org>
Mon, 3 Jun 2019 20:49:14 +0000 (15:49 -0500)
committerJames Tabor <james.tabor@reactos.org>
Mon, 3 Jun 2019 20:49:14 +0000 (15:49 -0500)
Remove pointer hack. Safer since using wines Enhanced Meta headers with
unknown wine magic information.

win32ss/gdi/gdi32/objects/metafile.c

index e1a51fb..42bd22e 100644 (file)
@@ -139,16 +139,22 @@ GdiCreateLocalMetaFilePict(HANDLE hmo)
     {
         static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
         HENHMETAFILE hEMF;
     {
         static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
         HENHMETAFILE hEMF;
-        PENHMETAHEADER pemh = (PENHMETAHEADER)Buffer;
-
-        pInfo->mm   = MM_ANISOTROPIC;
-        pInfo->xExt = pemh->rclFrame.right   - pemh->rclFrame.left; // Width
-        pInfo->yExt = pemh->rclFrame.bottom  - pemh->rclFrame.top;  // Height
+        ENHMETAHEADER emh;
 
         hEMF = SetEnhMetaFileBits(nSize, Buffer);
         if (hEMF == NULL)
             goto Exit;
 
 
         hEMF = SetEnhMetaFileBits(nSize, Buffer);
         if (hEMF == NULL)
             goto Exit;
 
+        if (!GetEnhMetaFileHeader( hEMF, sizeof(emh), &emh ))
+        {
+            DeleteEnhMetaFile(hEMF);
+            goto Exit;
+        }
+
+        pInfo->mm   = MM_ANISOTROPIC; // wine uses MM_ISOTROPIC.
+        pInfo->xExt = emh.rclFrame.right   - emh.rclFrame.left; // Width
+        pInfo->yExt = emh.rclFrame.bottom  - emh.rclFrame.top;  // Height
+
         hDC = CreateDCW(szDisplayW, NULL, NULL, NULL);
         if (hDC)
         {
         hDC = CreateDCW(szDisplayW, NULL, NULL, NULL);
         if (hDC)
         {