ddraw: Add a test for incorrect surface desc sizes for Lock().
This commit is contained in:
parent
2a98b40a9f
commit
e019cebd16
|
@ -582,17 +582,12 @@ IDirectDrawSurfaceImpl_Lock(IDirectDrawSurface7 *iface,
|
|||
* for the supported values. The others are ignored by WineD3D
|
||||
*/
|
||||
|
||||
/* Hmm. Anarchy online passes an uninitialized surface descriptor,
|
||||
* that means it doesn't have dwSize set. Init it to some sane
|
||||
* value
|
||||
*/
|
||||
if(DDSD->dwSize <= sizeof(DDSURFACEDESC))
|
||||
if(DDSD->dwSize != sizeof(DDSURFACEDESC) &&
|
||||
DDSD->dwSize != sizeof(DDSURFACEDESC2))
|
||||
{
|
||||
DDSD->dwSize = sizeof(DDSURFACEDESC);
|
||||
}
|
||||
else
|
||||
{
|
||||
DDSD->dwSize = sizeof(DDSURFACEDESC2);
|
||||
WARN("Invalid structure size %d, returning DDERR_INVALIDPARAMS\n", DDERR_INVALIDPARAMS);
|
||||
LeaveCriticalSection(&ddraw_cs);
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
hr = IWineD3DSurface_LockRect(This->WineD3DSurface,
|
||||
|
|
|
@ -2315,6 +2315,52 @@ static void StructSizeTest(void)
|
|||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
|
||||
/* Tests for Lock() */
|
||||
|
||||
desc.desc1.dwSize = sizeof(DDSURFACEDESC);
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC) returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
ok(desc.desc1.dwSize == sizeof(DDSURFACEDESC), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC) returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
ok(desc.desc2.dwSize == sizeof(DDSURFACEDESC), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
|
||||
desc.desc2.dwSize = sizeof(DDSURFACEDESC2);
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC2) returned %08x\n", hr);
|
||||
ok(desc.desc1.dwSize == sizeof(DDSURFACEDESC2), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC2) returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
ok(desc.desc2.dwSize == sizeof(DDSURFACEDESC2), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
|
||||
desc.desc2.dwSize = 0;
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Lock with desc size 0 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size 0 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
|
||||
desc.desc1.dwSize = sizeof(DDSURFACEDESC) + 1;
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC) + 1 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC) + 1 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
|
||||
desc.desc2.dwSize = sizeof(DDSURFACEDESC2) + 1;
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
|
||||
IDirectDrawSurface7_Release(surface7);
|
||||
IDirectDrawSurface_Release(surface1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue