From 4d54d71f8f89c51a6032cdb846d7b83f6bea60c7 Mon Sep 17 00:00:00 2001 From: Gregor Brunmar Date: Thu, 21 Aug 2008 03:19:02 +0000 Subject: [PATCH] Added some more parameter error checking to D3D9::CreateDevice() svn path=/trunk/; revision=35498 --- reactos/dll/directx/d3d9/d3d9_impl.c | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/reactos/dll/directx/d3d9/d3d9_impl.c b/reactos/dll/directx/d3d9/d3d9_impl.c index e6bf562b695..b482afe1672 100644 --- a/reactos/dll/directx/d3d9/d3d9_impl.c +++ b/reactos/dll/directx/d3d9/d3d9_impl.c @@ -923,7 +923,42 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapte if (hFocusWindow != NULL && FALSE == IsWindow(hFocusWindow)) { - DPRINT1("Invalid hFocusWindow parameter specified"); + DPRINT1("Invalid hFocusWindow parameter specified, expected NULL or a valid HWND"); + UNLOCK_D3D9(); + return D3DERR_INVALIDCALL; + } + + if (NULL == pPresentationParameters) + { + DPRINT1("Invalid pPresentationParameters parameter specified"); + UNLOCK_D3D9(); + return D3DERR_INVALIDCALL; + } + + if (pPresentationParameters->hDeviceWindow != NULL && FALSE == IsWindow(pPresentationParameters->hDeviceWindow)) + { + DPRINT1("Invalid pPresentationParameters->hDeviceWindow parameter specified, expected NULL or a valid HWND"); + UNLOCK_D3D9(); + return D3DERR_INVALIDCALL; + } + + if (FALSE == pPresentationParameters->Windowed && hFocusWindow == NULL) + { + DPRINT1("When pPresentationParameters->Windowed is not set, hFocusWindow must be a valid HWND"); + UNLOCK_D3D9(); + return D3DERR_INVALIDCALL; + } + + if (NULL == hFocusWindow && NULL == pPresentationParameters->hDeviceWindow) + { + DPRINT1("Any of pPresentationParameters->Windowed and hFocusWindow must be set to a valid HWND"); + UNLOCK_D3D9(); + return D3DERR_INVALIDCALL; + } + + if (Adapter > 0 && NULL == pPresentationParameters->hDeviceWindow) + { + DPRINT1("Invalid pPresentationParameters->hDeviceWindow, must be set to a valid unique HWND when Adapter is greater than 0"); UNLOCK_D3D9(); return D3DERR_INVALIDCALL; }