ddraw: Verify the viewport belongs to the device on execute buffer execution.

This commit is contained in:
Henri Verbeet 2011-04-19 00:08:00 +02:00 committed by Alexandre Julliard
parent 9edeb22c34
commit d429aaa9e9
3 changed files with 14 additions and 11 deletions

View File

@ -515,8 +515,8 @@ HRESULT d3d_execute_buffer_init(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, D3DEXECUTEBUFFERDESC *desc) DECLSPEC_HIDDEN;
/* The execute function */
void IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *Device, IDirect3DViewportImpl *ViewportImpl) DECLSPEC_HIDDEN;
HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, IDirect3DViewportImpl *viewport) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3DVertexBuffer

View File

@ -718,6 +718,7 @@ IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DExecuteBufferImpl *Direct3DExecuteBufferImpl = (IDirect3DExecuteBufferImpl *)ExecuteBuffer;
IDirect3DViewportImpl *Direct3DViewportImpl = (IDirect3DViewportImpl *)Viewport;
HRESULT hr;
TRACE("iface %p, buffer %p, viewport %p, flags %#x.\n", iface, ExecuteBuffer, Viewport, Flags);
@ -726,10 +727,10 @@ IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
/* Execute... */
EnterCriticalSection(&ddraw_cs);
IDirect3DExecuteBufferImpl_Execute(Direct3DExecuteBufferImpl, This, Direct3DViewportImpl);
hr = d3d_execute_buffer_execute(Direct3DExecuteBufferImpl, This, Direct3DViewportImpl);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
return hr;
}
/*****************************************************************************

View File

@ -68,10 +68,8 @@ static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC *lpDesc) {
* Viewport: Viewport for this operation
*
*****************************************************************************/
void
IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice,
IDirect3DViewportImpl *lpViewport)
HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice, IDirect3DViewportImpl *lpViewport)
{
/* DWORD bs = This->desc.dwBufferSize; */
DWORD vs = This->data.dwVertexOffset;
@ -81,10 +79,14 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
char *instr = (char *)This->desc.lpData + is;
/* Should check if the viewport was added or not to the device */
if (lpViewport->active_device != lpDevice)
{
WARN("Viewport %p active device is %p.\n",
lpViewport, lpViewport->active_device);
return DDERR_INVALIDPARAMS;
}
/* Activate the viewport */
lpViewport->active_device = lpDevice;
viewport_activate(lpViewport, FALSE);
TRACE("ExecuteData :\n");
@ -551,7 +553,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
}
end_of_buffer:
;
return D3D_OK;
}
/*****************************************************************************