Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/surface.c | 18 ++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 13 +++++++++++++ 2 files changed, 31 insertions(+)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index b6a7ebb734..9850a1e8c9 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1110,6 +1110,12 @@ static HRESULT WINAPI ddraw_surface7_Lock(IDirectDrawSurface7 *iface, if (!surface_validate_lock_desc(surface, (DDSURFACEDESC *)surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
+ if (ddraw_surface_is_lost(surface)) + { + WARN("Surface is lost.\n"); + return DDERR_SURFACELOST; + } + return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h); }
@@ -1125,6 +1131,12 @@ static HRESULT WINAPI ddraw_surface4_Lock(IDirectDrawSurface4 *iface, RECT *rect if (!surface_validate_lock_desc(surface, (DDSURFACEDESC *)surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
+ if (ddraw_surface_is_lost(surface)) + { + WARN("Surface is lost.\n"); + return DDERR_SURFACELOST; + } + return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h); }
@@ -1138,6 +1150,12 @@ static HRESULT ddraw_surface_lock_ddsd(struct ddraw_surface *surface, RECT *rect if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
+ if (ddraw_surface_is_lost(surface)) + { + WARN("Surface is lost.\n"); + return DDERR_SURFACELOST; + } + surface_desc2.dwSize = surface_desc->dwSize; surface_desc2.dwFlags = 0; hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 5c0c5bb7c3..abe5249cc0 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -1056,6 +1056,7 @@ static void test_coop_level_d3d_state(void) IDirectDrawSurface7 *rt, *surface; IDirect3DDevice7 *device; IDirectDraw7 *ddraw; + DDSURFACEDESC2 lock; IDirect3D7 *d3d; D3DCOLOR color; DDSCAPS2 caps; @@ -1116,6 +1117,13 @@ static void test_coop_level_d3d_state(void) hr = IDirectDrawSurface7_IsLost(rt); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+ memset(&lock, 0, sizeof(lock)); + lock.dwSize = sizeof(lock); + lock.lpSurface = (void *)0xdeadbeef; + hr = IDirectDrawSurface7_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface); + memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_ZBUFFER; hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface); @@ -1127,6 +1135,11 @@ static void test_coop_level_d3d_state(void) hr = IDirectDraw7_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_Unlock(rt, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + caps.dwCaps = DDSCAPS_ZBUFFER; hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);