From: Stefan Dösinger Subject: [PATCH 2/5] ddraw: Thunk to surface1, not surface7 in unlock. Message-Id: <1435059566-11498-2-git-send-email-stefan@codeweavers.com> Date: Tue, 23 Jun 2015 13:39:23 +0200 Fraps only hooks IDirectDrawSurface::Unlock to catch frontbuffer updates and expects later versions to call version 1. We could make this change for all ddraw methods in all interfaces, but IMO that's just a big amount of code change without a real use. As far as Fraps is concerned we can remove DECLSPEC_HOTPATCH from version 2 to 7 again, but I think it's better to keep them. There may be other applications that hook newer versions. --- dlls/ddraw/surface.c | 52 +++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 77a3d44..baf76ee 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1142,25 +1142,14 @@ static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect, return hr; } -/***************************************************************************** - * IDirectDrawSurface7::Unlock - * - * Unlocks an locked surface - * - * Params: - * Rect: Not used by this implementation - * - * Returns: - * D3D_OK on success - * For more details, see IWineD3DSurface::UnlockRect - * - *****************************************************************************/ -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pRect) +/* Note that we thunk to version 1 here. Fraps depends on this, as it hooks only methods from + * IDirectDrawSurface and expects later versions to call through version 1. */ +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Unlock(IDirectDrawSurface *iface, void *data) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface); HRESULT hr; - TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(pRect)); + TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(data)); wined3d_mutex_lock(); hr = wined3d_surface_unmap(surface->wined3d_surface); @@ -1171,43 +1160,40 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface return hr; } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Unlock(IDirectDrawSurface4 *iface, RECT *pRect) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *rect) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); - TRACE("iface %p, rect %p.\n", iface, pRect); + TRACE("iface %p, rect %p.\n", iface, rect); - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, pRect); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, rect); } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *data) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Unlock(IDirectDrawSurface4 *iface, RECT *rect) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface); - TRACE("iface %p, data %p.\n", iface, data); + TRACE("iface %p, rect %p.\n", iface, rect); - /* data might not be the LPRECT of later versions, so drop it. */ - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, NULL); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, rect); } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Unlock(IDirectDrawSurface2 *iface, void *data) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *data) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface); TRACE("iface %p, data %p.\n", iface, data); - /* data might not be the LPRECT of later versions, so drop it. */ - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, NULL); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, data); } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Unlock(IDirectDrawSurface *iface, void *data) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Unlock(IDirectDrawSurface2 *iface, void *data) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface); TRACE("iface %p, data %p.\n", iface, data); - /* data might not be the LPRECT of later versions, so drop it. */ - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, NULL); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, data); } static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 *iface, -- 2.3.6