In CreateDIBSection, the offset into the file mapping does not have to
be a multiple of the memory allocation granularity.

diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c
index 13b998a..1dda259 100644
--- a/graphics/x11drv/dib.c
+++ b/graphics/x11drv/dib.c
@@ -3793,6 +3793,7 @@
   BITMAPINFOHEADER *bi = &bmi->bmiHeader;
   INT effHeight, totalSize;
   BITMAP bm;
+  LPVOID mapBits = NULL;
   
   TRACE("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
 	bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
@@ -3814,8 +3815,21 @@
     ? bi->biSizeImage : bm.bmWidthBytes * effHeight;
   
   if (section)
-    bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS, 
-			      0L, offset, totalSize);
+  {
+      SYSTEM_INFO SystemInfo;
+      DWORD mapOffset;
+      INT mapSize;
+
+      GetSystemInfo( &SystemInfo );
+      mapOffset = offset - (offset % SystemInfo.dwAllocationGranularity);
+      mapSize = totalSize + (offset - mapOffset);
+      mapBits = MapViewOfFile( section,
+			       FILE_MAP_ALL_ACCESS, 
+			       0L,
+			       mapOffset,
+			       mapSize );
+      bm.bmBits = (char *)mapBits + (offset - mapOffset);
+  }
   else if (ovr_pitch && offset)
     bm.bmBits = (LPVOID) offset;
   else {
@@ -3916,7 +3930,7 @@
       if (bm.bmBits)
         {
 	  if (section)
-	    UnmapViewOfFile(bm.bmBits), bm.bmBits = NULL;
+	    UnmapViewOfFile(mapBits), bm.bmBits = NULL;
 	  else if (!offset)
 	    VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
         }
diff --git a/objects/dib.c b/objects/dib.c
index 29f8090..5dfb6c9 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -930,7 +930,12 @@
         if (dib->dsBm.bmBits)
         {
             if (dib->dshSection)
-                UnmapViewOfFile(dib->dsBm.bmBits);
+	    {
+		SYSTEM_INFO SystemInfo;
+		GetSystemInfo( &SystemInfo );
+		UnmapViewOfFile( (char *)dib->dsBm.bmBits -
+				 (dib->dsOffset % SystemInfo.dwAllocationGranularity) );
+	    }
             else if (!dib->dsOffset)
                 VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
         }