1 #ifndef _DXG_PCH_ 2 #define _DXG_PCH_ 3 4 #include <ntifs.h> 5 6 /* Win32 Headers */ 7 #define WINBASEAPI 8 9 #define DDHMG_HANDLE_LIMIT 0x200000 10 #define DDHMG_HTOI(DdHandle) ((DWORD_PTR)DdHandle & (DDHMG_HANDLE_LIMIT-1)) 11 12 #include <windef.h> 13 #include <winerror.h> 14 #include <wingdi.h> 15 #include <winddi.h> 16 #include <ddkernel.h> 17 #include <initguid.h> 18 #include <ddrawi.h> 19 #include <ntgdityp.h> 20 #include <psfuncs.h> 21 22 DEFINE_GUID(GUID_NTCallbacks, 0x6fe9ecde, 0xdf89, 0x11d1, 0x9d, 0xb0, 0x00, 0x60, 0x08, 0x27, 0x71, 0xba); 23 DEFINE_GUID(GUID_DDMoreCaps, 0x880baf30, 0xb030, 0x11d0, 0x8e, 0xa7, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); 24 DEFINE_GUID(GUID_NTPrivateDriverCaps, 0xfad16a23, 0x7b66, 0x11d2, 0x83, 0xd7, 0x00, 0xc0, 0x4f, 0x7c, 0xe5, 0x8c); 25 26 /* DXG treats this as opaque */ 27 typedef PVOID PDC; 28 typedef PVOID PW32THREAD; 29 30 typedef struct _DD_BASEOBJECT 31 { 32 HGDIOBJ hHmgr; 33 ULONG ulShareCount; 34 USHORT cExclusiveLock; 35 USHORT BaseFlags; 36 PW32THREAD Tid; 37 } DD_BASEOBJECT, *PDD_BASEOBJECT; 38 39 #include <drivers/directx/directxint.h> 40 #include <drivers/directx/dxg.h> 41 #include <drivers/directx/dxeng.h> 42 43 #include "tags.h" 44 45 #define CapOver_DisableAccel 0x1 46 #define CapOver_DisableD3DDDAccel 0x2 47 #define CapOver_DisableD3DAccel 0x4 48 #define CapOver_DisableOGL 0x8 49 #define CapOver_DisableEscapes 0x10 50 51 #define ObjType_DDLOCAL_TYPE 1 52 #define ObjType_DDSURFACE_TYPE 2 53 #define ObjType_DDCONTEXT_TYPE 3 54 #define ObjType_DDVIDEOPORT_TYPE 4 55 #define ObjType_DDMOTIONCOMP_TYPE 5 56 57 typedef struct _DD_ENTRY 58 { 59 union 60 { 61 PDD_BASEOBJECT pobj; 62 ULONG NextFree; 63 }; 64 HANDLE Pid; 65 USHORT FullUnique; 66 UCHAR Objt; 67 } DD_ENTRY, *PDD_ENTRY; 68 69 typedef struct _EDD_SURFACE_LOCAL 70 { 71 DD_BASEOBJECT Object; 72 DD_SURFACE_LOCAL Surfacelcl; 73 } EDD_SURFACE_LOCAL, *PEDD_SURFACE_LOCAL; 74 75 76 typedef BOOLEAN (APIENTRY* PFN_DxEngNUIsTermSrv)(VOID); 77 typedef DWORD (APIENTRY* PFN_DxEngScreenAccessCheck)(VOID); 78 typedef BOOLEAN (APIENTRY* PFN_DxEngRedrawDesktop)(VOID); 79 typedef ULONG (APIENTRY* PFN_DxEngDispUniq)(VOID); 80 typedef BOOLEAN (APIENTRY* PFN_DxEngIncDispUniq)(VOID); 81 typedef ULONG (APIENTRY* PFN_DxEngVisRgnUniq)(VOID); 82 typedef BOOLEAN (APIENTRY* PFN_DxEngLockShareSem)(VOID); 83 typedef BOOLEAN (APIENTRY* PFN_DxEngUnlockShareSem)(VOID); 84 typedef HDEV* (APIENTRY* PFN_DxEngEnumerateHdev)(HDEV*); 85 typedef BOOLEAN (APIENTRY* PFN_DxEngLockHdev)(HDEV); 86 typedef BOOLEAN (APIENTRY* PFN_DxEngUnlockHdev)(HDEV); 87 typedef BOOLEAN (APIENTRY* PFN_DxEngIsHdevLockedByCurrentThread)(HDEV); 88 typedef BOOLEAN (APIENTRY* PFN_DxEngReferenceHdev)(HDEV); 89 typedef BOOLEAN (APIENTRY* PFN_DxEngUnreferenceHdev)(HDEV); 90 typedef BOOL (APIENTRY* PFN_DxEngGetDeviceGammaRamp)(HDEV, PGAMMARAMP); 91 typedef BOOLEAN (APIENTRY* PFN_DxEngSetDeviceGammaRamp)(HDEV, PGAMMARAMP, BOOL); 92 typedef DWORD (APIENTRY* PFN_DxEngSpTearDownSprites)(DWORD, DWORD, DWORD); 93 typedef DWORD (APIENTRY* PFN_DxEngSpUnTearDownSprites)(DWORD, DWORD, DWORD); 94 typedef DWORD (APIENTRY* PFN_DxEngSpSpritesVisible)(DWORD); 95 typedef DWORD_PTR (APIENTRY* PFN_DxEngGetHdevData)(HDEV, DXEGSHDEVDATA); 96 typedef BOOLEAN (APIENTRY* PFN_DxEngSetHdevData)(HDEV, DXEGSHDEVDATA, DWORD_PTR); 97 typedef HDC (APIENTRY* PFN_DxEngCreateMemoryDC)(HDEV); 98 typedef HDC (APIENTRY* PFN_DxEngGetDesktopDC)(ULONG, BOOL, BOOL); 99 typedef BOOLEAN (APIENTRY* PFN_DxEngDeleteDC)(HDC, BOOL); 100 typedef BOOLEAN (APIENTRY* PFN_DxEngCleanDC)(HDC hdc); 101 typedef BOOL (APIENTRY* PFN_DxEngSetDCOwner)(HGDIOBJ, DWORD); 102 typedef PDC (APIENTRY* PFN_DxEngLockDC)(HDC); 103 typedef BOOLEAN (APIENTRY* PFN_DxEngUnlockDC)(PDC); 104 typedef BOOLEAN (APIENTRY* PFN_DxEngSetDCState)(HDC, DWORD, DWORD); 105 typedef DWORD_PTR (APIENTRY* PFN_DxEngGetDCState)(HDC, DWORD); 106 typedef DWORD (APIENTRY* PFN_DxEngSelectBitmap)(DWORD, DWORD); 107 typedef DWORD (APIENTRY* PFN_DxEngSetBitmapOwner)(DWORD, DWORD); 108 typedef DWORD (APIENTRY* PFN_DxEngDeleteSurface)(DWORD); 109 typedef DWORD (APIENTRY* PFN_DxEngGetSurfaceData)(DWORD, DWORD); 110 typedef DWORD (APIENTRY* PFN_DxEngAltLockSurface)(DWORD); 111 typedef DWORD (APIENTRY* PFN_DxEngUploadPaletteEntryToSurface)(DWORD, DWORD, DWORD, DWORD); 112 typedef DWORD (APIENTRY* PFN_DxEngMarkSurfaceAsDirectDraw)(DWORD, DWORD); 113 typedef DWORD (APIENTRY* PFN_DxEngSelectPaletteToSurface)(DWORD, DWORD); 114 typedef DWORD (APIENTRY* PFN_DxEngSyncPaletteTableWithDevice)(DWORD, DWORD); 115 typedef DWORD (APIENTRY* PFN_DxEngSetPaletteState)(DWORD, DWORD, DWORD); 116 typedef DWORD (APIENTRY* PFN_DxEngGetRedirectionBitmap)(DWORD); 117 typedef DWORD (APIENTRY* PFN_DxEngLoadImage)(DWORD, DWORD); 118 119 120 typedef struct _DXENG_FUNCTIONS 121 { 122 PVOID Reserved; 123 PFN_DxEngNUIsTermSrv DxEngNUIsTermSrv; 124 PFN_DxEngScreenAccessCheck DxEngScreenAccessCheck; 125 PFN_DxEngRedrawDesktop DxEngRedrawDesktop; 126 PFN_DxEngDispUniq DxEngDispUniq; 127 PFN_DxEngIncDispUniq DxEngIncDispUniq; 128 PFN_DxEngVisRgnUniq DxEngVisRgnUniq; 129 PFN_DxEngLockShareSem DxEngLockShareSem; 130 PFN_DxEngUnlockShareSem DxEngUnlockShareSem; 131 PFN_DxEngEnumerateHdev DxEngEnumerateHdev; 132 PFN_DxEngLockHdev DxEngLockHdev; 133 PFN_DxEngUnlockHdev DxEngUnlockHdev; 134 PFN_DxEngIsHdevLockedByCurrentThread DxEngIsHdevLockedByCurrentThread; 135 PFN_DxEngReferenceHdev DxEngReferenceHdev; 136 PFN_DxEngUnreferenceHdev DxEngUnreferenceHdev; 137 PFN_DxEngGetDeviceGammaRamp DxEngGetDeviceGammaRamp; 138 PFN_DxEngSetDeviceGammaRamp DxEngSetDeviceGammaRamp; 139 PFN_DxEngSpTearDownSprites DxEngSpTearDownSprites; 140 PFN_DxEngSpUnTearDownSprites DxEngSpUnTearDownSprites; 141 PFN_DxEngSpSpritesVisible DxEngSpSpritesVisible; 142 PFN_DxEngGetHdevData DxEngGetHdevData; 143 PFN_DxEngSetHdevData DxEngSetHdevData; 144 PFN_DxEngCreateMemoryDC DxEngCreateMemoryDC; 145 PFN_DxEngGetDesktopDC DxEngGetDesktopDC; 146 PFN_DxEngDeleteDC DxEngDeleteDC; 147 PFN_DxEngCleanDC DxEngCleanDC; 148 PFN_DxEngSetDCOwner DxEngSetDCOwner; 149 PFN_DxEngLockDC DxEngLockDC; 150 PFN_DxEngUnlockDC DxEngUnlockDC; 151 PFN_DxEngSetDCState DxEngSetDCState; 152 PFN_DxEngGetDCState DxEngGetDCState; 153 PFN_DxEngSelectBitmap DxEngSelectBitmap; 154 PFN_DxEngSetBitmapOwner DxEngSetBitmapOwner; 155 PFN_DxEngDeleteSurface DxEngDeleteSurface; 156 PFN_DxEngGetSurfaceData DxEngGetSurfaceData; 157 PFN_DxEngAltLockSurface DxEngAltLockSurface; 158 PFN_DxEngUploadPaletteEntryToSurface DxEngUploadPaletteEntryToSurface; 159 PFN_DxEngMarkSurfaceAsDirectDraw DxEngMarkSurfaceAsDirectDraw; 160 PFN_DxEngSelectPaletteToSurface DxEngSelectPaletteToSurface; 161 PFN_DxEngSyncPaletteTableWithDevice DxEngSyncPaletteTableWithDevice; 162 PFN_DxEngSetPaletteState DxEngSetPaletteState; 163 PFN_DxEngGetRedirectionBitmap DxEngGetRedirectionBitmap; 164 PFN_DxEngLoadImage DxEngLoadImage; 165 } DXENG_FUNCTIONS, *PDXENG_FUNCTIONS; 166 167 /* exported functions */ 168 NTSTATUS NTAPI DriverEntry(IN PVOID Context1, IN PVOID Context2); 169 NTSTATUS NTAPI GsDriverEntry(IN PVOID Context1, IN PVOID Context2); 170 NTSTATUS APIENTRY DxDdCleanupDxGraphics(VOID); 171 BOOL NTAPI DxDdEnableDirectDraw(HANDLE hDev, BOOL arg2); 172 DWORD NTAPI DxDdCreateDirectDrawObject(HDC hDC); 173 174 /* Global pointers */ 175 extern ULONG gcSizeDdHmgr; 176 extern PDD_ENTRY gpentDdHmgr; 177 extern ULONG gcMaxDdHmgr; 178 extern PDD_ENTRY gpentDdHmgrLast; 179 extern ULONG ghFreeDdHmgr; 180 extern HSEMAPHORE ghsemHmgr; 181 extern LONG gcDummyPageRefCnt; 182 extern HSEMAPHORE ghsemDummyPage; 183 extern VOID *gpDummyPage; 184 extern PEPROCESS gpepSession; 185 extern PLARGE_INTEGER gpLockShortDelay; 186 extern DXENG_FUNCTIONS gpEngFuncs; 187 188 /* Driver list export functions */ 189 DWORD NTAPI DxDxgGenericThunk(ULONG_PTR ulIndex, ULONG_PTR ulHandle, SIZE_T *pdwSizeOfPtr1, PVOID pvPtr1, SIZE_T *pdwSizeOfPtr2, PVOID pvPtr2); 190 DWORD NTAPI DxDdIoctl(ULONG ulIoctl, PVOID pBuffer, ULONG ulBufferSize); 191 PDD_SURFACE_LOCAL NTAPI DxDdLockDirectDrawSurface(HANDLE hDdSurface); 192 BOOL NTAPI DxDdUnlockDirectDrawSurface(PDD_SURFACE_LOCAL pSurface); 193 DWORD NTAPI DxDdGetDriverInfo(HANDLE DdHandle, PDD_GETDRIVERINFODATA drvInfoData); 194 BOOL NTAPI DxDdQueryDirectDrawObject(HANDLE DdHandle, DD_HALINFO* pDdHalInfo, DWORD* pCallBackFlags, LPD3DNTHAL_CALLBACKS pd3dNtHalCallbacks, 195 LPD3DNTHAL_GLOBALDRIVERDATA pd3dNtGlobalDriverData, PDD_D3DBUFCALLBACKS pd3dBufCallbacks, LPDDSURFACEDESC pTextureFormats, 196 DWORD* p8, VIDEOMEMORY* p9, DWORD* pdwNumFourCC, DWORD* pdwFourCC); 197 DWORD NTAPI DxDdReenableDirectDrawObject(HANDLE DdHandle, PVOID p2); 198 DWORD NTAPI DxDdCanCreateSurface(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData); 199 DWORD NTAPI DxDdCanCreateD3DBuffer(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData); 200 DWORD NTAPI DxDdCreateD3DBuffer(HANDLE hDirectDrawLocal, PEDD_SURFACE pDdSurfList, DDSURFACEDESC2 *a3, DD_SURFACE_GLOBAL *pDdSurfGlob, DD_SURFACE_LOCAL *pDdSurfLoc, 201 DD_SURFACE_MORE *pDdSurfMore, DD_CREATESURFACEDATA *pDdCreateSurfaceData, PVOID Address); 202 DWORD NTAPI DxDdLock(HANDLE hSurface, PDD_LOCKDATA puLockData, HDC hdcClip); 203 DWORD NTAPI DxDdUnlock(HANDLE hSurface, PDD_UNLOCKDATA puUnlockData); 204 HANDLE NTAPI DxDdCreateSurfaceObject(HANDLE hDirectDrawLocal, HANDLE hSurface, PDD_SURFACE_LOCAL puSurfaceLocal, PDD_SURFACE_MORE puSurfaceMore, PDD_SURFACE_GLOBAL puSurfaceGlobal, BOOL bComplete); 205 206 207 /* Internal functions */ 208 BOOL FASTCALL VerifyObjectOwner(PDD_ENTRY pEntry); 209 BOOL FASTCALL DdHmgCreate(VOID); 210 BOOL FASTCALL DdHmgDestroy(VOID); 211 PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned); 212 HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock); 213 PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal, 214 PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore); 215 216 #endif /* _DXG_PCH_ */ 217