user32: Fix METAFILEPICT marshalling for 64-bit.

Spotted by Sebastian Lackner.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-09-28 11:34:19 +09:00
parent c2150301b3
commit ab44b31287
1 changed files with 24 additions and 7 deletions

View File

@ -74,6 +74,15 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
}; };
static CRITICAL_SECTION clipboard_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; static CRITICAL_SECTION clipboard_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
/* platform-independent version of METAFILEPICT */
struct metafile_pict
{
LONG mm;
LONG xExt;
LONG yExt;
BYTE bits[1];
};
/* get a debug string for a format id */ /* get a debug string for a format id */
static const char *debugstr_format( UINT id ) static const char *debugstr_format( UINT id )
{ {
@ -155,21 +164,24 @@ static HANDLE marshal_data( UINT format, HANDLE handle, data_size_t *ret_size )
case CF_METAFILEPICT: case CF_METAFILEPICT:
case CF_DSPMETAFILEPICT: case CF_DSPMETAFILEPICT:
{ {
METAFILEPICT *mf, *mfbits; METAFILEPICT *mf;
struct metafile_pict *mfbits;
if (!(mf = GlobalLock( handle ))) return 0; if (!(mf = GlobalLock( handle ))) return 0;
if (!(size = GetMetaFileBitsEx( mf->hMF, 0, NULL ))) if (!(size = GetMetaFileBitsEx( mf->hMF, 0, NULL )))
{ {
GlobalUnlock( handle ); GlobalUnlock( handle );
return 0; return 0;
} }
*ret_size = sizeof(*mf) + size; *ret_size = offsetof( struct metafile_pict, bits[size] );
if (!(mfbits = GlobalAlloc( GMEM_FIXED, *ret_size ))) if (!(mfbits = GlobalAlloc( GMEM_FIXED, *ret_size )))
{ {
GlobalUnlock( handle ); GlobalUnlock( handle );
return 0; return 0;
} }
*mfbits = *mf; mfbits->mm = mf->mm;
GetMetaFileBitsEx( mf->hMF, size, mfbits + 1 ); mfbits->xExt = mf->xExt;
mfbits->yExt = mf->yExt;
GetMetaFileBitsEx( mf->hMF, size, mfbits->bits );
GlobalUnlock( handle ); GlobalUnlock( handle );
return mfbits; return mfbits;
} }
@ -235,9 +247,14 @@ static HANDLE unmarshal_data( UINT format, void *data, data_size_t size )
case CF_METAFILEPICT: case CF_METAFILEPICT:
case CF_DSPMETAFILEPICT: case CF_DSPMETAFILEPICT:
{ {
METAFILEPICT *mf = handle; METAFILEPICT mf;
if (size <= sizeof(*mf)) break; struct metafile_pict *mfbits = handle;
mf->hMF = SetMetaFileBitsEx( size - sizeof(*mf), (BYTE *)(mf + 1) ); if (size <= sizeof(*mfbits)) break;
mf.mm = mfbits->mm;
mf.xExt = mfbits->xExt;
mf.yExt = mfbits->yExt;
mf.hMF = SetMetaFileBitsEx( size - offsetof( struct metafile_pict, bits ), mfbits->bits );
*(METAFILEPICT *)handle = mf;
return handle; return handle;
} }
} }