[PATCH 03/10] dxgi: Validate that we got a valid window in wined3d_device_setup_fullscreen_window().
Henri Verbeet
hverbeet at codeweavers.com
Wed Jun 19 16:59:48 CDT 2019
From: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
This supersedes patch 166680.
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 f5e1b10a746..69c868cf3b4 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 81b5a3ab620..4c323f2387c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -926,13 +926,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",
@@ -956,6 +963,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 780734112fe..8d6306eee66 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 a0ff3f13354..abef3f0ad02 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,
--
2.11.0
More information about the wine-devel
mailing list