Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 lines
12 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: ddrawpr.h
  6. * Content: DirectDraw private header file
  7. * History: Confidential. If we told you, we'd have to...
  8. *
  9. ***************************************************************************/
  10. #ifndef __DDRAWPR_INCLUDED__
  11. #define __DDRAWPR_INCLUDED__
  12. #ifdef WIN95
  13. #ifdef WINNT
  14. #undef WINNT
  15. #endif
  16. #endif
  17. #ifndef WIN95
  18. #include <nt.h>
  19. #include <ntrtl.h>
  20. #include <nturtl.h>
  21. #include <stddef.h>
  22. #endif
  23. #ifdef WIN95
  24. #define WIN16_SEPARATE
  25. #endif
  26. #include "verinfo.h"
  27. #ifndef WIN32_LEAN_AND_MEAN
  28. #define WIN32_LEAN_AND_MEAN
  29. #endif
  30. #include <windows.h>
  31. #include <mmsystem.h>
  32. #include <string.h>
  33. #include <stddef.h>
  34. #pragma warning( disable: 4704)
  35. #include "dpf.h"
  36. /*
  37. * registry stuff
  38. */
  39. #include "ddreg.h"
  40. #include "memalloc.h"
  41. #include <objbase.h>
  42. #include "ddrawi.h"
  43. #include "d3d8ddi.h"
  44. #include "dwininfo.h"
  45. // Information stored on each device in the system
  46. #define MAX_DX8_ADAPTERS 12
  47. typedef struct _ADAPTERINFO
  48. {
  49. GUID Guid;
  50. char DeviceName[MAX_PATH];
  51. BOOL bIsPrimary;
  52. BOOL bIsDisplay;
  53. DWORD NumModes;
  54. D3DDISPLAYMODE* pModeTable;
  55. D3DFORMAT Unknown16;
  56. D3D8_DRIVERCAPS HALCaps;
  57. UINT HALFlags;
  58. BOOL bNoDDrawSupport;
  59. } ADAPTERINFO, * PADAPTERINFO;
  60. #ifdef __cplusplus
  61. #include "d3d8p.h"
  62. #include "enum.hpp"
  63. #include "dxgint.h"
  64. #endif
  65. /*
  66. * Need this to get CDS_ macros under NT build environment for win95.
  67. * winuserp.h comes from private\windows\inc
  68. */
  69. #ifdef NT_BUILD_ENVIRONMENT
  70. #ifdef WIN32
  71. #include "winuserp.h"
  72. #endif
  73. #endif
  74. #include "ids8.h"
  75. /*
  76. * NT kernel mode stub(ish)s
  77. */
  78. #ifndef WIN95
  79. #include "ddrawgdi.h"
  80. #endif
  81. /*
  82. * Direct3D interfacing defines.
  83. */
  84. #ifdef __cplusplus
  85. extern "C" {
  86. #endif
  87. /*
  88. * reminder
  89. */
  90. #define QUOTE(x) #x
  91. #define QQUOTE(y) QUOTE(y)
  92. #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) "):" str
  93. /*
  94. * synchronization
  95. */
  96. #ifdef WINNT
  97. #define NT_USES_CRITICAL_SECTION
  98. #endif
  99. #include "ddheap.h"
  100. #include "ddagp.h"
  101. /* ddraw.dll exports */
  102. #ifdef WIN95
  103. extern BOOL WINAPI DdCreateDirectDrawObject( LPDDRAWI_DIRECTDRAW_GBL pddd, LPGUID lpGuid, DWORD dwFlags );
  104. extern BOOL WINAPI DdReenableDirectDrawObject( LPDDRAWI_DIRECTDRAW_GBL pddd, LPBOOL pbNewMode );
  105. extern BOOL WINAPI DdQueryDirectDrawObject( LPDDRAWI_DIRECTDRAW_GBL pddd, LPDDHALINFO lpDDHALInfo, LPDDHAL_DDCALLBACKS pddHALDD, LPDDHAL_DDSURFACECALLBACKS pddHALDDSurface, LPDDHAL_DDPALETTECALLBACKS pddHALDDPalette, LPD3DHAL_CALLBACKS pd3dHALCallbacks, LPD3DHAL_GLOBALDRIVERDATA pd3dHALDriverData, LPDDHAL_DDEXEBUFCALLBACKS pddNTHALBufferCallbacks, LPVOID pVoid1, LPVOID pVoid2, LPVOID pVoid3 );
  106. extern ULONG WINAPI DdQueryDisplaySettingsUniqueness( VOID );
  107. #endif
  108. /* enum.cpp */
  109. extern BOOL IsSupportedOp (D3DFORMAT Format, DDSURFACEDESC* pList, UINT NumElements, DWORD dwRequestedOps);
  110. /* ddcreate.c */
  111. extern BOOL IsVGADevice(LPSTR szDevice);
  112. extern BOOL xxxEnumDisplayDevicesA(LPVOID lpUnused, DWORD iDevice, struct _DISPLAY_DEVICEA *pdd, DWORD dwFlags);
  113. extern HMONITOR GetMonitorFromDeviceName(LPSTR szName);
  114. extern void FetchDirectDrawData( PD3D8_DEVICEDATA pBaseData, void* pInitFunction, D3DFORMAT Unknown16, DDSURFACEDESC* pHalOpList, DWORD NumHalOps);
  115. extern DWORD DirectDrawMsg(LPSTR msg);
  116. extern BOOL InternalGetMonitorInfo(HMONITOR hMon, MONITORINFO *lpInfo);
  117. #ifdef WINNT
  118. extern BOOL GetCurrentMode(LPDDRAWI_DIRECTDRAW_GBL, LPDDHALINFO lpHalInfo, char *szDrvName);
  119. extern HRESULT GetNTDeviceRect( LPSTR pDriverName, LPRECT lpRect );
  120. #endif
  121. extern HDC DD_CreateDC(LPSTR pdrvname);
  122. extern void DD_DoneDC(HDC hdc);
  123. extern LONG xxxChangeDisplaySettingsExA(LPCSTR szDevice, LPDEVMODEA pdm, HWND hwnd, DWORD dwFlags,LPVOID lParam);
  124. extern HRESULT InternalDirectDrawCreate( PD3D8_DEVICEDATA *lplpDD, PADAPTERINFO pDeviceInfo, D3DDEVTYPE DeviceType, VOID* pInitFunction, D3DFORMAT Unknown16, DDSURFACEDESC* pHalOpList, DWORD NumHalOps);
  125. extern HRESULT InternalDirectDrawRelease(PD3D8_DEVICEDATA pBaseData);
  126. /* dddefwp.c */
  127. extern HRESULT SetAppHWnd( LPDDRAWI_DIRECTDRAW_LCL thisg, HWND hWnd, DWORD dwFlags );
  128. extern VOID CleanupWindowList( DWORD pid );
  129. extern void ClipTheCursor(LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl, LPRECT lpRect);
  130. /* drvinfo.c */
  131. extern BOOL Voodoo1GoodToGo( GUID * pGuid );
  132. extern void GetAdapterInfo( char* pDriverName, D3DADAPTER_IDENTIFIER8* pDI, BOOL bDisplayDriver, BOOL bGuidOnly, BOOL bDriverName);
  133. DEFINE_GUID( guidVoodoo1A, 0x3a0cfd01,0x9320,0x11cf,0xac,0xa1,0x00,0xa0,0x24,0x13,0xc2,0xe2 );
  134. DEFINE_GUID( guidVoodoo1B, 0xaba52f41,0xf744,0x11cf,0xb4,0x52,0x00,0x00,0x1d,0x1b,0x41,0x26 );
  135. /*
  136. * macros for validating pointers
  137. */
  138. #ifndef DEBUG
  139. #define FAST_CHECKING
  140. #endif
  141. /*
  142. * VALIDEX_xxx macros are the same for debug and retail
  143. */
  144. #define VALIDEX_PTR( ptr, size ) \
  145. (!IsBadReadPtr( ptr, size) )
  146. #define VALIDEX_IID_PTR( ptr ) \
  147. (!IsBadReadPtr( ptr, sizeof( IID )) )
  148. #define VALIDEX_PTR_PTR( ptr ) \
  149. (!IsBadWritePtr( ptr, sizeof( LPVOID )) )
  150. #define VALIDEX_CODE_PTR( ptr ) \
  151. (!IsBadCodePtr( (FARPROC) ptr ) )
  152. #define VALIDEX_GUID_PTR( ptr ) \
  153. (!IsBadReadPtr( ptr, sizeof( GUID ) ) )
  154. #define VALIDEX_DDDEVICEIDENTIFIER_PTR( ptr ) (!IsBadWritePtr( ptr, sizeof( DDDEVICEIDENTIFIER )))
  155. #define VALIDEX_DDDEVICEIDENTIFIER2_PTR( ptr ) (!IsBadWritePtr( ptr, sizeof( DDDEVICEIDENTIFIER2 )))
  156. /*
  157. * These macros validate the size (in debug and retail) of callback
  158. * tables.
  159. *
  160. * NOTE: It is essential that the comparison against the current
  161. * callback size expected by this DirectDraw the comparison operator
  162. * be >= rather than ==. This is to ensure that newer drivers can run
  163. * against older DirectDraws.
  164. */
  165. #define VALIDEX_DDCALLBACKSSIZE( ptr ) \
  166. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  167. ( ( ( ptr )->dwSize == DDCALLBACKSSIZE_V1 ) || \
  168. ( ( ptr )->dwSize >= DDCALLBACKSSIZE ) ) )
  169. #define VALIDEX_DDSURFACECALLBACKSSIZE( ptr ) \
  170. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  171. ( ( ptr )->dwSize >= DDSURFACECALLBACKSSIZE ) )
  172. #define VALIDEX_DDPALETTECALLBACKSSIZE( ptr ) \
  173. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  174. ( ( ptr )->dwSize >= DDPALETTECALLBACKSSIZE ) )
  175. #define VALIDEX_DDPALETTECALLBACKSSIZE( ptr ) \
  176. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  177. ( ( ptr )->dwSize >= DDPALETTECALLBACKSSIZE ) )
  178. #define VALIDEX_DDEXEBUFCALLBACKSSIZE( ptr ) \
  179. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  180. ( ( ptr )->dwSize >= DDEXEBUFCALLBACKSSIZE ) )
  181. #define VALIDEX_DDVIDEOPORTCALLBACKSSIZE( ptr ) \
  182. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  183. ( ( ptr )->dwSize >= DDVIDEOPORTCALLBACKSSIZE ) )
  184. #define VALIDEX_DDMOTIONCOMPCALLBACKSSIZE( ptr ) \
  185. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  186. ( ( ptr )->dwSize >= DDMOTIONCOMPCALLBACKSSIZE ) )
  187. #define VALIDEX_DDCOLORCONTROLCALLBACKSSIZE( ptr ) \
  188. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  189. ( ( ptr )->dwSize >= DDCOLORCONTROLCALLBACKSSIZE ) )
  190. #define VALIDEX_DDMISCELLANEOUSCALLBACKSSIZE( ptr ) \
  191. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  192. ( ( ptr )->dwSize >= DDMISCELLANEOUSCALLBACKSSIZE ) )
  193. #define VALIDEX_DDMISCELLANEOUS2CALLBACKSSIZE( ptr ) \
  194. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  195. ( ( ptr )->dwSize >= DDMISCELLANEOUS2CALLBACKSSIZE ) )
  196. #define VALIDEX_D3DCALLBACKS2SIZE( ptr ) \
  197. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  198. ( (( ptr )->dwSize >= D3DHAL_CALLBACKS2SIZE ) ))
  199. #define VALIDEX_D3DCOMMANDBUFFERCALLBACKSSIZE( ptr ) \
  200. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  201. ( ( ptr )->dwSize >= D3DHAL_COMMANDBUFFERCALLBACKSSIZE ) )
  202. #define VALIDEX_D3DCALLBACKS3SIZE( ptr ) \
  203. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  204. ( ( ptr )->dwSize >= D3DHAL_CALLBACKS3SIZE ) )
  205. #define VALIDEX_DDKERNELCALLBACKSSIZE( ptr ) \
  206. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  207. ( ( ptr )->dwSize >= DDKERNELCALLBACKSSIZE ) )
  208. #define VALIDEX_DDUMODEDRVINFOSIZE( ptr ) \
  209. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  210. ( ( ptr )->dwSize >= DDHAL_DDUMODEDRVINFOSIZE ) )
  211. #define VALIDEX_DDOPTSURFKMODEINFOSIZE( ptr ) \
  212. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  213. ( ( ptr )->dwSize >= DDOPTSURFACEKMODEINFOSIZE ) )
  214. #define VALIDEX_DDOPTSURFUMODEINFOSIZE( ptr ) \
  215. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  216. ( ( ptr )->dwSize >= DDOPTSURFACEUMODEINFOSIZE ) )
  217. #define VALIDEX_DDNTCALLBACKSSIZE( ptr ) \
  218. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  219. ( ( ptr )->dwSize >= DDNTCALLBACKSSIZE ) )
  220. #ifndef FAST_CHECKING
  221. #define VALID_DDKERNELCAPS_PTR( ptr ) \
  222. (!IsBadWritePtr( ptr, sizeof( DDKERNELCAPS ) ) && \
  223. (ptr->dwSize == sizeof( DDKERNELCAPS )) )
  224. #define VALID_DWORD_PTR( ptr ) \
  225. (!IsBadWritePtr( ptr, sizeof( DWORD ) ))
  226. #define VALID_BOOL_PTR( ptr ) \
  227. (!IsBadWritePtr( ptr, sizeof( BOOL ) ))
  228. #define VALID_HDC_PTR( ptr ) \
  229. (!IsBadWritePtr( ptr, sizeof( HDC ) ))
  230. #define VALID_RGNDATA_PTR( ptr, size ) \
  231. (!IsBadWritePtr( ptr, size ) )
  232. #define VALID_PTR_PTR( ptr ) \
  233. (!IsBadWritePtr( ptr, sizeof( LPVOID )) )
  234. #define VALID_IID_PTR( ptr ) \
  235. (!IsBadReadPtr( ptr, sizeof( IID )) )
  236. #define VALID_HWND_PTR( ptr ) \
  237. (!IsBadWritePtr( (LPVOID) ptr, sizeof( HWND )) )
  238. #define VALID_VMEM_PTR( ptr ) \
  239. (!IsBadWritePtr( (LPVOID) ptr, sizeof( VMEM )) )
  240. #define VALID_POINTER_ARRAY( ptr, cnt ) \
  241. (!IsBadWritePtr( ptr, sizeof( LPVOID ) * cnt ) )
  242. #define VALID_HANDLE_PTR( ptr ) \
  243. (!IsBadWritePtr( ptr, sizeof( HANDLE )) )
  244. #define VALID_DDCORECAPS_PTR( ptr ) \
  245. (!IsBadWritePtr( ptr, sizeof( DDCORECAPS ) ) && \
  246. (ptr->dwSize == sizeof( DDCORECAPS ) ) )
  247. #define VALID_DWORD_ARRAY( ptr, cnt ) \
  248. (!IsBadWritePtr( ptr, sizeof( DWORD ) * cnt ) )
  249. #define VALID_GUID_PTR( ptr ) \
  250. (!IsBadReadPtr( ptr, sizeof( GUID ) ) )
  251. #define VALID_BYTE_ARRAY( ptr, cnt ) \
  252. (!IsBadWritePtr( ptr, sizeof( BYTE ) * cnt ) )
  253. #define VALID_PTR( ptr, size ) \
  254. (!IsBadReadPtr( ptr, size) )
  255. #define VALID_WRITEPTR( ptr, size ) \
  256. (!IsBadWritePtr( ptr, size) )
  257. #else
  258. #define VALID_PTR( ptr, size ) 1
  259. #define VALID_WRITEPTR( ptr, size ) 1
  260. #define VALID_DDKERNELCAPS_PTR( ptr) (ptr->dwSize == sizeof( DDKERNELCAPS ))
  261. #define VALID_DWORD_PTR( ptr ) 1
  262. #define VALID_BOOL_PTR( ptr ) 1
  263. #define VALID_HDC_PTR( ptr ) 1
  264. #define VALID_RGNDATA_PTR( ptr ) 1
  265. #define VALID_PTR_PTR( ptr ) 1
  266. #define VALID_IID_PTR( ptr ) 1
  267. #define VALID_HWND_PTR( ptr ) 1
  268. #define VALID_VMEM_PTR( ptr ) 1
  269. #define VALID_POINTER_ARRAY( ptr, cnt ) 1
  270. #define VALID_PALETTEENTRY_ARRAY( ptr, cnt ) 1
  271. #define VALID_HANDLE_PTR( ptr ) 1
  272. #define VALID_DDCORECAPS_PTR( ptr ) (ptr->dwSize == sizeof( DDCORECAPS )
  273. #define VALID_DWORD_ARRAY( ptr, cnt ) 1
  274. #define VALID_GUID_PTR( ptr ) 1
  275. #define VALID_BYTE_ARRAY( ptr, cnt ) 1
  276. #endif
  277. /*
  278. * All global data is should be just here.
  279. */
  280. #define GLOBAL_STORAGE_CLASS extern
  281. /*
  282. * This member should stay at the top in order to guarantee that it be intialized to zero
  283. * -see dllmain.c 's instance of this structure
  284. */
  285. GLOBAL_STORAGE_CLASS HINSTANCE g_hModule;
  286. /*
  287. * Winnt specific global statics
  288. */
  289. GLOBAL_STORAGE_CLASS HANDLE hExclusiveModeMutex;
  290. GLOBAL_STORAGE_CLASS HANDLE hCheckExclusiveModeMutex;
  291. /*
  292. * IMPORTANT NOTE: This function validates the HAL information passed to us from the driver.
  293. * It is vital that we code this check so that we will pass HAL information structures
  294. * larger than the ones we know about so that new drivers can work with old DirectDraws.
  295. */
  296. #define VALIDEX_DDHALINFO_PTR( ptr ) \
  297. ( ( ( ( ptr )->dwSize == sizeof( DDHALINFO_V1 ) ) || \
  298. ( ( ptr )->dwSize == DDHALINFOSIZE_V2 ) || \
  299. ( ( ptr )->dwSize >= sizeof( DDHALINFO ) ) ) && \
  300. !IsBadWritePtr( ( ptr ), ( UINT ) ( ( ptr )->dwSize ) ) )
  301. /* Turn on D3D stats collection for Debug builds HERE */
  302. #define COLLECTSTATS DBG
  303. #ifdef __cplusplus
  304. } // extern "C"
  305. #endif
  306. #endif