Andrew Eikum : wined3d: Validate that we got a valid window in wined3d_device_setup_fullscreen_window ().
Alexandre Julliard
julliard at winehq.org
Thu Jun 20 16:04:14 CDT 2019
Module: wine
Branch: master
Commit: 628d60a1596eb470e155b41e158e6b68d9c3ddd9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=628d60a1596eb470e155b41e158e6b68d9c3ddd9
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Thu Jun 20 02:47:48 2019 +0430
wined3d: Validate that we got a valid window in wined3d_device_setup_fullscreen_window().
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dxgi/tests/dxgi.c | 4 ++--
dlls/wined3d/device.c | 11 ++++++++++-
dlls/wined3d/swapchain.c | 4 +++-
include/wine/wined3d.h | 3 ++-
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index f5e1b10..69c868c 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -2292,7 +2292,7 @@ static void test_set_fullscreen(void)
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, NULL);
- todo_wine ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
+ ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
refcount = IDXGISwapChain_Release(swapchain);
@@ -2310,7 +2310,7 @@ static void test_set_fullscreen(void)
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, NULL);
- todo_wine ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
+ ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
refcount = IDXGISwapChain_Release(swapchain);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 768375d..d35a064 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -927,13 +927,20 @@ static LONG fullscreen_exstyle(LONG exstyle)
return exstyle;
}
-void CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h)
+HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
+ HWND window, unsigned int w, unsigned int h)
{
BOOL filter_messages;
LONG style, exstyle;
TRACE("Setting up window %p for fullscreen mode.\n", window);
+ if (!IsWindow(window))
+ {
+ WARN("%p is not a valid window.\n", window);
+ return WINED3DERR_NOTAVAILABLE;
+ }
+
if (device->style || device->exStyle)
{
ERR("Changing the window style for window %p, but another style (%08x, %08x) is already stored.\n",
@@ -957,6 +964,8 @@ void CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
SetWindowPos(window, HWND_TOPMOST, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
device->filter_messages = filter_messages;
+
+ return WINED3D_OK;
}
void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window,
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 7807341..8d6306e 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1478,7 +1478,9 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha
if (swapchain->desc.windowed)
{
/* Switch from windowed to fullscreen */
- wined3d_device_setup_fullscreen_window(device, swapchain->device_window, width, height);
+ if (FAILED(hr = wined3d_device_setup_fullscreen_window(device,
+ swapchain->device_window, width, height)))
+ return hr;
}
else
{
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index a0ff3f1..abef3f0 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2483,7 +2483,8 @@ HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device,
void __cdecl wined3d_device_set_vs_resource_view(struct wined3d_device *device,
UINT idx, struct wined3d_shader_resource_view *view);
void __cdecl wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler);
-void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h);
+HRESULT __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
+ HWND window, unsigned int w, unsigned int h);
BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show);
void __cdecl wined3d_device_update_sub_resource(struct wined3d_device *device, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
More information about the wine-cvs
mailing list