d3d: Fix the surface locking rectangle validation.

This commit is contained in:
H. Verbeet 2007-05-03 20:58:48 +02:00 committed by Alexandre Julliard
parent 1fca7eccb0
commit 7b48db196f
4 changed files with 30 additions and 22 deletions

View File

@ -147,6 +147,22 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p) Relay\n", This);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
if (pRect) {
D3DSURFACE_DESC desc;
IDirect3DSurface8_GetDesc(iface, &desc);
if ((pRect->left < 0)
|| (pRect->top < 0)
|| (pRect->left >= pRect->right)
|| (pRect->top >= pRect->bottom)
|| (pRect->right > desc.Width)
|| (pRect->bottom > desc.Height)) {
WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
return D3DERR_INVALIDCALL;
}
}
return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}

View File

@ -549,6 +549,20 @@ IDirectDrawSurfaceImpl_Lock(IDirectDrawSurface7 *iface,
HRESULT hr;
TRACE("(%p)->(%p,%p,%x,%p)\n", This, Rect, DDSD, Flags, h);
if (Rect)
{
if ((Rect->left < 0)
|| (Rect->top < 0)
|| (Rect->left > Rect->right)
|| (Rect->top > Rect->bottom)
|| (Rect->right > This->surface_desc.dwWidth)
|| (Rect->bottom > This->surface_desc.dwHeight))
{
WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
return DDERR_INVALIDPARAMS;
}
}
if(!DDSD)
return DDERR_INVALIDPARAMS;

View File

@ -720,17 +720,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
} else {
TRACE("Lock Rect (%p) = l %d, t %d, r %d, b %d\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
if ((pRect->top < 0) ||
(pRect->left < 0) ||
(pRect->left >= pRect->right) ||
(pRect->top >= pRect->bottom) ||
(pRect->right > This->currentDesc.Width) ||
(pRect->bottom > This->currentDesc.Height))
{
WARN(" Invalid values in pRect !!!\n");
return WINED3DERR_INVALIDCALL;
}
/* DXTn textures are based on compressed blocks of 4x4 pixels, each
* 16 bytes large (8 bytes in case of DXT1). Because of that Pitch has
* slightly different meaning compared to regular textures. For DXTn

View File

@ -209,17 +209,6 @@ IWineGDISurfaceImpl_LockRect(IWineD3DSurface *iface,
TRACE("Lock Rect (%p) = l %d, t %d, r %d, b %d\n",
pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
if ((pRect->top < 0) ||
(pRect->left < 0) ||
(pRect->left >= pRect->right) ||
(pRect->top >= pRect->bottom) ||
(pRect->right > This->currentDesc.Width) ||
(pRect->bottom > This->currentDesc.Height))
{
WARN(" Invalid values in pRect !!!\n");
return WINED3DERR_INVALIDCALL;
}
if (This->resource.format == WINED3DFMT_DXT1)
{
/* DXT1 is half byte per pixel */