netapi31: Add basic support for NetServerGetInfo.
[wine] / dlls / ddraw / ddraw_thunks.c
1 /* Direct Draw Thunks and old vtables
2  * Copyright 2000 TransGaming Technologies Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20 #include "wine/port.h"
21
22 #include <assert.h>
23 #include <stdarg.h>
24 #include <string.h>
25 #include <stdlib.h>
26
27 #define COBJMACROS
28 #define NONAMELESSUNION
29
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winerror.h"
33 #include "wingdi.h"
34 #include "wine/exception.h"
35
36 #include "ddraw.h"
37 #include "d3d.h"
38
39 #include "ddraw_private.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
43 WINE_DECLARE_DEBUG_CHANNEL(ddraw);
44
45 static HRESULT WINAPI
46 IDirectDrawImpl_QueryInterface(LPDIRECTDRAW This, REFIID iid, LPVOID *ppObj)
47 {
48     return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw1(This), iid, ppObj);
49 }
50
51 static HRESULT WINAPI
52 IDirectDraw2Impl_QueryInterface(LPDIRECTDRAW2 This, REFIID iid, LPVOID *ppObj)
53 {
54     return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw2(This), iid, ppObj);
55 }
56
57 static HRESULT WINAPI
58 IDirectDraw3Impl_QueryInterface(LPDIRECTDRAW3 This, REFIID iid, LPVOID *ppObj)
59 {
60     return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw3(This), iid, ppObj);
61 }
62
63 static HRESULT WINAPI
64 IDirectDraw4Impl_QueryInterface(LPDIRECTDRAW4 This, REFIID iid, LPVOID *ppObj)
65 {
66     return IDirectDraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw4(This), iid, ppObj);
67 }
68
69 static ULONG WINAPI
70 IDirectDrawImpl_AddRef(LPDIRECTDRAW iface)
71 {
72     IDirectDrawImpl *This = ddraw_from_ddraw1(iface);
73     ULONG ref = InterlockedIncrement(&This->ref1);
74
75     TRACE("(%p) : incrementing IDirectDraw refcount from %u.\n", This, ref -1);
76
77     if(ref == 1) InterlockedIncrement(&This->numIfaces);
78
79     return ref;
80 }
81
82 static ULONG WINAPI
83 IDirectDraw2Impl_AddRef(LPDIRECTDRAW2 iface)
84 {
85     IDirectDrawImpl *This = ddraw_from_ddraw2(iface);
86     ULONG ref = InterlockedIncrement(&This->ref2);
87
88     TRACE("(%p) : incrementing IDirectDraw2 refcount from %u.\n", This, ref -1);
89
90     if(ref == 1) InterlockedIncrement(&This->numIfaces);
91
92     return ref;
93 }
94
95 static ULONG WINAPI
96 IDirectDraw3Impl_AddRef(LPDIRECTDRAW3 iface)
97 {
98     IDirectDrawImpl *This = ddraw_from_ddraw3(iface);
99     ULONG ref = InterlockedIncrement(&This->ref3);
100
101     TRACE("(%p) : incrementing IDirectDraw3 refcount from %u.\n", This, ref -1);
102
103     if(ref == 1) InterlockedIncrement(&This->numIfaces);
104
105     return ref;
106 }
107
108 static ULONG WINAPI
109 IDirectDraw4Impl_AddRef(LPDIRECTDRAW4 iface)
110 {
111     IDirectDrawImpl *This = ddraw_from_ddraw4(iface);
112     ULONG ref = InterlockedIncrement(&This->ref4);
113
114     TRACE("(%p) : incrementing IDirectDraw4 refcount from %u.\n", This, ref -1);
115
116     if(ref == 1) InterlockedIncrement(&This->numIfaces);
117
118     return ref;
119 }
120
121 static ULONG WINAPI
122 IDirectDrawImpl_Release(LPDIRECTDRAW iface)
123 {
124     IDirectDrawImpl *This = ddraw_from_ddraw1(iface);
125     ULONG ref = InterlockedDecrement(&This->ref1);
126
127     TRACE_(ddraw)("(%p)->() decrementing IDirectDraw refcount from %u.\n", This, ref +1);
128
129     if(ref == 0)
130     {
131         ULONG ifacecount = InterlockedDecrement(&This->numIfaces);
132         if(ifacecount == 0) IDirectDrawImpl_Destroy(This);
133     }
134
135     return ref;
136 }
137
138 static ULONG WINAPI
139 IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface)
140 {
141     IDirectDrawImpl *This = ddraw_from_ddraw2(iface);
142     ULONG ref = InterlockedDecrement(&This->ref2);
143
144     TRACE_(ddraw)("(%p)->() decrementing IDirectDraw2 refcount from %u.\n", This, ref +1);
145
146     if(ref == 0)
147     {
148         ULONG ifacecount = InterlockedDecrement(&This->numIfaces);
149         if(ifacecount == 0) IDirectDrawImpl_Destroy(This);
150     }
151
152     return ref;
153 }
154
155 static ULONG WINAPI
156 IDirectDraw3Impl_Release(LPDIRECTDRAW3 iface)
157 {
158     IDirectDrawImpl *This = ddraw_from_ddraw3(iface);
159     ULONG ref = InterlockedDecrement(&This->ref3);
160
161     TRACE_(ddraw)("(%p)->() decrementing IDirectDraw3 refcount from %u.\n", This, ref +1);
162
163     if(ref == 0)
164     {
165         ULONG ifacecount = InterlockedDecrement(&This->numIfaces);
166         if(ifacecount == 0) IDirectDrawImpl_Destroy(This);
167     }
168
169     return ref;
170 }
171
172 static ULONG WINAPI
173 IDirectDraw4Impl_Release(LPDIRECTDRAW4 iface)
174 {
175     IDirectDrawImpl *This = ddraw_from_ddraw4(iface);
176     ULONG ref = InterlockedDecrement(&This->ref4);
177
178     TRACE_(ddraw)("(%p)->() decrementing IDirectDraw4 refcount from %u.\n", This, ref +1);
179
180     if(ref == 0)
181     {
182         ULONG ifacecount = InterlockedDecrement(&This->numIfaces);
183         if(ifacecount == 0) IDirectDrawImpl_Destroy(This);
184     }
185
186     return ref;
187 }
188
189 static HRESULT WINAPI
190 IDirectDrawImpl_Compact(LPDIRECTDRAW This)
191 {
192     return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw1(This));
193 }
194
195 static HRESULT WINAPI
196 IDirectDraw2Impl_Compact(LPDIRECTDRAW2 This)
197 {
198     return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw2(This));
199 }
200
201     static HRESULT WINAPI
202 IDirectDraw3Impl_Compact(LPDIRECTDRAW3 This)
203 {
204     return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw3(This));
205 }
206
207 static HRESULT WINAPI
208 IDirectDraw4Impl_Compact(LPDIRECTDRAW4 This)
209 {
210     return IDirectDraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw4(This));
211 }
212
213 static HRESULT WINAPI
214 IDirectDrawImpl_CreateClipper(LPDIRECTDRAW This, DWORD dwFlags,
215                               LPDIRECTDRAWCLIPPER *ppClipper,
216                               IUnknown *pUnkOuter)
217 {
218     return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw1(This), dwFlags, ppClipper, pUnkOuter);
219 }
220
221 static HRESULT WINAPI
222 IDirectDraw2Impl_CreateClipper(LPDIRECTDRAW2 This, DWORD dwFlags,
223                                LPDIRECTDRAWCLIPPER *ppClipper,
224                                IUnknown *pUnkOuter)
225 {
226     return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw2(This), dwFlags, ppClipper, pUnkOuter);
227 }
228
229 static HRESULT WINAPI
230 IDirectDraw3Impl_CreateClipper(LPDIRECTDRAW3 This, DWORD dwFlags,
231                                LPDIRECTDRAWCLIPPER *ppClipper,
232                                IUnknown *pUnkOuter)
233 {
234     return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw3(This), dwFlags, ppClipper, pUnkOuter);
235 }
236
237 static HRESULT WINAPI
238 IDirectDraw4Impl_CreateClipper(LPDIRECTDRAW4 This, DWORD dwFlags,
239                                LPDIRECTDRAWCLIPPER *ppClipper,
240                                IUnknown *pUnkOuter)
241 {
242     return IDirectDraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, ppClipper, pUnkOuter);
243 }
244
245 static HRESULT WINAPI
246 IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags,
247                               LPPALETTEENTRY pEntries,
248                               LPDIRECTDRAWPALETTE *ppPalette,
249                               IUnknown *pUnkOuter)
250 {
251     HRESULT hr;
252     hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw1(This), dwFlags, pEntries, ppPalette, pUnkOuter);
253     if(SUCCEEDED(hr) && *ppPalette)
254     {
255         IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
256         IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw1(This));
257         impl->ifaceToRelease = NULL;
258
259     }
260     return hr;
261 }
262
263 static HRESULT WINAPI
264 IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags,
265                                LPPALETTEENTRY pEntries,
266                                LPDIRECTDRAWPALETTE *ppPalette,
267                                IUnknown *pUnkOuter)
268 {
269     HRESULT hr;
270     hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw2(This), dwFlags, pEntries, ppPalette, pUnkOuter);
271     if(SUCCEEDED(hr) && *ppPalette)
272     {
273         IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
274         IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw2(This));
275         impl->ifaceToRelease = NULL;
276     }
277     return hr;
278 }
279
280 static HRESULT WINAPI
281 IDirectDraw3Impl_CreatePalette(LPDIRECTDRAW3 This, DWORD dwFlags,
282                                LPPALETTEENTRY pEntries,
283                                LPDIRECTDRAWPALETTE *ppPalette,
284                                IUnknown *pUnkOuter)
285 {
286     HRESULT hr;
287     hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw3(This), dwFlags, pEntries, ppPalette, pUnkOuter);
288     if(SUCCEEDED(hr) && *ppPalette)
289     {
290         IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
291         IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw3(This));
292         IDirectDraw4_AddRef(This);
293         impl->ifaceToRelease = (IUnknown *) This;
294     }
295     return hr;
296 }
297
298 static HRESULT WINAPI
299 IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags,
300                                LPPALETTEENTRY pEntries,
301                                LPDIRECTDRAWPALETTE *ppPalette,
302                                IUnknown *pUnkOuter)
303 {
304     HRESULT hr;
305     hr = IDirectDraw7_CreatePalette((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, pEntries, ppPalette, pUnkOuter);
306     if(SUCCEEDED(hr) && *ppPalette)
307     {
308         IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*ppPalette;
309         IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw4(This));
310         IDirectDraw4_AddRef(This);
311         impl->ifaceToRelease = (IUnknown *) This;
312     }
313     return hr;
314 }
315
316 /* Must set all attached surfaces (e.g. mipmaps) versions as well */
317 static void set_surf_version(IDirectDrawSurfaceImpl *surf, int version)
318 {
319     int i;
320     TRACE("%p->version(%d) = %d\n", surf, surf->version, version);
321     surf->version = version;
322     for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
323     {
324         if(!surf->complex_array[i]) break;
325         set_surf_version(surf->complex_array[i], version);
326     }
327     while( (surf = surf->next_attached) )
328     {
329         set_surf_version(surf, version);
330     }
331 }
332
333 static HRESULT WINAPI
334 IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
335                               LPDIRECTDRAWSURFACE *ppSurface,
336                               IUnknown *pUnkOuter)
337 {
338     LPDIRECTDRAWSURFACE7 pSurface7;
339     IDirectDrawSurfaceImpl *impl;
340     HRESULT hr;
341
342     /* Remove front buffer flag, this causes failure in v7, and its added to normal
343      * primaries anyway
344      */
345     pSDesc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
346     /* the LPDDSURFACEDESC -> LPDDSURFACEDESC2 conversion should be ok,
347      * since the data layout is the same */
348     hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw1(This),
349             (LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
350     if (FAILED(hr))
351     {
352         *ppSurface = NULL;
353         return hr;
354     }
355
356     impl = (IDirectDrawSurfaceImpl *)pSurface7;
357     *ppSurface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
358     set_surf_version(impl, 1);
359     IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw1(This));
360     impl->ifaceToRelease = NULL;
361
362     return hr;
363 }
364
365 static HRESULT WINAPI
366 IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
367                                LPDIRECTDRAWSURFACE *ppSurface,
368                                IUnknown *pUnkOuter)
369 {
370     LPDIRECTDRAWSURFACE7 pSurface7;
371     IDirectDrawSurfaceImpl *impl;
372     HRESULT hr;
373
374     hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw2(This),
375             (LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
376     if (FAILED(hr))
377     {
378         *ppSurface = NULL;
379         return hr;
380     }
381
382     impl = (IDirectDrawSurfaceImpl *)pSurface7;
383     *ppSurface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
384     set_surf_version(impl, 2);
385     IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw2(This));
386     impl->ifaceToRelease = NULL;
387
388     return hr;
389 }
390
391 static HRESULT WINAPI
392 IDirectDraw3Impl_CreateSurface(LPDIRECTDRAW3 This, LPDDSURFACEDESC pSDesc,
393                                LPDIRECTDRAWSURFACE *ppSurface,
394                                IUnknown *pUnkOuter)
395 {
396     LPDIRECTDRAWSURFACE7 pSurface7;
397     IDirectDrawSurfaceImpl *impl;
398     HRESULT hr;
399
400     hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw3(This),
401             (LPDDSURFACEDESC2)pSDesc, &pSurface7, pUnkOuter);
402     if (FAILED(hr))
403     {
404         *ppSurface = NULL;
405         return hr;
406     }
407
408     impl = (IDirectDrawSurfaceImpl *)pSurface7;
409     *ppSurface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
410     set_surf_version(impl, 3);
411     IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw3(This));
412     IDirectDraw3_AddRef(This);
413     impl->ifaceToRelease = (IUnknown *) This;
414
415     return hr;
416 }
417
418 static HRESULT WINAPI
419 IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
420                                LPDIRECTDRAWSURFACE4 *ppSurface,
421                                IUnknown *pUnkOuter)
422 {
423     HRESULT hr;
424     IDirectDrawSurfaceImpl *impl;
425
426     hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)ddraw_from_ddraw4(This),
427             pSDesc, (LPDIRECTDRAWSURFACE7 *)ppSurface, pUnkOuter);
428     impl = (IDirectDrawSurfaceImpl *)*ppSurface;
429     if(SUCCEEDED(hr) && impl)
430     {
431         set_surf_version(impl, 4);
432         IDirectDraw7_Release((IDirectDraw7 *)ddraw_from_ddraw4(This));
433         IDirectDraw4_AddRef(This);
434         impl->ifaceToRelease = (IUnknown *) This;
435     }
436     return hr;
437 }
438
439 static HRESULT WINAPI
440 IDirectDrawImpl_DuplicateSurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE pSrc,
441                                  LPDIRECTDRAWSURFACE *ppDst)
442 {
443     LPDIRECTDRAWSURFACE7 pDst7;
444     HRESULT hr;
445
446     hr = IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw1(This),
447             pSrc ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)pSrc) : NULL, &pDst7);
448
449     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
450      * IDirectDrawSurface vtable layout at the beginning  */
451     *ppDst = pDst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pDst7)->IDirectDrawSurface3_vtbl : NULL;
452
453     return hr;
454 }
455
456 static HRESULT WINAPI
457 IDirectDraw2Impl_DuplicateSurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE pSrc,
458                                   LPDIRECTDRAWSURFACE *ppDst)
459 {
460     LPDIRECTDRAWSURFACE7 pDst7;
461     HRESULT hr;
462
463     hr = IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw2(This),
464             pSrc ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)pSrc) : NULL, &pDst7);
465
466     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
467      * IDirectDrawSurface vtable layout at the beginning  */
468     *ppDst = pDst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pDst7)->IDirectDrawSurface3_vtbl : NULL;
469
470     return hr;
471 }
472
473 static HRESULT WINAPI
474 IDirectDraw3Impl_DuplicateSurface(LPDIRECTDRAW3 This, LPDIRECTDRAWSURFACE pSrc,
475                                   LPDIRECTDRAWSURFACE *ppDst)
476 {
477     LPDIRECTDRAWSURFACE7 pDst7;
478     HRESULT hr;
479
480     hr = IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw3(This),
481             pSrc ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)pSrc) : NULL, &pDst7);
482
483     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
484      * IDirectDrawSurface vtable layout at the beginning  */
485     *ppDst = pDst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pDst7)->IDirectDrawSurface3_vtbl : NULL;
486
487     return hr;
488 }
489
490 static HRESULT WINAPI
491 IDirectDraw4Impl_DuplicateSurface(LPDIRECTDRAW4 This,
492                                   LPDIRECTDRAWSURFACE4 pSrc,
493                                   LPDIRECTDRAWSURFACE4 *ppDst)
494 {
495     return IDirectDraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw4(This),
496             (LPDIRECTDRAWSURFACE7)pSrc, (LPDIRECTDRAWSURFACE7 *)ppDst);
497 }
498
499 struct displaymodescallback_context
500 {
501     LPDDENUMMODESCALLBACK func;
502     LPVOID context;
503 };
504
505 static HRESULT CALLBACK
506 EnumDisplayModesCallbackThunk(LPDDSURFACEDESC2 pDDSD2, LPVOID context)
507 {
508     DDSURFACEDESC DDSD;
509     struct displaymodescallback_context *cbcontext = context;
510
511     memcpy(&DDSD,pDDSD2,sizeof(DDSD));
512     DDSD.dwSize = sizeof(DDSD);
513
514     return cbcontext->func(&DDSD, cbcontext->context);
515 }
516
517 static HRESULT WINAPI
518 IDirectDrawImpl_EnumDisplayModes(LPDIRECTDRAW This, DWORD dwFlags,
519                                  LPDDSURFACEDESC pDDSD, LPVOID context,
520                                  LPDDENUMMODESCALLBACK cb)
521 {
522     struct displaymodescallback_context cbcontext;
523
524     cbcontext.func    = cb;
525     cbcontext.context = context;
526
527     return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw1(This),
528             dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumDisplayModesCallbackThunk);
529 }
530
531 static HRESULT WINAPI
532 IDirectDraw2Impl_EnumDisplayModes(LPDIRECTDRAW2 This, DWORD dwFlags,
533                                   LPDDSURFACEDESC pDDSD, LPVOID context,
534                                   LPDDENUMMODESCALLBACK cb)
535 {
536     struct displaymodescallback_context cbcontext;
537
538     cbcontext.func    = cb;
539     cbcontext.context = context;
540
541     return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw2(This),
542             dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumDisplayModesCallbackThunk);
543 }
544
545 static HRESULT WINAPI
546 IDirectDraw3Impl_EnumDisplayModes(LPDIRECTDRAW3 This, DWORD dwFlags,
547                                   LPDDSURFACEDESC pDDSD, LPVOID context,
548                                   LPDDENUMMODESCALLBACK cb)
549 {
550     struct displaymodescallback_context cbcontext;
551
552     cbcontext.func    = cb;
553     cbcontext.context = context;
554
555     return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw3(This),
556             dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumDisplayModesCallbackThunk);
557 }
558
559 static HRESULT WINAPI
560 IDirectDraw4Impl_EnumDisplayModes(LPDIRECTDRAW4 This, DWORD dwFlags,
561                                   LPDDSURFACEDESC2 pDDSD, LPVOID context,
562                                   LPDDENUMMODESCALLBACK2 cb)
563 {
564     return IDirectDraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, pDDSD, context, cb);
565 }
566
567 struct surfacescallback_context
568 {
569     LPDDENUMSURFACESCALLBACK func;
570     LPVOID context;
571 };
572
573 static HRESULT CALLBACK
574 EnumSurfacesCallbackThunk(LPDIRECTDRAWSURFACE7 pSurf, LPDDSURFACEDESC2 pDDSD,
575                           LPVOID context)
576 {
577     struct surfacescallback_context *cbcontext = context;
578
579     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
580      * IDirectDrawSurface vtable layout at the beginning  */
581     return cbcontext->func(
582             pSurf ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf)->IDirectDrawSurface3_vtbl : NULL,
583             (LPDDSURFACEDESC)pDDSD, cbcontext->context);
584 }
585
586 static HRESULT WINAPI
587 IDirectDrawImpl_EnumSurfaces(LPDIRECTDRAW This, DWORD dwFlags,
588                              LPDDSURFACEDESC pDDSD, LPVOID context,
589                              LPDDENUMSURFACESCALLBACK cb)
590 {
591     struct surfacescallback_context cbcontext;
592
593     cbcontext.func    = cb;
594     cbcontext.context = context;
595
596     return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw1(This),
597             dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumSurfacesCallbackThunk);
598 }
599
600 static HRESULT WINAPI
601 IDirectDraw2Impl_EnumSurfaces(LPDIRECTDRAW2 This, DWORD dwFlags,
602                               LPDDSURFACEDESC pDDSD, LPVOID context,
603                               LPDDENUMSURFACESCALLBACK cb)
604 {
605     struct surfacescallback_context cbcontext;
606
607     cbcontext.func    = cb;
608     cbcontext.context = context;
609
610     return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw2(This),
611             dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumSurfacesCallbackThunk);
612 }
613
614 static HRESULT WINAPI
615 IDirectDraw3Impl_EnumSurfaces(LPDIRECTDRAW3 This, DWORD dwFlags,
616                               LPDDSURFACEDESC pDDSD, LPVOID context,
617                               LPDDENUMSURFACESCALLBACK cb)
618 {
619     struct surfacescallback_context cbcontext;
620
621     cbcontext.func    = cb;
622     cbcontext.context = context;
623
624     return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw3(This),
625             dwFlags, (LPDDSURFACEDESC2)pDDSD, &cbcontext, EnumSurfacesCallbackThunk);
626 }
627
628 static HRESULT WINAPI
629 IDirectDraw4Impl_EnumSurfaces(LPDIRECTDRAW4 This, DWORD dwFlags,
630                               LPDDSURFACEDESC2 pDDSD, LPVOID context,
631                               LPDDENUMSURFACESCALLBACK2 cb)
632 {
633     return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(This),
634             dwFlags, pDDSD, context, (LPDDENUMSURFACESCALLBACK7)cb);
635 }
636
637 static HRESULT WINAPI
638 IDirectDrawImpl_FlipToGDISurface(LPDIRECTDRAW This)
639 {
640     return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(This));
641 }
642
643 static HRESULT WINAPI
644 IDirectDraw2Impl_FlipToGDISurface(LPDIRECTDRAW2 This)
645 {
646     return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(This));
647 }
648
649 static HRESULT WINAPI
650 IDirectDraw3Impl_FlipToGDISurface(LPDIRECTDRAW3 This)
651 {
652     return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(This));
653 }
654
655 static HRESULT WINAPI
656 IDirectDraw4Impl_FlipToGDISurface(LPDIRECTDRAW4 This)
657 {
658     return IDirectDraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(This));
659 }
660
661 static HRESULT WINAPI
662 IDirectDrawImpl_GetCaps(LPDIRECTDRAW This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
663 {
664     return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw1(This), pDDC1, pDDC2);
665 }
666
667 static HRESULT WINAPI
668 IDirectDraw2Impl_GetCaps(LPDIRECTDRAW2 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
669 {
670     return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw2(This), pDDC1, pDDC2);
671 }
672
673 static HRESULT WINAPI
674 IDirectDraw3Impl_GetCaps(LPDIRECTDRAW3 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
675 {
676     return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw3(This), pDDC1, pDDC2);
677 }
678
679 static HRESULT WINAPI
680 IDirectDraw4Impl_GetCaps(LPDIRECTDRAW4 This, LPDDCAPS pDDC1, LPDDCAPS pDDC2)
681 {
682     return IDirectDraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw4(This), pDDC1, pDDC2);
683 }
684
685 static HRESULT WINAPI
686 IDirectDrawImpl_GetDisplayMode(LPDIRECTDRAW This, LPDDSURFACEDESC pDDSD)
687 {
688     return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(This), (LPDDSURFACEDESC2)pDDSD);
689 }
690
691 static HRESULT WINAPI
692 IDirectDraw2Impl_GetDisplayMode(LPDIRECTDRAW2 This, LPDDSURFACEDESC pDDSD)
693 {
694     return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(This), (LPDDSURFACEDESC2)pDDSD);
695 }
696
697 static HRESULT WINAPI
698 IDirectDraw3Impl_GetDisplayMode(LPDIRECTDRAW3 This, LPDDSURFACEDESC pDDSD)
699 {
700     return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(This), (LPDDSURFACEDESC2)pDDSD);
701 }
702
703 static HRESULT WINAPI
704 IDirectDraw4Impl_GetDisplayMode(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pDDSD)
705 {
706     return IDirectDraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(This), (LPDDSURFACEDESC2)pDDSD);
707 }
708
709 static HRESULT WINAPI
710 IDirectDrawImpl_GetFourCCCodes(LPDIRECTDRAW This, LPDWORD lpNumCodes,
711                                LPDWORD lpCodes)
712 {
713     return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw1(This), lpNumCodes, lpCodes);
714 }
715
716 static HRESULT WINAPI
717 IDirectDraw2Impl_GetFourCCCodes(LPDIRECTDRAW2 This, LPDWORD lpNumCodes,
718                                 LPDWORD lpCodes)
719 {
720     return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw2(This), lpNumCodes, lpCodes);
721 }
722
723 static HRESULT WINAPI
724 IDirectDraw3Impl_GetFourCCCodes(LPDIRECTDRAW3 This, LPDWORD lpNumCodes,
725                                 LPDWORD lpCodes)
726 {
727     return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw3(This), lpNumCodes, lpCodes);
728 }
729
730 static HRESULT WINAPI
731 IDirectDraw4Impl_GetFourCCCodes(LPDIRECTDRAW4 This, LPDWORD lpNumCodes,
732                                 LPDWORD lpCodes)
733 {
734     return IDirectDraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw4(This), lpNumCodes, lpCodes);
735 }
736
737 static HRESULT WINAPI
738 IDirectDrawImpl_GetGDISurface(LPDIRECTDRAW This, LPDIRECTDRAWSURFACE *ppSurf)
739 {
740     LPDIRECTDRAWSURFACE7 pSurf7;
741     HRESULT hr;
742
743     hr = IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(This), &pSurf7);
744
745     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
746      * IDirectDrawSurface vtable layout at the beginning  */
747     *ppSurf = pSurf7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf7)->IDirectDrawSurface3_vtbl : NULL;
748
749     return hr;
750 }
751
752 static HRESULT WINAPI
753 IDirectDraw2Impl_GetGDISurface(LPDIRECTDRAW2 This, LPDIRECTDRAWSURFACE *ppSurf)
754 {
755     LPDIRECTDRAWSURFACE7 pSurf7;
756     HRESULT hr;
757
758     hr = IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(This), &pSurf7);
759
760     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
761      * IDirectDrawSurface vtable layout at the beginning  */
762     *ppSurf = pSurf7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf7)->IDirectDrawSurface3_vtbl : NULL;
763
764     return hr;
765 }
766
767 static HRESULT WINAPI
768 IDirectDraw3Impl_GetGDISurface(LPDIRECTDRAW3 This, LPDIRECTDRAWSURFACE *ppSurf)
769 {
770     LPDIRECTDRAWSURFACE7 pSurf7;
771     HRESULT hr;
772
773     hr = IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(This), &pSurf7);
774
775     /* This coercion is safe, since the IDirectDrawSurface3 vtable has the
776      * IDirectDrawSurface vtable layout at the beginning  */
777     *ppSurf = pSurf7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)pSurf7)->IDirectDrawSurface3_vtbl : NULL;
778
779     return hr;
780 }
781
782 static HRESULT WINAPI
783 IDirectDraw4Impl_GetGDISurface(LPDIRECTDRAW4 This,
784                                LPDIRECTDRAWSURFACE4 *ppSurf)
785 {
786     return IDirectDraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(This), (LPDIRECTDRAWSURFACE7 *)ppSurf);
787 }
788
789 static HRESULT WINAPI
790 IDirectDrawImpl_GetMonitorFrequency(LPDIRECTDRAW This, LPDWORD pdwFreq)
791 {
792     return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw1(This), pdwFreq);
793 }
794
795 static HRESULT WINAPI
796 IDirectDraw2Impl_GetMonitorFrequency(LPDIRECTDRAW2 This, LPDWORD pdwFreq)
797 {
798     return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw2(This), pdwFreq);
799 }
800
801 static HRESULT WINAPI
802 IDirectDraw3Impl_GetMonitorFrequency(LPDIRECTDRAW3 This, LPDWORD pdwFreq)
803 {
804     return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw3(This), pdwFreq);
805 }
806
807 static HRESULT WINAPI
808 IDirectDraw4Impl_GetMonitorFrequency(LPDIRECTDRAW4 This, LPDWORD pdwFreq)
809 {
810     return IDirectDraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw4(This), pdwFreq);
811 }
812
813 static HRESULT WINAPI
814 IDirectDrawImpl_GetScanLine(LPDIRECTDRAW This, LPDWORD pdwLine)
815 {
816     return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw1(This), pdwLine);
817 }
818
819 static HRESULT WINAPI
820 IDirectDraw2Impl_GetScanLine(LPDIRECTDRAW2 This, LPDWORD pdwLine)
821 {
822     return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw2(This), pdwLine);
823 }
824
825 static HRESULT WINAPI
826 IDirectDraw3Impl_GetScanLine(LPDIRECTDRAW3 This, LPDWORD pdwLine)
827 {
828     return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw3(This), pdwLine);
829 }
830
831 static HRESULT WINAPI
832 IDirectDraw4Impl_GetScanLine(LPDIRECTDRAW4 This, LPDWORD pdwLine)
833 {
834     return IDirectDraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw4(This), pdwLine);
835 }
836
837 static HRESULT WINAPI
838 IDirectDrawImpl_GetVerticalBlankStatus(LPDIRECTDRAW This, LPBOOL lpbIsInVB)
839 {
840     return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw1(This), lpbIsInVB);
841 }
842
843 static HRESULT WINAPI
844 IDirectDraw2Impl_GetVerticalBlankStatus(LPDIRECTDRAW2 This, LPBOOL lpbIsInVB)
845 {
846     return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw2(This), lpbIsInVB);
847 }
848
849 static HRESULT WINAPI
850 IDirectDraw3Impl_GetVerticalBlankStatus(LPDIRECTDRAW3 This, LPBOOL lpbIsInVB)
851 {
852     return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw3(This), lpbIsInVB);
853 }
854
855 static HRESULT WINAPI
856 IDirectDraw4Impl_GetVerticalBlankStatus(LPDIRECTDRAW4 This, LPBOOL lpbIsInVB)
857 {
858     return IDirectDraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw4(This), lpbIsInVB);
859 }
860
861 static HRESULT WINAPI
862 IDirectDrawImpl_Initialize(LPDIRECTDRAW iface, LPGUID pGUID)
863 {
864     IDirectDrawImpl *This = ddraw_from_ddraw1(iface);
865     HRESULT ret_value;
866
867     ret_value = IDirectDraw7_Initialize((IDirectDraw7 *)This, pGUID);
868
869     return ret_value;
870 }
871
872 static HRESULT WINAPI
873 IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 iface, LPGUID pGUID)
874 {
875     IDirectDrawImpl *This = ddraw_from_ddraw2(iface);
876     HRESULT ret_value;
877
878     ret_value = IDirectDraw7_Initialize((IDirectDraw7 *)This, pGUID);
879
880     return ret_value;
881 }
882
883 static HRESULT WINAPI
884 IDirectDraw3Impl_Initialize(LPDIRECTDRAW3 iface, LPGUID pGUID)
885 {
886     IDirectDrawImpl *This = ddraw_from_ddraw3(iface);
887     HRESULT ret_value;
888
889     ret_value = IDirectDraw7_Initialize((IDirectDraw7 *)This, pGUID);
890
891     return ret_value;
892 }
893
894 static HRESULT WINAPI
895 IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 iface, LPGUID pGUID)
896 {
897     IDirectDrawImpl *This = ddraw_from_ddraw4(iface);
898     HRESULT ret_value;
899
900     ret_value = IDirectDraw7_Initialize((IDirectDraw7 *)This, pGUID);
901
902     return ret_value;
903 }
904
905
906 static HRESULT WINAPI
907 IDirectDrawImpl_RestoreDisplayMode(LPDIRECTDRAW This)
908 {
909     return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(This));
910 }
911
912 static HRESULT WINAPI
913 IDirectDraw2Impl_RestoreDisplayMode(LPDIRECTDRAW2 This)
914 {
915     return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(This));
916 }
917
918 static HRESULT WINAPI
919 IDirectDraw3Impl_RestoreDisplayMode(LPDIRECTDRAW3 This)
920 {
921     return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(This));
922 }
923
924 static HRESULT WINAPI
925 IDirectDraw4Impl_RestoreDisplayMode(LPDIRECTDRAW4 This)
926 {
927     return IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(This));
928 }
929
930 static HRESULT WINAPI
931 IDirectDrawImpl_SetCooperativeLevel(LPDIRECTDRAW This, HWND hWnd,
932                                     DWORD dwFlags)
933 {
934     return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw1(This), hWnd, dwFlags);
935 }
936
937 static HRESULT WINAPI
938 IDirectDraw2Impl_SetCooperativeLevel(LPDIRECTDRAW2 This, HWND hWnd,
939                                      DWORD dwFlags)
940 {
941     return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw2(This), hWnd, dwFlags);
942 }
943
944 static HRESULT WINAPI
945 IDirectDraw3Impl_SetCooperativeLevel(LPDIRECTDRAW3 This, HWND hWnd,
946                                      DWORD dwFlags)
947 {
948     return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw3(This), hWnd, dwFlags);
949 }
950
951 static HRESULT WINAPI
952 IDirectDraw4Impl_SetCooperativeLevel(LPDIRECTDRAW4 This, HWND hWnd,
953                                      DWORD dwFlags)
954 {
955     return IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(This), hWnd, dwFlags);
956 }
957
958 static HRESULT WINAPI
959 IDirectDrawImpl_SetDisplayMode(LPDIRECTDRAW This, DWORD a, DWORD b, DWORD c)
960 {
961     return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(This), a, b, c, 0, 0);
962 }
963
964 static HRESULT WINAPI
965 IDirectDraw2Impl_SetDisplayMode(LPDIRECTDRAW2 This, DWORD a, DWORD b, DWORD c,
966                                 DWORD d, DWORD e)
967 {
968     return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(This), a, b, c, d, e);
969 }
970
971 static HRESULT WINAPI
972 IDirectDraw3Impl_SetDisplayMode(LPDIRECTDRAW3 This, DWORD a, DWORD b, DWORD c,
973                                 DWORD d, DWORD e)
974 {
975     return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(This), a, b, c, d, e);
976 }
977
978 static HRESULT WINAPI
979 IDirectDraw4Impl_SetDisplayMode(LPDIRECTDRAW4 This, DWORD a, DWORD b, DWORD c,
980                                 DWORD d, DWORD e)
981 {
982     return IDirectDraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(This), a, b, c, d, e);
983 }
984
985 static HRESULT WINAPI
986 IDirectDrawImpl_WaitForVerticalBlank(LPDIRECTDRAW This, DWORD dwFlags,
987                                      HANDLE hEvent)
988 {
989     return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw1(This), dwFlags, hEvent);
990 }
991
992 static HRESULT WINAPI
993 IDirectDraw2Impl_WaitForVerticalBlank(LPDIRECTDRAW2 This, DWORD dwFlags,
994                                       HANDLE hEvent)
995 {
996     return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw2(This), dwFlags, hEvent);
997 }
998
999 static HRESULT WINAPI
1000 IDirectDraw3Impl_WaitForVerticalBlank(LPDIRECTDRAW3 This, DWORD dwFlags,
1001                                       HANDLE hEvent)
1002 {
1003     return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw3(This), dwFlags, hEvent);
1004 }
1005
1006 static HRESULT WINAPI
1007 IDirectDraw4Impl_WaitForVerticalBlank(LPDIRECTDRAW4 This, DWORD dwFlags,
1008                                       HANDLE hEvent)
1009 {
1010     return IDirectDraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw4(This), dwFlags, hEvent);
1011 }
1012
1013 static HRESULT WINAPI
1014 IDirectDraw2Impl_GetAvailableVidMem(LPDIRECTDRAW2 This, LPDDSCAPS pCaps,
1015                                     LPDWORD pdwTotal, LPDWORD pdwFree)
1016 {
1017     DDSCAPS2 Caps2;
1018     DDRAW_Convert_DDSCAPS_1_To_2(pCaps, &Caps2);
1019
1020     return IDirectDraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw2(This), &Caps2, pdwTotal, pdwFree);
1021 }
1022
1023 static HRESULT WINAPI
1024 IDirectDraw3Impl_GetAvailableVidMem(LPDIRECTDRAW3 This, LPDDSCAPS pCaps,
1025                                     LPDWORD pdwTotal, LPDWORD pdwFree)
1026 {
1027     DDSCAPS2 Caps2;
1028     DDRAW_Convert_DDSCAPS_1_To_2(pCaps, &Caps2);
1029
1030     return IDirectDraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw3(This), &Caps2, pdwTotal, pdwFree);
1031 }
1032
1033 static HRESULT WINAPI
1034 IDirectDraw4Impl_GetAvailableVidMem(LPDIRECTDRAW4 This, LPDDSCAPS2 pCaps,
1035                                     LPDWORD pdwTotal, LPDWORD pdwFree)
1036 {
1037     return IDirectDraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw4(This), pCaps, pdwTotal, pdwFree);
1038 }
1039
1040 static HRESULT WINAPI
1041 IDirectDraw3Impl_GetSurfaceFromDC(LPDIRECTDRAW3 This, HDC hDC,
1042                                   LPDIRECTDRAWSURFACE *pSurf)
1043 {
1044     return IDirectDraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw3(This), hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
1045 }
1046
1047 static HRESULT WINAPI
1048 IDirectDraw4Impl_GetSurfaceFromDC(LPDIRECTDRAW4 This, HDC hDC,
1049                                   LPDIRECTDRAWSURFACE4 *pSurf)
1050 {
1051     return IDirectDraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw4(This), hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
1052 }
1053
1054 static HRESULT WINAPI
1055 IDirectDraw4Impl_RestoreAllSurfaces(LPDIRECTDRAW4 This)
1056 {
1057     return IDirectDraw7_RestoreAllSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(This));
1058 }
1059
1060 static HRESULT WINAPI
1061 IDirectDraw4Impl_TestCooperativeLevel(LPDIRECTDRAW4 This)
1062 {
1063     return IDirectDraw7_TestCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(This));
1064 }
1065
1066 static HRESULT WINAPI
1067 IDirectDraw4Impl_GetDeviceIdentifier(LPDIRECTDRAW4 This,
1068                                      LPDDDEVICEIDENTIFIER pDDDI, DWORD dwFlags)
1069 {
1070     DDDEVICEIDENTIFIER2 DDDI2;
1071     HRESULT hr;
1072
1073     hr = IDirectDraw7_GetDeviceIdentifier((IDirectDraw7 *)ddraw_from_ddraw4(This), &DDDI2, dwFlags);
1074
1075     DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(&DDDI2, pDDDI);
1076
1077     return hr;
1078 }
1079
1080 const IDirectDrawVtbl IDirectDraw1_Vtbl =
1081 {
1082     IDirectDrawImpl_QueryInterface,
1083     IDirectDrawImpl_AddRef,
1084     IDirectDrawImpl_Release,
1085     IDirectDrawImpl_Compact,
1086     IDirectDrawImpl_CreateClipper,
1087     IDirectDrawImpl_CreatePalette,
1088     IDirectDrawImpl_CreateSurface,
1089     IDirectDrawImpl_DuplicateSurface,
1090     IDirectDrawImpl_EnumDisplayModes,
1091     IDirectDrawImpl_EnumSurfaces,
1092     IDirectDrawImpl_FlipToGDISurface,
1093     IDirectDrawImpl_GetCaps,
1094     IDirectDrawImpl_GetDisplayMode,
1095     IDirectDrawImpl_GetFourCCCodes,
1096     IDirectDrawImpl_GetGDISurface,
1097     IDirectDrawImpl_GetMonitorFrequency,
1098     IDirectDrawImpl_GetScanLine,
1099     IDirectDrawImpl_GetVerticalBlankStatus,
1100     IDirectDrawImpl_Initialize,
1101     IDirectDrawImpl_RestoreDisplayMode,
1102     IDirectDrawImpl_SetCooperativeLevel,
1103     IDirectDrawImpl_SetDisplayMode,
1104     IDirectDrawImpl_WaitForVerticalBlank,
1105 };
1106
1107 const IDirectDraw2Vtbl IDirectDraw2_Vtbl =
1108 {
1109     IDirectDraw2Impl_QueryInterface,
1110     IDirectDraw2Impl_AddRef,
1111     IDirectDraw2Impl_Release,
1112     IDirectDraw2Impl_Compact,
1113     IDirectDraw2Impl_CreateClipper,
1114     IDirectDraw2Impl_CreatePalette,
1115     IDirectDraw2Impl_CreateSurface,
1116     IDirectDraw2Impl_DuplicateSurface,
1117     IDirectDraw2Impl_EnumDisplayModes,
1118     IDirectDraw2Impl_EnumSurfaces,
1119     IDirectDraw2Impl_FlipToGDISurface,
1120     IDirectDraw2Impl_GetCaps,
1121     IDirectDraw2Impl_GetDisplayMode,
1122     IDirectDraw2Impl_GetFourCCCodes,
1123     IDirectDraw2Impl_GetGDISurface,
1124     IDirectDraw2Impl_GetMonitorFrequency,
1125     IDirectDraw2Impl_GetScanLine,
1126     IDirectDraw2Impl_GetVerticalBlankStatus,
1127     IDirectDraw2Impl_Initialize,
1128     IDirectDraw2Impl_RestoreDisplayMode,
1129     IDirectDraw2Impl_SetCooperativeLevel,
1130     IDirectDraw2Impl_SetDisplayMode,
1131     IDirectDraw2Impl_WaitForVerticalBlank,
1132     IDirectDraw2Impl_GetAvailableVidMem
1133 };
1134
1135 const IDirectDraw3Vtbl IDirectDraw3_Vtbl =
1136 {
1137     IDirectDraw3Impl_QueryInterface,
1138     IDirectDraw3Impl_AddRef,
1139     IDirectDraw3Impl_Release,
1140     IDirectDraw3Impl_Compact,
1141     IDirectDraw3Impl_CreateClipper,
1142     IDirectDraw3Impl_CreatePalette,
1143     IDirectDraw3Impl_CreateSurface,
1144     IDirectDraw3Impl_DuplicateSurface,
1145     IDirectDraw3Impl_EnumDisplayModes,
1146     IDirectDraw3Impl_EnumSurfaces,
1147     IDirectDraw3Impl_FlipToGDISurface,
1148     IDirectDraw3Impl_GetCaps,
1149     IDirectDraw3Impl_GetDisplayMode,
1150     IDirectDraw3Impl_GetFourCCCodes,
1151     IDirectDraw3Impl_GetGDISurface,
1152     IDirectDraw3Impl_GetMonitorFrequency,
1153     IDirectDraw3Impl_GetScanLine,
1154     IDirectDraw3Impl_GetVerticalBlankStatus,
1155     IDirectDraw3Impl_Initialize,
1156     IDirectDraw3Impl_RestoreDisplayMode,
1157     IDirectDraw3Impl_SetCooperativeLevel,
1158     IDirectDraw3Impl_SetDisplayMode,
1159     IDirectDraw3Impl_WaitForVerticalBlank,
1160     IDirectDraw3Impl_GetAvailableVidMem,
1161     IDirectDraw3Impl_GetSurfaceFromDC,
1162 };
1163
1164 const IDirectDraw4Vtbl IDirectDraw4_Vtbl =
1165 {
1166     IDirectDraw4Impl_QueryInterface,
1167     IDirectDraw4Impl_AddRef,
1168     IDirectDraw4Impl_Release,
1169     IDirectDraw4Impl_Compact,
1170     IDirectDraw4Impl_CreateClipper,
1171     IDirectDraw4Impl_CreatePalette,
1172     IDirectDraw4Impl_CreateSurface,
1173     IDirectDraw4Impl_DuplicateSurface,
1174     IDirectDraw4Impl_EnumDisplayModes,
1175     IDirectDraw4Impl_EnumSurfaces,
1176     IDirectDraw4Impl_FlipToGDISurface,
1177     IDirectDraw4Impl_GetCaps,
1178     IDirectDraw4Impl_GetDisplayMode,
1179     IDirectDraw4Impl_GetFourCCCodes,
1180     IDirectDraw4Impl_GetGDISurface,
1181     IDirectDraw4Impl_GetMonitorFrequency,
1182     IDirectDraw4Impl_GetScanLine,
1183     IDirectDraw4Impl_GetVerticalBlankStatus,
1184     IDirectDraw4Impl_Initialize,
1185     IDirectDraw4Impl_RestoreDisplayMode,
1186     IDirectDraw4Impl_SetCooperativeLevel,
1187     IDirectDraw4Impl_SetDisplayMode,
1188     IDirectDraw4Impl_WaitForVerticalBlank,
1189     IDirectDraw4Impl_GetAvailableVidMem,
1190     IDirectDraw4Impl_GetSurfaceFromDC,
1191     IDirectDraw4Impl_RestoreAllSurfaces,
1192     IDirectDraw4Impl_TestCooperativeLevel,
1193     IDirectDraw4Impl_GetDeviceIdentifier
1194 };