Author: sgasiorek
Date: Sat Jun 24 22:24:04 2017
New Revision: 75189
URL:
http://svn.reactos.org/svn/reactos?rev=75189&view=rev
Log:
- update EDD_DIRECTDRAW_LOCAL, EDD_SURFACE and EDD_DIRECTDRAW_GLOBAL structures
- initial implementation of DxDdCreateD3DBuffer and DxDdCreateSurfaceObject CORE-4490
Modified:
trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h
trunk/reactos/win32ss/reactx/dxg/d3d.c
trunk/reactos/win32ss/reactx/dxg/ddraw.c
trunk/reactos/win32ss/reactx/dxg/dxg_driver.h
trunk/reactos/win32ss/reactx/dxg/dxg_int.h
trunk/reactos/win32ss/reactx/dxg/tags.h
Modified: trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/driver…
==============================================================================
--- trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h [iso-8859-1]
(original)
+++ trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h [iso-8859-1] Sat Jun 24
22:24:04 2017
@@ -15,9 +15,9 @@
//
/* 0x00 */ DD_BASEOBJECT pobj; // verified to match Windows XP
/* 0x10 */ struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal; // verified to match
Windows XP
-/* 0x14 */ struct _EDD_SURFACE * peSurface_DdList;
-/* 0x18 */ ULONG unk_018;
-/* 0x1C */ ULONG unk_01c;
+/* 0x14 */ ULONG hRefCount;
+/* 0x18 */ struct _EDD_SURFACE * peSurface_DdList;
+/* 0x1C */ ULONG hSurface;
/* 0x20 */ ULONG unk_020;
/* 0x24 */ struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2; // verified to match
Windows XP
/* 0x28 */ FLATPTR fpProcess;
@@ -26,9 +26,9 @@
// points to the old
DDLocal when new handle is created.
/* 0x34 */ FLATPTR fpProcess2; // surface memory
address returned by graphic driver
/* 0x38 */ ULONG isMemoryMapped; // surface memory
mapped?
-/* 0x3C */ HANDLE UniqueProcess;
+/* 0x3C */ HANDLE hCreatorProcess;
/* 0x40 */ PEPROCESS Process;
-/* 0x44 */ VOID *unk_044;
+/* 0x44 */ VOID *heapList;
/* 0x48 */ ULONG unk_048;
/* 0x4C */ ULONG unk_04C;
/* 0x50 */ ULONG unk_050;
@@ -68,12 +68,8 @@
// Private Direct Draw Data
//
struct _EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal;
+ struct _EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobalNext;
struct _EDD_DIRECTDRAW_LOCAL* peDirectDrawLocal;
-
- //
- // Flags
- //
- FLONG fl;
//
// Surface Attributes
@@ -84,17 +80,23 @@
HANDLE hSecure;
HANDLE hdc;
HBITMAP hbmGdi;
-
- //
- // Unknown
- //
- ULONG field_E8;
+ HANDLE hGdiSurface;
//
// Surface Lock
//
RECTL rclLock;
- ULONG field_FC[2];
+ ULONG field_FC;
+ ULONG field_100;
+ ULONG field_104;
+ ULONG field_108;
+ ULONG field_10C;
+
+ ULONG ldev;
+ struct _EDD_DIRECTDRAW_GLOBAL* peDirectDrawGlobal3;
+ ULONG gdev;
+ ULONG wWidth;
+ ULONG wHeight;
} EDD_SURFACE, *PEDD_SURFACE;
@@ -118,7 +120,9 @@
/* 0x000 */ PVOID dhpdev; // 0x000 <-- verified to match Windows XP,
dhpdev, the drv hPDev -->
/* 0x004 */ DWORD dwReserved1;
/* 0x008 */ DWORD dwReserved2;
-/* 0x00C */ ULONG unk_000c[3];
+/* 0x00C */ LPDDVIDEOPORTCAPS lpDDVideoPortCaps; // 0x00C <--
verified to match Win2k3
+/* 0x010 */ ULONG unk_010;
+/* 0x014 */ ULONG unk_014;
/* 0x018 */ LONG cDriverReferences;
/* 0x01C */ ULONG unk_01c;
/* 0x020 */ DWORD dwCallbackFlags; /* 0x020 <-- verified to match Windows XP,
dwCallbackFlags
Modified: trunk/reactos/win32ss/reactx/dxg/d3d.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/d3d.c?r…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/d3d.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/d3d.c [iso-8859-1] Sat Jun 24 22:24:04 2017
@@ -37,3 +37,89 @@
return RetVal;
}
+
+DWORD
+FASTCALL
+intDdCreateSurfaceOrBuffer(HANDLE hDirectDrawLocal,
+ PEDD_SURFACE pDdSurfList, DDSURFACEDESC2 *a3,
+ DD_SURFACE_GLOBAL *pDdSurfGlob,
+ DD_SURFACE_LOCAL *pDdSurfLoc,
+ DD_SURFACE_MORE *pDdSurfMore,
+ DD_CREATESURFACEDATA *pDdCreateSurfaceData,
+ PVOID Address)
+{
+ PEDD_DIRECTDRAW_LOCAL peDdL = NULL;
+ PEDD_DIRECTDRAW_GLOBAL peDdGl = NULL;
+ DD_SURFACE_LOCAL *pCurSurfLocal;
+ DD_SURFACE_GLOBAL *pCurSurfGlobal;
+ DD_SURFACE_MORE *pCurSurfMore;
+ PEDD_SURFACE pCurSurf;
+
+ ULONG CurSurf;
+
+ if (!pDdCreateSurfaceData)
+ return FALSE;
+
+ if (!pDdCreateSurfaceData->dwSCnt)
+ {
+ pDdCreateSurfaceData->ddRVal = E_FAIL;
+ return FALSE;
+ }
+
+ peDdL = (PEDD_DIRECTDRAW_LOCAL)DdHmgLock(hDirectDrawLocal, ObjType_DDLOCAL_TYPE,
FALSE);
+ if (!peDdL)
+ return FALSE;
+
+ peDdGl = peDdL->peDirectDrawGlobal2;
+
+ if (!(pDdSurfLoc->ddsCaps.dwCaps & DDSCAPS_VISIBLE) &&
!(peDdGl->ddCallbacks.dwFlags & DDHAL_CB32_CREATESURFACE))
+ {
+ pDdCreateSurfaceData->ddRVal = E_FAIL;
+ return FALSE;
+ }
+
+ pDdSurfList = (PEDD_SURFACE)EngAllocMem(FL_ZERO_MEMORY, pDdCreateSurfaceData->dwSCnt
* sizeof(EDD_SURFACE), TAG_GDDP);
+ pDdSurfGlob = (DD_SURFACE_GLOBAL *)EngAllocMem(FL_ZERO_MEMORY,
pDdCreateSurfaceData->dwSCnt * sizeof(DD_SURFACE_GLOBAL), TAG_GDDP);
+ pDdSurfLoc = (DD_SURFACE_LOCAL *)EngAllocMem(FL_ZERO_MEMORY,
pDdCreateSurfaceData->dwSCnt * sizeof(DD_SURFACE_LOCAL), TAG_GDDP);
+ pDdSurfMore = (DD_SURFACE_MORE *)EngAllocMem(FL_ZERO_MEMORY,
pDdCreateSurfaceData->dwSCnt * sizeof(DD_SURFACE_MORE), TAG_GDDP);
+
+ gpEngFuncs.DxEngLockShareSem();
+ gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
+
+ // create all surface objects
+ for (CurSurf = 0; CurSurf < pDdCreateSurfaceData->dwSCnt; CurSurf++)
+ {
+ pCurSurf = &pDdSurfList[CurSurf];
+ pCurSurfLocal = &pDdSurfLoc[CurSurf];
+ pCurSurfGlobal = &pDdSurfGlob[CurSurf];
+ pCurSurfMore = &pDdSurfMore[CurSurf];
+
+ pCurSurf = intDdCreateNewSurfaceObject(
+ peDdL,
+ pCurSurf,
+ pCurSurfGlobal,
+ pCurSurfLocal,
+ pCurSurfMore);
+ Address = pCurSurf;
+ }
+
+ gpEngFuncs.DxEngUnlockHdev(peDdGl->hDev);
+ gpEngFuncs.DxEngUnlockShareSem();
+
+ return DDHAL_DRIVER_HANDLED;
+}
+
+DWORD
+NTAPI
+DxDdCreateD3DBuffer(
+ HANDLE hDirectDrawLocal,
+ PEDD_SURFACE pDdSurfList,
+ DDSURFACEDESC2 *a3,
+ DD_SURFACE_GLOBAL *pDdSurfGlob,
+ DD_SURFACE_LOCAL *pDdSurfLoc,
+ DD_SURFACE_MORE *pDdSurfMore,
+ DD_CREATESURFACEDATA *pDdCreateSurfaceData,
+ PVOID Address)
+{
+ return intDdCreateSurfaceOrBuffer(hDirectDrawLocal, pDdSurfList, a3, pDdSurfGlob,
pDdSurfLoc, pDdSurfMore, pDdCreateSurfaceData, Address);
+}
Modified: trunk/reactos/win32ss/reactx/dxg/ddraw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/ddraw.c…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/ddraw.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/ddraw.c [iso-8859-1] Sat Jun 24 22:24:04 2017
@@ -223,7 +223,7 @@
/* initialize DIRECTDRAW_LOCAL */
peDdL->peDirectDrawLocal_prev = peDdGl->peDirectDrawLocalList;
- peDdL->UniqueProcess = PsGetCurrentThreadProcessId();
+ peDdL->hCreatorProcess = PsGetCurrentThreadProcessId();
peDdL->Process = PsGetCurrentProcess();
// link DirectDrawGlobal and DirectDrawLocal
@@ -233,7 +233,7 @@
gpEngFuncs.DxEngReferenceHdev(hDev);
- InterlockedExchangeAdd((LONG*)&peDdL->pobj.cExclusiveLock, 0xFFFFFFFF);
+ InterlockedDecrement((VOID*)&peDdL->pobj.cExclusiveLock);
return peDdL->pobj.hHmgr;
}
@@ -331,7 +331,7 @@
}
if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_VideoPortCaps))
{
- pInfo = (VOID*)peDdGl->unk_000c[0];
+ pInfo = (VOID*)peDdGl->lpDDVideoPortCaps;
dwInfoSize = 72 * peDdGl->ddHalInfo.ddCaps.dwMaxVideoPorts;
}
if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_D3DCallbacks3))
@@ -462,13 +462,13 @@
*(DWORD*)((ULONG)pCallBackFlags + 8) =
peDdGl->ddPaletteCallbacks.dwFlags;
}
- if ( pd3dNtHalCallbacks )
+ if (pd3dNtHalCallbacks)
memcpy(pd3dNtHalCallbacks, &peDdGl->d3dNtHalCallbacks,
sizeof(peDdGl->d3dNtHalCallbacks));
- if ( pd3dNtGlobalDriverData )
+ if (pd3dNtGlobalDriverData)
memcpy(pd3dNtGlobalDriverData, &peDdGl->d3dNtGlobalDriverData,
sizeof(peDdGl->d3dNtGlobalDriverData));
- if ( pd3dBufCallbacks )
+ if (pd3dBufCallbacks)
memcpy(pd3dBufCallbacks, &peDdGl->d3dBufCallbacks,
sizeof(peDdGl->d3dBufCallbacks));
if (pTextureFormats)
@@ -581,3 +581,95 @@
return RetVal;
}
+
+PEDD_SURFACE
+NTAPI
+intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal,
PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE
pDdSurfMore)
+{
+ PEDD_SURFACE pSurface = NULL;
+
+ // first check if we can assign it from current ddHandle
+ if (hDirectDrawLocal)
+ {
+ pSurface = (PEDD_SURFACE)DdHmgLock(hDirectDrawLocal, ObjType_DDSURFACE_TYPE,
FALSE);
+ // check if surface is locked and belongs to correct DirectDrawLocal
+ if ((pSurface)&&((pSurface->peDirectDrawLocal !=
peDdL)||(!pSurface->hSecure)))
+ {
+ InterlockedDecrement((VOID*)&peDdL->pobj.cExclusiveLock);
+ return NULL;
+ }
+ }
+
+ // if surface not found from ddHandle or ddHandle not provided
+ if (!pSurface)
+ {
+ // create new surface object
+ pSurface = (PEDD_SURFACE)DdHmgAlloc(sizeof(EDD_SURFACE), ObjType_DDSURFACE_TYPE,
TRUE);
+ if (pSurface)
+ {
+ pSurface->ddsSurfaceLocal.lpGbl = &pSurface->ddsSurfaceGlobal;
+ pSurface->ddsSurfaceLocal.lpSurfMore = &pSurface->ddsSurfaceMore;
+ pSurface->ddsSurfaceInt.lpLcl = &pSurface->ddsSurfaceLocal;
+ pSurface->peDirectDrawLocal = peDdL;
+ pSurface->peDirectDrawGlobalNext = peDdL->peDirectDrawGlobal2;
+ pSurface->ldev =
gpEngFuncs.DxEngGetHdevData(pSurface->peDirectDrawGlobalNext->hDev,
DxEGShDevData_ldev);
+ pSurface->gdev =
gpEngFuncs.DxEngGetHdevData(pSurface->peDirectDrawGlobalNext->hDev,
DxEGShDevData_GDev);
+ pSurface->hSecure = (VOID*)1;
+ }
+ }
+
+ if (pSurface)
+ {
+ pSurface->ddsSurfaceGlobal.fpVidMem = pDdSurfGlob->fpVidMem;
+ pSurface->ddsSurfaceGlobal.lPitch = pDdSurfGlob->lPitch;
+ pSurface->ddsSurfaceGlobal.wWidth = pDdSurfGlob->wWidth;
+ pSurface->ddsSurfaceGlobal.wHeight = pDdSurfGlob->wHeight;
+ pSurface->wWidth = pDdSurfGlob->wWidth;
+ pSurface->wHeight = pDdSurfGlob->wHeight;
+ memcpy(&pSurface->ddsSurfaceGlobal.ddpfSurface,
&pDdSurfGlob->ddpfSurface, sizeof(pSurface->ddsSurfaceGlobal.ddpfSurface));
+ pSurface->ddsSurfaceLocal.ddsCaps.dwCaps = pDdSurfLoc->ddsCaps.dwCaps;
+ pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps2 =
pDdSurfMore->ddsCapsEx.dwCaps2;
+ pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps3 =
pDdSurfMore->ddsCapsEx.dwCaps3;
+ pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps4 =
pDdSurfMore->ddsCapsEx.dwCaps4;
+ pSurface->ddsSurfaceMore.dwSurfaceHandle = pDdSurfMore->dwSurfaceHandle;
+ pSurface->hSecure = (VOID*)1;
+
+ peDdL->peSurface_DdList = pSurface;
+ peDdL->hSurface = (ULONG)pSurface->pobj.hHmgr;
+ }
+
+ return pSurface;
+}
+
+HANDLE
+NTAPI
+DxDdCreateSurfaceObject(HANDLE hDirectDrawLocal,
+ HANDLE hSurface,
+ PDD_SURFACE_LOCAL puSurfaceLocal,
+ PDD_SURFACE_MORE puSurfaceMore,
+ PDD_SURFACE_GLOBAL puSurfaceGlobal,
+ BOOL bComplete)
+{
+ HANDLE RetVal = FALSE;
+ PEDD_DIRECTDRAW_LOCAL peDdL = NULL;
+ PEDD_SURFACE pDdSurface = NULL;
+
+ peDdL = (PEDD_DIRECTDRAW_LOCAL)DdHmgLock(hDirectDrawLocal, ObjType_DDLOCAL_TYPE,
FALSE);
+
+ if (!peDdL)
+ return RetVal;
+
+ pDdSurface = intDdCreateNewSurfaceObject(peDdL, hSurface, puSurfaceGlobal,
puSurfaceLocal, puSurfaceMore);
+ if (!pDdSurface)
+ {
+ InterlockedDecrement((VOID*)&peDdL->pobj.cExclusiveLock);
+ return RetVal;
+ }
+
+ RetVal = pDdSurface->pobj.hHmgr;
+
+ InterlockedDecrement((VOID*)&pDdSurface->pobj.cExclusiveLock);
+ InterlockedDecrement((VOID*)&peDdL->pobj.cExclusiveLock);
+
+ return RetVal;
+}
Modified: trunk/reactos/win32ss/reactx/dxg/dxg_driver.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/dxg_dri…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/dxg_driver.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/dxg_driver.h [iso-8859-1] Sat Jun 24 22:24:04 2017
@@ -131,40 +131,10 @@
DWORD
NTAPI
-DxDdCreateD3DBuffer(
- PVOID p1,
- PVOID p2,
- PVOID p3,
- PVOID p4,
- PVOID p5,
- PVOID p6,
- PVOID p7,
- PVOID p8)
-{
- TRACE();
- return 0;
-}
-
-DWORD
-NTAPI
DxDdCreateMoComp(
PVOID p1,
PVOID p2)
{
- return 0;
-}
-
-DWORD
-NTAPI
-DxDdCreateSurfaceObject(
- PVOID p1,
- PVOID p2,
- PVOID p3,
- PVOID p4,
- PVOID p5,
- PVOID p6)
-{
- TRACE();
return 0;
}
Modified: trunk/reactos/win32ss/reactx/dxg/dxg_int.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/dxg_int…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/dxg_int.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/dxg_int.h [iso-8859-1] Sat Jun 24 22:24:04 2017
@@ -202,8 +202,11 @@
DWORD NTAPI DxDdReenableDirectDrawObject(HANDLE DdHandle, PVOID p2);
DWORD NTAPI DxDdCanCreateSurface(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData);
DWORD NTAPI DxDdCanCreateD3DBuffer(HANDLE DdHandle, PDD_CANCREATESURFACEDATA
SurfaceData);
+DWORD NTAPI DxDdCreateD3DBuffer(HANDLE hDirectDrawLocal, PEDD_SURFACE pDdSurfList,
DDSURFACEDESC2 *a3, DD_SURFACE_GLOBAL *pDdSurfGlob, DD_SURFACE_LOCAL *pDdSurfLoc,
+ DD_SURFACE_MORE *pDdSurfMore, DD_CREATESURFACEDATA
*pDdCreateSurfaceData, PVOID Address);
DWORD NTAPI DxDdLock(HANDLE hSurface, PDD_LOCKDATA puLockData, HDC hdcClip);
DWORD NTAPI DxDdUnlock(HANDLE hSurface, PDD_UNLOCKDATA puUnlockData);
+HANDLE NTAPI DxDdCreateSurfaceObject(HANDLE hDirectDrawLocal, HANDLE hSurface,
PDD_SURFACE_LOCAL puSurfaceLocal, PDD_SURFACE_MORE puSurfaceMore, PDD_SURFACE_GLOBAL
puSurfaceGlobal, BOOL bComplete);
/* Internal functions */
@@ -212,6 +215,7 @@
BOOL FASTCALL DdHmgDestroy(VOID);
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned);
HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock);
-
+PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE
hDirectDrawLocal,
+ PDD_SURFACE_GLOBAL pDdSurfGlob,
PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore);
#endif /* _DXG_PCH_ */
Modified: trunk/reactos/win32ss/reactx/dxg/tags.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/tags.h?…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/tags.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/tags.h [iso-8859-1] Sat Jun 24 22:24:04 2017
@@ -2,4 +2,5 @@
#define TAG_GINI 'iniG'
#define TAG_GDDV 'vddG'
#define TAG_GDDF 'fddG'
+#define TAG_GDDP 'pddG'
#define TAG_DH_0 '0 hD'