Module: wine Branch: master Commit: ca6b29983b43db43e34cc1befaf064a650f7359f URL: http://source.winehq.org/git/wine.git/?a=commit;h=ca6b29983b43db43e34cc1befa...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Feb 1 12:02:56 2017 +0100
ddraw: Validate the primary surface dimensions in ddraw_surface7_Restore().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ddraw/surface.c | 20 ++++++++++++++++++++ dlls/ddraw/tests/ddraw1.c | 12 ++++++------ dlls/ddraw/tests/ddraw2.c | 12 ++++++------ dlls/ddraw/tests/ddraw4.c | 12 ++++++------ dlls/ddraw/tests/ddraw7.c | 12 ++++++------ 5 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 94f850b..c46472c 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -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;
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 2f83314..28b67fd 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -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; diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 70382bd..f27889f 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -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; diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 925852e..bcbc2f3 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -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; diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index fef3801..3774afb 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -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;