Commit b3ced2fa authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

ddraw: Avoid some unsafe IDirect3D7 iface to IDirectDrawImpl transitions.

parent 19fa0b32
...@@ -1727,56 +1727,50 @@ IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7 *iface, ...@@ -1727,56 +1727,50 @@ IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7 *iface,
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI static HRESULT WINAPI IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface,
Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface, IDirect3D3 **Direct3D3)
IDirect3D3 **Direct3D3)
{ {
IDirect3DDeviceImpl *This = device_from_device3(iface); IDirect3DDeviceImpl *This = device_from_device3(iface);
HRESULT ret;
IDirect3D7 *ret_ptr;
TRACE("iface %p, d3d %p.\n", iface, Direct3D3); TRACE("iface %p, d3d %p.\n", iface, Direct3D3);
ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr); if(!Direct3D3)
if(ret != D3D_OK) return DDERR_INVALIDPARAMS;
return ret;
*Direct3D3 = ret_ptr ? (IDirect3D3 *)&ddraw_from_d3d7(ret_ptr)->IDirect3D3_vtbl : NULL; IDirect3D3_AddRef((IDirect3D3 *)&This->ddraw->IDirect3D3_vtbl);
*Direct3D3 = (IDirect3D3 *)&This->ddraw->IDirect3D3_vtbl;
TRACE(" returning interface %p\n", *Direct3D3); TRACE(" returning interface %p\n", *Direct3D3);
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI static HRESULT WINAPI IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface,
Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface, IDirect3D2 **Direct3D2)
IDirect3D2 **Direct3D2)
{ {
IDirect3DDeviceImpl *This = device_from_device2(iface); IDirect3DDeviceImpl *This = device_from_device2(iface);
HRESULT ret;
IDirect3D7 *ret_ptr;
TRACE("iface %p, d3d %p.\n", iface, Direct3D2); TRACE("iface %p, d3d %p.\n", iface, Direct3D2);
ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr); if(!Direct3D2)
if(ret != D3D_OK) return DDERR_INVALIDPARAMS;
return ret;
*Direct3D2 = ret_ptr ? (IDirect3D2 *)&ddraw_from_d3d7(ret_ptr)->IDirect3D2_vtbl : NULL; IDirect3D2_AddRef((IDirect3D2 *)&This->ddraw->IDirect3D2_vtbl);
*Direct3D2 = (IDirect3D2 *)&This->ddraw->IDirect3D2_vtbl;
TRACE(" returning interface %p\n", *Direct3D2); TRACE(" returning interface %p\n", *Direct3D2);
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI static HRESULT WINAPI IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface,
Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface, IDirect3D **Direct3D)
IDirect3D **Direct3D)
{ {
IDirect3DDeviceImpl *This = device_from_device1(iface); IDirect3DDeviceImpl *This = device_from_device1(iface);
HRESULT ret;
IDirect3D7 *ret_ptr;
TRACE("iface %p, d3d %p.\n", iface, Direct3D); TRACE("iface %p, d3d %p.\n", iface, Direct3D);
ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr); if(!Direct3D)
if(ret != D3D_OK) return DDERR_INVALIDPARAMS;
return ret;
*Direct3D = ret_ptr ? (IDirect3D *)&ddraw_from_d3d7(ret_ptr)->IDirect3D_vtbl : NULL; IDirect3D_AddRef((IDirect3D *)&This->ddraw->IDirect3D_vtbl);
*Direct3D = (IDirect3D *)&This->ddraw->IDirect3D_vtbl;
TRACE(" returning interface %p\n", *Direct3D); TRACE(" returning interface %p\n", *Direct3D);
return D3D_OK; return D3D_OK;
} }
...@@ -6806,7 +6800,7 @@ static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl = ...@@ -6806,7 +6800,7 @@ static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl =
Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats, Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats,
Thunk_IDirect3DDeviceImpl_3_BeginScene, Thunk_IDirect3DDeviceImpl_3_BeginScene,
Thunk_IDirect3DDeviceImpl_3_EndScene, Thunk_IDirect3DDeviceImpl_3_EndScene,
Thunk_IDirect3DDeviceImpl_3_GetDirect3D, IDirect3DDeviceImpl_3_GetDirect3D,
IDirect3DDeviceImpl_3_SetCurrentViewport, IDirect3DDeviceImpl_3_SetCurrentViewport,
IDirect3DDeviceImpl_3_GetCurrentViewport, IDirect3DDeviceImpl_3_GetCurrentViewport,
Thunk_IDirect3DDeviceImpl_3_SetRenderTarget, Thunk_IDirect3DDeviceImpl_3_SetRenderTarget,
...@@ -6855,7 +6849,7 @@ static const struct IDirect3DDevice2Vtbl d3d_device2_vtbl = ...@@ -6855,7 +6849,7 @@ static const struct IDirect3DDevice2Vtbl d3d_device2_vtbl =
IDirect3DDeviceImpl_2_EnumTextureFormats, IDirect3DDeviceImpl_2_EnumTextureFormats,
Thunk_IDirect3DDeviceImpl_2_BeginScene, Thunk_IDirect3DDeviceImpl_2_BeginScene,
Thunk_IDirect3DDeviceImpl_2_EndScene, Thunk_IDirect3DDeviceImpl_2_EndScene,
Thunk_IDirect3DDeviceImpl_2_GetDirect3D, IDirect3DDeviceImpl_2_GetDirect3D,
Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport, Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport,
Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport, Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport,
Thunk_IDirect3DDeviceImpl_2_SetRenderTarget, Thunk_IDirect3DDeviceImpl_2_SetRenderTarget,
...@@ -6903,7 +6897,7 @@ static const struct IDirect3DDeviceVtbl d3d_device1_vtbl = ...@@ -6903,7 +6897,7 @@ static const struct IDirect3DDeviceVtbl d3d_device1_vtbl =
IDirect3DDeviceImpl_1_DeleteMatrix, IDirect3DDeviceImpl_1_DeleteMatrix,
Thunk_IDirect3DDeviceImpl_1_BeginScene, Thunk_IDirect3DDeviceImpl_1_BeginScene,
Thunk_IDirect3DDeviceImpl_1_EndScene, Thunk_IDirect3DDeviceImpl_1_EndScene,
Thunk_IDirect3DDeviceImpl_1_GetDirect3D IDirect3DDeviceImpl_1_GetDirect3D
}; };
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment