From 88fc3a3ef504bf95090533cc5a3c2aff353592dc Mon Sep 17 00:00:00 2001 From: Aaryaman Vasishta Date: Fri, 15 Jul 2016 15:46:06 +0530 Subject: [PATCH] d3drm: Fix IDirect3DRMDevice{2-3}::GetDirect3DDevice2 return values on failure. Signed-off-by: Aaryaman Vasishta Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3drm/device.c | 8 ++++++-- dlls/d3drm/tests/d3drm.c | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dlls/d3drm/device.c b/dlls/d3drm/device.c index b388b63c34d..c5db65245aa 100644 --- a/dlls/d3drm/device.c +++ b/dlls/d3drm/device.c @@ -1267,7 +1267,8 @@ static HRESULT WINAPI d3drm_device3_GetDirect3DDevice2(IDirect3DRMDevice3 *iface TRACE("iface %p, d3d_device %p.\n", iface, d3d_device); - IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device); + if (FAILED(IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device))) + return D3DRMERR_BADOBJECT; return D3DRM_OK; } @@ -1278,7 +1279,10 @@ static HRESULT WINAPI d3drm_device2_GetDirect3DDevice2(IDirect3DRMDevice2 *iface TRACE("iface %p, d3d_device %p.\n", iface, d3d_device); - return d3drm_device3_GetDirect3DDevice2(&device->IDirect3DRMDevice3_iface, d3d_device); + IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device); + + /* d3drm returns D3DRM_OK even if the call fails. */ + return D3DRM_OK; } static HRESULT WINAPI d3drm_device3_FindPreferredTextureFormat(IDirect3DRMDevice3 *iface, diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index e23f13fdda7..5b5df66206b 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -3992,15 +3992,15 @@ static void test_create_device_from_d3d1(void) hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device2); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr); hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2); - ok(SUCCEEDED(hr), "Expected hr == DD_OK, got %x).\n", hr); + ok(SUCCEEDED(hr), "Expected hr == D3DRM_OK, got %#x.\n", hr); ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2); IDirect3DRMDevice2_Release(device2); d3ddevice2 = (IDirect3DDevice2 *)0xdeadbeef; - hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice2, (void **)&device3); - ok(hr == DD_OK, "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr); + hr = IDirect3DRMDevice_QueryInterface(device1, &IID_IDirect3DRMDevice3, (void **)&device3); + ok(hr == DD_OK, "Cannot get IDirect3DRMDevice3 Interface (hr = %x).\n", hr); hr = IDirect3DRMDevice3_GetDirect3DDevice2(device3, &d3ddevice2); - ok(hr == DD_OK, "Expected hr == DD_OK, got %x).\n", hr); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(d3ddevice2 == NULL, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2); IDirect3DRMDevice3_Release(device3);