Small DDraw patch

Lionel Ulmer lionel.ulmer at free.fr
Fri Aug 2 12:09:44 CDT 2002


Hi all,

An application was calling SetSurfaceDesc with more than the SURFACE /
PIXELFORMAT flags set, thus triggering an 'abort' in Wine code.

This fixes that by being a bit more strict on parameter checking.

Changelog:
 Be less strict on parameter checking in the SetSurfaceDesc function.

                         Lionel

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/ddraw/dsurface/dib.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/dsurface/dib.c,v
retrieving revision 1.12
diff -u -r1.12 dib.c
--- dlls/ddraw/dsurface/dib.c	10 Jul 2002 23:10:54 -0000	1.12
+++ dlls/ddraw/dsurface/dib.c	2 Aug 2002 17:07:34 -0000
@@ -920,13 +920,28 @@
     ICOM_THIS(IDirectDrawSurfaceImpl,iface);
     DIB_PRIV_VAR(priv, This);
     HRESULT hr = DD_OK;
-
-    TRACE("(%p)->(%p,%08lx)\n",iface,pDDSD,dwFlags);
-    if (pDDSD->dwFlags == DDSD_LPSURFACE) {
+    DWORD flags = pDDSD->dwFlags;
+    
+    if (TRACE_ON(ddraw)) {
+        TRACE("(%p)->(%p,%08lx)\n",iface,pDDSD,dwFlags);
+        DDRAW_dump_surface_desc(pDDSD);
+    }
+    
+    if (pDDSD->dwFlags & DDSD_PIXELFORMAT) {
+        flags &= ~DDSD_PIXELFORMAT;
+	if (flags & DDSD_LPSURFACE) {
+	    This->surface_desc.u4.ddpfPixelFormat = pDDSD->u4.ddpfPixelFormat;
+	} else {
+	    FIXME("Change of pixel format without surface re-allocation is not supported !\n");
+	}
+    }
+    if (pDDSD->dwFlags & DDSD_LPSURFACE) {
 	HBITMAP oldbmp = priv->dib.DIBsection;
 	LPVOID oldsurf = This->surface_desc.lpSurface;
 	BOOL oldc = priv->dib.client_memory;
 
+	flags &= ~DDSD_LPSURFACE;
+	
 	TRACE("new lpSurface=%p\n",pDDSD->lpSurface);
 	This->surface_desc.lpSurface = pDDSD->lpSurface;
 	priv->dib.client_memory = TRUE;
@@ -944,13 +959,9 @@
 
 	if (!oldc)
 	    VirtualFree(oldsurf, 0, MEM_RELEASE);
-
-	return hr;
     }
-    else {
-	FIXME("flags=%08lx\n",pDDSD->dwFlags);
-	abort();
-	hr = E_FAIL;
+    if (flags) {
+        WARN("Unhandled flags : %08lx\n", flags);
     }
     return hr;
 }


More information about the wine-patches mailing list