Implemented thunks for IDirectDrawSurface and IDirectDraw. This isn't good code, because it is a mixture of wine and our code. But it works as far as I can see. I will fix it someday.
Modified: trunk/reactos/lib/ddraw/ddraw.xml
Modified: trunk/reactos/lib/ddraw/main/clipper.c
Modified: trunk/reactos/lib/ddraw/main/color.c
Modified: trunk/reactos/lib/ddraw/main/ddraw.c
Modified: trunk/reactos/lib/ddraw/main/gamma.c
Modified: trunk/reactos/lib/ddraw/main/palette.c
Modified: trunk/reactos/lib/ddraw/main/surface.c
Modified: trunk/reactos/lib/ddraw/main.c
Modified: trunk/reactos/lib/ddraw/rosdraw.h
Added: trunk/reactos/lib/ddraw/thunks/ddraw.c
Added: trunk/reactos/lib/ddraw/thunks/surface.c
Added: trunk/reactos/lib/ddraw/winedraw.h

Modified: trunk/reactos/lib/ddraw/ddraw.xml
--- trunk/reactos/lib/ddraw/ddraw.xml	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/ddraw.xml	2005-10-24 16:29:36 UTC (rev 18740)
@@ -1,4 +1,4 @@
-<module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll" allowwarnings="true">
+<module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll">
 	<importlibrary definition="ddraw.def" />
 	<include base="ddraw">.</include>	
 	<define name="UNICODE" />
@@ -35,4 +35,9 @@
 		<file>ddraw.c</file>
 		<file>surface.c</file>
 	</directory>
+
+	<directory name="thunks">
+		<file>ddraw.c</file>
+		<file>surface.c</file>
+	</directory>
 </module>

Modified: trunk/reactos/lib/ddraw/main/clipper.c
--- trunk/reactos/lib/ddraw/main/clipper.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main/clipper.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,7 @@
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS
  * FILE:                 lib/ddraw/main/clipper.c
- * PURPOSE:              DirectDraw Implementation 
+ * PURPOSE:              IDirectDrawClipper Implementation 
  * PROGRAMMER:           Maarten Bosma
  *
  */

Modified: trunk/reactos/lib/ddraw/main/color.c
--- trunk/reactos/lib/ddraw/main/color.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main/color.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,7 @@
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS
  * FILE:                 lib/ddraw/main/color.c
- * PURPOSE:              DirectDraw Implementation 
+ * PURPOSE:              IDirectDrawColorControl Implementation 
  * PROGRAMMER:           Maarten Bosma
  *
  */

Modified: trunk/reactos/lib/ddraw/main/ddraw.c
--- trunk/reactos/lib/ddraw/main/ddraw.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main/ddraw.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,7 @@
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS
  * FILE:                 lib/ddraw/main/ddraw.c
- * PURPOSE:              DirectDraw Implementation 
+ * PURPOSE:              IDirectDraw7 Implementation 
  * PROGRAMMER:           Magnus Olsen, Maarten Bosma
  *
  */
@@ -140,7 +140,9 @@
 	if (That == NULL) 
 		return E_OUTOFMEMORY;
 
-	That->lpVtbl = &DirectDrawSurface_Vtable;
+	That->lpVtbl = &DirectDrawSurface7_Vtable;
+	That->lpVtbl_v3 = &DDRAW_IDDS3_Thunk_VTable;
+
 	That->ref = 1;
 	*ppSurf = (LPDIRECTDRAWSURFACE7)That;
 
@@ -173,13 +175,39 @@
    	return ref;
 }
 
-/**** Stubs ****/
+HRESULT WINAPI Main_DirectDraw_QueryInterface (
+	LPDIRECTDRAW7 iface, REFIID id, LPVOID *obj ) 
+{
+    IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+    
+    if (IsEqualGUID(&IID_IDirectDraw7, id))
+	{
+		*obj = &This->lpVtbl;
+    }
+    else if (IsEqualGUID(&IID_IDirectDraw, id))
+	{
+		*obj = &This->lpVtbl_v1;
+    }
+    else if (IsEqualGUID(&IID_IDirectDraw2, id))
+	{
+		*obj = &This->lpVtbl_v2;
+    }
+    else if (IsEqualGUID(&IID_IDirectDraw4, id))
+	{
+		*obj = &This->lpVtbl_v4;
+    }
+    else
+	{
+		*obj = NULL;
+		return E_NOINTERFACE;
+    }
 
-HRESULT WINAPI Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj) 
-{
-	DX_STUB;
+    Main_DirectDraw_AddRef(iface);
+    return S_OK;
 }
 
+/**** Stubs ****/
+
 HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 iface) 
 {
    	DX_STUB;
@@ -380,7 +408,7 @@
    	DX_STUB;
 }
 
-IDirectDraw7Vtbl DirectDraw_Vtable =
+IDirectDraw7Vtbl DirectDraw7_Vtable =
 {
     Main_DirectDraw_QueryInterface,
     Main_DirectDraw_AddRef,

Modified: trunk/reactos/lib/ddraw/main/gamma.c
--- trunk/reactos/lib/ddraw/main/gamma.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main/gamma.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,7 @@
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS
  * FILE:                 lib/ddraw/main/gamma.c
- * PURPOSE:              DirectDraw Implementation 
+ * PURPOSE:              IDirectDrawGamma Implementation 
  * PROGRAMMER:           Maarten Bosma
  *
  */

Modified: trunk/reactos/lib/ddraw/main/palette.c
--- trunk/reactos/lib/ddraw/main/palette.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main/palette.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,7 @@
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS
  * FILE:                 lib/ddraw/main/palette.c
- * PURPOSE:              DirectDraw Implementation 
+ * PURPOSE:              IDirectDrawPalette Implementation 
  * PROGRAMMER:           Maarten Bosma
  *
  */

Modified: trunk/reactos/lib/ddraw/main/surface.c
--- trunk/reactos/lib/ddraw/main/surface.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main/surface.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,7 @@
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS
  * FILE:                 lib/ddraw/main/surface.c
- * PURPOSE:              DirectDraw Implementation 
+ * PURPOSE:              IDirectDrawSurface7 Implementation 
  * PROGRAMMER:           Magnus Olsen, Maarten Bosma
  *
  */
@@ -113,6 +113,13 @@
 
 /**** Stubs ****/
 
+HRESULT WINAPI
+Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
+				      LPVOID* ppObj)
+{
+    DX_STUB;
+}
+
 HRESULT WINAPI Main_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst,
 			  LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
 {
@@ -131,13 +138,6 @@
 }
 
 HRESULT WINAPI
-Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
-				      LPVOID* ppObj)
-{
-    DX_STUB;
-}
-
-HRESULT WINAPI
 Main_DDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
 					  LPDIRECTDRAWSURFACE7 pAttach)
 {
@@ -421,7 +421,7 @@
     DX_STUB;
 }
 
-IDirectDrawSurface7Vtbl DirectDrawSurface_Vtable =
+IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable =
 {
     Main_DDrawSurface_QueryInterface,
     Main_DDrawSurface_AddRef,

Modified: trunk/reactos/lib/ddraw/main.c
--- trunk/reactos/lib/ddraw/main.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/main.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -13,8 +13,7 @@
 #include "rosdraw.h"
 
 
-HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
-										IUnknown* pUnkOuter, BOOL ex)
+HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, REFIID id, BOOL ex)
 {   
     IDirectDrawImpl* This = (IDirectDrawImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawImpl));
 
@@ -23,10 +22,17 @@
 
 	ZeroMemory(This,sizeof(IDirectDrawImpl));
 
-	This->lpVtbl = &DirectDraw_Vtable;
+	This->lpVtbl = &DirectDraw7_Vtable;
+	This->lpVtbl_v1 = &DDRAW_IDirectDraw_VTable;
+	This->lpVtbl_v2 = &DDRAW_IDirectDraw2_VTable;
+	This->lpVtbl_v4 = &DDRAW_IDirectDraw4_VTable;
+
 	This->DirectDrawGlobal.dwRefCnt = 1;
 	*pIface = (LPDIRECTDRAW)This;
 
+	if(This->lpVtbl->QueryInterface ((LPDIRECTDRAW7)This, id, (void**)&pIface) != S_OK)
+		return DDERR_INVALIDPARAMS;
+
 	return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID);
 }
 
@@ -39,10 +45,10 @@
 		return DDERR_INVALIDPARAMS; 
 	}
 	
-	return Create_DirectDraw (lpGUID, lplpDD, pUnkOuter, FALSE);
+	return Create_DirectDraw (lpGUID, lplpDD, &IID_IDirectDraw, FALSE);
 }
  
-HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID iid, LPUNKNOWN pUnkOuter)
+HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
 {    	
 	/* check see if pUnkOuter is null or not */
 	if (pUnkOuter)
@@ -52,12 +58,12 @@
 	}
 	
 	/* Is it a DirectDraw 7 Request or not */
-	if (!IsEqualGUID(iid, &IID_IDirectDraw7)) 
+	if (!IsEqualGUID(id, &IID_IDirectDraw7)) 
 	{
 	  return DDERR_INVALIDPARAMS;
 	}
 
-    return Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, pUnkOuter, TRUE);
+    return Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, id, TRUE);
 }
 
 HRESULT WINAPI DirectDrawEnumerateA(
@@ -65,7 +71,7 @@
   LPVOID lpContext
 )
 {
-    return DD_OK;
+    DX_STUB;
 }
 
 
@@ -74,7 +80,7 @@
   LPVOID lpContext
 )
 {
-    return DD_OK;
+    DX_STUB;
 }
 
 HRESULT WINAPI DirectDrawEnumerateExA(
@@ -83,7 +89,7 @@
   DWORD dwFlags
 )
 {
-    return DD_OK;
+    DX_STUB;
 }
 
 HRESULT WINAPI DirectDrawEnumerateExW(
@@ -92,7 +98,7 @@
   DWORD dwFlags
 )
 {
-    return DD_OK;
+     DX_STUB;
 }
  
 HRESULT WINAPI DirectDrawCreateClipper(
@@ -101,6 +107,5 @@
   LPUNKNOWN pUnkOuter
 )
 {
-    return DD_OK;
+     DX_STUB;
 }
-

Modified: trunk/reactos/lib/ddraw/rosdraw.h
--- trunk/reactos/lib/ddraw/rosdraw.h	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/rosdraw.h	2005-10-24 16:29:36 UTC (rev 18740)
@@ -3,7 +3,6 @@
 
 /********* Includes  *********/
 
-
 #include <windows.h>
 #include <stdio.h>
 #include <ddraw.h>
@@ -16,6 +15,10 @@
 typedef struct 
 {
 	IDirectDraw7Vtbl* lpVtbl;
+	IDirectDraw4Vtbl* lpVtbl_v4;
+	IDirectDraw2Vtbl* lpVtbl_v2;
+	IDirectDrawVtbl*  lpVtbl_v1;
+
 	DDRAWI_DIRECTDRAW_GBL DirectDrawGlobal;
 	DDHALINFO HalInfo;	
 
@@ -33,6 +36,8 @@
 typedef struct 
 {
 	IDirectDrawSurface7Vtbl* lpVtbl;
+	IDirectDrawSurface3Vtbl* lpVtbl_v3;
+
     LONG ref;
 
     IDirectDrawImpl* owner;
@@ -63,8 +68,14 @@
 
 /*********** VTables ************/
 
-extern IDirectDraw7Vtbl				DirectDraw_Vtable;
-extern IDirectDrawSurface7Vtbl		DirectDrawSurface_Vtable;
+extern IDirectDraw7Vtbl				DirectDraw7_Vtable;
+extern IDirectDrawVtbl				DDRAW_IDirectDraw_VTable;
+extern IDirectDraw2Vtbl				DDRAW_IDirectDraw2_VTable;
+extern IDirectDraw4Vtbl				DDRAW_IDirectDraw4_VTable;
+
+extern IDirectDrawSurface7Vtbl		DirectDrawSurface7_Vtable;
+extern IDirectDrawSurface3Vtbl		DDRAW_IDDS3_Thunk_VTable;
+
 extern IDirectDrawPaletteVtbl		DirectDrawPalette_Vtable;
 extern IDirectDrawClipperVtbl		DirectDrawClipper_Vtable;
 extern IDirectDrawColorControlVtbl	DirectDrawColorControl_Vtable;

Added: trunk/reactos/lib/ddraw/thunks/ddraw.c
--- trunk/reactos/lib/ddraw/thunks/ddraw.c	2005-10-24 15:56:03 UTC (rev 18739)
+++ trunk/reactos/lib/ddraw/thunks/ddraw.c	2005-10-24 16:29:36 UTC (rev 18740)
@@ -0,0 +1,1049 @@
+/* Direct Draw Thunks and old vtables
+ * Copyright 2000 TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*
+ * Taken form wine (wine/dlls/ddraw/ddraw_thunks.c rev 1.2)
+ * with some little changes
+ *
+ */
+
+#include "winedraw.h"
+
+
+static HRESULT WINAPI
+IDirectDrawImpl_QueryInterface(LPDIRECTDRAW This, REFIID iid, LPVOID *ppObj)
+{
+    return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw,
+							  IDirectDraw7, This),
+				       iid, ppObj);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_QueryInterface(LPDIRECTDRAW2 This, REFIID iid, LPVOID *ppObj)
+{
+    return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw2,
+							  IDirectDraw7, This),
+				       iid, ppObj);
+}
+
+
+static HRESULT WINAPI
+IDirectDraw4Impl_QueryInterface(LPDIRECTDRAW4 This, REFIID iid, LPVOID *ppObj)
+{
+    return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw4,
+							  IDirectDraw7, This),
+				       iid, ppObj);
+}
+
+static ULONG WINAPI
+IDirectDrawImpl_AddRef(LPDIRECTDRAW This)
+{
+    return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl,
+						  IDirectDraw, IDirectDraw7,
+						  This));
+}
+
+static ULONG WINAPI
+IDirectDraw2Impl_AddRef(LPDIRECTDRAW2 This)
+{
+    return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl,
+						  IDirectDraw2, IDirectDraw7,
+						  This));
+}
+
+static ULONG WINAPI
+IDirectDraw4Impl_AddRef(LPDIRECTDRAW4 This)
+{
+    return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl,
+						  IDirectDraw4, IDirectDraw7,
+						  This));
+}
+
+static ULONG WINAPI
+IDirectDrawImpl_Release(LPDIRECTDRAW This)
+{
+    return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw, IDirectDraw7,
+						   This));
+}
+
+static ULONG WINAPI
+IDirectDraw2Impl_Release(LPDIRECTDRAW2 This)
+{
+    return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw2, IDirectDraw7,
+						   This));
+}
+
+static ULONG WINAPI
+IDirectDraw4Impl_Release(LPDIRECTDRAW4 This)
+{
+    return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw4, IDirectDraw7,
+						   This));
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_Compact(LPDIRECTDRAW This)
+{
+    return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw, IDirectDraw7,
+						   This));
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_Compact(LPDIRECTDRAW2 This)
+{
+    return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw2, IDirectDraw7,
+						   This));
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_Compact(LPDIRECTDRAW4 This)
+{
+    return IDirectDraw7_Compact(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw4, IDirectDraw7,
+						   This));
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_CreateClipper(LPDIRECTDRAW This, DWORD dwFlags,
+			      LPDIRECTDRAWCLIPPER *ppClipper,
+			      IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw,
+							 IDirectDraw7,
+							 This),
+				      dwFlags, ppClipper, pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_CreateClipper(LPDIRECTDRAW2 This, DWORD dwFlags,
+			       LPDIRECTDRAWCLIPPER *ppClipper,
+			       IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw2,
+							 IDirectDraw7,
+							 This),
+				      dwFlags, ppClipper, pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_CreateClipper(LPDIRECTDRAW4 This, DWORD dwFlags,
+			       LPDIRECTDRAWCLIPPER *ppClipper,
+			       IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreateClipper(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw4,
+							 IDirectDraw7,
+							 This),
+				      dwFlags, ppClipper, pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags,
+			      LPPALETTEENTRY pEntries,
+			      LPDIRECTDRAWPALETTE *ppPalette,
+			      IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw,
+							 IDirectDraw7,
+							 This),
+				      dwFlags, pEntries, ppPalette, pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags,
+			       LPPALETTEENTRY pEntries,
+			       LPDIRECTDRAWPALETTE *ppPalette,
+			       IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw2,
+							 IDirectDraw7,
+							 This),
+				      dwFlags, pEntries, ppPalette, pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags,
+			       LPPALETTEENTRY pEntries,
+			       LPDIRECTDRAWPALETTE *ppPalette,
+			       IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreatePalette(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw4,
+							 IDirectDraw7,
+							 This),
+				      dwFlags, pEntries, ppPalette, pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
+			      LPDIRECTDRAWSURFACE *ppSurface,
+			      IUnknown *pUnkOuter)
+{
+    LPDIRECTDRAWSURFACE7 pSurface7;
+    HRESULT hr;
+
+    /* the LPDDSURFACEDESC -> LPDDSURFACEDESC2 conversion should be ok,
+     * since the data layout is the same */
+    hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+						       IDirectDraw,
+						       IDirectDraw7,
+						       This),
+				    (LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    *ppSurface = (LPDIRECTDRAWSURFACE) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
+				    IDirectDrawSurface7, IDirectDrawSurface3,
+				    pSurface7);
+
+    return hr;
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
+			       LPDIRECTDRAWSURFACE *ppSurface,
+			       IUnknown *pUnkOuter)
+{
+    LPDIRECTDRAWSURFACE7 pSurface7;
+    HRESULT hr;
+
+    hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+						       IDirectDraw2,
+						       IDirectDraw7,
+						       This),
+				    (LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    *ppSurface = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
+				    IDirectDrawSurface7, IDirectDrawSurface3,
+				    pSurface7);
+
+    return hr;
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
+			       LPDIRECTDRAWSURFACE4 *ppSurface,
+			       IUnknown *pUnkOuter)
+{
+    return IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw4,
+							 IDirectDraw7,
+							 This),
+				      pSDesc,
+				      (LPDIRECTDRAWSURFACE7 *)ppSurface,
+				      pUnkOuter);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_DuplicateSurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE pSrc,
+				 LPDIRECTDRAWSURFACE *ppDst)
+{
+    LPDIRECTDRAWSURFACE7 pDst7;
+    HRESULT hr;
+
+    hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw,
+							  IDirectDraw7, This),
+				       COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
+							  IDirectDrawSurface3,
+							  IDirectDrawSurface7,
+							  pSrc),
+				       &pDst7);
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    *ppDst = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
+				IDirectDrawSurface3, pDst7);
+
+    return hr;
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_DuplicateSurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE pSrc,
+				  LPDIRECTDRAWSURFACE *ppDst)
+{
+    LPDIRECTDRAWSURFACE7 pDst7;
+    HRESULT hr;
+
+    hr = IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw2,
+							  IDirectDraw7, This),
+				       COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
+							  IDirectDrawSurface3,
+							  IDirectDrawSurface7,
+							  pSrc),
+				       &pDst7);
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    *ppDst = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
+				IDirectDrawSurface3, pDst7);
+
+    return hr;
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_DuplicateSurface(LPDIRECTDRAW4 This,
+				  LPDIRECTDRAWSURFACE4 pSrc,
+				  LPDIRECTDRAWSURFACE4 *ppDst)
+{
+    return IDirectDraw7_DuplicateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw4,
+							    IDirectDraw7,
+							    This),
+					 (LPDIRECTDRAWSURFACE7)pSrc,
+					 (LPDIRECTDRAWSURFACE7 *)ppDst);
+}
+
+struct displaymodescallback_context
+{
+    LPDDENUMMODESCALLBACK func;
+    LPVOID context;
+};
+
+static HRESULT CALLBACK
+EnumDisplayModesCallbackThunk(LPDDSURFACEDESC2 pDDSD2, LPVOID context)
+{
+    DDSURFACEDESC DDSD;
+    struct displaymodescallback_context *cbcontext = context;
+
+    memcpy(&DDSD,pDDSD2,sizeof(DDSD));
+    DDSD.dwSize = sizeof(DDSD);
+
+    return cbcontext->func(&DDSD, cbcontext->context);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_EnumDisplayModes(LPDIRECTDRAW This, DWORD dwFlags,
+				 LPDDSURFACEDESC pDDSD, LPVOID context,
+				 LPDDENUMMODESCALLBACK cb)
+{
+    struct displaymodescallback_context cbcontext;
+
+    cbcontext.func    = cb;
+    cbcontext.context = context;
+
+    return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw,
+							    IDirectDraw7,
+							    This),
+					 dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext,
+					 EnumDisplayModesCallbackThunk);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_EnumDisplayModes(LPDIRECTDRAW2 This, DWORD dwFlags,
+				  LPDDSURFACEDESC pDDSD, LPVOID context,
+				  LPDDENUMMODESCALLBACK cb)
+{
+    struct displaymodescallback_context cbcontext;
+
+    cbcontext.func    = cb;
+    cbcontext.context = context;
+
+    return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw2,
+							    IDirectDraw7,
+							    This),
+					 dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext,
+					 EnumDisplayModesCallbackThunk);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_EnumDisplayModes(LPDIRECTDRAW4 This, DWORD dwFlags,
+				  LPDDSURFACEDESC2 pDDSD, LPVOID context,
+				  LPDDENUMMODESCALLBACK2 cb)
+{
+    return IDirectDraw7_EnumDisplayModes(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw4,
+							    IDirectDraw7,
+							    This),
+					 dwFlags, pDDSD, context, cb);
+}
+
+struct surfacescallback_context
+{
+    LPDDENUMSURFACESCALLBACK func;
+    LPVOID context;
+};
+
+static HRESULT CALLBACK
+EnumSurfacesCallbackThunk(LPDIRECTDRAWSURFACE7 pSurf, LPDDSURFACEDESC2 pDDSD,
+			  LPVOID context)
+{
+    struct surfacescallback_context *cbcontext = context;
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    return cbcontext->func((LPDIRECTDRAWSURFACE)
+                           COM_INTERFACE_CAST(IDirectDrawSurfaceImpl,
+					      IDirectDrawSurface7,
+					      IDirectDrawSurface3, pSurf),
+			   (LPDDSURFACEDESC)pDDSD, cbcontext->context);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_EnumSurfaces(LPDIRECTDRAW This, DWORD dwFlags,
+			     LPDDSURFACEDESC pDDSD, LPVOID context,
+			     LPDDENUMSURFACESCALLBACK cb)
+{
+    struct surfacescallback_context cbcontext;
+
+    cbcontext.func    = cb;
+    cbcontext.context = context;
+
+    return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
+							IDirectDraw,
+							IDirectDraw7, This),
+				     dwFlags, (LPDDSURFACEDESC2)pDDSD,
+				     &cbcontext, EnumSurfacesCallbackThunk);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_EnumSurfaces(LPDIRECTDRAW2 This, DWORD dwFlags,
+			      LPDDSURFACEDESC pDDSD, LPVOID context,
+			      LPDDENUMSURFACESCALLBACK cb)
+{
+    struct surfacescallback_context cbcontext;
+
+    cbcontext.func    = cb;
+    cbcontext.context = context;
+
+    return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
+							IDirectDraw2,
+							IDirectDraw7, This),
+				     dwFlags, (LPDDSURFACEDESC2)pDDSD,
+				     &cbcontext, EnumSurfacesCallbackThunk);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_EnumSurfaces(LPDIRECTDRAW4 This, DWORD dwFlags,
+			      LPDDSURFACEDESC2 pDDSD, LPVOID context,
+			      LPDDENUMSURFACESCALLBACK2 cb)
+{
+    return IDirectDraw7_EnumSurfaces(COM_INTERFACE_CAST(IDirectDrawImpl,
+							IDirectDraw4,
+							IDirectDraw7, This),
+				     dwFlags, pDDSD, context,
+				     (LPDDENUMSURFACESCALLBACK7)cb);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_FlipToGDISurface(LPDIRECTDRAW This)
+{
+    return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw,
+							    IDirectDraw7,
+							    This));
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_FlipToGDISurface(LPDIRECTDRAW2 This)
+{
+    return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw2,
+							    IDirectDraw7,
+							    This));
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_FlipToGDISurface(LPDIRECTDRAW4 This)
+{
+    return IDirectDraw7_FlipToGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							    IDirectDraw4,
+							    IDirectDraw7,
+							    This));
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_GetCaps(LPDIRECTDRAW This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
+{
+    return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw, IDirectDraw7,
+						   This), pDDC1, pDDC2);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_GetCaps(LPDIRECTDRAW2 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
+{
+    return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw2, IDirectDraw7,
+						   This), pDDC1, pDDC2);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_GetCaps(LPDIRECTDRAW4 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
+{
+    return IDirectDraw7_GetCaps(COM_INTERFACE_CAST(IDirectDrawImpl,
+						   IDirectDraw4, IDirectDraw7,
+						   This), pDDC1, pDDC2);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_GetDisplayMode(LPDIRECTDRAW This, LPDDSURFACEDESC pDDSD)
+{
+    return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw,
+							  IDirectDraw7, This),
+				       (LPDDSURFACEDESC2)pDDSD);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_GetDisplayMode(LPDIRECTDRAW2 This, LPDDSURFACEDESC pDDSD)
+{
+    return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw2,
+							  IDirectDraw7, This),
+				       (LPDDSURFACEDESC2)pDDSD);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_GetDisplayMode(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pDDSD)
+{
+    return IDirectDraw7_GetDisplayMode(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw4,
+							  IDirectDraw7, This),
+				       pDDSD);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_GetFourCCCodes(LPDIRECTDRAW This, LPDWORD lpNumCodes,
+			       LPDWORD lpCodes)
+{
+    return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw,
+							  IDirectDraw7,
+							  This),
+				       lpNumCodes, lpCodes);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_GetFourCCCodes(LPDIRECTDRAW2 This, LPDWORD lpNumCodes,
+				LPDWORD lpCodes)
+{
+    return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw2,
+							  IDirectDraw7,
+							  This),
+				       lpNumCodes, lpCodes);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_GetFourCCCodes(LPDIRECTDRAW4 This, LPDWORD lpNumCodes,
+				LPDWORD lpCodes)
+{
+    return IDirectDraw7_GetFourCCCodes(COM_INTERFACE_CAST(IDirectDrawImpl,
+							  IDirectDraw4,
+							  IDirectDraw7,
+							  This),
+				       lpNumCodes, lpCodes);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_GetGDISurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE *ppSurf)
+{
+    LPDIRECTDRAWSURFACE7 pSurf7;
+    HRESULT hr;
+
+    hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+						       IDirectDraw,
+						       IDirectDraw7,
+						       This), &pSurf7);
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    *ppSurf = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
+				 IDirectDrawSurface3, pSurf7);
+
+    return hr;
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_GetGDISurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE *ppSurf)
+{
+    LPDIRECTDRAWSURFACE7 pSurf7;
+    HRESULT hr;
+
+    hr = IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+						       IDirectDraw2,
+						       IDirectDraw7,
+						       This), &pSurf7);
+
+    /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
+     * IDirectDrawSurface vtable layout at the beginning  */
+    *ppSurf = (LPDIRECTDRAWSURFACE)COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
+				 IDirectDrawSurface3, pSurf7);
+
+    return hr;
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_GetGDISurface(LPDIRECTDRAW4 This,
+			       LPDIRECTDRAWSURFACE4 *ppSurf)
+{
+    return IDirectDraw7_GetGDISurface(COM_INTERFACE_CAST(IDirectDrawImpl,
+							 IDirectDraw4,
+							 IDirectDraw7,
+							 This),
+				      (LPDIRECTDRAWSURFACE7 *)ppSurf);
+}
+
+static HRESULT WINAPI
+IDirectDrawImpl_GetMonitorFrequency(LPDIRECTDRAW This, LPDWORD pdwFreq)
+{
+    return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
+							       IDirectDraw,
+							       IDirectDraw7,
+							       This),
+					    pdwFreq);
+}
+
+static HRESULT WINAPI
+IDirectDraw2Impl_GetMonitorFrequency(LPDIRECTDRAW2 This, LPDWORD pdwFreq)
+{
+    return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
+							       IDirectDraw2,
+							       IDirectDraw7,
+							       This),
+					    pdwFreq);
+}
+
+static HRESULT WINAPI
+IDirectDraw4Impl_GetMonitorFrequency(LPDIRECTDRAW4 This, LPDWORD pdwFreq)
+{
+    return IDirectDraw7_GetMonitorFrequency(COM_INTERFACE_CAST(IDirectDrawImpl,
[truncated at 1000 lines; 966 more skipped]