ReactOS  0.4.14-dev-50-g13bb5e2
ddraw.c File Reference
#include <dxg_int.h>
Include dependency graph for ddraw.c:

Go to the source code of this file.

Functions

BOOL intDdGetDriverInfo (PEDD_DIRECTDRAW_GLOBAL peDdGl, GUID guid, PVOID callbackStruct, ULONG callbackSize, ULONG *returnSize)
 
VOID intDdGetAllDriverInfo (PEDD_DIRECTDRAW_GLOBAL peDdGl)
 
VOID intDdEnableDriver (PEDD_DIRECTDRAW_GLOBAL peDdGl)
 
PVOID FASTCALL intDdCreateDirectDrawLocal (HDEV hDev)
 
DWORD NTAPI DxDdCreateDirectDrawObject (HDC hDC)
 
DWORD NTAPI DxDdGetDriverInfo (HANDLE DdHandle, PDD_GETDRIVERINFODATA drvInfoData)
 
BOOL NTAPI DxDdQueryDirectDrawObject (HANDLE DdHandle, DD_HALINFO *pDdHalInfo, DWORD *pCallBackFlags, LPD3DNTHAL_CALLBACKS pd3dNtHalCallbacks, LPD3DNTHAL_GLOBALDRIVERDATA pd3dNtGlobalDriverData, PDD_D3DBUFCALLBACKS pd3dBufCallbacks, LPDDSURFACEDESC pTextureFormats, DWORD *p8, VIDEOMEMORY *p9, DWORD *pdwNumFourCC, DWORD *pdwFourCC)
 
BOOL NTAPI DxDdEnableDirectDraw (HANDLE hDev, BOOL arg2)
 
DWORD NTAPI DxDdReenableDirectDrawObject (HANDLE DdHandle, PVOID p2)
 
PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject (PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal, PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore)
 
HANDLE NTAPI DxDdCreateSurfaceObject (HANDLE hDirectDrawLocal, HANDLE hSurface, PDD_SURFACE_LOCAL puSurfaceLocal, PDD_SURFACE_MORE puSurfaceMore, PDD_SURFACE_GLOBAL puSurfaceGlobal, BOOL bComplete)
 

Function Documentation

◆ DxDdCreateDirectDrawObject()

DWORD NTAPI DxDdCreateDirectDrawObject ( HDC  hDC)

Definition at line 258 of file ddraw.c.

260 {
261  PDC pDC = NULL;
262  HDEV hDev = NULL;
263  DWORD_PTR retVal = 0;
264 
265  pDC = gpEngFuncs.DxEngLockDC(hDC);
266  if (!pDC)
267  return 0;
268 
269  // get driver hDev from DC
270  hDev = (HDEV)gpEngFuncs.DxEngGetDCState(hDC, 3);
271  if (!hDev) {
273  return 0;
274  }
275 
276  // is this primary display?
278  {
280  return 0;
281  }
282 
284 
285  // create object only for 8BPP and more
287  retVal = (DWORD_PTR)intDdCreateDirectDrawLocal(hDev);
288 
291  return retVal;
292 }
PFN_DxEngLockDC DxEngLockDC
Definition: dxg_int.h:154
PVOID FASTCALL intDdCreateDirectDrawLocal(HDEV hDev)
Definition: ddraw.c:210
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
Definition: xlate.c:10
smooth NULL
Definition: ftsmooth.c:416
PFN_DxEngGetDCState DxEngGetDCState
Definition: dxg_int.h:157
Definition: polytest.cpp:40
uint32_t DWORD_PTR
Definition: typedefs.h:63
static HDC hDC
Definition: 3dtext.c:33
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:147
PFN_DxEngUnlockDC DxEngUnlockDC
Definition: dxg_int.h:155
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:137
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:138

◆ DxDdCreateSurfaceObject()

HANDLE NTAPI DxDdCreateSurfaceObject ( HANDLE  hDirectDrawLocal,
HANDLE  hSurface,
PDD_SURFACE_LOCAL  puSurfaceLocal,
PDD_SURFACE_MORE  puSurfaceMore,
PDD_SURFACE_GLOBAL  puSurfaceGlobal,
BOOL  bComplete 
)

Definition at line 647 of file ddraw.c.

653 {
654  HANDLE RetVal = FALSE;
655  PEDD_DIRECTDRAW_LOCAL peDdL = NULL;
656  PEDD_SURFACE pDdSurface = NULL;
657 
658  peDdL = (PEDD_DIRECTDRAW_LOCAL)DdHmgLock(hDirectDrawLocal, ObjType_DDLOCAL_TYPE, FALSE);
659 
660  if (!peDdL)
661  return RetVal;
662 
663  pDdSurface = intDdCreateNewSurfaceObject(peDdL, hSurface, puSurfaceGlobal, puSurfaceLocal, puSurfaceMore);
664  if (!pDdSurface)
665  {
667  return RetVal;
668  }
669 
670  RetVal = pDdSurface->pobj.hHmgr;
671 
674 
675  return RetVal;
676 }
USHORT cExclusiveLock
Definition: dxg_int.h:39
PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal, PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore)
Definition: ddraw.c:588
smooth NULL
Definition: ftsmooth.c:416
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:56
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
DD_BASEOBJECT pobj
Definition: directxint.h:16
#define InterlockedDecrement
Definition: armddk.h:52
HGDIOBJ hHmgr
Definition: dxg_int.h:37
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
DD_BASEOBJECT pobj
Definition: directxint.h:46

◆ DxDdEnableDirectDraw()

BOOL NTAPI DxDdEnableDirectDraw ( HANDLE  hDev,
BOOL  arg2 
)

Definition at line 504 of file ddraw.c.

505 {
506  PEDD_DIRECTDRAW_GLOBAL peDdGl = NULL;
507 
509  {
511  peDdGl->hDev = hDev;
512  peDdGl->bSuspended = FALSE;
514  intDdEnableDriver(peDdGl);
515  return TRUE;
516  }
517 
518  return FALSE;
519 }
#define TRUE
Definition: types.h:120
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
VOID intDdEnableDriver(PEDD_DIRECTDRAW_GLOBAL peDdGl)
Definition: ddraw.c:131
struct _EDD_DIRECTDRAW_GLOBAL * PEDD_DIRECTDRAW_GLOBAL
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:147

◆ DxDdGetDriverInfo()

DWORD NTAPI DxDdGetDriverInfo ( HANDLE  DdHandle,
PDD_GETDRIVERINFODATA  drvInfoData 
)

Definition at line 309 of file ddraw.c.

310 {
311  PEDD_DIRECTDRAW_LOCAL peDdL;
312  PEDD_DIRECTDRAW_GLOBAL peDdGl;
313  PVOID pInfo = NULL;
314  DWORD dwInfoSize = 0;
315  BYTE callbackStruct[1024];
316  DWORD RetVal = FALSE;
317 
319  if (!peDdL)
320  return RetVal;
321 
322  peDdGl = peDdL->peDirectDrawGlobal2;
323 
324  // check VideoPort related callbacks
326  {
327  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_VideoPortCallbacks))
328  {
329  dwInfoSize = sizeof(DD_VIDEOPORTCALLBACKS);
330  pInfo = (VOID*)&peDdGl->ddVideoPortCallback;
331  }
332  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_VideoPortCaps))
333  {
334  pInfo = (VOID*)peDdGl->lpDDVideoPortCaps;
335  dwInfoSize = 72 * peDdGl->ddHalInfo.ddCaps.dwMaxVideoPorts;
336  }
337  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_D3DCallbacks3))
338  {
339  dwInfoSize = sizeof(D3DNTHAL_CALLBACKS3);
340  pInfo = (VOID*)&peDdGl->d3dNtHalCallbacks3;
341  }
342  }
343 
344  // check ColorControl related callbacks
346  {
347  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_ColorControlCallbacks))
348  {
349  dwInfoSize = sizeof(DD_COLORCONTROLCALLBACKS);
350  pInfo = (VOID*)&peDdGl->ddColorControlCallbacks;
351  }
352  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_NTCallbacks))
353  {
354  dwInfoSize = sizeof(DD_NTCALLBACKS);
355  pInfo = (VOID*)&peDdGl->ddNtCallbacks;
356  }
357  }
358 
359  // check Miscellaneous callbacks
361  {
362  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_MiscellaneousCallbacks))
363  {
364  dwInfoSize = sizeof(DD_MISCELLANEOUSCALLBACKS);
365  pInfo = (VOID*)&peDdGl->ddMiscellanousCallbacks;
366  }
367  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_DDMoreCaps))
368  {
369  dwInfoSize = sizeof(DD_MORECAPS);
370  pInfo = &peDdGl->ddMoreCaps;
371  }
372  }
373 
374  if (peDdGl->dwCallbackFlags & EDDDGBL_MISC2CALLBACKS &&
375  InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_Miscellaneous2Callbacks))
376  {
377  dwInfoSize = sizeof(DD_MISCELLANEOUS2CALLBACKS);
378  pInfo = (VOID*)&peDdGl->ddMiscellanous2Callbacks;
379  }
380 
382  InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_MotionCompCallbacks))
383  {
384  dwInfoSize = sizeof(DD_MOTIONCOMPCALLBACKS);
385  pInfo = (VOID*)&peDdGl->ddMotionCompCallbacks;
386  }
387 
388  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_KernelCaps) )
389  {
390  dwInfoSize = sizeof(DD_KERNELCALLBACKS);
391  pInfo = &peDdGl->ddKernelCaps;
392  }
393 
394  if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_DDMoreSurfaceCaps))
395  {
396  dwInfoSize = sizeof(DDMORESURFACECAPS);
397  pInfo = &peDdGl->ddMoreSurfaceCaps;
398  }
399 
400  if (dwInfoSize && pInfo)
401  {
402  gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
403  intDdGetDriverInfo(peDdGl, drvInfoData->guidInfo, &callbackStruct, dwInfoSize, &dwInfoSize);
405  memcpy(drvInfoData->lpvData, callbackStruct, dwInfoSize);
406  }
407 
409 
410  return TRUE;
411 }
#define TRUE
Definition: types.h:120
#define EDDDGBL_COLORCONTROLCALLBACKS
Definition: directxint.h:109
#define EDDDGBL_MOTIONCOMPCALLBACKS
Definition: directxint.h:110
DDNTCORECAPS ddCaps
Definition: ddrawint.h:1126
DD_MORECAPS ddMoreCaps
Definition: directxint.h:158
struct DD_MOTIONCOMPCALLBACKS DD_MOTIONCOMPCALLBACKS
USHORT cExclusiveLock
Definition: dxg_int.h:39
DD_MOTIONCOMPCALLBACKS ddMotionCompCallbacks
Definition: directxint.h:174
struct _DD_MISCELLANEOUSCALLBACKS DD_MISCELLANEOUSCALLBACKS
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
DD_COLORCONTROLCALLBACKS ddColorControlCallbacks
Definition: directxint.h:171
#define EDDDGBL_MISC2CALLBACKS
Definition: directxint.h:111
LPDDVIDEOPORTCAPS lpDDVideoPortCaps
Definition: directxint.h:123
DD_MISCELLANEOUS2CALLBACKS ddMiscellanous2Callbacks
Definition: directxint.h:169
DD_MISCELLANEOUSCALLBACKS ddMiscellanousCallbacks
Definition: directxint.h:168
smooth NULL
Definition: ftsmooth.c:416
struct DD_KERNELCALLBACKS DD_KERNELCALLBACKS
DDMORESURFACECAPS ddMoreSurfaceCaps
Definition: directxint.h:175
DD_VIDEOPORTCALLBACKS ddVideoPortCallback
Definition: directxint.h:167
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:56
struct DD_VIDEOPORTCALLBACKS DD_VIDEOPORTCALLBACKS
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
DD_BASEOBJECT pobj
Definition: directxint.h:16
#define EDDDGBL_MISCCALLBACKS
Definition: directxint.h:107
struct _DD_MISCELLANEOUS2CALLBACKS DD_MISCELLANEOUS2CALLBACKS
struct _DD_MORECAPS DD_MORECAPS
#define InterlockedDecrement
Definition: armddk.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
DWORD dwMaxVideoPorts
Definition: ddrawint.h:1110
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
DD_NTCALLBACKS ddNtCallbacks
Definition: directxint.h:170
#define EDDDGBL_VIDEOPORTCALLBACKS
Definition: directxint.h:108
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
struct _DD_NTCALLBACKS DD_NTCALLBACKS
BOOL intDdGetDriverInfo(PEDD_DIRECTDRAW_GLOBAL peDdGl, GUID guid, PVOID callbackStruct, ULONG callbackSize, ULONG *returnSize)
Definition: ddraw.c:42
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:137
struct _DD_COLORCONTROLCALLBACKS DD_COLORCONTROLCALLBACKS
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:138
struct _D3DNTHAL_CALLBACKS3 D3DNTHAL_CALLBACKS3
D3DNTHAL_CALLBACKS3 d3dNtHalCallbacks3
Definition: directxint.h:173
#define InlineIsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:142
struct _DDMORESURFACECAPS DDMORESURFACECAPS
DDKERNELCAPS ddKernelCaps
Definition: directxint.h:157

◆ DxDdQueryDirectDrawObject()

BOOL NTAPI DxDdQueryDirectDrawObject ( HANDLE  DdHandle,
DD_HALINFO pDdHalInfo,
DWORD pCallBackFlags,
LPD3DNTHAL_CALLBACKS  pd3dNtHalCallbacks,
LPD3DNTHAL_GLOBALDRIVERDATA  pd3dNtGlobalDriverData,
PDD_D3DBUFCALLBACKS  pd3dBufCallbacks,
LPDDSURFACEDESC  pTextureFormats,
DWORD p8,
VIDEOMEMORY p9,
DWORD pdwNumFourCC,
DWORD pdwFourCC 
)

Definition at line 424 of file ddraw.c.

436 {
437  PEDD_DIRECTDRAW_LOCAL peDdL;
438  PEDD_DIRECTDRAW_GLOBAL peDdGl;
439  BOOL RetVal = FALSE;
440 
441  if (!DdHandle)
442  return RetVal;
443 
444  if (!pDdHalInfo)
445  return RetVal;
446 
448  return RetVal;
449 
451  if (peDdL)
452  {
453  peDdGl = peDdL->peDirectDrawGlobal2;
454  gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
455 
456  memcpy(pDdHalInfo, &peDdGl->ddHalInfo, sizeof(DD_HALINFO));
457 
458  if (pCallBackFlags)
459  {
460  *(DWORD*)pCallBackFlags = peDdGl->ddCallbacks.dwFlags;
461  *(DWORD*)((ULONG_PTR)pCallBackFlags + 4) = peDdGl->ddSurfaceCallbacks.dwFlags;
462  *(DWORD*)((ULONG_PTR)pCallBackFlags + 8) = peDdGl->ddPaletteCallbacks.dwFlags;
463  }
464 
465  if (pd3dNtHalCallbacks)
466  memcpy(pd3dNtHalCallbacks, &peDdGl->d3dNtHalCallbacks, sizeof(peDdGl->d3dNtHalCallbacks));
467 
468  if (pd3dNtGlobalDriverData)
469  memcpy(pd3dNtGlobalDriverData, &peDdGl->d3dNtGlobalDriverData, sizeof(peDdGl->d3dNtGlobalDriverData));
470 
471  if (pd3dBufCallbacks)
472  memcpy(pd3dBufCallbacks, &peDdGl->d3dBufCallbacks, sizeof(peDdGl->d3dBufCallbacks));
473 
474  if (pTextureFormats)
476 
477  if (pdwNumFourCC)
478  *pdwNumFourCC = peDdGl->dwNumFourCC;
479 
480  if (pdwFourCC)
481  memcpy(pdwFourCC, &peDdGl->pdwFourCC, 4 * peDdGl->dwNumFourCC);
482 
483  RetVal = TRUE;
484 
486 
488  }
489 
490  return RetVal;
491 }
#define TRUE
Definition: types.h:120
USHORT cExclusiveLock
Definition: dxg_int.h:39
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
D3DNTHAL_CALLBACKS d3dNtHalCallbacks
Definition: directxint.h:164
uint32_t ULONG_PTR
Definition: typedefs.h:63
DD_PALETTECALLBACKS ddPaletteCallbacks
Definition: directxint.h:162
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:56
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
LPDDSURFACEDESC lpTextureFormats
Definition: d3dnthal.h:132
DD_BASEOBJECT pobj
Definition: directxint.h:16
#define InterlockedDecrement
Definition: armddk.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
DD_CALLBACKS ddCallbacks
Definition: directxint.h:160
_Out_ DD_HALINFO _Out_ DWORD _Out_ VIDEOMEMORY _Out_ DWORD _Out_ DWORD * pdwFourCC
Definition: winddi.h:4226
DD_D3DBUFCALLBACKS d3dBufCallbacks
Definition: directxint.h:165
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
PFN_DxEngScreenAccessCheck DxEngScreenAccessCheck
Definition: dxg_int.h:129
DD_SURFACECALLBACKS ddSurfaceCallbacks
Definition: directxint.h:161
DWORD dwFlags
Definition: ddrawint.h:499
#define ULONG_PTR
Definition: config.h:101
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:137
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:138
D3DNTHAL_GLOBALDRIVERDATA d3dNtGlobalDriverData
Definition: directxint.h:163

◆ DxDdReenableDirectDrawObject()

DWORD NTAPI DxDdReenableDirectDrawObject ( HANDLE  DdHandle,
PVOID  p2 
)

Definition at line 541 of file ddraw.c.

544 {
545  PEDD_DIRECTDRAW_LOCAL peDdL;
546  PEDD_DIRECTDRAW_GLOBAL peDdGl;
547  HDC hDC;
548  DWORD RetVal = FALSE;
549 
551 
552  if (!peDdL)
553  return RetVal;
554 
555  peDdGl = peDdL->peDirectDrawGlobal2;
556 
558 
560  gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
561 
562  if (peDdGl->fl & 1 &&
563  gpEngFuncs.DxEngGetDCState(hDC, 2) != 1 &&
568  {
569  // reset acceleration and suspend flags
570  peDdGl->fl &= 0xFFFFFFFD;
571  peDdGl->bSuspended = 0;
573 
574  RetVal = TRUE;
575  // FIXME AGP Stuff
576  }
577 
580 
582 
583  return RetVal;
584 }
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
USHORT cExclusiveLock
Definition: dxg_int.h:39
PFN_DxEngUnlockShareSem DxEngUnlockShareSem
Definition: dxg_int.h:135
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
Definition: xlate.c:10
PFN_DxEngGetDesktopDC DxEngGetDesktopDC
Definition: dxg_int.h:150
void * PVOID
Definition: retypes.h:9
PFN_DxEngGetDCState DxEngGetDCState
Definition: dxg_int.h:157
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:56
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
DD_BASEOBJECT pobj
Definition: directxint.h:16
#define InterlockedDecrement
Definition: armddk.h:52
static HDC hDC
Definition: 3dtext.c:33
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:147
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:137
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:138
PFN_DxEngLockShareSem DxEngLockShareSem
Definition: dxg_int.h:134

◆ intDdCreateDirectDrawLocal()

PVOID FASTCALL intDdCreateDirectDrawLocal ( HDEV  hDev)

Definition at line 210 of file ddraw.c.

211 {
212  PEDD_DIRECTDRAW_GLOBAL peDdGl = NULL;
213  PEDD_DIRECTDRAW_LOCAL peDdL = NULL;
214  PDD_ENTRY AllocRet;
215 
217 
219  if (!AllocRet)
220  return NULL;
221 
222  peDdL = (PEDD_DIRECTDRAW_LOCAL)AllocRet->pobj;
223 
224  /* initialize DIRECTDRAW_LOCAL */
227  peDdL->Process = PsGetCurrentProcess();
228 
229  // link DirectDrawGlobal and DirectDrawLocal
230  peDdGl->peDirectDrawLocalList = peDdL;
231  peDdL->peDirectDrawGlobal = peDdGl;
232  peDdL->peDirectDrawGlobal2 = peDdGl;
233 
235 
237 
238  return peDdL->pobj.hHmgr;
239 }
Definition: dxg_int.h:62
#define TRUE
Definition: types.h:120
USHORT cExclusiveLock
Definition: dxg_int.h:39
struct _EDD_DIRECTDRAW_LOCAL * peDirectDrawLocal_prev
Definition: directxint.h:25
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
PFN_DxEngReferenceHdev DxEngReferenceHdev
Definition: dxg_int.h:140
PDD_BASEOBJECT pobj
Definition: dxg_int.h:66
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:56
DD_BASEOBJECT pobj
Definition: directxint.h:16
EDD_DIRECTDRAW_LOCAL * peDirectDrawLocalList
Definition: directxint.h:176
#define InterlockedDecrement
Definition: armddk.h:52
HANDLE NTAPI PsGetCurrentThreadProcessId(VOID)
Definition: thread.c:755
struct _EDD_DIRECTDRAW_GLOBAL * PEDD_DIRECTDRAW_GLOBAL
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
HGDIOBJ hHmgr
Definition: dxg_int.h:37
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:147
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal
Definition: directxint.h:17
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock)
Definition: ddhmg.c:340

Referenced by DxDdCreateDirectDrawObject().

◆ intDdCreateNewSurfaceObject()

PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject ( PEDD_DIRECTDRAW_LOCAL  peDdL,
HANDLE  hDirectDrawLocal,
PDD_SURFACE_GLOBAL  pDdSurfGlob,
PDD_SURFACE_LOCAL  pDdSurfLoc,
PDD_SURFACE_MORE  pDdSurfMore 
)

Definition at line 588 of file ddraw.c.

589 {
591 
592  // first check if we can assign it from current ddHandle
593  if (hDirectDrawLocal)
594  {
596  // check if surface is locked and belongs to correct DirectDrawLocal
597  if ((pSurface)&&((pSurface->peDirectDrawLocal != peDdL)||(!pSurface->hSecure)))
598  {
600  return NULL;
601  }
602  }
603 
604  // if surface not found from ddHandle or ddHandle not provided
605  if (!pSurface)
606  {
607  // create new surface object
609  if (pSurface)
610  {
611  pSurface->ddsSurfaceLocal.lpGbl = &pSurface->ddsSurfaceGlobal;
612  pSurface->ddsSurfaceLocal.lpSurfMore = &pSurface->ddsSurfaceMore;
613  pSurface->ddsSurfaceInt.lpLcl = &pSurface->ddsSurfaceLocal;
614  pSurface->peDirectDrawLocal = peDdL;
615  pSurface->peDirectDrawGlobalNext = peDdL->peDirectDrawGlobal2;
616  pSurface->ldev = gpEngFuncs.DxEngGetHdevData(pSurface->peDirectDrawGlobalNext->hDev, DxEGShDevData_ldev);
617  pSurface->gdev = gpEngFuncs.DxEngGetHdevData(pSurface->peDirectDrawGlobalNext->hDev, DxEGShDevData_GDev);
618  pSurface->hSecure = (VOID*)1;
619  }
620  }
621 
622  if (pSurface)
623  {
624  pSurface->ddsSurfaceGlobal.fpVidMem = pDdSurfGlob->fpVidMem;
625  pSurface->ddsSurfaceGlobal.lPitch = pDdSurfGlob->lPitch;
626  pSurface->ddsSurfaceGlobal.wWidth = pDdSurfGlob->wWidth;
627  pSurface->ddsSurfaceGlobal.wHeight = pDdSurfGlob->wHeight;
628  pSurface->wWidth = pDdSurfGlob->wWidth;
629  pSurface->wHeight = pDdSurfGlob->wHeight;
630  memcpy(&pSurface->ddsSurfaceGlobal.ddpfSurface, &pDdSurfGlob->ddpfSurface, sizeof(pSurface->ddsSurfaceGlobal.ddpfSurface));
631  pSurface->ddsSurfaceLocal.ddsCaps.dwCaps = pDdSurfLoc->ddsCaps.dwCaps;
632  pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps2 = pDdSurfMore->ddsCapsEx.dwCaps2;
633  pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps3 = pDdSurfMore->ddsCapsEx.dwCaps3;
634  pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps4 = pDdSurfMore->ddsCapsEx.dwCaps4;
635  pSurface->ddsSurfaceMore.dwSurfaceHandle = pDdSurfMore->dwSurfaceHandle;
636  pSurface->hSecure = (VOID*)1;
637 
638  peDdL->peSurface_DdList = pSurface;
639  peDdL->hSurface = (ULONG_PTR)pSurface->pobj.hHmgr;
640  }
641 
642  return pSurface;
643 }
#define TRUE
Definition: types.h:120
DWORD dwSurfaceHandle
Definition: ddrawint.h:166
DDSCAPSEX ddsCapsEx
Definition: ddrawint.h:165
DWORD dwCaps
Definition: ddraw.h:727
DDSCAPS ddsCaps
Definition: ddrawint.h:174
DWORD dwCaps3
Definition: ddraw.h:1060
USHORT cExclusiveLock
Definition: dxg_int.h:39
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
#define ObjType_DDSURFACE_TYPE
Definition: dxg_int.h:57
DWORD dwCaps4
Definition: ddraw.h:1063
smooth NULL
Definition: ftsmooth.c:416
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
DWORD dwCaps2
Definition: ddraw.h:1059
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
struct _EDD_SURFACE * peSurface_DdList
Definition: directxint.h:19
DD_BASEOBJECT pobj
Definition: directxint.h:16
#define InterlockedDecrement
Definition: armddk.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
DDPIXELFORMAT ddpfSurface
Definition: ddrawint.h:156
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:147
HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock)
Definition: ddhmg.c:340
FLATPTR fpVidMem
Definition: ddrawint.h:146
#define ULONG_PTR
Definition: config.h:101
struct _EDD_SURFACE * PEDD_SURFACE

Referenced by DxDdCreateSurfaceObject(), and intDdCreateSurfaceOrBuffer().

◆ intDdEnableDriver()

VOID intDdEnableDriver ( PEDD_DIRECTDRAW_GLOBAL  peDdGl)

Definition at line 131 of file ddraw.c.

132 {
133  PDRIVER_FUNCTIONS DriverFunctions;
134  LPD3DNTHAL_GLOBALDRIVERDATA GlobalDriverData;
135  LPD3DNTHAL_CALLBACKS HalCallbacks;
136  PDD_D3DBUFCALLBACKS D3DBufCallbacks;
137 
138 
139  gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
141 
142  // check if driver has DirectDraw functions
143  if ((!DriverFunctions->GetDirectDrawInfo)||(!DriverFunctions->EnableDirectDraw)||(!DriverFunctions->DisableDirectDraw))
144  peDdGl->dhpdev = 0;
145 
146 
147  // reset acceleration flag
148  peDdGl->fl = peDdGl->fl & 0xFFFFFFFE;
149 
150  // ask for structure sizes
151  if ((peDdGl->dhpdev)&&(DriverFunctions->GetDirectDrawInfo(peDdGl->dhpdev, &peDdGl->ddHalInfo, &peDdGl->dwNumHeaps, NULL, &peDdGl->dwNumFourCC, NULL)))
152  {
153  // allocate memory for DX data
154  if (peDdGl->dwNumHeaps)
155  peDdGl->pvmList = EngAllocMem(FL_ZERO_MEMORY, peDdGl->dwNumHeaps*sizeof(VIDEOMEMORY), TAG_GDDV);
156  if (peDdGl->dwNumFourCC)
157  peDdGl->pdwFourCC = EngAllocMem(FL_ZERO_MEMORY, peDdGl->dwNumFourCC * 4, TAG_GDDF);
158 
159  // get data from driver
160  if (!DriverFunctions->GetDirectDrawInfo(peDdGl->dhpdev, &peDdGl->ddHalInfo, &peDdGl->dwNumHeaps, peDdGl->pvmList, &peDdGl->dwNumFourCC, peDdGl->pdwFourCC))
161  {
162  // failed - cleanup and exit
163  if (peDdGl->pvmList)
164  EngFreeMem(peDdGl->pvmList);
165  if (peDdGl->pdwFourCC)
166  EngFreeMem(peDdGl->pdwFourCC);
168  return;
169  }
170 
171  // check if we can enable DirectDraw acceleration
172  if ((peDdGl->ddHalInfo.vmiData.pvPrimary) &&
173  (DriverFunctions->EnableDirectDraw(peDdGl->dhpdev, &peDdGl->ddCallbacks, &peDdGl->ddSurfaceCallbacks, &peDdGl->ddPaletteCallbacks))&&
175  (peDdGl->ddHalInfo.dwSize == sizeof(DD_HALINFO)))
176  {
177  GlobalDriverData = peDdGl->ddHalInfo.lpD3DGlobalDriverData;
178  HalCallbacks = peDdGl->ddHalInfo.lpD3DHALCallbacks;
179  D3DBufCallbacks = peDdGl->ddHalInfo.lpD3DHALCallbacks;
180 
181  if (GlobalDriverData && GlobalDriverData->dwSize == sizeof(D3DNTHAL_GLOBALDRIVERDATA))
182  memcpy(&peDdGl->d3dNtGlobalDriverData, GlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
183 
184  if (HalCallbacks && HalCallbacks->dwSize == sizeof(D3DNTHAL_CALLBACKS))
185  memcpy(&peDdGl->d3dNtHalCallbacks, HalCallbacks, sizeof(D3DNTHAL_CALLBACKS));
186 
187  if (D3DBufCallbacks && D3DBufCallbacks->dwSize == sizeof(DD_D3DBUFCALLBACKS))
188  memcpy(&peDdGl->d3dBufCallbacks, D3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
189 
190  intDdGetAllDriverInfo(peDdGl);
191 
192  // enable DirectDraw acceleration
193  peDdGl->fl |= 1;
194  }
195  else
196  {
197  // failed - cleanup and exit
198  if (peDdGl->pvmList)
199  EngFreeMem(peDdGl->pvmList);
200  if (peDdGl->pdwFourCC)
201  EngFreeMem(peDdGl->pdwFourCC);
202  }
203  }
204 
206 }
#define TAG_GDDV
Definition: tags.h:3
#define EngFreeMem
Definition: polytest.cpp:56
#define TAG_GDDF
Definition: tags.h:4
PFN_DrvGetDirectDrawInfo GetDirectDrawInfo
Definition: ntgdityp.h:627
VIDEOMEMORY * pvmList
Definition: directxint.h:150
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
D3DNTHAL_CALLBACKS d3dNtHalCallbacks
Definition: directxint.h:164
#define CapOver_DisableD3DAccel
Definition: dxg_int.h:52
DWORD dwSize
Definition: ddrawint.h:1124
DD_PALETTECALLBACKS ddPaletteCallbacks
Definition: directxint.h:162
smooth NULL
Definition: ftsmooth.c:416
struct _DRIVER_FUNCTIONS * PDRIVER_FUNCTIONS
VIDEOMEMORYINFO vmiData
Definition: ddrawint.h:1125
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
PFN_DrvDisableDirectDraw DisableDirectDraw
Definition: ntgdityp.h:629
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PVOID lpD3DGlobalDriverData
Definition: ddrawint.h:1129
VOID intDdGetAllDriverInfo(PEDD_DIRECTDRAW_GLOBAL peDdGl)
Definition: ddraw.c:85
DD_CALLBACKS ddCallbacks
Definition: directxint.h:160
DD_D3DBUFCALLBACKS d3dBufCallbacks
Definition: directxint.h:165
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:147
DD_SURFACECALLBACKS ddSurfaceCallbacks
Definition: directxint.h:161
PFN_DrvEnableDirectDraw EnableDirectDraw
Definition: ntgdityp.h:628
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:137
PVOID lpD3DHALCallbacks
Definition: ddrawint.h:1130
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:138
D3DNTHAL_GLOBALDRIVERDATA d3dNtGlobalDriverData
Definition: directxint.h:163

Referenced by DxDdEnableDirectDraw().

◆ intDdGetAllDriverInfo()

VOID intDdGetAllDriverInfo ( PEDD_DIRECTDRAW_GLOBAL  peDdGl)

Definition at line 85 of file ddraw.c.

86 {
88  {
89  intDdGetDriverInfo(peDdGl, GUID_KernelCaps, &peDdGl->ddKernelCaps, sizeof(peDdGl->ddKernelCaps), 0);
90  intDdGetDriverInfo(peDdGl, GUID_KernelCallbacks, &peDdGl->ddKernelCallbacks, sizeof(peDdGl->ddKernelCallbacks), 0);
91 
92  if (intDdGetDriverInfo(peDdGl, GUID_D3DCallbacks3, &peDdGl->d3dNtHalCallbacks3, sizeof(peDdGl->d3dNtHalCallbacks3), 0))
94 
95  if (intDdGetDriverInfo(peDdGl, GUID_ColorControlCallbacks, &peDdGl->ddColorControlCallbacks, sizeof(peDdGl->ddColorControlCallbacks), 0))
97 
98  if (intDdGetDriverInfo(peDdGl, GUID_MiscellaneousCallbacks, &peDdGl->ddMiscellanousCallbacks, sizeof(peDdGl->ddMiscellanousCallbacks), 0))
100 
101  if (intDdGetDriverInfo(peDdGl, GUID_Miscellaneous2Callbacks, &peDdGl->ddMiscellanous2Callbacks, sizeof(peDdGl->ddMiscellanous2Callbacks), 0))
103 
104  if (intDdGetDriverInfo(peDdGl, GUID_NTCallbacks, &peDdGl->ddNtCallbacks, sizeof(peDdGl->ddNtCallbacks), 0) )
106 
107  if (intDdGetDriverInfo(peDdGl, GUID_DDMoreCaps, &peDdGl->ddMoreCaps, sizeof(peDdGl->ddMoreCaps), 0) )
109 
110  if (intDdGetDriverInfo(peDdGl, GUID_NTPrivateDriverCaps, &peDdGl->ddNtPrivateDriverCaps, sizeof(peDdGl->ddNtPrivateDriverCaps), 0) )
112 
113  if (intDdGetDriverInfo(peDdGl, GUID_MotionCompCallbacks, &peDdGl->ddMotionCompCallbacks, sizeof(peDdGl->ddMotionCompCallbacks), 0) )
115  }
116 }
#define EDDDGBL_DDMORECAPS
Definition: directxint.h:112
#define EDDDGBL_COLORCONTROLCALLBACKS
Definition: directxint.h:109
#define EDDDGBL_MOTIONCOMPCALLBACKS
Definition: directxint.h:110
DWORD dwFlags
Definition: ddrawint.h:1128
DD_MORECAPS ddMoreCaps
Definition: directxint.h:158
DD_MOTIONCOMPCALLBACKS ddMotionCompCallbacks
Definition: directxint.h:174
DD_COLORCONTROLCALLBACKS ddColorControlCallbacks
Definition: directxint.h:171
#define EDDDGBL_MISC2CALLBACKS
Definition: directxint.h:111
#define EDDDGBL_NTCALLBACKS
Definition: directxint.h:114
DD_MISCELLANEOUS2CALLBACKS ddMiscellanous2Callbacks
Definition: directxint.h:169
DD_MISCELLANEOUSCALLBACKS ddMiscellanousCallbacks
Definition: directxint.h:168
#define EDDDGBL_D3DCALLBACKS3
Definition: directxint.h:113
#define DDHALINFO_GETDRIVERINFOSET
Definition: ddrawi.h:667
#define EDDDGBL_MISCCALLBACKS
Definition: directxint.h:107
#define EDDDGBL_PRIVATEDRIVERCAPS
Definition: directxint.h:115
DD_NTCALLBACKS ddNtCallbacks
Definition: directxint.h:170
PDD_GETDRIVERINFO GetDriverInfo
Definition: ddrawint.h:1127
BOOL intDdGetDriverInfo(PEDD_DIRECTDRAW_GLOBAL peDdGl, GUID guid, PVOID callbackStruct, ULONG callbackSize, ULONG *returnSize)
Definition: ddraw.c:42
D3DNTHAL_CALLBACKS3 d3dNtHalCallbacks3
Definition: directxint.h:173
DD_NTPRIVATEDRIVERCAPS ddNtPrivateDriverCaps
Definition: directxint.h:159
DD_KERNELCALLBACKS ddKernelCallbacks
Definition: directxint.h:172
DDKERNELCAPS ddKernelCaps
Definition: directxint.h:157

Referenced by intDdEnableDriver().

◆ intDdGetDriverInfo()

BOOL intDdGetDriverInfo ( PEDD_DIRECTDRAW_GLOBAL  peDdGl,
GUID  guid,
PVOID  callbackStruct,
ULONG  callbackSize,
ULONG returnSize 
)

Definition at line 42 of file ddraw.c.

43 {
44  DD_GETDRIVERINFODATA ddGetDriverInfoData;
45 
47  {
48  memset(&ddGetDriverInfoData, 0, sizeof(DD_GETDRIVERINFODATA));
49  ddGetDriverInfoData.dwSize = sizeof(DD_GETDRIVERINFODATA);
50  ddGetDriverInfoData.dhpdev = peDdGl->dhpdev;
51  memcpy(&ddGetDriverInfoData.guidInfo, &guid, sizeof(GUID));
52  ddGetDriverInfoData.dwExpectedSize = callbackSize;
53  ddGetDriverInfoData.lpvData = callbackStruct;
54  ddGetDriverInfoData.ddRVal = DDERR_CURRENTLYNOTAVAIL;
55  if (peDdGl->ddHalInfo.GetDriverInfo(&ddGetDriverInfoData) && !ddGetDriverInfoData.ddRVal)
56  {
57  if (returnSize)
58  *returnSize = ddGetDriverInfoData.dwActualSize;
59  return TRUE;
60  }
61 
62  }
63 
64  /* cleanup on error */
65  memset(callbackStruct, 0, callbackSize);
66  if (returnSize)
67  *returnSize = 0;
68  return FALSE;
69 }
#define TRUE
Definition: types.h:120
DWORD dwExpectedSize
Definition: main.c:55
DWORD dwFlags
Definition: ddrawint.h:1128
struct _DD_GETDRIVERINFODATA DD_GETDRIVERINFODATA
const GUID * guid
DWORD dwActualSize
Definition: main.c:57
HRESULT ddRVal
Definition: main.c:58
#define DDHALINFO_GETDRIVERINFOSET
Definition: ddrawi.h:667
#define DDERR_CURRENTLYNOTAVAIL
Definition: ddraw.h:70
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PDD_GETDRIVERINFO GetDriverInfo
Definition: ddrawint.h:1127
#define memset(x, y, z)
Definition: compat.h:39

Referenced by DxDdGetDriverInfo(), and intDdGetAllDriverInfo().