Commit ca6b2998 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Validate the primary surface dimensions in ddraw_surface7_Restore().

parent 0885e3f5
......@@ -3622,6 +3622,26 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
TRACE("iface %p.\n", iface);
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
struct wined3d_swapchain *swapchain = surface->ddraw->wined3d_swapchain;
struct wined3d_display_mode mode;
HRESULT hr;
if (FAILED(hr = wined3d_swapchain_get_display_mode(swapchain, &mode, NULL)))
{
WARN("Failed to get display mode, hr %#x.\n", hr);
return hr;
}
if (mode.width != surface->surface_desc.dwWidth || mode.height != surface->surface_desc.dwHeight)
{
WARN("Display mode %ux%u doesn't match surface dimensions %ux%u.\n",
mode.width, mode.height, surface->surface_desc.dwWidth, surface->surface_desc.dwHeight);
return DDERR_WRONGMODE;
}
}
ddraw_update_lost_surfaces(surface->ddraw);
surface->is_lost = FALSE;
......
......@@ -2724,7 +2724,7 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
......@@ -2735,9 +2735,9 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......@@ -2894,13 +2894,13 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......
......@@ -2891,7 +2891,7 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
......@@ -2902,9 +2902,9 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......@@ -3061,13 +3061,13 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......
......@@ -3034,13 +3034,13 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface4_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface4_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......@@ -3197,13 +3197,13 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface4_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface4_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......
......@@ -2760,13 +2760,13 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface7_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface7_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......@@ -2923,13 +2923,13 @@ static void test_coop_level_mode_set(void)
screen_size.cy = 0;
hr = IDirectDrawSurface7_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDrawSurface7_Restore(primary);
todo_wine ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_IsLost(primary);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment