Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
94127492
Commit
94127492
authored
May 24, 2007
by
Stefan Dösinger
Committed by
Alexandre Julliard
May 31, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Check the validy of IDirectDrawSurface::BltFast parameters.
parent
8b6a3610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
surface.c
dlls/ddraw/surface.c
+29
-0
dsurface.c
dlls/ddraw/tests/dsurface.c
+57
-0
No files found.
dlls/ddraw/surface.c
View file @
94127492
...
@@ -2027,6 +2027,35 @@ IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
...
@@ -2027,6 +2027,35 @@ IDirectDrawSurfaceImpl_BltFast(IDirectDrawSurface7 *iface,
IDirectDrawSurfaceImpl
*
src
=
ICOM_OBJECT
(
IDirectDrawSurfaceImpl
,
IDirectDrawSurface7
,
Source
);
IDirectDrawSurfaceImpl
*
src
=
ICOM_OBJECT
(
IDirectDrawSurfaceImpl
,
IDirectDrawSurface7
,
Source
);
TRACE
(
"(%p)->(%d,%d,%p,%p,%d): Relay
\n
"
,
This
,
dstx
,
dsty
,
Source
,
rsrc
,
trans
);
TRACE
(
"(%p)->(%d,%d,%p,%p,%d): Relay
\n
"
,
This
,
dstx
,
dsty
,
Source
,
rsrc
,
trans
);
/* Source must be != NULL, This is not checked by windows. Windows happily throws a 0xc0000005
* in that case
*/
if
(
rsrc
)
{
if
(
rsrc
->
top
>
rsrc
->
bottom
||
rsrc
->
left
>
rsrc
->
right
||
rsrc
->
right
>
src
->
surface_desc
.
dwWidth
||
rsrc
->
bottom
>
src
->
surface_desc
.
dwHeight
)
{
WARN
(
"Source rectangle is invalid, returning DDERR_INVALIDRECT
\n
"
);
return
DDERR_INVALIDRECT
;
}
if
(
dstx
+
rsrc
->
right
-
rsrc
->
left
>
This
->
surface_desc
.
dwWidth
||
dsty
+
rsrc
->
bottom
-
rsrc
->
top
>
This
->
surface_desc
.
dwHeight
)
{
WARN
(
"Destination area out of bounds, returning DDERR_INVALIDRECT
\n
"
);
return
DDERR_INVALIDRECT
;
}
}
else
{
if
(
dstx
+
src
->
surface_desc
.
dwWidth
>
This
->
surface_desc
.
dwWidth
||
dsty
+
src
->
surface_desc
.
dwHeight
>
This
->
surface_desc
.
dwHeight
)
{
WARN
(
"Destination area out of bounds, returning DDERR_INVALIDRECT
\n
"
);
return
DDERR_INVALIDRECT
;
}
}
EnterCriticalSection
(
&
ddraw_cs
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DSurface_BltFast
(
This
->
WineD3DSurface
,
hr
=
IWineD3DSurface_BltFast
(
This
->
WineD3DSurface
,
dstx
,
dsty
,
dstx
,
dsty
,
...
...
dlls/ddraw/tests/dsurface.c
View file @
94127492
...
@@ -2203,6 +2203,62 @@ static void PrivateDataTest(void)
...
@@ -2203,6 +2203,62 @@ static void PrivateDataTest(void)
ok
(
ref2
==
ref
,
"Object reference is %d, expected %d
\n
"
,
ref2
,
ref
);
ok
(
ref2
==
ref
,
"Object reference is %d, expected %d
\n
"
,
ref2
,
ref
);
}
}
static
void
BltParamTest
(
void
)
{
IDirectDrawSurface
*
surface1
=
NULL
,
*
surface2
=
NULL
;
DDSURFACEDESC
desc
;
HRESULT
hr
;
RECT
valid
=
{
10
,
10
,
20
,
20
};
RECT
invalid1
=
{
20
,
10
,
10
,
20
};
RECT
invalid2
=
{
20
,
20
,
20
,
20
};
RECT
invalid3
=
{
-
1
,
-
1
,
20
,
20
};
RECT
invalid4
=
{
60
,
60
,
70
,
70
};
memset
(
&
desc
,
0
,
sizeof
(
desc
));
desc
.
dwSize
=
sizeof
(
desc
);
desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_HEIGHT
|
DDSD_WIDTH
;
desc
.
ddsCaps
.
dwCaps
|=
DDSCAPS_OFFSCREENPLAIN
;
desc
.
dwHeight
=
128
;
desc
.
dwWidth
=
128
;
hr
=
IDirectDraw_CreateSurface
(
lpDD
,
&
desc
,
&
surface1
,
NULL
);
ok
(
hr
==
DD_OK
,
"Creating an offscreen plain surface failed with %08x
\n
"
,
hr
);
desc
.
dwHeight
=
64
;
desc
.
dwWidth
=
64
;
hr
=
IDirectDraw_CreateSurface
(
lpDD
,
&
desc
,
&
surface2
,
NULL
);
ok
(
hr
==
DD_OK
,
"Creating an offscreen plain surface failed with %08x
\n
"
,
hr
);
if
(
0
)
{
/* This crashes */
hr
=
IDirectDrawSurface_BltFast
(
surface1
,
0
,
0
,
NULL
,
NULL
,
0
);
ok
(
hr
==
DD_OK
,
"BltFast from NULL surface returned %08x
\n
"
,
hr
);
}
hr
=
IDirectDrawSurface_BltFast
(
surface1
,
0
,
0
,
surface2
,
NULL
,
0
);
ok
(
hr
==
DD_OK
,
"BltFast from smaller to bigger surface returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface2
,
0
,
0
,
surface1
,
NULL
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast from bigger to smaller surface returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface2
,
0
,
0
,
surface1
,
&
valid
,
0
);
ok
(
hr
==
DD_OK
,
"BltFast from bigger to smaller surface using a valid rectangle returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface2
,
60
,
60
,
surface1
,
&
valid
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast with a rectangle resulting in an off-surface write returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface1
,
90
,
90
,
surface2
,
NULL
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast with a rectangle resulting in an off-surface write returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface2
,
0
,
0
,
surface1
,
&
invalid1
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast with invalid rectangle 1 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface2
,
0
,
0
,
surface1
,
&
invalid2
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast with invalid rectangle 2 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface2
,
0
,
0
,
surface1
,
&
invalid3
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast with invalid rectangle 3 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface1
,
0
,
0
,
surface2
,
&
invalid4
,
0
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"BltFast with invalid rectangle 3 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_BltFast
(
surface1
,
0
,
0
,
surface1
,
NULL
,
0
);
ok
(
hr
==
DD_OK
,
"BltFast blitting a surface onto itself returned %08x
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface1
);
IDirectDrawSurface_Release
(
surface2
);
}
START_TEST
(
dsurface
)
START_TEST
(
dsurface
)
{
{
if
(
!
CreateDirectDraw
())
if
(
!
CreateDirectDraw
())
...
@@ -2222,5 +2278,6 @@ START_TEST(dsurface)
...
@@ -2222,5 +2278,6 @@ START_TEST(dsurface)
CompressedTest
();
CompressedTest
();
SizeTest
();
SizeTest
();
PrivateDataTest
();
PrivateDataTest
();
BltParamTest
();
ReleaseDirectDraw
();
ReleaseDirectDraw
();
}
}
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