ReactOS  0.4.14-dev-317-g96040ec
ddraw_main.c File Reference
#include "rosdraw.h"
#include <string.h>
Include dependency graph for ddraw_main.c:

Go to the source code of this file.

Functions

LPDDRAWI_DIRECTDRAW_INT internal_directdraw_int_alloc (LPDDRAWI_DIRECTDRAW_INT This)
 
HRESULT WINAPI Main_DirectDraw_QueryInterface (LPDDRAWI_DIRECTDRAW_INT This, REFIID id, LPVOID *obj)
 
ULONG WINAPI Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This)
 
ULONG WINAPI Main_DirectDraw_Release (LPDDRAWI_DIRECTDRAW_INT This)
 
HRESULT WINAPI Main_DirectDraw_Initialize (LPDDRAWI_DIRECTDRAW_INT This, LPGUID lpGUID)
 
HRESULT WINAPI Main_DirectDraw_Compact (LPDDRAWI_DIRECTDRAW_INT This)
 
HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem (LPDDRAWI_DIRECTDRAW_INT This, LPDDSCAPS ddscaps, LPDWORD dwTotal, LPDWORD dwFree)
 
HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem4 (LPDDRAWI_DIRECTDRAW_INT This, LPDDSCAPS2 ddscaps, LPDWORD dwTotal, LPDWORD dwFree)
 
HRESULT WINAPI Main_DirectDraw_GetFourCCCodes (LPDDRAWI_DIRECTDRAW_INT This, LPDWORD lpNumCodes, LPDWORD lpCodes)
 
HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC pDDSD, LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
 
HRESULT WINAPI Main_DirectDraw_CreateSurface4 (LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC2 pDDSD, LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
 
HRESULT WINAPI Main_DirectDraw_CreatePalette (LPDDRAWI_DIRECTDRAW_INT This, DWORD dwFlags, LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE *ppPalette, LPUNKNOWN pUnkOuter)
 

Function Documentation

◆ internal_directdraw_int_alloc()

LPDDRAWI_DIRECTDRAW_INT internal_directdraw_int_alloc ( LPDDRAWI_DIRECTDRAW_INT  This)

Definition at line 23 of file ddraw_main.c.

24 {
26  DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
27  if (newThis)
28  {
29  newThis->lpLcl = This->lpLcl;
30  newThis->lpLink = This;
31  }
32 
33  return newThis;
34 }
LPDDRAWI_DIRECTDRAW_LCL lpLcl
Definition: ddrawi.h:1148
#define DxHeapMemAlloc(p, m)
Definition: rosdraw.h:113
LPDDRAWI_DIRECTDRAW_INT lpLink
Definition: ddrawi.h:1149

Referenced by Main_DirectDraw_QueryInterface().

◆ Main_DirectDraw_AddRef()

ULONG WINAPI Main_DirectDraw_AddRef ( LPDDRAWI_DIRECTDRAW_INT  This)

Definition at line 145 of file ddraw_main.c.

146 {
147  ULONG retValue = 0;
148 
149  DX_WINDBG_trace();
150 
151  /* Lock the thread */
153 
154  _SEH2_TRY
155  {
156  /* Increment the internal ref counter */
157  This->dwIntRefCnt++;
158 
159  /* Increment the local internal ref counter */
160  This->lpLcl->dwLocalRefCnt++;
161 
162  if (This->lpLcl->lpGbl != NULL)
163  {
164  /* Increment the global internal ref counter */
165  This->lpLcl->lpGbl->dwRefCnt++;
166  }
167  }
169  {
170  }
171  _SEH2_END;
172 
173  _SEH2_TRY
174  {
175  retValue = This->dwIntRefCnt;
176  }
178  {
179  retValue = 0;
180  }
181  _SEH2_END;
182 
183  /* Release the thread lock */
185 
186  /* Return the local Ref counter */
187  return retValue;
188 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
_SEH2_TRY
Definition: create.c:4250
VOID WINAPI AcquireDDThreadLock()
Definition: main.c:412
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI ReleaseDDThreadLock()
Definition: main.c:421
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by Create_DirectDraw(), Main_DirectDraw_CreatePalette(), Main_DirectDraw_CreateSurface4(), Main_DirectDraw_QueryInterface(), ThunkDirectDraw2_AddRef(), ThunkDirectDraw4_AddRef(), and ThunkDirectDraw_AddRef().

◆ Main_DirectDraw_Compact()

HRESULT WINAPI Main_DirectDraw_Compact ( LPDDRAWI_DIRECTDRAW_INT  This)

Definition at line 267 of file ddraw_main.c.

268 {
269  HRESULT retVal = DD_OK;
270 
271  DX_WINDBG_trace();
272 
273  /* Lock the thread */
275 
276  _SEH2_TRY
277  {
278  /* Check if Exclusive mode has been activated */
279  if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl)
280  {
281  retVal = DDERR_NOEXCLUSIVEMODE;
282  }
283  }
285  {
286  }
287  _SEH2_END;
288 
289  /* Release the thread lock */
291 
292  return retVal;
293 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
_SEH2_TRY
Definition: create.c:4250
VOID WINAPI AcquireDDThreadLock()
Definition: main.c:412
#define DD_OK
Definition: ddraw.h:186
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
LONG HRESULT
Definition: typedefs.h:77
VOID WINAPI ReleaseDDThreadLock()
Definition: main.c:421
#define DDERR_NOEXCLUSIVEMODE
Definition: ddraw.h:93
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by ThunkDirectDraw2_Compact(), ThunkDirectDraw4_Compact(), and ThunkDirectDraw_Compact().

◆ Main_DirectDraw_CreatePalette()

HRESULT WINAPI Main_DirectDraw_CreatePalette ( LPDDRAWI_DIRECTDRAW_INT  This,
DWORD  dwFlags,
LPPALETTEENTRY  palent,
LPDIRECTDRAWPALETTE ppPalette,
LPUNKNOWN  pUnkOuter 
)

Definition at line 545 of file ddraw_main.c.

547 {
548  HRESULT ret = DD_OK;
549  DX_WINDBG_trace();
550 
552  *ppPalette = NULL;
553 
554  _SEH2_TRY
555  {
556  ret = Internal_CreatePalette(This, dwFlags, palent, ppPalette, pUnkOuter);
557  }
559  {
561  }
562  _SEH2_END;
563 
564  //Versions 7 and 4 are addref'ed
565  if((This->lpVtbl == &DirectDraw7_Vtable || This->lpVtbl == &DirectDraw4_Vtable) && *ppPalette != NULL)
567 
569  return ret;
570 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
CRITICAL_SECTION ddcs
Definition: main.c:14
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_SEH2_TRY
Definition: create.c:4250
IDirectDraw4Vtbl DirectDraw4_Vtable
Definition: ddraw_thunk.c:890
#define DD_OK
Definition: ddraw.h:186
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_SEH2_END
Definition: create.c:4424
ULONG WINAPI Main_DirectDraw_AddRef(LPDDRAWI_DIRECTDRAW_INT This)
Definition: ddraw_main.c:145
HRESULT Internal_CreatePalette(LPDDRAWI_DIRECTDRAW_INT pDDraw, DWORD dwFlags, LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE *ppPalette, LPUNKNOWN pUnkOuter)
Definition: createpalette.c:33
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
IDirectDraw7Vtbl DirectDraw7_Vtable
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

Referenced by ThunkDirectDraw2_CreatePalette(), ThunkDirectDraw4_CreatePalette(), and ThunkDirectDraw_CreatePalette().

◆ Main_DirectDraw_CreateSurface()

HRESULT WINAPI Main_DirectDraw_CreateSurface ( LPDDRAWI_DIRECTDRAW_INT  This,
LPDDSURFACEDESC  pDDSD,
LPDDRAWI_DDRAWSURFACE_INT ppSurf,
IUnknown pUnkOuter 
)

Definition at line 478 of file ddraw_main.c.

480 {
482  DDSURFACEDESC2 dd_desc_v2;
483 
484  DX_WINDBG_trace();
485 
487  *ppSurf = NULL;
488 
489  _SEH2_TRY
490  {
491  if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
492  {
493  CopyDDSurfDescToDDSurfDesc2(&dd_desc_v2, (LPDDSURFACEDESC)pDDSD);
495  &dd_desc_v2,
496  ppSurf,
497  pUnkOuter);
498  }
499  else
500  {
502  }
503  }
505  {
507  }
508  _SEH2_END;
510  return ret;
511 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
CRITICAL_SECTION ddcs
Definition: main.c:14
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_SEH2_TRY
Definition: create.c:4250
HRESULT Internal_CreateSurface(LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD, LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
Definition: createsurface.c:18
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define DDERR_GENERIC
Definition: ddraw.h:72
LONG HRESULT
Definition: typedefs.h:77
int ret
void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc)
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

Referenced by ThunkDirectDraw2_CreateSurface(), ThunkDirectDraw4_CreateSurface(), and ThunkDirectDraw_CreateSurface().

◆ Main_DirectDraw_CreateSurface4()

HRESULT WINAPI Main_DirectDraw_CreateSurface4 ( LPDDRAWI_DIRECTDRAW_INT  This,
LPDDSURFACEDESC2  pDDSD,
LPDDRAWI_DDRAWSURFACE_INT ppSurf,
IUnknown pUnkOuter 
)

Definition at line 516 of file ddraw_main.c.

518 {
519  HRESULT ret = DD_OK;
520  DX_WINDBG_trace();
521 
523  *ppSurf = NULL;
524 
525  _SEH2_TRY
526  {
527  ret = Internal_CreateSurface(This, pDDSD, ppSurf, pUnkOuter);
528  }
530  {
532  }
533  _SEH2_END;
534 
535  if(*ppSurf != NULL)
537 
539  return ret;
540 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
CRITICAL_SECTION ddcs
Definition: main.c:14
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_SEH2_TRY
Definition: create.c:4250
HRESULT Internal_CreateSurface(LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD, LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
Definition: createsurface.c:18
#define DD_OK
Definition: ddraw.h:186
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
int ret
_SEH2_END
Definition: create.c:4424
ULONG WINAPI Main_DirectDraw_AddRef(LPDDRAWI_DIRECTDRAW_INT This)
Definition: ddraw_main.c:145
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ Main_DirectDraw_GetAvailableVidMem()

HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem ( LPDDRAWI_DIRECTDRAW_INT  This,
LPDDSCAPS  ddscaps,
LPDWORD  dwTotal,
LPDWORD  dwFree 
)

Definition at line 296 of file ddraw_main.c.

297 {
298  DDSCAPS2 myddscaps;
299  HRESULT retValue = DD_OK;
300 
301  ZeroMemory(&myddscaps, sizeof(DDSCAPS2));
302 
303  _SEH2_TRY
304  {
305  myddscaps.dwCaps = ddscaps->dwCaps;
306  retValue = Main_DirectDraw_GetAvailableVidMem4(This, &myddscaps, dwTotal, dwFree);
307  }
309  {
310  retValue = DDERR_INVALIDPARAMS;
311  }
312  _SEH2_END;
313 
314  return retValue;
315 }
DWORD dwCaps
Definition: ddraw.h:727
#define ZeroMemory
Definition: winbase.h:1642
_SEH2_TRY
Definition: create.c:4250
#define DD_OK
Definition: ddraw.h:186
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
DWORD dwCaps
Definition: ddraw.h:732
LONG HRESULT
Definition: typedefs.h:77
_SEH2_END
Definition: create.c:4424
HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSCAPS2 ddscaps, LPDWORD dwTotal, LPDWORD dwFree)
Definition: ddraw_main.c:318
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ Main_DirectDraw_GetAvailableVidMem4()

HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem4 ( LPDDRAWI_DIRECTDRAW_INT  This,
LPDDSCAPS2  ddscaps,
LPDWORD  dwTotal,
LPDWORD  dwFree 
)

Definition at line 318 of file ddraw_main.c.

320 {
321  HRESULT retVal = DD_OK;
323 
324  DX_WINDBG_trace();
325 
326  _SEH2_TRY
327  {
328  // There is no HEL implementation of this api
329  if (!(This->lpLcl->lpDDCB->HALDDMiscellaneous.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY) ||
330  (This->lpLcl->lpGbl->dwFlags & DDRAWI_NOHARDWARE) )
331  {
332  retVal = DDERR_NODIRECTDRAWHW;
333  }
334  else
335  {
336  if ((!dwTotal && !dwFree) || !ddscaps)
337  {
338  retVal = DDERR_INVALIDPARAMS;
339  _SEH2_LEAVE;
340  }
341 
345  {
346  retVal = DDERR_INVALIDPARAMS;
347  _SEH2_LEAVE;
348  }
349 
350 
351  /* ddscaps->dwCaps2 & 0x01
352  this flag is outdate and are
353  set to 0 in ms dxsdk the name of
354  this flag is DDSCAPS2_HARDWAREDEINTERLACE
355  */
356 
357  if ( ddscaps->dwCaps2 & 0x01)
358  {
359  retVal = DDERR_INVALIDCAPS;
360  _SEH2_LEAVE;
361  }
362 
366  DDSCAPS3_DMAP))
367  {
368  retVal = DDERR_INVALIDCAPS;
369  _SEH2_LEAVE;
370  }
371 
372  if ( ddscaps->dwCaps4)
373  {
374  retVal = DDERR_INVALIDCAPS;
375  _SEH2_LEAVE;
376  }
377 
378  ZeroMemory(&memdata, sizeof(DDHAL_GETAVAILDRIVERMEMORYDATA));
379  memdata.lpDD = This->lpLcl->lpGbl;
380  memdata.ddRVal = DDERR_INVALIDPARAMS;
381 
382  memdata.ddsCapsEx.dwCaps2 = ddscaps->dwCaps2;
383  memdata.ddsCapsEx.dwCaps3 = ddscaps->dwCaps3;
384 
385  This->lpLcl->lpGbl->hDD = This->lpLcl->hDD;
386 
387  if (This->lpLcl->lpDDCB->HALDDMiscellaneous.GetAvailDriverMemory(&memdata) == DDHAL_DRIVER_NOTHANDLED)
388  {
389  retVal = DDERR_NODIRECTDRAWHW;
390 
391  if (dwTotal)
392  *dwTotal = 0;
393 
394  if (dwFree)
395  *dwFree = 0;
396  }
397  else
398  {
399  if (dwTotal)
400  *dwTotal = memdata.dwTotal;
401 
402  if (dwFree)
403  *dwFree = memdata.dwFree;
404 
405  retVal = memdata.ddRVal;
406  }
407  }
408  }
410  {
411  }
412  _SEH2_END;
413 
414  return retVal;
415 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define DDHAL_MISCCB32_GETAVAILDRIVERMEMORY
Definition: ddrawi.h:688
#define DDERR_NODIRECTDRAWHW
Definition: ddraw.h:137
#define DDSCAPS3_MULTISAMPLE_QUALITY_MASK
Definition: ddraw.h:321
#define DDSCAPS3_AUTOGENMIPMAP
Definition: ddraw.h:326
#define DDSCAPS3_DMAP
Definition: ddraw.h:327
#define DDSCAPS_WRITEONLY
Definition: ddraw.h:266
DWORD dwCaps2
Definition: ddraw.h:733
#define DDSCAPS_PALETTE
Definition: ddraw.h:257
#define DDHAL_DRIVER_NOTHANDLED
Definition: ddrawi.h:320
DWORD dwCaps3
Definition: ddraw.h:1060
#define ZeroMemory
Definition: winbase.h:1642
DWORD dwCaps4
Definition: ddraw.h:737
#define DDSCAPS_OWNDC
Definition: ddraw.h:268
_SEH2_TRY
Definition: create.c:4250
#define DDSCAPS_FLIP
Definition: ddraw.h:253
#define DDSCAPS_VISIBLE
Definition: ddraw.h:265
#define DDSCAPS3_MULTISAMPLE_MASK
Definition: ddraw.h:320
#define DD_OK
Definition: ddraw.h:186
#define DDSCAPS_SYSTEMMEMORY
Definition: ddraw.h:261
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define DDRAWI_NOHARDWARE
Definition: ddrawi.h:1301
DWORD dwCaps
Definition: ddraw.h:732
#define DDSCAPS_FRONTBUFFER
Definition: ddraw.h:254
#define DDSCAPS3_RESERVED1
Definition: ddraw.h:323
#define DDSCAPS_COMPLEX
Definition: ddraw.h:252
LONG HRESULT
Definition: typedefs.h:77
DWORD dwCaps2
Definition: ddraw.h:1059
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:1754
DWORD dwCaps3
Definition: ddraw.h:734
_SEH2_END
Definition: create.c:4424
#define DDSCAPS_BACKBUFFER
Definition: ddraw.h:251
#define DDSCAPS3_RESERVED2
Definition: ddraw.h:324
#define DDERR_INVALIDCAPS
Definition: ddraw.h:75
#define DDSCAPS3_LIGHTWEIGHTMIPMAP
Definition: ddraw.h:325
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_LEAVE
Definition: filesup.c:20
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

Referenced by Main_DirectDraw_GetAvailableVidMem(), and Main_DirectDraw_GetCaps().

◆ Main_DirectDraw_GetFourCCCodes()

HRESULT WINAPI Main_DirectDraw_GetFourCCCodes ( LPDDRAWI_DIRECTDRAW_INT  This,
LPDWORD  lpNumCodes,
LPDWORD  lpCodes 
)

Definition at line 418 of file ddraw_main.c.

419 {
420  HRESULT retVal = DD_OK;
421 
422  DX_WINDBG_trace();
423 
424 
425  // EnterCriticalSection(&ddcs);
426 
427  _SEH2_TRY
428  {
429  if(IsBadWritePtr(lpNumCodes,sizeof(LPDWORD)))
430  {
431  retVal = DDERR_INVALIDPARAMS;
432  }
433  else
434  {
435  if(!(IsBadWritePtr(lpNumCodes,sizeof(LPDWORD))))
436  {
437  DWORD size;
438 
439  if (*lpNumCodes > This->lpLcl->lpGbl->dwNumFourCC)
440  {
441  *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
442  }
443 
444  size = *lpNumCodes * sizeof(DWORD);
445 
446  if(!IsBadWritePtr(lpCodes, size ))
447  {
448  memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, size );
449  }
450  else
451  {
452  *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
453  }
454  }
455  }
456  }
458  {
459  }
460  _SEH2_END;
461 
462  //LeaveCriticalSection(&ddcs);
463  return retVal;
464 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:885
#define DWORD
Definition: nt_native.h:44
_SEH2_TRY
Definition: create.c:4250
#define DD_OK
Definition: ddraw.h:186
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_SEH2_END
Definition: create.c:4424
uint32_t * LPDWORD
Definition: typedefs.h:57
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

Referenced by ThunkDirectDraw2_GetFourCCCodes(), ThunkDirectDraw4_GetFourCCCodes(), and ThunkDirectDraw_GetFourCCCodes().

◆ Main_DirectDraw_Initialize()

HRESULT WINAPI Main_DirectDraw_Initialize ( LPDDRAWI_DIRECTDRAW_INT  This,
LPGUID  lpGUID 
)

Definition at line 247 of file ddraw_main.c.

248 {
250 }
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67

◆ Main_DirectDraw_QueryInterface()

HRESULT WINAPI Main_DirectDraw_QueryInterface ( LPDDRAWI_DIRECTDRAW_INT  This,
REFIID  id,
LPVOID obj 
)

Definition at line 37 of file ddraw_main.c.

40 {
41  HRESULT retVal = DD_OK;
42 
44 
45  _SEH2_TRY
46  {
47  /* FIXME
48  the D3D object can be obtained from here
49  Direct3D7
50  */
51  if (IsEqualGUID(&IID_IDirectDraw7, id))
52  {
53  if (This->lpVtbl != &DirectDraw7_Vtable)
54  {
56  if (!This)
57  {
58  retVal = DDERR_OUTOFVIDEOMEMORY;
60  }
61  }
62 
63  This->lpVtbl = &DirectDraw7_Vtable;
64  *obj = This;
66  }
67  else if (IsEqualGUID(&IID_IDirectDraw4, id))
68  {
69  if (This->lpVtbl != &DirectDraw4_Vtable)
70  {
72  if (!This)
73  {
74  retVal = DDERR_OUTOFVIDEOMEMORY;
76  }
77  }
78 
79  This->lpVtbl = &DirectDraw4_Vtable;
80  *obj = This;
82  }
83 
84  else if (IsEqualGUID(&IID_IDirectDraw2, id))
85  {
86  if (This->lpVtbl != &DirectDraw2_Vtable)
87  {
89  if (!This)
90  {
91  retVal = DDERR_OUTOFVIDEOMEMORY;
93  }
94  }
95 
96  This->lpVtbl = &DirectDraw2_Vtable;
97  *obj = This;
99  }
100  else if (IsEqualGUID(&IID_IDirectDraw, id))
101  {
102  if (This->lpVtbl != &DirectDraw_Vtable)
103  {
105  if (!This)
106  {
107  retVal = DDERR_OUTOFVIDEOMEMORY;
108  _SEH2_LEAVE;
109  }
110  }
111 
112  This->lpVtbl = &DirectDraw_Vtable;
113  *obj = This;
115  }
116  else
117  {
118  *obj = NULL;
119  DX_STUB_str("E_NOINTERFACE");
120  retVal = E_NOINTERFACE;
121  }
122  }
124  {
125  }
126  _SEH2_END;
127 
128  return retVal;
129 }
LPDDRAWI_DIRECTDRAW_INT internal_directdraw_int_alloc(LPDDRAWI_DIRECTDRAW_INT This)
Definition: ddraw_main.c:23
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define E_NOINTERFACE
Definition: winerror.h:2364
IDirectDrawVtbl DirectDraw_Vtable
Definition: ddraw_thunk.c:835
#define DX_STUB_str(x)
Definition: rosdraw.h:254
#define DDERR_OUTOFVIDEOMEMORY
Definition: ddraw.h:112
IDirectDraw2Vtbl DirectDraw2_Vtable
Definition: ddraw_thunk.c:862
_SEH2_TRY
Definition: create.c:4250
IDirectDraw4Vtbl DirectDraw4_Vtable
Definition: ddraw_thunk.c:890
#define DD_OK
Definition: ddraw.h:186
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
_SEH2_END
Definition: create.c:4424
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
ULONG WINAPI Main_DirectDraw_AddRef(LPDDRAWI_DIRECTDRAW_INT This)
Definition: ddraw_main.c:145
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_LEAVE
Definition: filesup.c:20
IDirectDraw7Vtbl DirectDraw7_Vtable

Referenced by ThunkDirectDraw2_QueryInterface(), ThunkDirectDraw4_QueryInterface(), and ThunkDirectDraw_QueryInterface().

◆ Main_DirectDraw_Release()

ULONG WINAPI Main_DirectDraw_Release ( LPDDRAWI_DIRECTDRAW_INT  This)

Definition at line 194 of file ddraw_main.c.

195 {
196  ULONG Counter = 0;
197 
198  DX_WINDBG_trace();
199 
200  /* Lock the thread */
202 
203  _SEH2_TRY
204  {
205  if (This!=NULL)
206  {
207  This->lpLcl->dwLocalRefCnt--;
208  This->dwIntRefCnt--;
209 
210  if (This->lpLcl->lpGbl != NULL)
211  {
212  This->lpLcl->lpGbl->dwRefCnt--;
213  }
214 
215  if ( This->lpLcl->lpGbl->dwRefCnt == 0)
216  {
217  // set resolution back to the one in registry
218  /*if(This->cooperative_level & DDSCL_EXCLUSIVE)
219  {
220  ChangeDisplaySettings(NULL, 0);
221  }*/
222 
223  Cleanup(This);
224  }
225 
226  /* FIXME cleanup being not call why ?? */
227  Counter = This->dwIntRefCnt;
228  }
229  else
230  {
231  Counter = This->dwIntRefCnt;
232  }
233  }
235  {
236  }
237  _SEH2_END;
238 
239  /* Release the thread lock */
241 
242  return Counter;
243 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
_SEH2_TRY
Definition: create.c:4250
VOID WINAPI AcquireDDThreadLock()
Definition: main.c:412
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI ReleaseDDThreadLock()
Definition: main.c:421
static const WCHAR Cleanup[]
Definition: register.c:80
_SEH2_END
Definition: create.c:4424
static LARGE_INTEGER Counter
Definition: clock.c:43
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by DirectDrawPalette_Release(), Main_DDrawSurface_Release4(), ThunkDirectDraw2_Release(), ThunkDirectDraw4_Release(), and ThunkDirectDraw_Release().