Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6aa84e0e
Commit
6aa84e0e
authored
May 28, 2007
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
May 29, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Perform consistency checks when loading an EMF, add a test case.
parent
fb0a9291
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
23 deletions
+65
-23
enhmetafile.c
dlls/gdi32/enhmetafile.c
+19
-21
metafile.c
dlls/gdi32/tests/metafile.c
+46
-2
No files found.
dlls/gdi32/enhmetafile.c
View file @
6aa84e0e
...
...
@@ -250,9 +250,20 @@ static inline BOOL is_dib_monochrome( const BITMAPINFO* info )
HENHMETAFILE
EMF_Create_HENHMETAFILE
(
ENHMETAHEADER
*
emh
,
BOOL
on_disk
)
{
HENHMETAFILE
hmf
=
0
;
ENHMETAFILEOBJ
*
metaObj
=
GDI_AllocObject
(
sizeof
(
ENHMETAFILEOBJ
),
ENHMETAFILE_MAGIC
,
(
HGDIOBJ
*
)
&
hmf
,
NULL
);
ENHMETAFILEOBJ
*
metaObj
;
if
(
emh
->
iType
!=
EMR_HEADER
||
emh
->
dSignature
!=
ENHMETA_SIGNATURE
||
(
emh
->
nBytes
&
3
))
/* refuse to load unaligned EMF as Windows does */
{
WARN
(
"Invalid emf header type 0x%08x sig 0x%08x.
\n
"
,
emh
->
iType
,
emh
->
dSignature
);
SetLastError
(
ERROR_INVALID_DATA
);
return
0
;
}
metaObj
=
GDI_AllocObject
(
sizeof
(
ENHMETAFILEOBJ
),
ENHMETAFILE_MAGIC
,
(
HGDIOBJ
*
)
&
hmf
,
NULL
);
if
(
metaObj
)
{
metaObj
->
emh
=
emh
;
...
...
@@ -304,6 +315,7 @@ static HENHMETAFILE EMF_GetEnhMetaFile( HANDLE hFile )
{
ENHMETAHEADER
*
emh
;
HANDLE
hMapping
;
HENHMETAFILE
hemf
;
hMapping
=
CreateFileMappingA
(
hFile
,
NULL
,
PAGE_READONLY
,
0
,
0
,
NULL
);
emh
=
MapViewOfFile
(
hMapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
...
...
@@ -311,24 +323,10 @@ static HENHMETAFILE EMF_GetEnhMetaFile( HANDLE hFile )
if
(
!
emh
)
return
0
;
if
(
emh
->
iType
!=
EMR_HEADER
||
emh
->
dSignature
!=
ENHMETA_SIGNATURE
)
{
WARN
(
"Invalid emf header type 0x%08x sig 0x%08x.
\n
"
,
emh
->
iType
,
emh
->
dSignature
);
goto
err
;
}
/* refuse to load unaligned EMF as Windows does */
if
(
emh
->
nBytes
&
3
)
{
WARN
(
"Refusing to load unaligned EMF
\n
"
);
goto
err
;
}
return
EMF_Create_HENHMETAFILE
(
emh
,
TRUE
);
err:
UnmapViewOfFile
(
emh
);
return
0
;
hemf
=
EMF_Create_HENHMETAFILE
(
emh
,
TRUE
);
if
(
!
hemf
)
UnmapViewOfFile
(
emh
);
return
hemf
;
}
...
...
dlls/gdi32/tests/metafile.c
View file @
6aa84e0e
...
...
@@ -1541,7 +1541,7 @@ static void test_gdiis(void)
ok
(
!
pGdiIsMetaPrintDC
(
hmfDC
),
"ismetaprint on metafile
\n
"
);
ok
(
pGdiIsMetaFileDC
(
hmfDC
),
"ismetafile on metafile
\n
"
);
ok
(
!
pGdiIsPlayMetafileDC
(
hmfDC
),
"isplaymetafile on metafile
\n
"
);
Delete
Object
(
CloseMetaFile
(
hmfDC
));
Delete
MetaFile
(
CloseMetaFile
(
hmfDC
));
/* try with an enhanced metafile */
hdc
=
GetDC
(
NULL
);
...
...
@@ -1554,10 +1554,53 @@ static void test_gdiis(void)
hemf
=
CloseEnhMetaFile
(
hemfDC
);
ok
(
hemf
!=
NULL
,
"failed to close EMF
\n
"
);
Delete
Object
(
hemf
);
Delete
EnhMetaFile
(
hemf
);
ReleaseDC
(
NULL
,
hdc
);
}
static
void
test_SetEnhMetaFileBits
(
void
)
{
BYTE
data
[
256
];
HENHMETAFILE
hemf
;
ENHMETAHEADER
*
emh
;
memset
(
data
,
0xAA
,
sizeof
(
data
));
SetLastError
(
0xdeadbeef
);
hemf
=
SetEnhMetaFileBits
(
sizeof
(
data
),
data
);
ok
(
!
hemf
,
"SetEnhMetaFileBits should fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_DATA
,
"expected ERROR_INVALID_DATA, got %u
\n
"
,
GetLastError
());
emh
=
(
ENHMETAHEADER
*
)
data
;
memset
(
emh
,
0
,
sizeof
(
*
emh
));
emh
->
iType
=
EMR_HEADER
;
emh
->
nSize
=
sizeof
(
*
emh
);
emh
->
dSignature
=
ENHMETA_SIGNATURE
;
/* emh->nVersion = 0x10000; XP doesn't care about version */
emh
->
nBytes
=
sizeof
(
*
emh
);
/* emh->nRecords = 1; XP doesn't care about records */
emh
->
nHandles
=
1
;
/* XP refuses to load a EMF if nHandles == 0 */
SetLastError
(
0xdeadbeef
);
hemf
=
SetEnhMetaFileBits
(
emh
->
nBytes
,
data
);
ok
(
hemf
!=
0
,
"SetEnhMetaFileBits error %u
\n
"
,
GetLastError
());
DeleteEnhMetaFile
(
hemf
);
/* XP refuses to load unaligned EMF */
emh
->
nBytes
++
;
SetLastError
(
0xdeadbeef
);
hemf
=
SetEnhMetaFileBits
(
emh
->
nBytes
,
data
);
ok
(
!
hemf
,
"SetEnhMetaFileBits should fail
\n
"
);
/* XP doesn't set error in this case */
emh
->
dSignature
=
0
;
emh
->
nBytes
--
;
SetLastError
(
0xdeadbeef
);
hemf
=
SetEnhMetaFileBits
(
emh
->
nBytes
,
data
);
ok
(
!
hemf
,
"SetEnhMetaFileBits should fail
\n
"
);
/* XP doesn't set error in this case */
}
START_TEST
(
metafile
)
{
init_function_pointers
();
...
...
@@ -1580,4 +1623,5 @@ START_TEST(metafile)
test_SetWinMetaFileBits
();
test_gdiis
();
test_SetEnhMetaFileBits
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment