Leaked source code of windows server 2003
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.

2411 lines
117 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:
  8. * Date By Reason
  9. * ==== == ======
  10. * 25-dec-94 craige initial implementation
  11. * 06-jan-95 craige video memory manager
  12. * 13-jan-95 craige re-worked to updated spec + ongoing work
  13. * 31-jan-95 craige and even more ongoing work...
  14. * 22-feb-95 craige use critical sections on Win95
  15. * 27-feb-95 craige new sync. macros
  16. * 03-mar-95 craige WaitForVerticalBlank stuff
  17. * 06-mar-95 craige HEL integration
  18. * 08-mar-95 craige GetFourCCCodes
  19. * 11-mar-95 craige palette stuff
  20. * 19-mar-95 craige use HRESULTs
  21. * 20-mar-95 craige new CSECT work
  22. * 23-mar-95 craige attachment work
  23. * 26-mar-95 craige added TMPALLOC and TMPFREE
  24. * 27-mar-95 craige linear or rectangular vidmem
  25. * 28-mar-95 craige switched to PALETTEENTRY from RGBQUAD
  26. * 29-mar-95 craige debug memory manager; build.h; hacks for DLL
  27. * unload problem...
  28. * 31-mar-95 craige use critical sections with palettes
  29. * 03-apr-95 craige added MAKE_SURF_RECT
  30. * 04-apr-95 craige added DD_GetPaletteEntries, DD_SetPaletteEntries
  31. * 06-apr-95 craige split out process list stuff; fill in free vidmem
  32. * 12-apr-95 craige add debugging to CSECT macros
  33. * 13-apr-95 craige EricEng's little contribution to our being late
  34. * 14-may-95 craige added DoneExclusiveMode, DD16_EnableReboot; cleaned out
  35. * obsolete junk
  36. * 23-may-95 craige no longer use MapLS_Pool; added Flush, GetBatchLimit
  37. * and SetBatchLimit
  38. * 24-may-95 craige added Restore
  39. * 28-may-95 craige unicode support; cleaned up HAL: added GetBltStatus;
  40. * GetFlipStatus; GetScanLine
  41. * 02-jun-95 craige added SetDisplayMode
  42. * 04-jun-95 craige added AllocSurfaceMem, IsLost
  43. * 05-jun-95 craige removed GetVersion, FreeAllSurfaces, DefWindowProc;
  44. * change GarbageCollect to Compact
  45. * 06-jun-95 craige added RestoreDisplayMode
  46. * 07-jun-95 craige added StartExclusiveMode
  47. * 10-jun-95 craige split out vmemmgr stuff
  48. * 13-jun-95 kylej move FindAttachedFlip to misc.c, added CanBeFlippable
  49. * 18-jun-95 craige specify pitch for rectangular heaps
  50. * 20-jun-95 craige added DD16_InquireVisRgn; make retail builds
  51. * not bother to check for NULL (since there are 4
  52. * billion other invalid ptrs we don't check for...)
  53. * 21-jun-95 craige new clipper stuff
  54. * 23-jun-95 craige ATTACHED_PROCESSES stuff
  55. * 25-jun-95 craige one ddraw mutex
  56. * 26-jun-95 craige reorganized surface structure
  57. * 27-jun-95 craige replaced batch limit/flush stuff with BltBatch
  58. * 30-jun-95 kylej function prototypes to support mult. prim. surfaces
  59. * 30-jun-95 craige changed GET_PIXEL_FORMAT to use HASPIXELFORMAT flag
  60. * 01-jul-95 craige hide composition & streaming stuff
  61. * 02-jul-95 craige SEH macros; added DD16_ChangeDisplaySettings
  62. * 03-jul-95 kylej Changed EnumSurfaces declaration
  63. * 03-jul-95 craige YEEHAW: new driver struct; Removed GetProcessPrimary
  64. * 05-jul-95 craige added Initialize fn to each object
  65. * 07-jul-95 craige added some VALIDEX_xxx structs
  66. * 07-jul-95 kylej proto XformRect, STRETCH_X and STRETCH_Y macros
  67. * 08-jul-95 craige added FindProcessDDObject; added InvalidateAllSurfaces
  68. * 09-jul-95 craige added debug output to win16 lock macro; added
  69. * ComputePitch, added hasvram flag to MoveToSystemMemory;
  70. * changed SetExclusiveMode to SetCooperativeLevel;
  71. * added ChangeToSoftwareColorKey
  72. * 10-jul-95 craige support SetOverlayPosition
  73. * 13-jul-95 craige ENTER_DDRAW is now the win16 lock;
  74. * Get/SetOverlayPosition takes LONGs
  75. * 13-jul-95 toddla remove _export from thunk functions
  76. * 18-jul-95 craige removed DD_Surface_Flush
  77. * 20-jul-95 craige internal reorg to prevent thunking during modeset
  78. * 28-jul-95 craige go back to private DDRAW lock
  79. * 31-jul-95 craige added DCIIsBanked
  80. * 01-aug-95 craige added ENTER/LEAVE_BOTH; DOHALCALL_NOWIN16
  81. * 04-aug-95 craige added InternalLock/Unlock
  82. * 10-aug-95 toddla changed proto of EnumDisplayModes
  83. * 10-aug-95 toddla added VALIDEX_DDSURFACEDESC_PTR
  84. * 12-aug-95 craige added use_full_lock parm to MoveToSystemMemory and
  85. * ChangeToSoftwareColorKey
  86. * 13-aug-95 craige flags parm for Flip
  87. * 21-aug-95 craige mode X support
  88. * 27-aug-95 craige bug 735: added SetPaletteAlways
  89. * bug 738: use GUID instead of IID
  90. * 02-sep-95 craige bug 786: verify dwSize in retail
  91. * 04-sep-95 craige bug 894: force flag to SetDisplayMode
  92. * 10-sep-95 toddla added string ids
  93. * 21-sep-95 craige bug 1215: added DD16_SetCertified
  94. * 11-nov-95 colinmc added new pointer validition macro for byte arrays
  95. * 27-nov-95 colinmc new member to return available vram of a given type
  96. * (defined by DDSCAPS)
  97. * 10-dec-95 colinmc added execute buffer support
  98. * 14-dec-95 colinmc added shared back and z-buffer support
  99. * 25-dec-95 craige added class factory support
  100. * 31-dec-95 craige added VALID_IID_PTR
  101. * 26-jan-96 jeffno FlipToGDISurface now only takes 1 arg
  102. * 09-feb-96 colinmc local surface objects now have invalid surface flag
  103. * 12-feb-96 jeffno Cheaper Mutex implementation for NT
  104. * 15-feb-96 jeffno GETCURRENTPID needs to call HackCurrentPID on both 95 and NT
  105. * 17-feb-96 colinmc Removed dependency on Direct3D include files
  106. * 24-feb-96 colinmc Added prototype for new member which is used to
  107. * determine if the callback tables have already been
  108. * initialized.
  109. * 02-mar-96 colinmc Simply disgusting and temporary hack to keep
  110. * interim drivers working
  111. * 14-mar-96 colinmc Changes for the clipper class factory
  112. * 17-mar-96 colinmc Bug 13124: flippable mip-maps
  113. * 20-mar-96 colinmc Bug 13634: unidirectional attachments cause infinite
  114. * loop on cleanup
  115. * 22-mar-96 colinmc Bug 13316: Uninitialized interfaces
  116. * 24-mar-96 colinmc Bug 14321: not possible to specify back buffer and
  117. * mip-map count in a single call
  118. * 10-apr-96 colinmc Bug 16903: HEL using obsolete FindProcessDDObject
  119. * 13-apr-96 colinmc Bug 17736: No driver notifcation of flip to GDI
  120. * 15-apr-96 colinmc Bug 16885: Can't pass NULL to initialize in C++
  121. * 16-apr-96 colinmc Bug 17921: Remove interim driver support
  122. * 26-mar-96 jeffno Removed cheap mutexes. Added check for mode change for NT's
  123. * ENTERDDRAW.
  124. * 29-apr-96 colinmc Bug 19954: Must query for Direct3D before texture or
  125. * device interface
  126. * 11-may-96 colinmc Bug 22293: New macro to validate GUID even if not
  127. * in debug
  128. * 17-may-96 kylej Bug 23301: validate DDHALINFO size >= current size
  129. * 28-jul-96 colinmc Bug 2613: Minimal support for secondary (stacked)
  130. * drivers.
  131. * 16-aug-96 craige include ddreg.h, added dwRegFlags + flag defns
  132. * 03-sep-96 craige added app compat stuff.
  133. * 23-sep-96 ketand added InternalGetClipList
  134. * 01-oct-96 ketand added TIMING routings
  135. * 05-oct-96 colinmc Work Item: Remove requirement on taking Win16 lock
  136. * for VRAM surfaces (not primary)
  137. * 12-oct-96 colinmc Improvements to Win16 locking code to reduce virtual
  138. * memory usage
  139. * 09-nov-96 colinmc Fixed problem with old and new drivers not working
  140. * with DirectDraw
  141. * 17-nov-96 colinmc New ref flag to control the enabling and disabling
  142. * of PrintScreen
  143. * 02-jan-97 colinmc Initial AGP implementation work
  144. * 12-jan-97 colinmc More Win16 lock work
  145. * 13-jan-97 jvanaken Basic support for IDirectDrawSurface3 interface
  146. * 18-jan-97 colinmc AGP VMM support
  147. * 21-jan-97 ketand Change DD16_SetPaletteEntries for multi-mon. Deleted
  148. * unused code.
  149. * 26-jan-97 ketand Remove unused DD16_GetPaletteEntries. (It didn't handle
  150. * multi-mon; and wasn't worth fixing.) Also, remove
  151. * globals that don't work anymore with multi-mon.
  152. * 30-jan-97 colinmc Work item 4125: Need time bomb for final
  153. * 01-feb-97 colinmc Bug 5457: Fixed Win16 lock problem causing hang
  154. * with mutliple AMovie instances on old cards
  155. * 02-feb-97 toddla pass driver name to DD16_GetMonitor functions
  156. * added DD16_GetDeviceConfig
  157. * 02-feb-97 colinmc Bug 5625: V1.0 DirectX drivers don't get recognized
  158. * due to bad size check on DDCALLBACKS
  159. * 05-feb-97 ketand Remove unused parameter from ClipRgnToRect
  160. * 22-feb-97 colinmc Enabled OWNDC for explicit system memory surfaces
  161. * 03-mar-97 smac Added kernel mode interface
  162. * 03-mar-97 jeffno Work item: Extended surface memory alignment
  163. * 04-mar-97 ketand Added UpdateOutstandingDC to track palette changes
  164. * 08-mar-97 colinmc Added support for DMA style AGP parts
  165. * 13-mar-97 colinmc Bug 6533: Pass uncached flag to VMM correctly
  166. * 22-mar-97 colinmc Bug 6673: Add compile time option to allow new
  167. * applications to run against legacy run times.
  168. * 23-mar-97 colinmc Bug 6673 again: Changed structure numbering scheme
  169. * for consistency's sake
  170. * 24-mar-97 jeffno Optimized Surfaces
  171. * 07-may-97 colinmc Moved AGP support detection from misc.c to ddagp.c
  172. * 30-sep-97 jeffno IDirectDraw4
  173. * 03-oct-97 jeffno DDSCAPS2 and DDSURFACEDESC2
  174. * 31-oct-97 johnstep Persistent-content surfaces for Windows 9x
  175. * 26-nov-97 t-craigs Added IDirectDrawPalette2
  176. * 19-dec-97 jvanaken IDDS4::Unlock now takes a pointer to a rectangle.
  177. *
  178. ***************************************************************************/
  179. #ifndef __DDRAWPR_INCLUDED__
  180. #define __DDRAWPR_INCLUDED__
  181. #ifdef WIN95
  182. #ifdef WINNT
  183. #undef WINNT
  184. #endif
  185. #endif
  186. #ifndef WIN95
  187. #include <nt.h>
  188. #include <ntrtl.h>
  189. #include <nturtl.h>
  190. #include <stddef.h>
  191. #endif
  192. #ifdef WIN95
  193. #define WIN16_SEPARATE
  194. #endif
  195. #include "verinfo.h"
  196. #ifndef WIN32_LEAN_AND_MEAN
  197. #define WIN32_LEAN_AND_MEAN
  198. #endif
  199. #include <windows.h>
  200. #include <mmsystem.h>
  201. #if defined( WIN95 ) && !defined ( NT_BUILD_ENVIRONMENT )
  202. #undef PBT_APMRESUMEAUTOMATIC
  203. #include <pbt.h>
  204. #endif
  205. //#ifdef NT_BUILD_ENVIRONMENT
  206. /*
  207. * These are various definitions brought over from the win95 world, just to get us
  208. * compiling under the NT headers.
  209. */
  210. #ifdef WIN32
  211. /*
  212. * These come from \proj\dev\sdk\inc\winbase.h
  213. */
  214. #define FILE_FLAG_GLOBAL_HANDLE 0x00800000 // ;internal
  215. VOID // ;internal
  216. WINAPI // ;internal
  217. ReinitializeCriticalSection( // ;internal
  218. LPCRITICAL_SECTION lpCriticalSection // ;internal
  219. ); // ;internal
  220. //
  221. // Windows 9x stuff
  222. //
  223. #define CDS_EXCLUSIVE 0x80000000
  224. #define DISPLAY_DEVICE_VGA 0x00000010
  225. #define DCX_USESTYLE 0x00010000
  226. #endif //IS_32
  227. /*
  228. * These two come from \proj\dev\msdev\include\pbt.h
  229. */
  230. #define PBT_APMSUSPEND 0x0004
  231. #define PBT_APMSTANDBY 0x0005
  232. //#endif //NT_BUILD_ENVIRONMENT
  233. #include <string.h>
  234. #include <stddef.h>
  235. #if defined( IS_32 ) || defined( WIN32 ) || defined( _WIN32 )
  236. #undef IS_32
  237. #define IS_32
  238. #pragma pack(1)
  239. #include <dibeng.inc>
  240. #pragma pack()
  241. #ifndef HARDWARECURSOR
  242. //#pragma message("defining local version of HARDWARECURSOR")
  243. #define HARDWARECURSOR 0x0100 // new post-Win95 deFlag
  244. #endif
  245. #else
  246. #define IID void
  247. #endif
  248. #pragma warning( disable: 4704)
  249. #include "dpf.h"
  250. /*
  251. * registry stuff
  252. */
  253. #include "ddreg.h"
  254. /*
  255. * application compat. stuff
  256. */
  257. #define DDRAW_APPCOMPAT_MODEXONLY 0x00000001l
  258. #define DDRAW_APPCOMPAT_NODDSCAPSINDDSD 0x00000002l
  259. #define DDRAW_APPCOMPAT_MMXFORRGB 0x00000004l
  260. #define DDRAW_APPCOMPAT_EXPLICITMONITOR 0x00000008l
  261. #define DDRAW_APPCOMPAT_SCREENSAVER 0x00000010l
  262. #define DDRAW_APPCOMPAT_FORCEMODULATED 0x00000020l
  263. #define DDRAW_APPCOMPAT_TEXENUMINCL_0 0x00000040l // two bit field
  264. #define DDRAW_APPCOMPAT_TEXENUMINCL_1 0x00000080l
  265. #define DDRAW_APPCOMPAT_TEXENUMLIMIT 0x00000100l
  266. #define DDRAW_APPCOMPAT_SKIPWHEELMSG 0x00000200l // Win98 only
  267. #define DDRAW_APPCOMPAT_TEXENUMDX7FOURCC 0x00000400l
  268. #define DDRAW_APPCOMPAT_VALID 0x000007ffl
  269. #define DDRAW_REGFLAGS_MODEXONLY 0x00000001l
  270. #define DDRAW_REGFLAGS_EMULATIONONLY 0x00000002l
  271. #define DDRAW_REGFLAGS_SHOWFRAMERATE 0x00000004l
  272. #define DDRAW_REGFLAGS_ENABLEPRINTSCRN 0x00000008l
  273. #define DDRAW_REGFLAGS_FORCEAGPSUPPORT 0x00000010l
  274. #define DDRAW_REGFLAGS_DISABLEMMX 0x00000020l
  275. #define DDRAW_REGFLAGS_DISABLEWIDESURF 0x00000040l
  276. #define DDRAW_REGFLAGS_AGPPOLICYMAXBYTES 0x00000200l
  277. #define DDRAW_REGFLAGS_FORCEREFRESHRATE 0x00008000l
  278. #ifdef DEBUG
  279. #define DDRAW_REGFLAGS_DISABLENOSYSLOCK 0x00000080l
  280. #define DDRAW_REGFLAGS_FORCENOSYSLOCK 0x00000100l
  281. #endif
  282. #define DDRAW_REGFLAGS_NODDSCAPSINDDSD 0x00000400l
  283. #define DDRAW_REGFLAGS_DISABLEAGPSUPPORT 0x00000800l
  284. #ifdef DEBUG
  285. #define DDRAW_REGFLAGS_DISABLEINACTIVATE 0x00001000l
  286. #define DDRAW_REGFLAGS_PREGUARD 0x00002000l
  287. #define DDRAW_REGFLAGS_POSTGUARD 0x00004000l
  288. #endif
  289. #define DDRAW_REGFLAGS_USENONLOCALVIDMEM 0x00010000l
  290. #define DDRAW_REGFLAGS_ENUMERATEATTACHEDSECONDARIES 0x00008000l
  291. #define DDRAW_REGFLAGS_FLIPNONVSYNC 0x00020000l
  292. extern DWORD dwRegFlags;
  293. #include "memalloc.h"
  294. #if defined( IS_32 ) || defined( WIN32 ) || defined( _WIN32 )
  295. #include <objbase.h>
  296. #else
  297. #define IUnknown void
  298. #endif
  299. #include "ddrawi.h"
  300. #include "dwininfo.h"
  301. #ifdef WIN95
  302. #include "..\ddraw16\modex.h"
  303. #endif
  304. /*
  305. * Need this to get CDS_ macros under NT build environment for win95.
  306. * winuserp.h comes from private\windows\inc
  307. */
  308. #ifdef NT_BUILD_ENVIRONMENT
  309. #ifdef WIN32
  310. #include "winuserp.h"
  311. #endif
  312. #endif
  313. #include "ids.h"
  314. /*
  315. * NT kernel mode stub(ish)s
  316. */
  317. #ifndef WIN95
  318. #include "ddrawgdi.h"
  319. #endif
  320. /*
  321. * Driver version info
  322. */
  323. //========================================================================
  324. // advanced driver information
  325. //========================================================================
  326. typedef struct tagDDDRIVERINFOEX
  327. {
  328. DDDEVICEIDENTIFIER di;
  329. char szDeviceID[MAX_DDDEVICEID_STRING];
  330. } DDDRIVERINFOEX, * LPDDDRIVERINFOEX;
  331. /*
  332. * Direct3D interfacing defines.
  333. */
  334. #ifndef NO_D3D
  335. #include "ddd3dapi.h"
  336. #endif
  337. #ifdef __cplusplus
  338. extern "C" {
  339. #endif
  340. #ifdef WIN95
  341. #define USE_CRITSECTS
  342. extern void DDAPI DD16_SetEventHandle( DWORD hInstance, DWORD dwEvent );
  343. extern void DDAPI DD16_DoneDriver( DWORD hInstance );
  344. extern void DDAPI DD16_GetDriverFns( LPDDHALDDRAWFNS list );
  345. extern void DDAPI DD16_GetHALInfo( LPDDHALINFO pinfo );
  346. extern LONG DDAPI DD16_ChangeDisplaySettings( LPDEVMODE pdm, DWORD flags);
  347. extern HRGN DDAPI DD16_InquireVisRgn( HDC );
  348. extern void DDAPI DD16_SelectPalette( HDC, HPALETTE, BOOL );
  349. extern BOOL DDAPI DD16_SetPaletteEntries( HDC hdc, DWORD dwBase, DWORD dwNum, LPPALETTEENTRY, BOOL fPrimary );
  350. extern void DDAPI DD16_EnableReboot( BOOL );
  351. extern void DDAPI DD16_SetCertified( BOOL iscert );
  352. extern BOOL DDAPI DCIIsBanked( HDC hdc );
  353. #define GETCURRPID HackGetCurrentProcessId
  354. VOID WINAPI MakeCriticalSectionGlobal( CSECT_HANDLE lpcsCriticalSection );
  355. extern HDC DDAPI DD16_GetDC(HDC hdc, LPDDSURFACEDESC pddsd, LPPALETTEENTRY lpPalette);
  356. extern void DDAPI DD16_ReleaseDC(HDC hdc);
  357. extern BOOL DDAPI DD16_SafeMode(HDC hdc, BOOL fSafeMode);
  358. extern void DDAPI DD16_Exclude(DWORD dwPDevice, RECTL FAR *prcl);
  359. extern void DDAPI DD16_Unexclude(DWORD dwPDevice);
  360. extern int DDAPI DD16_Stretch(DWORD DstPtr, int DstPitch, UINT DstBPP, int DstX, int DstY, int DstDX, int DstDY,
  361. DWORD SrcPtr, int SrcPitch, UINT SrcBPP, int SrcX, int SrcY, int SrcDX, int SrcDY);
  362. extern BOOL DDAPI DD16_IsWin95MiniDriver( void );
  363. extern int DDAPI DD16_GetMonitorMaxSize(LPSTR szDevice);
  364. extern BOOL DDAPI DD16_GetMonitorRefreshRateRanges(LPSTR szDevice, int xres, int yres, int FAR *pmin, int FAR *pmax);
  365. extern DWORD DDAPI DD16_GetDeviceConfig(LPSTR szDevice, LPVOID lpConfig, DWORD size);
  366. extern BOOL DDAPI DD16_GetMonitorEDIDData(LPSTR szDevice, LPVOID lpEdidData);
  367. extern DWORD DDAPI DD16_GetRateFromRegistry( LPSTR szDevice );
  368. extern int DDAPI DD16_SetRateInRegistry( LPSTR szDevice, DWORD dwRateToRestore );
  369. #ifdef USE_ALIAS
  370. extern BOOL DDAPI DD16_FixupDIBEngine( void );
  371. #endif /* USE_ALIAS */
  372. extern WORD DDAPI DD16_MakeObjectPrivate(HDC hdc, BOOL fPrivate);
  373. extern BOOL DDAPI DD16_AttemptGamma(HDC hdc);
  374. extern BOOL DDAPI DD16_IsDeviceBusy(HDC hdc);
  375. #else
  376. #define DD16_DoneDriver( hInstance ) 0
  377. #define DD16_GetDriverFns( list ) 0
  378. #define DD16_GetHALInfo( pinfo ) 0
  379. #define DD16_ChangeDisplaySettings( pdm, flags) ChangeDisplaySettings( pdm, flags )
  380. #define DD16_SelectPalette( hdc, hpal ) SelectPalette( hdc, hpal, FALSE )
  381. #define DD16_EnableReboot( retboot ) 0
  382. #define DD16_WWOpen( ptr ) 0
  383. #define DD16_WWClose( ptr, newlist ) 0
  384. #define DD16_WWNotifyInit( pww, lpcallback, param ) 0
  385. #define DD16_WWGetClipList( pww, prect, rdsize, prd ) 0
  386. //
  387. // On NT, it is an assert that we are never called by DDHELP, so we should always be
  388. // working on the current process.
  389. //
  390. #define GETCURRPID GetCurrentProcessId
  391. #define DCIIsBanked( hdc ) FALSE
  392. #define DD16_IsWin95MiniDriver() TRUE
  393. #define DD16_SetCertified( iscert ) 0
  394. #define DD16_GetMonitorMaxSize(dev) 0
  395. #define DD16_GetMonitorRefreshRateRanges( dev, xres, yres, pmin, pmax) 0
  396. #define DD16_GetRateFromRegistry( szDevice ) 0
  397. #define DD16_SetRateInRegistry( szDevice, dwRateToRestore ) 0
  398. #ifdef USE_ALIAS
  399. #define DD16_FixupDIBEngine() TRUE
  400. #endif /* USE_ALIAS */
  401. #define DD16_AttemptGamma( hdc) 0
  402. #define DD16_IsDeviceBusy( hdc) 0
  403. #endif
  404. #ifndef NO_DDHELP
  405. #include "w95help.h"
  406. #endif //NO_DDHELP
  407. #define TRY _try
  408. #define EXCEPT(a) _except( a )
  409. extern LPDDRAWI_DDRAWCLIPPER_INT lpGlobalClipperList;
  410. /*
  411. * list of processes attached to DLL
  412. */
  413. typedef struct ATTACHED_PROCESSES
  414. {
  415. struct ATTACHED_PROCESSES *lpLink;
  416. DWORD dwPid;
  417. #ifdef WINNT
  418. DWORD dwNTToldYet;
  419. #endif
  420. } ATTACHED_PROCESSES, FAR *LPATTACHED_PROCESSES;
  421. //extern LPATTACHED_PROCESSES lpAttachedProcesses;
  422. /* Structure for keeping track of DCs that have
  423. * been handed out by DDraw for surfaces.
  424. */
  425. typedef struct _dcinfo
  426. {
  427. HDC hdc; // HDC associated with surface
  428. LPDDRAWI_DDRAWSURFACE_LCL pdds_lcl; // Surface associated with HDC
  429. struct _dcinfo * pdcinfoNext; // Pointer to next
  430. } DCINFO, *LPDCINFO;
  431. /*
  432. * Head of the list of DCs handed out.
  433. */
  434. extern DCINFO *g_pdcinfoHead;
  435. /*
  436. * macros for doing allocations of a temporary basis.
  437. * Tries alloca first, if that fails, it will allocate storage from the heap
  438. */
  439. #ifdef USEALLOCA
  440. #define TMPALLOC( ptr, size ) \
  441. ptr = _alloca( (size)+sizeof( DWORD ) ); \
  442. if( ptr == NULL ) \
  443. { \
  444. ptr = MemAlloc( (size)+sizeof( DWORD ) ); \
  445. if( ptr != NULL ) \
  446. { \
  447. *(DWORD *)ptr = 1; \
  448. (LPSTR) ptr += sizeof( DWORD ); \
  449. } \
  450. } \
  451. else \
  452. { \
  453. *(DWORD *)ptr = 0; \
  454. (LPSTR) ptr += sizeof( DWORD ); \
  455. }
  456. #define TMPFREE( ptr ) \
  457. if( ptr != NULL ) \
  458. { \
  459. (LPSTR) ptr -= sizeof( DWORD ); \
  460. if( (*(DWORD *) ptr) ) \
  461. { \
  462. MemFree( ptr ); \
  463. } \
  464. }
  465. #else
  466. #define TMPALLOC( ptr, size ) ptr = MemAlloc( size );
  467. #define TMPFREE( ptr ) MemFree( ptr );
  468. #endif
  469. /*
  470. * macros for getting at values that aren't always present in the surface
  471. * object
  472. */
  473. #define GET_PIXEL_FORMAT( thisx, thisl, pddpf ) \
  474. if( thisx->dwFlags & DDRAWISURF_HASPIXELFORMAT ) \
  475. { \
  476. pddpf = &thisl->ddpfSurface; \
  477. } \
  478. else \
  479. { \
  480. pddpf = &thisl->lpDD->vmiData.ddpfDisplay; \
  481. }
  482. /*
  483. * macro for building a rectangle that is the size of a surface.
  484. * For multi-monitor systems, we have a different code path
  485. * to deal with the fact that the upper-left coord may not be zero.
  486. */
  487. #define MAKE_SURF_RECT( surf, surf_lcl, r ) \
  488. r.top = 0; \
  489. r.left = 0; \
  490. r.bottom = (DWORD) surf->wHeight; \
  491. r.right = (DWORD) surf->wWidth;
  492. /*
  493. * macro for doing doing HAL call.
  494. *
  495. * Takes the Win16 lock for 32-bit Win95 driver routines. This serves a
  496. * 2-fold purpose:
  497. * 1) keeps the 16-bit portion of the driver safe
  498. * 2) 32-bit routine needs lock others out while its updating
  499. * its hardware
  500. */
  501. #if defined( WIN95 ) && defined( WIN16_SEPARATE )
  502. #define DOHALCALL( halcall, fn, data, rc, isHEL ) \
  503. if( (fn != _DDHAL_##halcall) && !isHEL ) { \
  504. ENTER_WIN16LOCK(); \
  505. rc = fn( &data ); \
  506. LEAVE_WIN16LOCK(); \
  507. } else { \
  508. rc = fn( &data ); \
  509. }
  510. #define DOHALCALL_NOWIN16( halcall, fn, data, rc, isHEL ) \
  511. rc = fn( &data );
  512. #else
  513. #define DOHALCALL( halcall, fn, data, rc, isHEL ) \
  514. if (fn) \
  515. rc = fn( &data );\
  516. else\
  517. rc = DDHAL_DRIVER_NOTHANDLED;
  518. #define DOHALCALL_NOWIN16( halcall, fn, data, rc, isHEL ) \
  519. if (fn) \
  520. rc = fn( &data );\
  521. else\
  522. rc = DDHAL_DRIVER_NOTHANDLED;
  523. #endif
  524. /*
  525. * macro for incrementing/decrementing the driver ref count
  526. */
  527. #define CHANGE_GLOBAL_CNT( pdrv, thisg, cnt ) \
  528. if( !(thisg->dwGlobalFlags & DDRAWISURFGBL_SYSMEMREQUESTED) ) \
  529. { \
  530. (int) pdrv->dwSurfaceLockCount += (int) (cnt); \
  531. }
  532. /*
  533. * reminder
  534. */
  535. #define QUOTE(x) #x
  536. #define QQUOTE(y) QUOTE(y)
  537. #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) "):" str
  538. /*
  539. * maximum timeout (in ms) when spinlocked on a surface
  540. */
  541. #define MAX_TIMEOUT 5000
  542. /*
  543. * defined in dllmain.c
  544. */
  545. extern CSECT_HANDLE lpDDCS;
  546. #ifdef WINNT
  547. extern HANDLE hDriverObjectListMutex;
  548. extern DWORD dwNumLockedWhenModeSwitched;
  549. #else
  550. #ifdef IS_32
  551. extern CRITICAL_SECTION csDriverObjectList;
  552. #endif
  553. #endif
  554. #define MAX_TIMER_HWNDS 15
  555. extern HWND ghwndTopmostList[MAX_TIMER_HWNDS];
  556. extern int giTopmostCnt;
  557. extern BOOL bGammaCalibratorExists;
  558. extern BYTE szGammaCalibrator[MAX_PATH];
  559. extern DWORD dwForceRefreshRate;
  560. /*
  561. * blt flags
  562. */
  563. #define DDBLT_PRIVATE_ALIASPATTERN 0x80000000l
  564. /*
  565. * get the fail code based on what HAL and HEL support; used by BLT
  566. *
  567. * assumes variables halonly, helonly, fail are defined
  568. */
  569. #define GETFAILCODEBLT( testhal, testhel, halonly, helonly, flag ) \
  570. if( halonly ) { \
  571. if( !(testhal & flag) ) { \
  572. fail = TRUE; \
  573. } \
  574. } else if( helonly ) { \
  575. if( !(testhel & flag) ) { \
  576. fail = TRUE; \
  577. } \
  578. } else { \
  579. if( !(testhal & flag) ) { \
  580. if( !(testhel & flag) ) { \
  581. fail = TRUE; \
  582. } else { \
  583. helonly = TRUE; \
  584. } \
  585. } else { \
  586. halonly = TRUE; \
  587. } \
  588. }
  589. /*
  590. * get the fail code based on what HAL and HEL support
  591. *
  592. * assumes variables halonly, helonly, fail are defined
  593. */
  594. #define GETFAILCODE( testhal, testhel, flag ) \
  595. if( halonly ) \
  596. { \
  597. if( !(testhal & flag) ) \
  598. { \
  599. fail = TRUE; \
  600. } \
  601. } \
  602. else if( helonly ) \
  603. { \
  604. if( !(testhel & flag) ) \
  605. { \
  606. fail = TRUE; \
  607. } \
  608. } \
  609. else \
  610. { \
  611. if( !(testhal & flag) ) \
  612. { \
  613. if( !(testhel & flag) ) \
  614. { \
  615. fail = TRUE; \
  616. } \
  617. else \
  618. { \
  619. helonly = TRUE; \
  620. } \
  621. } \
  622. else \
  623. { \
  624. halonly = TRUE; \
  625. } \
  626. }
  627. typedef struct {
  628. DWORD src_height;
  629. DWORD src_width;
  630. DWORD dest_height;
  631. DWORD dest_width;
  632. BOOL halonly;
  633. BOOL helonly;
  634. LPDDHALSURFCB_BLT bltfn;
  635. LPDDHALSURFCB_BLT helbltfn;
  636. } SPECIAL_BLT_DATA, FAR *LPSPECIAL_BLT_DATA;
  637. /*
  638. * synchronization
  639. */
  640. #ifdef WINNT
  641. #define RELEASE_EXCLUSIVEMODE_MUTEX \
  642. { \
  643. if (hExclusiveModeMutex) \
  644. { \
  645. BOOL bSucceed = ReleaseMutex(hExclusiveModeMutex); \
  646. if (!bSucceed) \
  647. { \
  648. DPF_ERR("Release Exclusive Mutex Failed. App " \
  649. "should not release Exclusive Mode on " \
  650. "different thread than it was taken."); \
  651. } \
  652. } \
  653. }
  654. #else
  655. #define RELEASE_EXCLUSIVEMODE_MUTEX ;
  656. #endif
  657. //--------------------------------- new cheap mutexes -------------------------------------------
  658. //
  659. // Global Critical Sections have two components. One piece is shared between all
  660. // applications using the global lock. This portion will typically reside in some
  661. // sort of shared memory
  662. //
  663. // The second piece is per-process. This contains a per-process handle to the shared
  664. // critical section lock semaphore. The semaphore is itself shared, but each process
  665. // may have a different handle value to the semaphore.
  666. //
  667. // Global critical sections are attached to by name. The application wishing to
  668. // attach must know the name of the critical section (actually the name of the shared
  669. // lock semaphore, and must know the address of the global portion of the critical
  670. // section
  671. //
  672. typedef struct _GLOBAL_SHARED_CRITICAL_SECTION {
  673. LONG LockCount;
  674. LONG RecursionCount;
  675. DWORD OwningThread;
  676. DWORD OwningProcess;
  677. DWORD Reserved;
  678. } GLOBAL_SHARED_CRITICAL_SECTION, *PGLOBAL_SHARED_CRITICAL_SECTION;
  679. typedef struct _GLOBAL_LOCAL_CRITICAL_SECTION {
  680. PGLOBAL_SHARED_CRITICAL_SECTION GlobalPortion;
  681. HANDLE LockSemaphore;
  682. DWORD Reserved1;
  683. DWORD Reserved2;
  684. } GLOBAL_LOCAL_CRITICAL_SECTION, *PGLOBAL_LOCAL_CRITICAL_SECTION;
  685. /*
  686. * The following functions are defined in mutex.c
  687. */
  688. BOOL
  689. WINAPI
  690. AttachToGlobalCriticalSection(
  691. PGLOBAL_LOCAL_CRITICAL_SECTION lpLocalPortion,
  692. PGLOBAL_SHARED_CRITICAL_SECTION lpGlobalPortion,
  693. LPCSTR lpName
  694. );
  695. BOOL
  696. WINAPI
  697. DetachFromGlobalCriticalSection(
  698. PGLOBAL_LOCAL_CRITICAL_SECTION lpLocalPortion
  699. );
  700. VOID
  701. WINAPI
  702. EnterGlobalCriticalSection(
  703. PGLOBAL_LOCAL_CRITICAL_SECTION lpLocalPortion
  704. );
  705. VOID
  706. WINAPI
  707. LeaveGlobalCriticalSection(
  708. PGLOBAL_LOCAL_CRITICAL_SECTION lpLocalPortion
  709. );
  710. void
  711. DestroyPIDsLock(
  712. PGLOBAL_SHARED_CRITICAL_SECTION GlobalPortion,
  713. DWORD dwPid,
  714. LPSTR lpName
  715. );
  716. #define DDRAW_FAST_CS_NAME "DdrawGlobalFastCrit"
  717. extern GLOBAL_LOCAL_CRITICAL_SECTION CheapMutexPerProcess;
  718. extern GLOBAL_SHARED_CRITICAL_SECTION CheapMutexCrossProcess;
  719. #define CHEAP_LEAVE {LeaveGlobalCriticalSection(&CheapMutexPerProcess);}
  720. #define CHEAP_ENTER {EnterGlobalCriticalSection(&CheapMutexPerProcess);}
  721. #ifdef WINNT
  722. // #define USE_CHEAP_MUTEX
  723. #define NT_USES_CRITICAL_SECTION
  724. #endif
  725. extern void ModeChangedOnENTERDDRAW(void); // in ddmodent.c
  726. extern ULONG uDisplaySettingsUnique;
  727. //
  728. #ifdef IS_32
  729. #ifndef USE_CRITSECTS
  730. #define INIT_DDRAW_CSECT()
  731. #define FINI_DDRAW_CSECT()
  732. #define ENTER_DDRAW()
  733. #define LEAVE_DDRAW()
  734. #define ENTER_DRIVERLISTCSECT()
  735. #define LEAVE_DRIVERLISTCSECT()
  736. #else //so use csects:
  737. #ifdef DEBUG
  738. //extern int iWin16Cnt;
  739. //extern int iDLLCSCnt;
  740. #define INCCSCNT() iDLLCSCnt++;
  741. #define DECCSCNT() iDLLCSCnt--;
  742. #define INCW16CNT() iWin16Cnt++;
  743. #define DECW16CNT() iWin16Cnt--;
  744. #else
  745. #define INCCSCNT()
  746. #define DECCSCNT()
  747. #define INCW16CNT()
  748. #define DECW16CNT()
  749. #endif //debug
  750. #ifdef WINNT
  751. extern HANDLE hDirectDrawMutex; //def'd in dllmain.c
  752. #ifdef USE_CHEAP_MUTEX
  753. //--------------------------------- new cheap mutexes -------------------------------------------
  754. #define ENTER_DDRAW() {CHEAP_ENTER;}
  755. #define ENTER_DDRAW_INDLLMAIN() CHEAP_ENTER
  756. #define LEAVE_DDRAW() CHEAP_LEAVE
  757. #define INIT_DDRAW_CSECT() \
  758. { \
  759. if (!AttachToGlobalCriticalSection(&CheapMutexPerProcess,&CheapMutexCrossProcess,DDRAW_FAST_CS_NAME) ) \
  760. {DPF(0,"===================== Mutex Creation FAILED =================");} \
  761. }
  762. #define FINI_DDRAW_CSECT() {DetachFromGlobalCriticalSection(&CheapMutexPerProcess);}
  763. #else
  764. #ifdef NT_USES_CRITICAL_SECTION
  765. //
  766. // Use critical sections
  767. //
  768. #define INIT_DDRAW_CSECT() InitializeCriticalSection( lpDDCS );
  769. #define FINI_DDRAW_CSECT() DeleteCriticalSection( lpDDCS );
  770. extern DWORD gdwRecursionCount;
  771. #define ENTER_DDRAW() \
  772. { \
  773. DWORD dwUniqueness; \
  774. EnterCriticalSection( (LPCRITICAL_SECTION) lpDDCS ); \
  775. gdwRecursionCount++; \
  776. dwUniqueness = DdQueryDisplaySettingsUniqueness(); \
  777. if (dwUniqueness != uDisplaySettingsUnique && \
  778. 1 == gdwRecursionCount) \
  779. { \
  780. ModeChangedOnENTERDDRAW(); \
  781. uDisplaySettingsUnique = dwUniqueness; \
  782. } \
  783. }
  784. #define ENTER_DDRAW_INDLLMAIN() \
  785. EnterCriticalSection( (LPCRITICAL_SECTION) lpDDCS ); \
  786. gdwRecursionCount++;
  787. #define LEAVE_DDRAW() { gdwRecursionCount--; LeaveCriticalSection( (LPCRITICAL_SECTION) lpDDCS );}
  788. #else
  789. //
  790. // Use a mutex object.
  791. //
  792. #define INIT_DDRAW_CSECT() \
  793. { if (hDirectDrawMutex) {DPF(0,"Direct draw mutex initialised twice!");} \
  794. else{ \
  795. hDirectDrawMutex = CreateMutex(NULL,FALSE,"DirectDrawMutexName"); \
  796. if (!hDirectDrawMutex) {DPF(0,"===================== Mutex Creation FAILED =================");}\
  797. } \
  798. }
  799. extern DWORD gdwRecursionCount;
  800. #define FINI_DDRAW_CSECT() { if (hDirectDrawMutex) CloseHandle(hDirectDrawMutex); }
  801. #define LEAVE_DDRAW() { gdwRecursionCount--;ReleaseMutex(hDirectDrawMutex); }
  802. #define ENTER_DDRAW() \
  803. { \
  804. DWORD dwUniqueness,dwWaitValue; \
  805. dwWaitValue = WaitForSingleObject(hDirectDrawMutex,INFINITE); \
  806. gdwRecursionCount++; \
  807. dwUniqueness = DdQueryDisplaySettingsUniqueness(); \
  808. if (dwUniqueness != uDisplaySettingsUnique && \
  809. 1 == gdwRecursionCount) \
  810. { \
  811. ModeChangedOnENTERDDRAW(); \
  812. uDisplaySettingsUnique = dwUniqueness; \
  813. } \
  814. }
  815. #define ENTER_DDRAW_INDLLMAIN() WaitForSingleObject(hDirectDrawMutex,INFINITE);
  816. #endif //use (expensive) mutexes
  817. #endif //use_cheap_mutex
  818. #define ENTER_DRIVERLISTCSECT() \
  819. WaitForSingleObject(hDriverObjectListMutex,INFINITE);
  820. #define LEAVE_DRIVERLISTCSECT() \
  821. ReleaseMutex(hDriverObjectListMutex);
  822. #else //not winnt:
  823. #ifdef WIN16_SEPARATE
  824. #define INIT_DDRAW_CSECT() \
  825. ReinitializeCriticalSection( lpDDCS ); \
  826. MakeCriticalSectionGlobal( lpDDCS );
  827. #define FINI_DDRAW_CSECT() \
  828. DeleteCriticalSection( lpDDCS );
  829. #define ENTER_DDRAW() \
  830. DPF( 7, "*****%08lx ENTER_DDRAW: CNT = %ld," REMIND( "" ), GETCURRPID(), iDLLCSCnt ); \
  831. EnterCriticalSection( (LPCRITICAL_SECTION) lpDDCS ); \
  832. INCCSCNT(); \
  833. DPF( 7, "*****%08lx GOT DDRAW CSECT: CNT = %ld," REMIND(""), GETCURRPID(), iDLLCSCnt );
  834. #define LEAVE_DDRAW() \
  835. DECCSCNT() \
  836. DPF( 7, "*****%08lx LEAVE_DDRAW: CNT = %ld," REMIND( "" ), GETCURRPID(), iDLLCSCnt ); \
  837. LeaveCriticalSection( (LPCRITICAL_SECTION) lpDDCS );
  838. #else //not WIN16_SEPARATE
  839. #define INIT_DDRAW_CSECT()
  840. #define FINI_DDRAW_CSECT()
  841. #define ENTER_DDRAW() \
  842. DPF( 7, "*****%08lx ENTER_WIN16LOCK: CNT = %ld," REMIND( "" ), GETCURRPID(), iWin16Cnt ); \
  843. _EnterSysLevel( lpWin16Lock ); \
  844. INCW16CNT(); \
  845. DPF( 7, "*****%08lx GOT WIN16LOCK: CNT = %ld," REMIND(""), GETCURRPID(), iWin16Cnt );
  846. #define LEAVE_DDRAW() \
  847. DECW16CNT() \
  848. DPF( 7, "*****%08lx LEAVE_WIN16LOCK: CNT = %ld," REMIND( "" ), GETCURRPID(), iWin16Cnt ); \
  849. _LeaveSysLevel( lpWin16Lock );
  850. #endif //win16_separate
  851. #define ENTER_DRIVERLISTCSECT() \
  852. EnterCriticalSection( &csDriverObjectList );
  853. #define LEAVE_DRIVERLISTCSECT() \
  854. LeaveCriticalSection( &csDriverObjectList );
  855. #endif //winnt
  856. #endif //use csects
  857. extern DWORD gdwSetIME; // from ddraw.c
  858. // This macro is used to show/hide the IME outside of the ddraw critsect
  859. #define HIDESHOW_IME() \
  860. if (gdwSetIME) \
  861. { \
  862. SystemParametersInfo( \
  863. SPI_SETSHOWIMEUI, gdwSetIME - 1, NULL, 0); \
  864. \
  865. InterlockedExchange(&gdwSetIME, 0); \
  866. }
  867. #if defined(WIN95)
  868. /*
  869. * selector management functions
  870. */
  871. extern DWORD _stdcall MapLS( LPVOID ); // flat -> 16:16
  872. extern void _stdcall UnMapLS( DWORD ); // unmap 16:16
  873. extern LPVOID _stdcall MapSLFix( DWORD ); // 16:16->flat
  874. extern LPVOID _stdcall MapSL( DWORD ); // 16:16->flat
  875. //extern void _stdcall UnMapSLFix( LPVOID ); // 16:16->flat
  876. /*
  877. * win16 lock
  878. */
  879. extern void _stdcall GetpWin16Lock( LPVOID FAR *);
  880. extern void _stdcall _EnterSysLevel( LPVOID );
  881. extern void _stdcall _LeaveSysLevel( LPVOID );
  882. extern LPVOID lpWin16Lock;
  883. #endif win95
  884. #endif //is_32
  885. #ifdef WIN95
  886. #ifdef WIN16_SEPARATE
  887. #define ENTER_WIN16LOCK() \
  888. DPF( 7, "*****%08lx ENTER_WIN16LOCK: CNT = %ld," REMIND( "" ), GETCURRPID(), iWin16Cnt ); \
  889. _EnterSysLevel( lpWin16Lock ); \
  890. INCW16CNT(); \
  891. DPF( 7, "*****%08lx GOT WIN16LOCK: CNT = %ld," REMIND(""), GETCURRPID(), iWin16Cnt );
  892. #define LEAVE_WIN16LOCK() \
  893. DECW16CNT() \
  894. DPF( 7,"*****%08lx LEAVE_WIN16LOCK: CNT = %ld," REMIND( "" ), GETCURRPID(), iWin16Cnt ); \
  895. _LeaveSysLevel( lpWin16Lock );
  896. #else
  897. #define ENTER_WIN16LOCK() badbadbad
  898. #define LEAVE_WIN16LOCK() badbadbad
  899. #endif
  900. #else
  901. #define ENTER_WIN16LOCK()
  902. #define LEAVE_WIN16LOCK()
  903. #endif
  904. #ifdef WIN16_SEPARATE
  905. #define ENTER_BOTH() \
  906. ENTER_DDRAW(); \
  907. ENTER_WIN16LOCK();
  908. #define LEAVE_BOTH() \
  909. LEAVE_WIN16LOCK(); \
  910. LEAVE_DDRAW();
  911. #else
  912. #define ENTER_BOTH() \
  913. ENTER_DDRAW();
  914. #define LEAVE_BOTH() \
  915. LEAVE_DDRAW();
  916. #endif
  917. /* We now have a special case in dllmain on NT... */
  918. #ifndef ENTER_DDRAW_INDLLMAIN
  919. #define ENTER_DDRAW_INDLLMAIN() ENTER_DDRAW()
  920. #endif
  921. #ifdef WIN95
  922. /*
  923. * DDHELP's handle for communicating with the DirectSound VXD. We need this
  924. * when we are executing DDRAW code with one of DDHELP's threads.
  925. */
  926. extern HANDLE hHelperDDVxd;
  927. /*
  928. * Macro to return the DirectSound VXD handle to use when communicating with
  929. * the VXD. This is necessary as we need to communicate with the VXD from
  930. * DirectDraw executing on a DDHELP thread. In which case we need to use
  931. * the VXD handle defined above (which is the VXD handle DDHELP got when it
  932. * loaded DDRAW.VXD). Otherwise, we use the VXD handle out of the given
  933. * local object.
  934. *
  935. * NOTE: We don't use GETCURRPID() or HackGetCurrentProcessId() as we want
  936. * the real PID not one that has been munged.
  937. */
  938. #define GETDDVXDHANDLE( pdrv_lcl ) \
  939. ( ( GetCurrentProcessId() == ( pdrv_lcl )->dwProcessId ) ? (HANDLE) ( ( pdrv_lcl )->hDDVxd ) : hHelperDDVxd )
  940. #else /* !WIN95 */
  941. #define GETDDVXDHANDLE( pdrv_lcl ) NULL
  942. #endif /* !WIN95 */
  943. #define VDPF(Args) DPF Args
  944. #include "ddheap.h"
  945. #include "ddagp.h"
  946. /* apphack.c */
  947. extern void FreeAppHackData(void);
  948. /* cliprgn.h */
  949. extern void ClipRgnToRect( LPRECT prect, LPRGNDATA prd );
  950. /* ddcsurf.c */
  951. extern BOOL isPowerOf2(DWORD dw, int* pPower);
  952. extern HRESULT checkSurfaceDesc( LPDDSURFACEDESC2 lpsd, LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD FAR *psflags, BOOL emulation, BOOL real_sysmem, LPDDRAWI_DIRECTDRAW_INT pdrv_int );
  953. extern DWORD ComputePitch( LPDDRAWI_DIRECTDRAW_GBL thisg, DWORD caps, DWORD width, UINT bpp );
  954. extern DWORD GetBytesFromPixels( DWORD pixels, UINT bpp );
  955. extern HRESULT createsurfaceEx(LPDDRAWI_DDRAWSURFACE_LCL lpSurfLcl);
  956. #ifdef WINNT
  957. extern BOOL WINAPI CompleteCreateSysmemSurface(LPDDRAWI_DDRAWSURFACE_LCL lpSurfLcl);
  958. #endif
  959. // modified and moved to dx8priv.h
  960. // extern HRESULT InternalCreateSurface( LPDDRAWI_DIRECTDRAW_LCL thisg, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lplpDDSurface, LPDDRAWI_DIRECTDRAW_INT this_int );
  961. extern HRESULT AllocSurfaceMem( LPDDRAWI_DIRECTDRAW_LCL this_lcl, LPDDRAWI_DDRAWSURFACE_LCL *slist, int nsurf );
  962. #ifdef DEBUG
  963. void SurfaceSanityTest( LPDDRAWI_DIRECTDRAW_LCL pdrv, LPSTR title );
  964. #define SURFSANITY( a,b ) SurfaceSanityTest( a, b );
  965. #else
  966. #define SURFSANITY( a,b )
  967. #endif
  968. /* ddclip.c */
  969. extern HRESULT InternalCreateClipper( LPDDRAWI_DIRECTDRAW_GBL lpDD, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter, BOOL fInitialized, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl, LPDDRAWI_DIRECTDRAW_INT pdrv_int );
  970. void ProcessClipperCleanup( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  971. /* ddcreate.c */
  972. extern BOOL IsVGADevice(LPSTR szDevice);
  973. extern char g_szPrimaryDisplay[];
  974. extern BOOL xxxEnumDisplayDevicesA(LPVOID lpUnused, DWORD iDevice, struct _DISPLAY_DEVICEA *pdd, DWORD dwFlags);
  975. extern BOOL CurrentProcessCleanup( BOOL );
  976. extern LPHEAPALIGNMENT GetExtendedHeapAlignment( LPDDRAWI_DIRECTDRAW_GBL pddd , LPDDHAL_GETHEAPALIGNMENTDATA pghad, int iHeap);
  977. extern void RemoveDriverFromList( LPDDRAWI_DIRECTDRAW_INT lpDD, BOOL );
  978. extern void RemoveLocalFromList( LPDDRAWI_DIRECTDRAW_LCL lpDD_lcl );
  979. extern LPDDRAWI_DIRECTDRAW_GBL DirectDrawObjectCreate( LPDDHALINFO lpDDHALInfo, BOOL reset, LPDDRAWI_DIRECTDRAW_GBL pdrv, HANDLE hDDVxd, char *szDrvName, DWORD dwDriverContext, DWORD dwLocalFlags );
  980. extern LPDDRAWI_DIRECTDRAW_GBL FetchDirectDrawData( LPDDRAWI_DIRECTDRAW_GBL pdrv, BOOL reset, DWORD hInstance, HANDLE hDDVxd, char *szDrvName, DWORD dwDriverContext, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  981. extern LPVOID NewDriverInterface( LPDDRAWI_DIRECTDRAW_GBL pdrv, LPVOID lpvtbl );
  982. extern DWORD DirectDrawMsg(LPSTR msg);
  983. extern BOOL DirectDrawSupported( BOOL bDisplayMessage );
  984. extern BOOL IsMultiMonitor( void );
  985. extern LPDDRAWI_DIRECTDRAW_GBL fetchModeXData(LPDDRAWI_DIRECTDRAW_GBL pdrv,LPDDHALMODEINFO pmi, HANDLE hDDVxd );
  986. #ifdef WINNT
  987. extern BOOL GetCurrentMode(LPDDRAWI_DIRECTDRAW_GBL, LPDDHALINFO lpHalInfo, char *szDrvName);
  988. extern HRESULT GetNTDeviceRect( LPSTR pDriverName, LPRECT lpRect );
  989. extern void CheckAliasedLocksOnModeChange( void );
  990. extern void NotifyDriverOfFreeAliasedLocks( void );
  991. extern void NotifyDriverToDeferFrees( void );
  992. #endif
  993. extern HDC DD_CreateDC(LPSTR pdrvname);
  994. extern void DD_DoneDC(HDC hdc);
  995. #ifdef IS_32
  996. extern LONG xxxChangeDisplaySettingsExA(LPCSTR szDevice, LPDEVMODEA pdm, HWND hwnd, DWORD dwFlags,LPVOID lParam);
  997. // modified and moved to dx8priv.h
  998. //extern HRESULT InternalDirectDrawCreate( GUID * lpGUID, LPDIRECTDRAW *lplpDD, LPDDRAWI_DIRECTDRAW_INT pnew_int, DWORD dwFlags );
  999. extern void UpdateRectFromDevice( LPDDRAWI_DIRECTDRAW_GBL pdrv );
  1000. extern void UpdateAllDeviceRects( void );
  1001. #endif
  1002. /* ddiunk.c */
  1003. extern HRESULT InitD3D( LPDDRAWI_DIRECTDRAW_INT this_int );
  1004. extern HRESULT InitDDrawPrivateD3DContext( LPDDRAWI_DIRECTDRAW_INT this_int );
  1005. /* dddefwp.c */
  1006. extern HRESULT SetAppHWnd( LPDDRAWI_DIRECTDRAW_LCL thisg, HWND hWnd, DWORD dwFlags );
  1007. extern VOID CleanupWindowList( DWORD pid );
  1008. extern void ClipTheCursor(LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl, LPRECT lpRect);
  1009. /* ddesurf.c */
  1010. extern void FillDDSurfaceDesc( LPDDRAWI_DDRAWSURFACE_LCL psurf, LPDDSURFACEDESC lpdsd );
  1011. extern void FillDDSurfaceDesc2( LPDDRAWI_DDRAWSURFACE_LCL psurf, LPDDSURFACEDESC2 lpdsd );
  1012. extern void FillEitherDDSurfaceDesc( LPDDRAWI_DDRAWSURFACE_LCL psurf, LPDDSURFACEDESC2 lpdsd );
  1013. /* ddfake.c */
  1014. extern BOOL getBitMask( LPDDHALMODEINFO pmi );
  1015. extern LPDDRAWI_DIRECTDRAW_GBL FakeDDCreateDriverObject( HDC hdc_dd, LPSTR szDrvName, LPDDRAWI_DIRECTDRAW_GBL, BOOL reset, HANDLE hDDVxd );
  1016. extern DWORD BuildModes( LPSTR szDevice, LPDDHALMODEINFO FAR *ppddhmi );
  1017. extern void BuildPixelFormat(HDC, LPDDHALMODEINFO, LPDDPIXELFORMAT);
  1018. /* ddpal.c */
  1019. extern void ResetSysPalette( LPDDRAWI_DDRAWSURFACE_GBL psurf, BOOL dofree );
  1020. extern void ProcessPaletteCleanup( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1021. extern ULONG DDAPI InternalPaletteRelease( LPDDRAWI_DDRAWPALETTE_INT this_int );
  1022. extern HRESULT SetPaletteAlways( LPDDRAWI_DDRAWSURFACE_INT psurf_int, LPDIRECTDRAWPALETTE lpDDPalette );
  1023. /* ddraw.c */
  1024. extern void DoneExclusiveMode( LPDDRAWI_DIRECTDRAW_LCL pdrv );
  1025. extern void StartExclusiveMode( LPDDRAWI_DIRECTDRAW_LCL pdrv, DWORD dwFlags, DWORD pid );
  1026. extern HRESULT FlipToGDISurface( LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl, LPDDRAWI_DDRAWSURFACE_INT psurf_int); //, FLATPTR fpprim );
  1027. extern void CheckExclusiveMode(LPDDRAWI_DIRECTDRAW_LCL this_lcl, LPBOOL pbExclusiveExists, LPBOOL pbThisLclOwnsExclusive, BOOL bKeepMutex, HWND hwnd, BOOL bCanGetIt);
  1028. /* ddsacc.c */
  1029. void WINAPI AcquireDDThreadLock(void);
  1030. void WINAPI ReleaseDDThreadLock(void);
  1031. extern void RemoveProcessLocks( LPDDRAWI_DIRECTDRAW_LCL pdrv, LPDDRAWI_DDRAWSURFACE_LCL this_lcl, DWORD pid );
  1032. extern HRESULT InternalLock( LPDDRAWI_DDRAWSURFACE_LCL thisx, LPVOID *pbits,
  1033. LPRECT lpDestRect, DWORD dwFlags);
  1034. extern HRESULT InternalUnlock( LPDDRAWI_DDRAWSURFACE_LCL thisx, LPVOID lpSurfaceData, LPRECT lpDestRect, DWORD dwFlags );
  1035. #ifdef USE_ALIAS
  1036. extern void BreakSurfaceLocks( LPDDRAWI_DDRAWSURFACE_GBL thisg );
  1037. #endif /* USE_ALIAS */
  1038. /* ddsatch.c */
  1039. extern void UpdateMipMapCount( LPDDRAWI_DDRAWSURFACE_INT psurf_int );
  1040. extern HRESULT AddAttachedSurface( LPDDRAWI_DDRAWSURFACE_INT psurf_from, LPDDRAWI_DDRAWSURFACE_INT psurf_to, BOOL implicit );
  1041. extern void DeleteAttachedSurfaceLists( LPDDRAWI_DDRAWSURFACE_LCL psurf );
  1042. #define DOA_DONTDELETEIMPLICIT FALSE
  1043. #define DOA_DELETEIMPLICIT TRUE
  1044. extern HRESULT DeleteOneAttachment( LPDDRAWI_DDRAWSURFACE_INT this_int, LPDDRAWI_DDRAWSURFACE_INT pattsurf_int, BOOL cleanup, BOOL delete_implicit );
  1045. extern HRESULT DeleteOneLink( LPDDRAWI_DDRAWSURFACE_INT this_int, LPDDRAWI_DDRAWSURFACE_INT pattsurf_int );
  1046. /* ddsblt.c */
  1047. extern void WaitForDriverToFinishWithSurface(LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl, LPDDRAWI_DDRAWSURFACE_LCL this_lcl );
  1048. extern LPDDRAWI_DDRAWSURFACE_LCL FindAttached( LPDDRAWI_DDRAWSURFACE_LCL ptr, DWORD caps );
  1049. extern HRESULT XformRect(RECT * prcSrc,RECT * prcDest,RECT * prcClippedDest,RECT * prcClippedSrc,DWORD scale_x,DWORD scale_y);
  1050. // SCALE_X and SCALE_Y are fixed point variables scaled 16.16. These macros used by calls to XformRect.
  1051. #define SCALE_X(rcSrc,rcDest) ( ((rcSrc.right - rcSrc.left) << 16) / (rcDest.right - rcDest.left))
  1052. #define SCALE_Y(rcSrc,rcDest) ( ((rcSrc.bottom - rcSrc.top) << 16) / (rcDest.bottom - rcDest.top))
  1053. /* ddsckey.c */
  1054. extern HRESULT CheckColorKey( DWORD dwFlags, LPDDRAWI_DIRECTDRAW_GBL pdrv, LPDDCOLORKEY lpDDColorKey, LPDWORD psflags, BOOL halonly, BOOL helonly );
  1055. extern HRESULT ChangeToSoftwareColorKey( LPDDRAWI_DDRAWSURFACE_INT this_int, BOOL );
  1056. /* ddsiunk.c */
  1057. extern LPDDRAWI_DDRAWSURFACE_LCL NewSurfaceLocal( LPDDRAWI_DDRAWSURFACE_LCL thisx, LPVOID lpvtbl );
  1058. extern LPDDRAWI_DDRAWSURFACE_INT NewSurfaceInterface( LPDDRAWI_DDRAWSURFACE_LCL thisx, LPVOID lpvtbl );
  1059. extern void DestroySurface( LPDDRAWI_DDRAWSURFACE_LCL thisg );
  1060. extern void LooseManagedSurface( LPDDRAWI_DDRAWSURFACE_LCL thisg );
  1061. extern DWORD InternalSurfaceRelease( LPDDRAWI_DDRAWSURFACE_INT this_int, BOOL bLightweight, BOOL bDX8 );
  1062. extern void ProcessSurfaceCleanup( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1063. extern void FreeD3DSurfaceIUnknowns( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1064. /* ddmode.c */
  1065. extern HRESULT SetDisplayMode( LPDDRAWI_DIRECTDRAW_LCL thisx, DWORD modeidx, BOOL force, BOOL useRefreshRate );
  1066. extern HRESULT RestoreDisplayMode( LPDDRAWI_DIRECTDRAW_LCL thisx, BOOL force );
  1067. extern void AddModeXModes( LPDDRAWI_DIRECTDRAW_GBL pdrv );
  1068. extern BOOL MonitorCanHandleMode(LPDDRAWI_DIRECTDRAW_GBL pddd, DWORD width, DWORD height, WORD refreshRate );
  1069. extern BOOL GetDDStereoMode( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD dwWidth, DWORD dwHeight, DWORD dwBpp, DWORD dwRefreshRate);
  1070. /* ddsurf.c */
  1071. extern HRESULT InternalGetBltStatus(LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl, LPDDRAWI_DDRAWSURFACE_LCL this_lcl , DWORD dwFlags );
  1072. extern HRESULT MoveToSystemMemory( LPDDRAWI_DDRAWSURFACE_INT this_int, BOOL hasvram, BOOL use_full_lock );
  1073. extern void InvalidateAllPrimarySurfaces( LPDDRAWI_DIRECTDRAW_GBL );
  1074. extern LPDDRAWI_DDRAWSURFACE_GBL FindGlobalPrimary( LPDDRAWI_DIRECTDRAW_GBL );
  1075. extern BOOL MatchPrimary( LPDDRAWI_DIRECTDRAW_GBL thisg, LPDDSURFACEDESC2 lpDDSD );
  1076. extern void InvalidateAllSurfaces( LPDDRAWI_DIRECTDRAW_GBL thisg, HANDLE hDDVxd, BOOL fRebuildAliases );
  1077. #ifdef SHAREDZ
  1078. extern LPDDRAWI_DDRAWSURFACE_GBL FindGlobalZBuffer( LPDDRAWI_DIRECTDRAW_GBL );
  1079. extern LPDDRAWI_DDRAWSURFACE_GBL FindGlobalBackBuffer( LPDDRAWI_DIRECTDRAW_GBL );
  1080. extern BOOL MatchSharedZBuffer( LPDDRAWI_DIRECTDRAW_GBL thisg, LPDDSURFACEDESC lpDDSD );
  1081. extern BOOL MatchSharedBackBuffer( LPDDRAWI_DIRECTDRAW_GBL thisg, LPDDSURFACEDESC lpDDSD );
  1082. #endif
  1083. extern HRESULT InternalPageLock( LPDDRAWI_DDRAWSURFACE_LCL this_lcl, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1084. extern HRESULT InternalPageUnlock( LPDDRAWI_DDRAWSURFACE_LCL this_lcl, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1085. extern LPDDRAWI_DDRAWSURFACE_INT getDDSInterface( LPDDRAWI_DIRECTDRAW_GBL pdrv, LPDDRAWI_DDRAWSURFACE_LCL this_lcl, LPVOID lpddcb );
  1086. extern HRESULT InternalGetDC( LPDDRAWI_DDRAWSURFACE_INT this_int, HDC FAR *lphdc
  1087. #ifdef WIN95
  1088. , BOOL bWin16Lock
  1089. #endif //WIN95
  1090. );
  1091. extern HRESULT InternalReleaseDC( LPDDRAWI_DDRAWSURFACE_LCL this_lcl, HDC hdc
  1092. #ifdef WIN95
  1093. , BOOL bWin16Lock
  1094. #endif //WIN95
  1095. );
  1096. extern HRESULT EXTERN_DDAPI GetSurfaceFromDC( HDC hdc, LPDIRECTDRAWSURFACE *ppdds, HDC *phdcDriver );
  1097. extern HRESULT InternalAssociateDC( HDC hdc, LPDDRAWI_DDRAWSURFACE_LCL pdds_lcl );
  1098. extern HRESULT InternalRemoveDCFromList( HDC hdc, LPDDRAWI_DDRAWSURFACE_LCL pdds_lcl );
  1099. // ddgdi32.c
  1100. #ifdef WIN95
  1101. extern void CleanupD3D8( LPDDRAWI_DIRECTDRAW_GBL pdrv, BOOL bDestroyAll, DWORD PID);
  1102. #endif
  1103. // function from ddsprite.c to clean pid from master sprite list:
  1104. void ProcessSpriteCleanup(LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid);
  1105. #ifdef WIN95
  1106. extern void UpdateOutstandingDC( LPDDRAWI_DDRAWSURFACE_LCL psurf_lcl, LPDDRAWI_DDRAWPALETTE_GBL ppal_gbl );
  1107. extern void UpdateDCOnPaletteChanges( LPDDRAWI_DDRAWPALETTE_GBL ppal_gbl );
  1108. #else
  1109. #define UpdateOutstandingDC(x,y)
  1110. #define UpdateDCOnPaletteChanges(x)
  1111. #endif
  1112. #ifdef USE_ALIAS
  1113. /* ddalias.c */
  1114. extern HRESULT CreateHeapAliases( HANDLE hvxd, LPDDRAWI_DIRECTDRAW_GBL pdrv );
  1115. extern BOOL ReleaseHeapAliases( HANDLE hvxd, LPHEAPALIASINFO phaiInfo );
  1116. extern HRESULT MapHeapAliasesToVidMem( HANDLE hvxd, LPHEAPALIASINFO phaiInfo );
  1117. extern HRESULT MapHeapAliasesToDummyMem( HANDLE hvxd, LPHEAPALIASINFO phaiInfo );
  1118. extern FLATPTR GetAliasedVidMem( LPDDRAWI_DIRECTDRAW_LCL pdrv,
  1119. LPDDRAWI_DDRAWSURFACE_LCL surf_lcl,
  1120. FLATPTR fpVidMem );
  1121. #endif /* USE_ALIAS */
  1122. /* dllmain.c */
  1123. extern BOOL RemoveProcessFromDLL( DWORD pid );
  1124. /* misc.c */
  1125. extern BOOL CanBeFlippable( LPDDRAWI_DDRAWSURFACE_LCL thisg, LPDDRAWI_DDRAWSURFACE_LCL this_attach);
  1126. extern LPDDRAWI_DDRAWSURFACE_INT FindAttachedFlip( LPDDRAWI_DDRAWSURFACE_INT thisg );
  1127. extern LPDDRAWI_DDRAWSURFACE_INT FindAttachedSurfaceLeft( LPDDRAWI_DDRAWSURFACE_INT thisg );
  1128. extern LPDDRAWI_DDRAWSURFACE_INT FindAttachedMipMap( LPDDRAWI_DDRAWSURFACE_INT thisg );
  1129. extern LPDDRAWI_DDRAWSURFACE_INT FindParentMipMap( LPDDRAWI_DDRAWSURFACE_INT thisg );
  1130. #ifdef WIN95
  1131. extern HANDLE GetDXVxdHandle( void );
  1132. #endif /* WIN95 */
  1133. /* ddcallbk.c */
  1134. extern void InitCallbackTables( void );
  1135. extern BOOL CallbackTablesInitialized( void );
  1136. /* ddvp.c */
  1137. extern void ProcessVideoPortCleanup( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1138. extern HRESULT InternalStopVideo( LPDDRAWI_DDVIDEOPORT_INT this_int );
  1139. extern LPDDRAWI_DDVIDEOPORT_LCL GetVideoPortFromSurface( LPDDRAWI_DDRAWSURFACE_INT surf_int );
  1140. extern DWORD IsValidAutoFlipSurface( LPDDRAWI_DDRAWSURFACE_INT lpSurface_int );
  1141. #define IVAS_NOAUTOFLIPPING 0
  1142. #define IVAS_SOFTWAREAUTOFLIPPING 1
  1143. #define IVAS_HARDWAREAUTOFLIPPING 2
  1144. extern VOID RequireSoftwareAutoflip( LPDDRAWI_DDRAWSURFACE_INT lpSurface_int );
  1145. extern VOID SetRingZeroSurfaceData( LPDDRAWI_DDRAWSURFACE_LCL lpSurface_lcl );
  1146. extern DWORD FlipVideoPortSurface( LPDDRAWI_DDRAWSURFACE_INT , DWORD );
  1147. extern VOID OverrideOverlay( LPDDRAWI_DDRAWSURFACE_INT lpSurf_int, LPDWORD lpdwFlags );
  1148. extern BOOL MustSoftwareBob( LPDDRAWI_DDRAWSURFACE_INT lpSurf_int );
  1149. extern VOID RequireSoftwareBob( LPDDRAWI_DDRAWSURFACE_INT lpSurface_int );
  1150. extern VOID DecrementRefCounts( LPDDRAWI_DDRAWSURFACE_INT surf_int );
  1151. /* ddcolor.c */
  1152. extern VOID ReleaseColorControl( LPDDRAWI_DDRAWSURFACE_LCL lpSurface );
  1153. /* ddgamma.c */
  1154. extern VOID ReleaseGammaControl( LPDDRAWI_DDRAWSURFACE_LCL lpSurface );
  1155. extern BOOL SetGamma( LPDDRAWI_DDRAWSURFACE_LCL this_lcl, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1156. extern VOID RestoreGamma( LPDDRAWI_DDRAWSURFACE_LCL lpSurface, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1157. extern VOID InitGamma( LPDDRAWI_DIRECTDRAW_GBL pdrv, LPSTR szDrvName );
  1158. /* ddkernel.c */
  1159. extern HRESULT InternalReleaseKernelSurfaceHandle( LPDDRAWI_DDRAWSURFACE_LCL lpSurface, BOOL bLosingSurface );
  1160. extern HRESULT InternalCreateKernelSurfaceHandle( LPDDRAWI_DDRAWSURFACE_LCL lpSurface, PULONG_PTR lpHandle );
  1161. extern HRESULT UpdateKernelSurface( LPDDRAWI_DDRAWSURFACE_LCL lpSurface );
  1162. extern HRESULT UpdateKernelVideoPort( LPDDRAWI_DDVIDEOPORT_LCL lpVideoPort, DWORD dwFlags );
  1163. extern HRESULT GetKernelFieldNum( LPDDRAWI_DDVIDEOPORT_LCL lpVideoPort, LPDWORD lpdwFieldNum );
  1164. extern HRESULT SetKernelFieldNum( LPDDRAWI_DDVIDEOPORT_LCL lpVideoPort, DWORD dwFieldNum );
  1165. extern HRESULT SetKernelSkipPattern( LPDDRAWI_DDVIDEOPORT_LCL lpVideoPort, DWORD dwStartField, DWORD dwPatternSize, DWORD dwPattern );
  1166. extern HRESULT InitKernelInterface( LPDDRAWI_DIRECTDRAW_LCL lpDD );
  1167. extern HRESULT GetKernelSurfaceState( LPDDRAWI_DDRAWSURFACE_LCL lpSurf, LPDWORD lpdwStateFlags );
  1168. extern HRESULT ReleaseKernelInterface( LPDDRAWI_DIRECTDRAW_LCL lpDD );
  1169. extern BOOL CanSoftwareAutoflip( LPDDRAWI_DDVIDEOPORT_LCL lpVideoPort );
  1170. extern BOOL IsKernelInterfaceSupported( LPDDRAWI_DIRECTDRAW_LCL lpDD );
  1171. extern HRESULT SetKernelDOSBoxEvent( LPDDRAWI_DIRECTDRAW_LCL lpDD );
  1172. extern VOID EnableAutoflip( LPDDRAWI_DDVIDEOPORT_LCL lpVideoPort, BOOL bEnable );
  1173. extern BOOL IsWindows98( VOID );
  1174. /* ddmc.c */
  1175. extern BOOL IsMotionCompSupported( LPDDRAWI_DIRECTDRAW_LCL this_lcl );
  1176. extern void ProcessMotionCompCleanup( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl );
  1177. /* private.c */
  1178. extern void FreeAllPrivateData(LPPRIVATEDATANODE * ppListHead);
  1179. /* factory.c */
  1180. extern HRESULT InternalCreateDDFactory2(void **, IUnknown * pUnkOuter);
  1181. // ddrestor.c
  1182. extern HRESULT AllocSurfaceContents(LPDDRAWI_DDRAWSURFACE_LCL this_lcl);
  1183. extern void FreeSurfaceContents(LPDDRAWI_DDRAWSURFACE_LCL this_lcl);
  1184. extern HRESULT BackupSurfaceContents(LPDDRAWI_DDRAWSURFACE_LCL this_lcl);
  1185. extern HRESULT RestoreSurfaceContents(LPDDRAWI_DDRAWSURFACE_LCL this_lcl);
  1186. extern void BackupAllSurfaces(LPDDRAWI_DIRECTDRAW_GBL this_gbl);
  1187. extern void MungeAutoflipCaps(LPDDRAWI_DIRECTDRAW_GBL pdrv);
  1188. /* ddrefrsh.c */
  1189. extern HRESULT DDGetMonitorInfo( LPDDRAWI_DIRECTDRAW_INT lpDD_int);
  1190. extern void MassageModeTable(LPDDRAWI_DIRECTDRAW_GBL);
  1191. extern HRESULT ExpandModeTable( LPDDRAWI_DIRECTDRAW_GBL pddd );
  1192. extern BOOL CanMonitorHandleRefreshRate( LPDDRAWI_DIRECTDRAW_GBL pddd, DWORD dwWidth, DWORD dwHeight, int wRefresh );
  1193. /* drvinfo.c */
  1194. extern BOOL Voodoo1GoodToGo( GUID * pGuid );
  1195. extern HRESULT InternalGetDeviceIdentifier7( LPDIRECTDRAW lpDD, LPDDDEVICEIDENTIFIER2 pDI, DWORD dwFlags, BOOL bWHQL);
  1196. /* A handy one from ddhel.c */
  1197. /* DDRAW16 doesn't need this. */
  1198. #ifdef WIN32
  1199. SCODE InitDIB(HDC hdc, LPBITMAPINFO lpbmi);
  1200. #endif
  1201. void ResetBITMAPINFO(LPDDRAWI_DIRECTDRAW_GBL thisg);
  1202. BOOL doPixelFormatsMatch(LPDDPIXELFORMAT lpddpf1,
  1203. LPDDPIXELFORMAT lpddpf2);
  1204. HRESULT ConvertToPhysColor(LPDDRAWI_DDRAWSURFACE_LCL surf_lcl, LPDDARGB pSource, LPDWORD pdwPhysColor);
  1205. HRESULT ConvertFromPhysColor(LPDDRAWI_DDRAWSURFACE_LCL surf_lcl, LPDWORD pdwPhysColor, LPDDARGB pDest);
  1206. extern DWORD GetSurfPFIndex(LPDDRAWI_DDRAWSURFACE_LCL surf_lcl);
  1207. extern DWORD GetDxtBlkSize(DWORD dwFourCC);
  1208. /*
  1209. * HEL's public memory allocator
  1210. */
  1211. extern void HELFreeSurfaceSysMem(LPDDRAWI_DDRAWSURFACE_LCL lpsurf_lcl);
  1212. extern LPVOID HELAllocateSurfaceSysMem(LPDDRAWI_DDRAWSURFACE_LCL lpsurf_lcl, DWORD nWidth,
  1213. DWORD nHeight, LPDWORD lpdwSurfaceSize, LPLONG lpSurfPitch );
  1214. #ifndef NO_DDHELP
  1215. /* w95hack.c */
  1216. extern DWORD HackGetCurrentProcessId( void );
  1217. extern BOOL DDAPI DDNotify( LPDDHELPDATA phd );
  1218. extern void DDAPI DDNotifyModeSet( LPDDRAWI_DIRECTDRAW_GBL );
  1219. extern void DDAPI DDNotifyDOSBox( LPDDRAWI_DIRECTDRAW_GBL );
  1220. #endif //NO_DDHELP
  1221. #ifdef POSTPONED
  1222. /* Delegating IUnknown functions */
  1223. extern HRESULT EXTERN_DDAPI DD_DelegatingQueryInterface(LPDIRECTDRAW, REFIID, LPVOID FAR *);
  1224. extern DWORD EXTERN_DDAPI DD_DelegatingAddRef( LPDIRECTDRAW lpDD );
  1225. extern DWORD EXTERN_DDAPI DD_DelegatingRelease( LPDIRECTDRAW lpDD );
  1226. #endif
  1227. /* DirectDrawFactory2 functions */
  1228. extern HRESULT EXTERN_DDAPI DDFac2_QueryInterface(LPDIRECTDRAWFACTORY2, REFIID, LPVOID FAR *);
  1229. extern DWORD EXTERN_DDAPI DDFac2_AddRef( LPDIRECTDRAWFACTORY2 lpDDFac );
  1230. extern ULONG EXTERN_DDAPI DDFac2_Release( LPDIRECTDRAWFACTORY2 lpDDFac );
  1231. extern HRESULT EXTERN_DDAPI DDFac2_CreateDirectDraw(LPDIRECTDRAWFACTORY2, GUID FAR *, HWND, DWORD dwCoopLevelFlags, DWORD, IUnknown *, struct IDirectDraw4 ** );
  1232. #ifdef IS_32
  1233. #ifdef SM_CMONITORS
  1234. extern HRESULT EXTERN_DDAPI DDFac2_DirectDrawEnumerate(LPDIRECTDRAWFACTORY2 , LPDDENUMCALLBACKEX , LPVOID , DWORD );
  1235. #else
  1236. /*
  1237. * This def'n is a hack to keep us building under NT build which doesn't have the
  1238. * multimon headers in it yet
  1239. */
  1240. extern HRESULT EXTERN_DDAPI DDFac2_DirectDrawEnumerate(LPDIRECTDRAWFACTORY2 , LPDDENUMCALLBACK , LPVOID , DWORD );
  1241. #endif
  1242. #endif
  1243. /* DIRECTDRAW functions */
  1244. extern HRESULT EXTERN_DDAPI DD_UnInitedQueryInterface( LPDIRECTDRAW lpDD, REFIID riid, LPVOID FAR * ppvObj );
  1245. extern HRESULT EXTERN_DDAPI DD_QueryInterface( LPDIRECTDRAW lpDD, REFIID riid, LPVOID FAR * ppvObj );
  1246. extern DWORD EXTERN_DDAPI DD_AddRef( LPDIRECTDRAW lpDD );
  1247. extern DWORD EXTERN_DDAPI DD_Release( LPDIRECTDRAW lpDD );
  1248. extern HRESULT EXTERN_DDAPI DD_Compact( LPDIRECTDRAW lpDD );
  1249. extern HRESULT EXTERN_DDAPI DD_CreateClipper( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter );
  1250. extern HRESULT EXTERN_DDAPI DD_CreatePalette( LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter );
  1251. extern HRESULT EXTERN_DDAPI DD_CreateSurface( LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *pUnkOuter );
  1252. extern HRESULT EXTERN_DDAPI DD_CreateSurface4( LPDIRECTDRAW lpDD, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *pUnkOuter );
  1253. extern HRESULT EXTERN_DDAPI DD_DuplicateSurface( LPDIRECTDRAW lpDD, LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE FAR *lplpDupDDSurface );
  1254. extern HRESULT EXTERN_DDAPI DD_EnumDisplayModes( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback );
  1255. extern HRESULT EXTERN_DDAPI DD_EnumDisplayModes4( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback );
  1256. extern HRESULT EXTERN_DDAPI DD_EnumSurfaces( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumCallback );
  1257. extern HRESULT EXTERN_DDAPI DD_EnumSurfaces4( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumCallback );
  1258. extern HRESULT EXTERN_DDAPI DD_FlipToGDISurface( LPDIRECTDRAW lpDD );
  1259. extern HRESULT EXTERN_DDAPI DD_GetCaps( LPDIRECTDRAW lpDD, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpHELCaps );
  1260. extern HRESULT EXTERN_DDAPI DD_GetColorKey( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey );
  1261. extern HRESULT EXTERN_DDAPI DD_GetDisplayMode( LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpSurfaceDesc );
  1262. extern HRESULT EXTERN_DDAPI DD_GetFourCCCodes(LPDIRECTDRAW,DWORD FAR *,DWORD FAR *);
  1263. extern HRESULT EXTERN_DDAPI DD_GetGDISurface( LPDIRECTDRAW lpDD, LPDIRECTDRAWSURFACE FAR * );
  1264. extern HRESULT EXTERN_DDAPI DD_GetScanLine( LPDIRECTDRAW lpDD, LPDWORD );
  1265. extern HRESULT EXTERN_DDAPI DD_GetVerticalBlankStatus( LPDIRECTDRAW lpDD, BOOL FAR * );
  1266. extern HRESULT EXTERN_DDAPI DD_Initialize(LPDIRECTDRAW, GUID FAR *);
  1267. extern HRESULT EXTERN_DDAPI DD_SetColorKey( LPDIRECTDRAW lpDD, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey );
  1268. extern HRESULT EXTERN_DDAPI DD_SetCooperativeLevel(LPDIRECTDRAW,HWND,DWORD);
  1269. extern HRESULT EXTERN_DDAPI DD_SetDisplayMode(LPDIRECTDRAW,DWORD,DWORD,DWORD);
  1270. extern HRESULT EXTERN_DDAPI DD_SetDisplayMode2(LPDIRECTDRAW,DWORD,DWORD,DWORD,DWORD,DWORD);
  1271. extern HRESULT EXTERN_DDAPI DD_RestoreDisplayMode(LPDIRECTDRAW);
  1272. extern HRESULT EXTERN_DDAPI DD_GetMonitorFrequency( LPDIRECTDRAW lpDD, LPDWORD lpdwFrequency);
  1273. extern HRESULT EXTERN_DDAPI DD_WaitForVerticalBlank( LPDIRECTDRAW lpDD, DWORD dwFlags, HANDLE hEvent );
  1274. extern HRESULT EXTERN_DDAPI DD_GetAvailableVidMem( LPDIRECTDRAW lpDD, LPDDSCAPS lpDDSCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree );
  1275. extern HRESULT EXTERN_DDAPI DD_GetAvailableVidMem4( LPDIRECTDRAW lpDD, LPDDSCAPS2 lpDDSCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree );
  1276. extern HRESULT EXTERN_DDAPI DD_GetSurfaceFromDC( LPDIRECTDRAW lpDD, HDC, LPDIRECTDRAWSURFACE *);
  1277. extern HRESULT EXTERN_DDAPI DD_RestoreAllSurfaces( LPDIRECTDRAW lpDD );
  1278. extern HRESULT EXTERN_DDAPI DD_GetDeviceIdentifier( LPDIRECTDRAW lpDD, LPDDDEVICEIDENTIFIER, DWORD);
  1279. extern HRESULT EXTERN_DDAPI DD_GetDeviceIdentifier7( LPDIRECTDRAW lpDD, LPDDDEVICEIDENTIFIER2, DWORD);
  1280. extern HRESULT EXTERN_DDAPI DD_StartModeTest( LPDIRECTDRAW7 lpDD, LPSIZE lpModesToTest, DWORD dwNumEntries, DWORD dwFlags );
  1281. extern HRESULT EXTERN_DDAPI DD_EvaluateMode( LPDIRECTDRAW7 lpDD, DWORD dwFlags, DWORD *pSecondsUntilTimeout);
  1282. #ifdef IS_32
  1283. //streaming stuff confuses ddraw16
  1284. #ifndef __cplusplus
  1285. extern HRESULT EXTERN_DDAPI DD_CreateSurfaceFromStream( LPDIRECTDRAW4 lpDD, IStream *, LPDDSURFACEDESC2, DWORD, LPDIRECTDRAWSURFACE4 *, IUnknown *);
  1286. extern HRESULT EXTERN_DDAPI DD_CreateSurfaceFromFile( LPDIRECTDRAW4 lpDD, BSTR, LPDDSURFACEDESC2, DWORD, LPDIRECTDRAWSURFACE4 *, IUnknown *);
  1287. #endif
  1288. #endif
  1289. extern HRESULT EXTERN_DDAPI DD_CreateOptSurface( LPDIRECTDRAW, LPDDOPTSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *pUnkOuter);
  1290. extern HRESULT EXTERN_DDAPI DD_ListOptSurfaceGUIDS(LPDIRECTDRAW, DWORD *, LPGUID);
  1291. extern HRESULT EXTERN_DDAPI DD_CanOptimizeSurface(LPDIRECTDRAW, LPDDSURFACEDESC2, LPDDOPTSURFACEDESC, BOOL FAR *);
  1292. extern HRESULT EXTERN_DDAPI DD_TestCooperativeLevel(LPDIRECTDRAW);
  1293. /* DIRECTDRAWPALETTE functions */
  1294. extern HRESULT EXTERN_DDAPI DD_Palette_QueryInterface( LPDIRECTDRAWPALETTE lpDDPalette, REFIID riid, LPVOID FAR * ppvObj );
  1295. extern DWORD EXTERN_DDAPI DD_Palette_AddRef( LPDIRECTDRAWPALETTE lpDDPalette );
  1296. extern DWORD EXTERN_DDAPI DD_Palette_Release( LPDIRECTDRAWPALETTE lpDDPalette );
  1297. extern HRESULT EXTERN_DDAPI DD_Palette_GetCaps( LPDIRECTDRAWPALETTE lpDDPalette, LPDWORD lpdwFlags );
  1298. extern HRESULT EXTERN_DDAPI DD_Palette_Initialize( LPDIRECTDRAWPALETTE, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable );
  1299. extern HRESULT EXTERN_DDAPI DD_Palette_SetEntries( LPDIRECTDRAWPALETTE lpDDPalette, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries );
  1300. extern HRESULT EXTERN_DDAPI DD_Palette_GetEntries( LPDIRECTDRAWPALETTE lpDDPalette, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries );
  1301. extern HRESULT EXTERN_DDAPI DD_Palette_SetPrivateData( LPDIRECTDRAWPALETTE, REFIID, LPVOID, DWORD, DWORD);
  1302. extern HRESULT EXTERN_DDAPI DD_Palette_GetPrivateData( LPDIRECTDRAWPALETTE, REFIID, LPVOID, LPDWORD);
  1303. extern HRESULT EXTERN_DDAPI DD_Palette_FreePrivateData( LPDIRECTDRAWPALETTE, REFIID );
  1304. extern HRESULT EXTERN_DDAPI DD_Palette_GetUniquenessValue( LPDIRECTDRAWPALETTE, LPDWORD );
  1305. extern HRESULT EXTERN_DDAPI DD_Palette_ChangeUniquenessValue( LPDIRECTDRAWPALETTE );
  1306. extern HRESULT EXTERN_DDAPI DD_Palette_IsEqual( LPDIRECTDRAWPALETTE, LPDIRECTDRAWPALETTE );
  1307. /* DIRECTDRAWCLIPPER functions */
  1308. extern HRESULT EXTERN_DDAPI DD_UnInitedClipperQueryInterface( LPDIRECTDRAWCLIPPER lpDD, REFIID riid, LPVOID FAR * ppvObj );
  1309. extern HRESULT EXTERN_DDAPI DD_Clipper_QueryInterface( LPVOID lpDDClipper, REFIID riid, LPVOID FAR * ppvObj );
  1310. extern ULONG EXTERN_DDAPI DD_Clipper_AddRef( LPVOID lpDDClipper );
  1311. extern ULONG EXTERN_DDAPI DD_Clipper_Release( LPVOID lpDDClipper );
  1312. extern HRESULT EXTERN_DDAPI DD_Clipper_GetClipList( LPDIRECTDRAWCLIPPER, LPRECT, LPRGNDATA, LPDWORD );
  1313. extern HRESULT EXTERN_DDAPI DD_Clipper_GetHWnd(LPDIRECTDRAWCLIPPER,HWND FAR *);
  1314. extern HRESULT EXTERN_DDAPI DD_Clipper_Initialize( LPDIRECTDRAWCLIPPER, LPDIRECTDRAW lpDD, DWORD dwFlags );
  1315. extern HRESULT EXTERN_DDAPI DD_Clipper_IsClipListChanged(LPDIRECTDRAWCLIPPER,BOOL FAR *);
  1316. extern HRESULT EXTERN_DDAPI DD_Clipper_SetClipList(LPDIRECTDRAWCLIPPER,LPRGNDATA, DWORD);
  1317. extern HRESULT EXTERN_DDAPI DD_Clipper_SetHWnd(LPDIRECTDRAWCLIPPER, DWORD, HWND );
  1318. extern HRESULT EXTERN_DDAPI DD_Clipper_SetNotificationCallback(LPDIRECTDRAWCLIPPER, DWORD,LPCLIPPERCALLBACK, LPVOID);
  1319. /* Private DIRECTDRAWCLIPPER functions */
  1320. extern HRESULT InternalGetClipList( LPDIRECTDRAWCLIPPER lpDDClipper, LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize, LPDDRAWI_DIRECTDRAW_GBL pdrv);
  1321. /* DIRECTDRAWSURFACE functions */
  1322. extern HRESULT EXTERN_DDAPI DD_Surface_QueryInterface( LPVOID lpDDSurface, REFIID riid, LPVOID FAR * ppvObj );
  1323. extern ULONG EXTERN_DDAPI DD_Surface_AddRef( LPVOID lpDDSurface );
  1324. extern ULONG EXTERN_DDAPI DD_Surface_Release( LPVOID lpDDSurface );
  1325. extern HRESULT EXTERN_DDAPI DD_Surface_AddAttachedSurface(LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE);
  1326. extern HRESULT EXTERN_DDAPI DD_Surface_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE, LPRECT);
  1327. extern HRESULT EXTERN_DDAPI DD_Surface_AlphaBlt(LPDIRECTDRAWSURFACE, LPRECT, LPDIRECTDRAWSURFACE, LPRECT, DWORD, LPDDALPHABLTFX);
  1328. extern HRESULT EXTERN_DDAPI DD_Surface_Blt(LPDIRECTDRAWSURFACE,LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX);
  1329. extern HRESULT EXTERN_DDAPI DD_Surface_BltFast(LPDIRECTDRAWSURFACE,DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT, DWORD );
  1330. extern HRESULT EXTERN_DDAPI DD_Surface_BltBatch( LPDIRECTDRAWSURFACE, LPDDBLTBATCH, DWORD, DWORD );
  1331. extern HRESULT EXTERN_DDAPI DD_Surface_ChangeUniquenessValue( LPDIRECTDRAWSURFACE );
  1332. extern HRESULT EXTERN_DDAPI DD_Surface_DeleteAttachedSurfaces(LPDIRECTDRAWSURFACE, DWORD,LPDIRECTDRAWSURFACE);
  1333. extern HRESULT EXTERN_DDAPI DD_Surface_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE,LPVOID, LPDDENUMSURFACESCALLBACK );
  1334. extern HRESULT EXTERN_DDAPI DD_Surface_EnumOverlayZOrders(LPDIRECTDRAWSURFACE,DWORD,LPVOID,LPDDENUMSURFACESCALLBACK);
  1335. extern HRESULT EXTERN_DDAPI DD_Surface_Flip(LPDIRECTDRAWSURFACE,LPDIRECTDRAWSURFACE, DWORD);
  1336. extern HRESULT EXTERN_DDAPI DD_Surface_FreePrivateData(LPDIRECTDRAWSURFACE, REFIID);
  1337. extern HRESULT EXTERN_DDAPI DD_Surface_GetAttachedSurface(LPDIRECTDRAWSURFACE,LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *);
  1338. extern HRESULT EXTERN_DDAPI DD_Surface_GetAttachedSurface4(LPDIRECTDRAWSURFACE4,LPDDSCAPS2, LPDIRECTDRAWSURFACE4 FAR *);
  1339. extern HRESULT EXTERN_DDAPI DD_Surface_GetAttachedSurface7(LPDIRECTDRAWSURFACE7,LPDDSCAPS2, LPDIRECTDRAWSURFACE7 FAR *);
  1340. extern HRESULT EXTERN_DDAPI DD_Surface_GetBltStatus(LPDIRECTDRAWSURFACE,DWORD);
  1341. extern HRESULT EXTERN_DDAPI DD_Surface_GetCaps( LPDIRECTDRAWSURFACE lpDDSurface, LPDDSCAPS lpDDSCaps );
  1342. extern HRESULT EXTERN_DDAPI DD_Surface_GetCaps4( LPDIRECTDRAWSURFACE lpDDSurface, LPDDSCAPS2 lpDDSCaps );
  1343. extern HRESULT EXTERN_DDAPI DD_Surface_GetClipper( LPDIRECTDRAWSURFACE, LPDIRECTDRAWCLIPPER FAR * );
  1344. extern HRESULT EXTERN_DDAPI DD_Surface_GetColorKey( LPDIRECTDRAWSURFACE lpDDSurface, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey );
  1345. extern HRESULT EXTERN_DDAPI DD_Surface_GetDC( LPDIRECTDRAWSURFACE, HDC FAR * );
  1346. extern HRESULT EXTERN_DDAPI DD_Surface_GetDDInterface(LPDIRECTDRAWSURFACE lpDDSurface, LPVOID FAR *lplpDD );
  1347. extern HRESULT EXTERN_DDAPI DD_Surface_GetOverlayPosition( LPDIRECTDRAWSURFACE, LPLONG, LPLONG );
  1348. extern HRESULT EXTERN_DDAPI DD_Surface_GetPalette(LPDIRECTDRAWSURFACE,LPDIRECTDRAWPALETTE FAR*);
  1349. extern HRESULT EXTERN_DDAPI DD_Surface_GetPixelFormat(LPDIRECTDRAWSURFACE, LPDDPIXELFORMAT);
  1350. extern HRESULT EXTERN_DDAPI DD_Surface_GetPrivateData(LPDIRECTDRAWSURFACE, REFIID, LPVOID, LPDWORD);
  1351. extern HRESULT EXTERN_DDAPI DD_Surface_GetSurfaceDesc(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC);
  1352. extern HRESULT EXTERN_DDAPI DD_Surface_GetSurfaceDesc4(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC2);
  1353. extern HRESULT EXTERN_DDAPI DD_Surface_GetFlipStatus(LPDIRECTDRAWSURFACE,DWORD);
  1354. extern HRESULT EXTERN_DDAPI DD_Surface_GetUniquenessValue( LPDIRECTDRAWSURFACE, LPDWORD );
  1355. extern HRESULT EXTERN_DDAPI DD_Surface_Initialize( LPDIRECTDRAWSURFACE, LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc);
  1356. extern HRESULT EXTERN_DDAPI DD_Surface_IsLost( LPDIRECTDRAWSURFACE lpDDSurface );
  1357. extern HRESULT EXTERN_DDAPI DD_Surface_Lock(LPDIRECTDRAWSURFACE,LPRECT,LPDDSURFACEDESC lpDDSurfaceDesc, DWORD, HANDLE hEvent );
  1358. extern HRESULT EXTERN_DDAPI DD_Surface_PageLock(LPDIRECTDRAWSURFACE,DWORD);
  1359. extern HRESULT EXTERN_DDAPI DD_Surface_PageUnlock(LPDIRECTDRAWSURFACE,DWORD);
  1360. extern HRESULT EXTERN_DDAPI DD_Surface_ReleaseDC(LPDIRECTDRAWSURFACE,HDC );
  1361. #ifdef POSTPONED2
  1362. extern HRESULT EXTERN_DDAPI DD_Surface_Resize(LPDIRECTDRAWSURFACE,DWORD,DWORD,DWORD);
  1363. #endif //POSTPONED2
  1364. extern HRESULT EXTERN_DDAPI DD_Surface_Restore( LPDIRECTDRAWSURFACE lpDDSurface );
  1365. extern HRESULT EXTERN_DDAPI DD_Surface_SetBltOrder(LPDIRECTDRAWSURFACE,DWORD);
  1366. extern HRESULT EXTERN_DDAPI DD_Surface_SetClipper( LPDIRECTDRAWSURFACE, LPDIRECTDRAWCLIPPER );
  1367. extern HRESULT EXTERN_DDAPI DD_Surface_SetColorKey( LPDIRECTDRAWSURFACE lpDDSurface, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey );
  1368. extern HRESULT EXTERN_DDAPI DD_Surface_SetOverlayPosition( LPDIRECTDRAWSURFACE, LONG, LONG );
  1369. extern HRESULT EXTERN_DDAPI DD_Surface_SetPalette(LPDIRECTDRAWSURFACE,LPDIRECTDRAWPALETTE);
  1370. extern HRESULT EXTERN_DDAPI DD_Surface_SetPrivateData(LPDIRECTDRAWSURFACE, REFIID, LPVOID, DWORD, DWORD);
  1371. #ifdef POSTPONED2
  1372. extern HRESULT EXTERN_DDAPI DD_Surface_SetSpriteDisplayList(LPDIRECTDRAWSURFACE,LPDDSPRITE *,DWORD,DWORD,LPDIRECTDRAWSURFACE,DWORD);
  1373. #endif //POSTPONED2
  1374. extern HRESULT EXTERN_DDAPI DD_Surface_SetSurfaceDesc( LPDIRECTDRAWSURFACE3, LPDDSURFACEDESC, DWORD );
  1375. extern HRESULT EXTERN_DDAPI DD_Surface_SetSurfaceDesc4( LPDIRECTDRAWSURFACE3, LPDDSURFACEDESC2, DWORD );
  1376. extern HRESULT EXTERN_DDAPI DD_Surface_Unlock(LPDIRECTDRAWSURFACE,LPVOID);
  1377. extern HRESULT EXTERN_DDAPI DD_Surface_Unlock4(LPDIRECTDRAWSURFACE,LPRECT);
  1378. extern HRESULT EXTERN_DDAPI DD_Surface_UpdateOverlay(LPDIRECTDRAWSURFACE,LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX);
  1379. extern HRESULT EXTERN_DDAPI DD_Surface_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE,DWORD);
  1380. extern HRESULT EXTERN_DDAPI DD_Surface_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE,DWORD,LPDIRECTDRAWSURFACE);
  1381. extern HRESULT EXTERN_DDAPI DD_Surface_SetPriority(LPDIRECTDRAWSURFACE7 lpDDSurface, DWORD dwPriority);
  1382. extern HRESULT EXTERN_DDAPI DD_Surface_GetPriority(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDWORD lpdwPriority);
  1383. extern HRESULT EXTERN_DDAPI DD_Surface_SetLOD(LPDIRECTDRAWSURFACE7 lpDDSurface, DWORD dwLOD);
  1384. extern HRESULT EXTERN_DDAPI DD_Surface_GetLOD(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDWORD lpdwLOD);
  1385. /* DrawDrawVideoPortContainer functions */
  1386. extern HRESULT EXTERN_DDAPI DDVPC_QueryInterface(LPDDVIDEOPORTCONTAINER lpDVP, REFIID riid, LPVOID FAR * ppvObj );
  1387. extern DWORD EXTERN_DDAPI DDVPC_AddRef(LPDDVIDEOPORTCONTAINER lpDVP );
  1388. extern DWORD EXTERN_DDAPI DDVPC_Release( LPDDVIDEOPORTCONTAINER lpDD );
  1389. extern HRESULT EXTERN_DDAPI DDVPC_CreateVideoPort(LPDDVIDEOPORTCONTAINER lpDVP, DWORD dwFlags, LPDDVIDEOPORTDESC lpDesc, LPDIRECTDRAWVIDEOPORT FAR *lplpVideoPort, IUnknown FAR *pUnkOuter );
  1390. extern HRESULT EXTERN_DDAPI DDVPC_EnumVideoPorts(LPDDVIDEOPORTCONTAINER lpDVP, DWORD dwReserved, LPDDVIDEOPORTCAPS lpCaps, LPVOID lpContext, LPDDENUMVIDEOCALLBACK lpCallback );
  1391. extern HRESULT EXTERN_DDAPI DDVPC_GetVideoPortConnectInfo(LPDDVIDEOPORTCONTAINER lpDVP, DWORD dwVideoPortID, LPDWORD lpdwNumGUIDs, LPDDVIDEOPORTCONNECT lpConnect );
  1392. extern HRESULT EXTERN_DDAPI DDVPC_QueryVideoPortStatus(LPDDVIDEOPORTCONTAINER lpDVP, DWORD dwVideoPortID, LPDDVIDEOPORTSTATUS lpStatus );
  1393. /* DirectDrawVideoPort functions */
  1394. extern HRESULT EXTERN_DDAPI DD_VP_QueryInterface(LPDIRECTDRAWVIDEOPORT lpDVP, REFIID riid, LPVOID FAR * ppvObj );
  1395. extern DWORD EXTERN_DDAPI DD_VP_AddRef(LPDIRECTDRAWVIDEOPORT lpDVP );
  1396. extern DWORD EXTERN_DDAPI DD_VP_Release(LPDIRECTDRAWVIDEOPORT lpDVP );
  1397. extern HRESULT EXTERN_DDAPI DD_VP_SetTargetSurface(LPDIRECTDRAWVIDEOPORT lpDVP, LPDIRECTDRAWSURFACE lpSurface, DWORD dwFlags );
  1398. extern HRESULT EXTERN_DDAPI DD_VP_Flip(LPDIRECTDRAWVIDEOPORT lpDVP, LPDIRECTDRAWSURFACE lpSurface, DWORD );
  1399. extern HRESULT EXTERN_DDAPI DD_VP_GetBandwidth(LPDIRECTDRAWVIDEOPORT lpDVP, LPDDPIXELFORMAT lpf, DWORD dwWidth, DWORD dwHeight, DWORD dwFlags, LPDDVIDEOPORTBANDWIDTH lpBandwidth );
  1400. extern HRESULT EXTERN_DDAPI DD_VP_GetInputFormats(LPDIRECTDRAWVIDEOPORT lpDVP, LPDWORD lpdwNum, LPDDPIXELFORMAT lpf, DWORD dwFlags );
  1401. extern HRESULT EXTERN_DDAPI DD_VP_GetOutputFormats(LPDIRECTDRAWVIDEOPORT lpDVP, LPDDPIXELFORMAT lpf, LPDWORD lp1, LPDDPIXELFORMAT lp2, DWORD dwFlags );
  1402. extern HRESULT EXTERN_DDAPI DD_VP_GetCurrentAutoFlip(LPDIRECTDRAWVIDEOPORT lpDVP, LPDIRECTDRAWSURFACE FAR* lpSurf, LPDIRECTDRAWSURFACE FAR* lpVBI, LPBOOL lpField );
  1403. extern HRESULT EXTERN_DDAPI DD_VP_GetLastAutoFlip(LPDIRECTDRAWVIDEOPORT lpDVP, LPDIRECTDRAWSURFACE FAR* lpSurf, LPDIRECTDRAWSURFACE FAR* lpVBI, LPBOOL lpField );
  1404. extern HRESULT EXTERN_DDAPI DD_VP_GetField(LPDIRECTDRAWVIDEOPORT lpDVP, LPBOOL lpField );
  1405. extern HRESULT EXTERN_DDAPI DD_VP_GetLine(LPDIRECTDRAWVIDEOPORT lpDVP, LPDWORD lpdwLine );
  1406. extern HRESULT EXTERN_DDAPI DD_VP_StartVideo(LPDIRECTDRAWVIDEOPORT lpDVP, LPDDVIDEOPORTINFO lpInfo );
  1407. extern HRESULT EXTERN_DDAPI DD_VP_StopVideo(LPDIRECTDRAWVIDEOPORT lpDVP );
  1408. extern HRESULT EXTERN_DDAPI DD_VP_UpdateVideo(LPDIRECTDRAWVIDEOPORT lpDVP, LPDDVIDEOPORTINFO lpInfo );
  1409. extern HRESULT EXTERN_DDAPI DD_VP_WaitForSync(LPDIRECTDRAWVIDEOPORT lpDVP, DWORD dwFlags, DWORD dwLine, DWORD dwTimeOut );
  1410. extern HRESULT EXTERN_DDAPI DD_VP_SetFieldNumber(LPDIRECTDRAWVIDEOPORT lpDVP, DWORD dwFieldNum );
  1411. extern HRESULT EXTERN_DDAPI DD_VP_GetFieldNumber(LPDIRECTDRAWVIDEOPORT lpDVP, LPDWORD lpdwFieldNum );
  1412. extern HRESULT EXTERN_DDAPI DD_VP_SetSkipFieldPattern(LPDIRECTDRAWVIDEOPORT lpDVP, DWORD dwStartField, DWORD dwPattSize, DWORD dwPatt );
  1413. extern HRESULT EXTERN_DDAPI DD_VP_GetSignalStatus(LPDIRECTDRAWVIDEOPORT lpDVP, LPDWORD lpdwStatus );
  1414. extern HRESULT EXTERN_DDAPI DD_VP_GetColorControls(LPDIRECTDRAWVIDEOPORT lpDVP, LPDDCOLORCONTROL lpColor );
  1415. extern HRESULT EXTERN_DDAPI DD_VP_SetColorControls(LPDIRECTDRAWVIDEOPORT lpDVP, LPDDCOLORCONTROL lpColor );
  1416. extern HRESULT EXTERN_DDAPI DD_VP_GetStateInfo(LPDIRECTDRAWVIDEOPORT lpDVP, LPDWORD lpdwStateFlags );
  1417. /* DirectDrawVideoPortNotify functions */
  1418. extern HRESULT EXTERN_DDAPI DD_VP_Notify_AcquireNotification( LPDIRECTDRAWVIDEOPORTNOTIFY lpNotify, HANDLE* pEvent, LPDDVIDEOPORTNOTIFY pBuffer );
  1419. extern HRESULT EXTERN_DDAPI DD_VP_Notify_ReleaseNotification( LPDIRECTDRAWVIDEOPORTNOTIFY lpNotify, HANDLE pEvent );
  1420. /* DrawDrawColorControl functions */
  1421. extern HRESULT EXTERN_DDAPI DD_Color_GetColorControls(LPDIRECTDRAWCOLORCONTROL lpDDCC, LPDDCOLORCONTROL lpColor );
  1422. extern HRESULT EXTERN_DDAPI DD_Color_SetColorControls(LPDIRECTDRAWCOLORCONTROL lpDDCC, LPDDCOLORCONTROL lpColor );
  1423. /* DrawDrawGammaControl functions */
  1424. extern HRESULT EXTERN_DDAPI DD_Gamma_GetGammaRamp(LPDIRECTDRAWGAMMACONTROL lpDDGC, DWORD dwFlags, LPVOID lpGammaTable );
  1425. extern HRESULT EXTERN_DDAPI DD_Gamma_SetGammaRamp(LPDIRECTDRAWGAMMACONTROL lpDDGC, DWORD dwFlags, LPVOID lpGammaTable );
  1426. /* DirectDrawKernel functions */
  1427. extern HRESULT EXTERN_DDAPI DD_Kernel_GetCaps(LPDIRECTDRAWKERNEL lpDDK, LPDDKERNELCAPS lpCaps );
  1428. extern HRESULT EXTERN_DDAPI DD_Kernel_GetKernelHandle(LPDIRECTDRAWKERNEL lpDDK, PULONG_PTR lpHandle );
  1429. extern HRESULT EXTERN_DDAPI DD_Kernel_ReleaseKernelHandle(LPDIRECTDRAWKERNEL lpDDK );
  1430. /* DirectDrawSurfaceKernel functions */
  1431. extern HRESULT EXTERN_DDAPI DD_SurfaceKernel_GetKernelHandle(LPDIRECTDRAWSURFACEKERNEL lpDDK, PULONG_PTR lpHandle );
  1432. extern HRESULT EXTERN_DDAPI DD_SurfaceKernel_ReleaseKernelHandle(LPDIRECTDRAWSURFACEKERNEL lpDDK );
  1433. /* DIrectDrawSurface and palette IPersist and IPersistStream functions */
  1434. #ifdef IS_32
  1435. extern HRESULT EXTERN_DDAPI DD_PStream_GetSizeMax(IPersistStream * lpSurfOrPalette, ULARGE_INTEGER * pMax);
  1436. extern HRESULT EXTERN_DDAPI DD_Surface_PStream_Save(LPDIRECTDRAWSURFACE lpDDS, IStream * pStrm, BOOL bClearDirty);
  1437. extern HRESULT EXTERN_DDAPI DD_Surface_PStream_IsDirty(LPDIRECTDRAWSURFACE lpDDS);
  1438. extern HRESULT EXTERN_DDAPI DD_Surface_Persist_GetClassID(LPDIRECTDRAWSURFACE lpDDS, CLSID * pClassID);
  1439. extern HRESULT EXTERN_DDAPI DD_Surface_PStream_Load(LPDIRECTDRAWSURFACE lpDDS, IStream * pStrm);
  1440. extern HRESULT EXTERN_DDAPI DD_Palette_PStream_Save(LPDIRECTDRAWPALETTE lpDDS, IStream * pStrm, BOOL bClearDirty);
  1441. extern HRESULT EXTERN_DDAPI DD_Palette_PStream_IsDirty(LPDIRECTDRAWPALETTE lpDDS);
  1442. extern HRESULT EXTERN_DDAPI DD_Palette_Persist_GetClassID(LPDIRECTDRAWPALETTE lpDDS, CLSID * pClassID);
  1443. extern HRESULT EXTERN_DDAPI DD_Palette_PStream_Load(LPDIRECTDRAWPALETTE lpDDS, IStream * pStrm);
  1444. #endif
  1445. /* DirectDrawOptSurface functions */
  1446. extern HRESULT EXTERN_DDAPI DD_OptSurface_GetOptSurfaceDesc(LPDIRECTDRAWSURFACE, LPDDOPTSURFACEDESC);
  1447. extern HRESULT EXTERN_DDAPI DD_OptSurface_LoadUnoptimizedSurf(LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE);
  1448. extern HRESULT EXTERN_DDAPI DD_OptSurface_CopyOptimizedSurf(LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE);
  1449. extern HRESULT EXTERN_DDAPI DD_OptSurface_Unoptimize(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *);
  1450. /* DrawDrawMotionCompContainer functions */
  1451. extern HRESULT EXTERN_DDAPI DDMCC_CreateMotionComp(LPDDVIDEOACCELERATORCONTAINER lpDDMCC, LPGUID lpGuid, LPDDVAUncompDataInfo lpUncompInfo, LPVOID lpData, DWORD dwDataSize, LPDIRECTDRAWVIDEOACCELERATOR FAR *lplpMotionComp, IUnknown FAR *pUnkOuter );
  1452. extern HRESULT EXTERN_DDAPI DDMCC_GetUncompressedFormats(LPDDVIDEOACCELERATORCONTAINER lpDDMCC, LPGUID lpGuid, LPDWORD lpNumFormats, LPDDPIXELFORMAT lpFormats );
  1453. extern HRESULT EXTERN_DDAPI DDMCC_GetMotionCompGUIDs(LPDDVIDEOACCELERATORCONTAINER lpDDMCC, LPDWORD lpNumGuids, LPGUID lpGuids );
  1454. extern HRESULT EXTERN_DDAPI DDMCC_GetCompBuffInfo(LPDDVIDEOACCELERATORCONTAINER lpDDMCC, LPGUID lpGuid, LPDDVAUncompDataInfo lpUncompInfo, LPDWORD lpNumBuffInfo, LPDDVACompBufferInfo lpCompBuffInfo );
  1455. extern HRESULT EXTERN_DDAPI DDMCC_GetInternalMoCompInfo(LPDDVIDEOACCELERATORCONTAINER lpDDMCC, LPGUID lpGuid, LPDDVAUncompDataInfo lpUncompInfo, LPDDVAInternalMemInfo lpMemInfo );
  1456. /* DrawDrawMotionComp functions */
  1457. extern HRESULT EXTERN_DDAPI DD_MC_QueryInterface(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC, REFIID riid, LPVOID FAR * ppvObj );
  1458. extern DWORD EXTERN_DDAPI DD_MC_AddRef(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC);
  1459. extern DWORD EXTERN_DDAPI DD_MC_Release(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC);
  1460. extern HRESULT EXTERN_DDAPI DD_MC_BeginFrame(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC, LPDDVABeginFrameInfo lpInfo);
  1461. extern HRESULT EXTERN_DDAPI DD_MC_EndFrame(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC, LPDDVAEndFrameInfo lpInfo);
  1462. extern HRESULT EXTERN_DDAPI DD_MC_QueryRenderStatus(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC, LPDIRECTDRAWSURFACE7 lpSurface, DWORD dwFlags);
  1463. extern HRESULT EXTERN_DDAPI DD_MC_RenderMacroBlocks(LPDIRECTDRAWVIDEOACCELERATOR lpDDMC, DWORD dwFunction, LPVOID lpInput, DWORD dwInputSize, LPVOID lpOutput, DWORD dwOutSize, DWORD dwNumBuffers, LPDDVABUFFERINFO lpBuffInfo);
  1464. //#endif //WIN95
  1465. /*
  1466. * HAL fns
  1467. */
  1468. //#ifdef WIN95
  1469. /*
  1470. * thunk helper fns
  1471. */
  1472. extern DWORD DDAPI _DDHAL_CreatePalette( LPDDHAL_CREATEPALETTEDATA lpCreatePaletteData );
  1473. extern DWORD DDAPI DDThunk16_CreatePalette( LPDDHAL_CREATEPALETTEDATA lpCreatePaletteData );
  1474. extern DWORD DDAPI _DDHAL_CreateSurface( LPDDHAL_CREATESURFACEDATA lpCreateSurfaceData );
  1475. extern DWORD DDAPI DDThunk16_CreateSurface( LPDDHAL_CREATESURFACEDATA lpCreateSurfaceData );
  1476. extern DWORD DDAPI _DDHAL_CanCreateSurface( LPDDHAL_CANCREATESURFACEDATA lpCanCreateSurfaceData );
  1477. extern DWORD DDAPI DDThunk16_CanCreateSurface( LPDDHAL_CANCREATESURFACEDATA lpCanCreateSurfaceData );
  1478. extern DWORD DDAPI _DDHAL_WaitForVerticalBlank( LPDDHAL_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlankData );
  1479. extern DWORD DDAPI DDThunk16_WaitForVerticalBlank( LPDDHAL_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlankData );
  1480. extern DWORD DDAPI _DDHAL_DestroyDriver( LPDDHAL_DESTROYDRIVERDATA lpDestroyDriverData );
  1481. extern DWORD DDAPI DDThunk16_DestroyDriver( LPDDHAL_DESTROYDRIVERDATA lpDestroyDriverData );
  1482. extern DWORD DDAPI _DDHAL_SetMode( LPDDHAL_SETMODEDATA lpSetModeData );
  1483. extern DWORD DDAPI DDThunk16_SetMode( LPDDHAL_SETMODEDATA lpSetModeData );
  1484. extern DWORD DDAPI _DDHAL_GetScanLine( LPDDHAL_GETSCANLINEDATA lpGetScanLineData );
  1485. extern DWORD DDAPI DDThunk16_GetScanLine( LPDDHAL_GETSCANLINEDATA lpGetScanLineData );
  1486. extern DWORD DDAPI _DDHAL_SetExclusiveMode( LPDDHAL_SETEXCLUSIVEMODEDATA lpSetExclusiveModeData );
  1487. extern DWORD DDAPI DDThunk16_SetExclusiveMode( LPDDHAL_SETEXCLUSIVEMODEDATA lpSetExclusiveModeData );
  1488. extern DWORD DDAPI _DDHAL_FlipToGDISurface( LPDDHAL_FLIPTOGDISURFACEDATA lpFlipToGDISurfaceData );
  1489. extern DWORD DDAPI DDThunk16_FlipToGDISurface( LPDDHAL_FLIPTOGDISURFACEDATA lpFlipToGDISurfaceData );
  1490. extern DWORD DDAPI _DDHAL_GetAvailDriverMemory ( LPDDHAL_GETAVAILDRIVERMEMORYDATA lpGetAvailDriverMemoryData );
  1491. extern DWORD DDAPI DDThunk16_GetAvailDriverMemory ( LPDDHAL_GETAVAILDRIVERMEMORYDATA lpGetAvailDriverMemoryData );
  1492. extern DWORD DDAPI _DDHAL_UpdateNonLocalHeap ( LPDDHAL_UPDATENONLOCALHEAPDATA lpUpdateNonLocalHeapData );
  1493. extern DWORD DDAPI DDThunk16_UpdateNonLocalHeap ( LPDDHAL_UPDATENONLOCALHEAPDATA lpUpdateNonLocalHeapData );
  1494. /*
  1495. * Palette Object HAL fns
  1496. */
  1497. extern DWORD DDAPI _DDHAL_DestroyPalette( LPDDHAL_DESTROYPALETTEDATA );
  1498. extern DWORD DDAPI DDThunk16_DestroyPalette( LPDDHAL_DESTROYPALETTEDATA );
  1499. extern DWORD DDAPI _DDHAL_SetEntries( LPDDHAL_SETENTRIESDATA );
  1500. extern DWORD DDAPI DDThunk16_SetEntries( LPDDHAL_SETENTRIESDATA );
  1501. /*
  1502. * Surface Object HAL fns
  1503. */
  1504. extern DWORD DDAPI _DDHAL_DestroySurface( LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData );
  1505. extern DWORD DDAPI DDThunk16_DestroySurface( LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData );
  1506. extern DWORD DDAPI _DDHAL_Flip( LPDDHAL_FLIPDATA lpFlipData );
  1507. extern DWORD DDAPI DDThunk16_Flip( LPDDHAL_FLIPDATA lpFlipData );
  1508. extern DWORD DDAPI _DDHAL_Blt( LPDDHAL_BLTDATA lpBltData );
  1509. extern DWORD DDAPI DDThunk16_Blt( LPDDHAL_BLTDATA lpBltData );
  1510. extern DWORD DDAPI _DDHAL_Lock( LPDDHAL_LOCKDATA lpLockData );
  1511. extern DWORD DDAPI DDThunk16_Lock( LPDDHAL_LOCKDATA lpLockData );
  1512. extern DWORD DDAPI _DDHAL_Unlock( LPDDHAL_UNLOCKDATA lpUnlockData );
  1513. extern DWORD DDAPI DDThunk16_Unlock( LPDDHAL_UNLOCKDATA lpUnlockData );
  1514. extern DWORD DDAPI _DDHAL_AddAttachedSurface( LPDDHAL_ADDATTACHEDSURFACEDATA lpAddAttachedSurfaceData );
  1515. extern DWORD DDAPI DDThunk16_AddAttachedSurface( LPDDHAL_ADDATTACHEDSURFACEDATA lpAddAttachedSurfaceData );
  1516. extern DWORD DDAPI _DDHAL_SetColorKey( LPDDHAL_SETCOLORKEYDATA lpSetColorKeyData );
  1517. extern DWORD DDAPI DDThunk16_SetColorKey( LPDDHAL_SETCOLORKEYDATA lpSetColorKeyData );
  1518. extern DWORD DDAPI _DDHAL_SetClipList( LPDDHAL_SETCLIPLISTDATA lpSetClipListData );
  1519. extern DWORD DDAPI DDThunk16_SetClipList( LPDDHAL_SETCLIPLISTDATA lpSetClipListData );
  1520. extern DWORD DDAPI _DDHAL_UpdateOverlay( LPDDHAL_UPDATEOVERLAYDATA lpUpdateOverlayData );
  1521. extern DWORD DDAPI DDThunk16_UpdateOverlay( LPDDHAL_UPDATEOVERLAYDATA lpUpdateOverlayData );
  1522. extern DWORD DDAPI _DDHAL_SetOverlayPosition( LPDDHAL_SETOVERLAYPOSITIONDATA lpSetOverlayPositionData );
  1523. extern DWORD DDAPI DDThunk16_SetOverlayPosition( LPDDHAL_SETOVERLAYPOSITIONDATA lpSetOverlayPositionData );
  1524. extern DWORD DDAPI _DDHAL_SetPalette( LPDDHAL_SETPALETTEDATA lpSetPaletteData );
  1525. extern DWORD DDAPI DDThunk16_SetPalette( LPDDHAL_SETPALETTEDATA lpSetPaletteData );
  1526. extern DWORD DDAPI _DDHAL_GetBltStatus( LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData );
  1527. extern DWORD DDAPI DDThunk16_GetBltStatus( LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData );
  1528. extern DWORD DDAPI _DDHAL_GetFlipStatus( LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData );
  1529. extern DWORD DDAPI DDThunk16_GetFlipStatus( LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData );
  1530. /*
  1531. * Execute Buffer Pseudo Object HAL fns
  1532. *
  1533. * NOTE: No DDThunk16 equivalents as these are just dummy place holders to keep
  1534. * DOHALCALL happy.
  1535. */
  1536. extern DWORD DDAPI _DDHAL_CanCreateExecuteBuffer( LPDDHAL_CANCREATESURFACEDATA lpCanCreateSurfaceData );
  1537. extern DWORD DDAPI _DDHAL_CreateExecuteBuffer( LPDDHAL_CREATESURFACEDATA lpCreateSurfaceData );
  1538. extern DWORD DDAPI _DDHAL_DestroyExecuteBuffer( LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData );
  1539. extern DWORD DDAPI _DDHAL_LockExecuteBuffer( LPDDHAL_LOCKDATA lpLockData );
  1540. extern DWORD DDAPI _DDHAL_UnlockExecuteBuffer( LPDDHAL_UNLOCKDATA lpUnlockData );
  1541. /*
  1542. * Video Port Pseudo Object HAL fns
  1543. *
  1544. * NOTE: No DDThunk16 equivalents as these are just dummy place holders to keep
  1545. * DOHALCALL happy.
  1546. */
  1547. extern DWORD DDAPI _DDHAL_GetVideoPortConnectInfo( LPDDHAL_GETVPORTCONNECTDATA lpGetTypeData );
  1548. extern DWORD DDAPI _DDHAL_CanCreateVideoPort( LPDDHAL_CANCREATEVPORTDATA lpCanCreateData );
  1549. extern DWORD DDAPI _DDHAL_CreateVideoPort( LPDDHAL_CREATEVPORTDATA lpCreateData );
  1550. extern DWORD DDAPI _DDHAL_DestroyVideoPort( LPDDHAL_DESTROYVPORTDATA lpDestroyData );
  1551. extern DWORD DDAPI _DDHAL_GetVideoPortInputFormats( LPDDHAL_GETVPORTINPUTFORMATDATA lpGetFormatData );
  1552. extern DWORD DDAPI _DDHAL_GetVideoPortOutputFormats( LPDDHAL_GETVPORTOUTPUTFORMATDATA lpGetFormatData );
  1553. extern DWORD DDAPI _DDHAL_GetVideoPortBandwidthInfo( LPDDHAL_GETVPORTBANDWIDTHDATA lpGetBandwidthData );
  1554. extern DWORD DDAPI _DDHAL_UpdateVideoPort( LPDDHAL_UPDATEVPORTDATA lpUpdateData );
  1555. extern DWORD DDAPI _DDHAL_GetVideoPortField( LPDDHAL_GETVPORTFIELDDATA lpGetFieldData );
  1556. extern DWORD DDAPI _DDHAL_GetVideoPortLine( LPDDHAL_GETVPORTLINEDATA lpGetLineData );
  1557. extern DWORD DDAPI _DDHAL_WaitForVideoPortSync( LPDDHAL_WAITFORVPORTSYNCDATA lpWaitSyncData );
  1558. extern DWORD DDAPI _DDHAL_FlipVideoPort( LPDDHAL_FLIPVPORTDATA lpFlipData );
  1559. extern DWORD DDAPI _DDHAL_GetVideoPortFlipStatus( LPDDHAL_GETVPORTFLIPSTATUSDATA lpFlipData );
  1560. extern DWORD DDAPI _DDHAL_GetVideoSignalStatus( LPDDHAL_GETVPORTSIGNALDATA lpData );
  1561. extern DWORD DDAPI _DDHAL_VideoColorControl( LPDDHAL_VPORTCOLORDATA lpData );
  1562. /*
  1563. * Color Control Pseudo Object HAL fns
  1564. */
  1565. extern DWORD DDAPI _DDHAL_ColorControl( LPDDHAL_COLORCONTROLDATA lpColorData );
  1566. extern DWORD DDAPI DDThunk16_ColorControl( LPDDHAL_COLORCONTROLDATA lpColorData );
  1567. /*
  1568. * Kernel Pseudo Object HAL fns
  1569. */
  1570. extern DWORD DDAPI _DDHAL_SyncSurfaceData( LPDDHAL_SYNCSURFACEDATA lpSyncData );
  1571. extern DWORD DDAPI _DDHAL_SyncVideoPortData( LPDDHAL_SYNCVIDEOPORTDATA lpSyncData );
  1572. /*
  1573. * MotionComp Pseudo Object HAL fns
  1574. */
  1575. extern DWORD DDAPI _DDHAL_GetMoCompGuids( LPDDHAL_GETMOCOMPGUIDSDATA lpGetGuidData );
  1576. extern DWORD DDAPI _DDHAL_GetMoCompFormats( LPDDHAL_GETMOCOMPFORMATSDATA lpGetFormatData );
  1577. extern DWORD DDAPI _DDHAL_CreateMoComp( LPDDHAL_CREATEMOCOMPDATA lpCreateData );
  1578. extern DWORD DDAPI _DDHAL_GetMoCompBuffInfo( LPDDHAL_GETMOCOMPCOMPBUFFDATA lpBuffData );
  1579. extern DWORD DDAPI _DDHAL_GetInternalMoCompInfo( LPDDHAL_GETINTERNALMOCOMPDATA lpInternalData );
  1580. extern DWORD DDAPI _DDHAL_DestroyMoComp( LPDDHAL_DESTROYMOCOMPDATA lpDestroyData );
  1581. extern DWORD DDAPI _DDHAL_BeginMoCompFrame( LPDDHAL_BEGINMOCOMPFRAMEDATA lpFrameData );
  1582. extern DWORD DDAPI _DDHAL_EndMoCompFrame( LPDDHAL_ENDMOCOMPFRAMEDATA lpFrameData );
  1583. extern DWORD DDAPI _DDHAL_RenderMoComp( LPDDHAL_RENDERMOCOMPDATA lpRenderData );
  1584. extern DWORD DDAPI _DDHAL_QueryMoCompStatus( LPDDHAL_QUERYMOCOMPSTATUSDATA lpStatusData );
  1585. #ifdef POSTPONED
  1586. extern DWORD DDAPI _DDHAL_CanOptimizeSurface( LPDDHAL_CANOPTIMIZESURFACEDATA);
  1587. extern DWORD DDAPI _DDHAL_OptimizeSurface( LPDDHAL_OPTIMIZESURFACEDATA);
  1588. extern DWORD DDAPI _DDHAL_UnOptimizeSurface( LPDDHAL_UNOPTIMIZESURFACEDATA);
  1589. extern DWORD DDAPI _DDHAL_CopyOptSurface( LPDDHAL_COPYOPTSURFACEDATA);
  1590. #endif
  1591. //#endif
  1592. #ifdef POSTPONED
  1593. #ifdef IS_32
  1594. /*
  1595. * DirectDrawFactory2 implementation
  1596. */
  1597. typedef struct _DDFACTORY2
  1598. {
  1599. IDirectDrawFactory2Vtbl *lpVtbl;
  1600. DWORD dwRefCnt;
  1601. /* internal data */
  1602. } DDFACTORY2, FAR * LPDDFACTORY2;
  1603. #endif
  1604. #endif //POSTPONED
  1605. /*
  1606. * Macros for checking interface versions
  1607. */
  1608. #define LOWERTHANDDRAW7(lpDD) \
  1609. (lpDD->lpVtbl == &ddCallbacks || lpDD->lpVtbl == &dd2Callbacks || lpDD->lpVtbl == &dd4Callbacks )
  1610. #define LOWERTHANDDRAW4(lpDD) \
  1611. (lpDD->lpVtbl == &ddCallbacks || lpDD->lpVtbl == &dd2Callbacks)
  1612. #define LOWERTHANDDRAW3(lpDD) \
  1613. (lpDD->lpVtbl == &ddCallbacks || lpDD->lpVtbl == &dd2Callbacks)
  1614. #define LOWERTHANSURFACE7(lpDDS) \
  1615. (lpDDS->lpVtbl == &ddSurfaceCallbacks || lpDDS->lpVtbl == &ddSurface2Callbacks || \
  1616. lpDDS->lpVtbl == &ddSurface3Callbacks || lpDDS->lpVtbl == &ddSurface4Callbacks )
  1617. #define LOWERTHANSURFACE4(lpDDS) \
  1618. (lpDDS->lpVtbl == &ddSurfaceCallbacks || lpDDS->lpVtbl == &ddSurface2Callbacks || lpDDS->lpVtbl == &ddSurface3Callbacks )
  1619. /*
  1620. * This macro allows testing an interface pointer to see if it's one that come from
  1621. * our implementation of ddraw, or somebody else's
  1622. */
  1623. #define IS_NATIVE_DDRAW_INTERFACE(ptr) \
  1624. ( ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&ddCallbacks) || \
  1625. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&dd2Callbacks) || \
  1626. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&dd4Callbacks) || \
  1627. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&dd7Callbacks) || \
  1628. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&dd2UninitCallbacks) || \
  1629. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&dd4UninitCallbacks) || \
  1630. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&dd5UninitCallbacks) || \
  1631. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&ddVideoPortContainerCallbacks) || \
  1632. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&ddKernelCallbacks) || \
  1633. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&ddMotionCompContainerCallbacks) || \
  1634. ((IUnknownVtbl*)ptr->lpVtbl == (IUnknownVtbl*)&ddUninitCallbacks) )
  1635. /*
  1636. * This macro tests if this ddraw interface is one for which child objects should take
  1637. * a ref count on that interface and thus achieve immortality wrt that interface.
  1638. */
  1639. #define CHILD_SHOULD_TAKE_REFCNT(dd_int) (!LOWERTHANDDRAW3(dd_int))
  1640. /*
  1641. * macros for checking if surface as been lost due to mode change
  1642. * NOTE: The flag for determining if a surface is lost or not is now
  1643. * stored in the local than global object. This prevents the scenario
  1644. * where a surface being shared by two processes is lost and restored
  1645. * by one of them - giving the other no notification that the contents
  1646. * of the surface are gone.
  1647. */
  1648. #define SURFACE_LOST( lcl_ptr ) (((lcl_ptr)->dwFlags & DDRAWISURF_INVALID))
  1649. /*
  1650. * Useful palette macros
  1651. *
  1652. * All these flags are really iritating to handle but but changing
  1653. * to use a numeric palette size would require an API change and
  1654. * internal structure mods (visible to the driver) so I am sticking
  1655. * with flags.
  1656. */
  1657. #define SIZE_PCAPS_TO_FLAGS( pcaps ) \
  1658. (((pcaps) & DDPCAPS_1BIT) ? DDRAWIPAL_2 : \
  1659. (((pcaps) & DDPCAPS_2BIT) ? DDRAWIPAL_4 : \
  1660. (((pcaps) & DDPCAPS_4BIT) ? DDRAWIPAL_16 : DDRAWIPAL_256)))
  1661. #define SIZE_FLAGS_TO_PCAPS( flags ) \
  1662. (((flags) & DDRAWIPAL_2) ? DDPCAPS_1BIT : \
  1663. (((flags) & DDRAWIPAL_4) ? DDPCAPS_2BIT : \
  1664. (((flags) & DDRAWIPAL_16) ? DDPCAPS_4BIT : DDPCAPS_8BIT)))
  1665. #define FLAGS_TO_SIZE( flags ) \
  1666. (((flags) & DDRAWIPAL_2) ? 2 : \
  1667. (((flags) & DDRAWIPAL_4) ? 4 : \
  1668. (((flags) & DDRAWIPAL_16) ? 16 : 256)))
  1669. /*
  1670. * has Direct3D been initialized for this DirectDraw driver object?
  1671. */
  1672. #define D3D_INITIALIZED( lcl_ptr ) (( NULL != (lcl_ptr)->pD3DIUnknown) && ( NULL != (lcl_ptr)->hD3DInstance ))
  1673. #if defined( _WIN32 ) && !defined( WINNT )
  1674. /*
  1675. * Macros and types to support secondary (stacked) drivers.
  1676. *
  1677. * NOTE: This stuff is only relevant to 32-bit DirectDraw and the GUIDs
  1678. * confuse DDRAW16.
  1679. */
  1680. #define MAX_SECONDARY_DRIVERNAME MAX_PATH
  1681. #define MAX_SECONDARY_ENTRYPOINTNAME 32UL
  1682. #define DEFAULT_SECONDARY_ENTRYPOINTNAME "GetInfo"
  1683. #define REGSTR_PATH_SECONDARY "Software\\Microsoft\\DirectDraw\\Secondary"
  1684. #define REGSTR_VALUE_SECONDARY_ENTRYPOINTNAME "Entry"
  1685. #define REGSTR_VALUE_SECONDARY_DRIVERNAME "Name"
  1686. typedef DWORD (WINAPI * LPSECONDARY_PATCHHALINFO)(
  1687. LPDDHALINFO lpDDHALInfo,
  1688. LPDDHAL_DDCALLBACKS lpDDCallbacks,
  1689. LPDDHAL_DDSURFACECALLBACKS lpDDSurfaceCallbacks,
  1690. LPDDHAL_DDPALETTECALLBACKS lpDDPaletteCallbacks,
  1691. LPDDHAL_DDEXEBUFCALLBACKS lpDDExeBufCallbacks);
  1692. typedef LPSECONDARY_PATCHHALINFO (WINAPI * LPSECONDARY_VALIDATE)(LPGUID lpGuid);
  1693. DEFINE_GUID( guidCertifiedSecondaryDriver, 0x8061d4e0,0xe895,0x11cf,0xa2,0xe0,0x00,0xaa,0x00,0xb9,0x33,0x56 );
  1694. #endif
  1695. #if defined( _WIN32 )
  1696. DEFINE_GUID( guidVoodoo1A, 0x3a0cfd01,0x9320,0x11cf,0xac,0xa1,0x00,0xa0,0x24,0x13,0xc2,0xe2 );
  1697. DEFINE_GUID( guidVoodoo1B, 0xaba52f41,0xf744,0x11cf,0xb4,0x52,0x00,0x00,0x1d,0x1b,0x41,0x26 );
  1698. #endif
  1699. /*
  1700. * macros for validating pointers
  1701. */
  1702. extern DIRECTDRAWCALLBACKS ddCallbacks;
  1703. extern DIRECTDRAWCALLBACKS ddUninitCallbacks;
  1704. extern DIRECTDRAW2CALLBACKS dd2UninitCallbacks;
  1705. extern DIRECTDRAW2CALLBACKS dd2Callbacks;
  1706. extern DIRECTDRAW4CALLBACKS dd4UninitCallbacks;
  1707. extern DIRECTDRAW4CALLBACKS dd4Callbacks;
  1708. extern DIRECTDRAW7CALLBACKS dd7UninitCallbacks;
  1709. extern DIRECTDRAW7CALLBACKS dd7Callbacks;
  1710. extern DIRECTDRAWSURFACECALLBACKS ddSurfaceCallbacks;
  1711. extern DIRECTDRAWSURFACE2CALLBACKS ddSurface2Callbacks;
  1712. extern DIRECTDRAWSURFACE3CALLBACKS ddSurface3Callbacks;
  1713. extern DIRECTDRAWSURFACE4CALLBACKS ddSurface4Callbacks;
  1714. extern DIRECTDRAWSURFACE7CALLBACKS ddSurface7Callbacks;
  1715. extern DIRECTDRAWCLIPPERCALLBACKS ddClipperCallbacks;
  1716. extern DIRECTDRAWCLIPPERCALLBACKS ddUninitClipperCallbacks;
  1717. extern DIRECTDRAWPALETTECALLBACKS ddPaletteCallbacks;
  1718. extern DDVIDEOPORTCONTAINERCALLBACKS ddVideoPortContainerCallbacks;
  1719. extern DIRECTDRAWVIDEOPORTCALLBACKS ddVideoPortCallbacks;
  1720. extern DIRECTDRAWVIDEOPORTNOTIFYCALLBACKS ddVideoPortNotifyCallbacks;
  1721. extern DIRECTDRAWKERNELCALLBACKS ddKernelCallbacks;
  1722. extern DIRECTDRAWSURFACEKERNELCALLBACKS ddSurfaceKernelCallbacks;
  1723. extern DIRECTDRAWPALETTECALLBACKS ddPaletteCallbacks;
  1724. extern DIRECTDRAWCOLORCONTROLCALLBACKS ddColorControlCallbacks;
  1725. extern DIRECTDRAWGAMMACONTROLCALLBACKS ddGammaControlCallbacks;
  1726. #ifdef POSTPONED
  1727. extern NONDELEGATINGUNKNOWNCALLBACKS ddNonDelegatingUnknownCallbacks;
  1728. extern NONDELEGATINGUNKNOWNCALLBACKS ddUninitNonDelegatingUnknownCallbacks;
  1729. extern LPVOID NonDelegatingIUnknownInterface;
  1730. extern LPVOID UninitNonDelegatingIUnknownInterface;
  1731. #endif
  1732. extern DDVIDEOACCELERATORCONTAINERCALLBACKS ddMotionCompContainerCallbacks;
  1733. extern DIRECTDRAWVIDEOACCELERATORCALLBACKS ddMotionCompCallbacks;
  1734. #ifdef POSTPONED
  1735. extern DDFACTORY2CALLBACKS ddFactory2Callbacks;
  1736. extern DIRECTDRAWPALETTE2CALLBACKS ddPalette2Callbacks;
  1737. extern DIRECTDRAWPALETTEPERSISTCALLBACKS ddPalettePersistCallbacks;
  1738. extern DIRECTDRAWPALETTEPERSISTSTREAMCALLBACKS ddPalettePersistStreamCallbacks;
  1739. extern DIRECTDRAWSURFACEPERSISTCALLBACKS ddSurfacePersistCallbacks;
  1740. extern DIRECTDRAWSURFACEPERSISTSTREAMCALLBACKS ddSurfacePersistStreamCallbacks;
  1741. extern DIRECTDRAWOPTSURFACECALLBACKS ddOptSurfaceCallbacks;
  1742. #endif
  1743. #ifndef DEBUG
  1744. #define FAST_CHECKING
  1745. #endif
  1746. /*
  1747. * VALIDEX_xxx macros are the same for debug and retail
  1748. */
  1749. #define VALIDEX_PTR( ptr, size ) \
  1750. (!IsBadReadPtr( ptr, size) )
  1751. #define VALIDEX_IID_PTR( ptr ) \
  1752. (!IsBadReadPtr( ptr, sizeof( IID )) )
  1753. #define VALIDEX_PTR_PTR( ptr ) \
  1754. (!IsBadWritePtr( ptr, sizeof( LPVOID )) )
  1755. #define VALIDEX_CODE_PTR( ptr ) \
  1756. (!IsBadCodePtr( (LPVOID) ptr ) )
  1757. #define VALIDEX_GUID_PTR( ptr ) \
  1758. (!IsBadReadPtr( ptr, sizeof( GUID ) ) )
  1759. #define VALIDEX_DIRECTDRAWFACTORY2_PTR( ptr ) \
  1760. (!IsBadWritePtr( ptr, sizeof( DDFACTORY2 )) && \
  1761. (ptr->lpVtbl == &ddFactory2Callbacks) )
  1762. #define VALIDEX_DIRECTDRAW_PTR( ptr ) \
  1763. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DIRECTDRAW_INT )) && \
  1764. ( (ptr->lpVtbl == &ddCallbacks) || \
  1765. (ptr->lpVtbl == &dd2Callbacks) || \
  1766. (ptr->lpVtbl == &dd4Callbacks) || \
  1767. (ptr->lpVtbl == &dd7Callbacks) || \
  1768. (ptr->lpVtbl == &dd2UninitCallbacks) || \
  1769. (ptr->lpVtbl == &dd4UninitCallbacks) || \
  1770. (ptr->lpVtbl == &dd7UninitCallbacks) || \
  1771. (ptr->lpVtbl == &ddVideoPortContainerCallbacks) || \
  1772. (ptr->lpVtbl == &ddKernelCallbacks) || \
  1773. (ptr->lpVtbl == &ddMotionCompContainerCallbacks) || \
  1774. (ptr->lpVtbl == &ddUninitCallbacks) ) )
  1775. #define VALIDEX_DIRECTDRAWSURFACE_PTR( ptr ) \
  1776. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DDRAWSURFACE_INT )) && \
  1777. ( (ptr->lpVtbl == &ddSurfaceCallbacks ) || \
  1778. (ptr->lpVtbl == &ddSurface7Callbacks ) || \
  1779. (ptr->lpVtbl == &ddSurface4Callbacks ) || \
  1780. (ptr->lpVtbl == &ddSurface3Callbacks ) || \
  1781. (ptr->lpVtbl == &ddSurface2Callbacks ) || \
  1782. (ptr->lpVtbl == &ddSurfaceKernelCallbacks ) || \
  1783. (ptr->lpVtbl == &ddColorControlCallbacks ) || \
  1784. (ptr->lpVtbl == &ddGammaControlCallbacks ) ) )
  1785. #define VALIDEX_DIRECTDRAWPALETTE_PTR( ptr ) \
  1786. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DDRAWPALETTE_INT )) && \
  1787. (ptr->lpVtbl == &ddPaletteCallbacks) )
  1788. #define VALIDEX_DIRECTDRAWCLIPPER_PTR( ptr ) \
  1789. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DDRAWCLIPPER_INT )) && \
  1790. ( (ptr->lpVtbl == &ddClipperCallbacks) || \
  1791. (ptr->lpVtbl == &ddUninitClipperCallbacks) ) )
  1792. #define VALIDEX_DDCOLORCONTROL_PTR( ptr ) \
  1793. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DDCOLORCONTROL_INT )) && \
  1794. (ptr->lpVtbl == &ddColorControlCallbacks) )
  1795. #define VALIDEX_DDDEVICEIDENTIFIER_PTR( ptr ) (!IsBadWritePtr( ptr, sizeof( DDDEVICEIDENTIFIER )))
  1796. #define VALIDEX_DDDEVICEIDENTIFIER2_PTR( ptr ) (!IsBadWritePtr( ptr, sizeof( DDDEVICEIDENTIFIER2 )))
  1797. /*
  1798. * These macros validate the size (in debug and retail) of callback
  1799. * tables.
  1800. *
  1801. * NOTE: It is essential that the comparison against the current
  1802. * callback size expected by this DirectDraw the comparison operator
  1803. * be >= rather than ==. This is to ensure that newer drivers can run
  1804. * against older DirectDraws.
  1805. */
  1806. #define VALIDEX_DDCALLBACKSSIZE( ptr ) \
  1807. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1808. ( ( ( ptr )->dwSize == DDCALLBACKSSIZE_V1 ) || \
  1809. ( ( ptr )->dwSize >= DDCALLBACKSSIZE ) ) )
  1810. #define VALIDEX_DDSURFACECALLBACKSSIZE( ptr ) \
  1811. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1812. ( ( ptr )->dwSize >= DDSURFACECALLBACKSSIZE ) )
  1813. #define VALIDEX_DDPALETTECALLBACKSSIZE( ptr ) \
  1814. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1815. ( ( ptr )->dwSize >= DDPALETTECALLBACKSSIZE ) )
  1816. #define VALIDEX_DDPALETTECALLBACKSSIZE( ptr ) \
  1817. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1818. ( ( ptr )->dwSize >= DDPALETTECALLBACKSSIZE ) )
  1819. #define VALIDEX_DDEXEBUFCALLBACKSSIZE( ptr ) \
  1820. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1821. ( ( ptr )->dwSize >= DDEXEBUFCALLBACKSSIZE ) )
  1822. #define VALIDEX_DDVIDEOPORTCALLBACKSSIZE( ptr ) \
  1823. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1824. ( ( ptr )->dwSize >= DDVIDEOPORTCALLBACKSSIZE ) )
  1825. #define VALIDEX_DDMOTIONCOMPCALLBACKSSIZE( ptr ) \
  1826. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1827. ( ( ptr )->dwSize >= DDMOTIONCOMPCALLBACKSSIZE ) )
  1828. #define VALIDEX_DDCOLORCONTROLCALLBACKSSIZE( ptr ) \
  1829. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1830. ( ( ptr )->dwSize >= DDCOLORCONTROLCALLBACKSSIZE ) )
  1831. #define VALIDEX_DDMISCELLANEOUSCALLBACKSSIZE( ptr ) \
  1832. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1833. ( ( ptr )->dwSize >= DDMISCELLANEOUSCALLBACKSSIZE ) )
  1834. #define VALIDEX_DDMISCELLANEOUS2CALLBACKSSIZE( ptr ) \
  1835. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1836. ( ( ptr )->dwSize >= DDMISCELLANEOUS2CALLBACKSSIZE ) )
  1837. #define VALIDEX_D3DCALLBACKS2SIZE( ptr ) \
  1838. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1839. ( (( ptr )->dwSize >= D3DHAL_CALLBACKS2SIZE ) ))
  1840. #define VALIDEX_D3DCOMMANDBUFFERCALLBACKSSIZE( ptr ) \
  1841. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1842. ( ( ptr )->dwSize >= D3DHAL_COMMANDBUFFERCALLBACKSSIZE ) )
  1843. #define VALIDEX_D3DCALLBACKS3SIZE( ptr ) \
  1844. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1845. ( ( ptr )->dwSize >= D3DHAL_CALLBACKS3SIZE ) )
  1846. #define VALIDEX_DDKERNELCALLBACKSSIZE( ptr ) \
  1847. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1848. ( ( ptr )->dwSize >= DDKERNELCALLBACKSSIZE ) )
  1849. #define VALIDEX_DDUMODEDRVINFOSIZE( ptr ) \
  1850. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1851. ( ( ptr )->dwSize >= DDHAL_DDUMODEDRVINFOSIZE ) )
  1852. #define VALIDEX_DDOPTSURFKMODEINFOSIZE( ptr ) \
  1853. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1854. ( ( ptr )->dwSize >= DDOPTSURFACEKMODEINFOSIZE ) )
  1855. #define VALIDEX_DDOPTSURFUMODEINFOSIZE( ptr ) \
  1856. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1857. ( ( ptr )->dwSize >= DDOPTSURFACEUMODEINFOSIZE ) )
  1858. #ifndef WIN95
  1859. #define VALIDEX_DDNTCALLBACKSSIZE( ptr ) \
  1860. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1861. ( ( ptr )->dwSize >= DDNTCALLBACKSSIZE ) )
  1862. #define VALIDEX_DDVPE2CALLBACKSSIZE( ptr ) \
  1863. ( ( ( ( ptr )->dwSize % sizeof( LPVOID ) ) == 0 ) && \
  1864. ( ( ptr )->dwSize >= DDVPE2CALLBACKSSIZE ) )
  1865. #endif
  1866. #ifndef FAST_CHECKING
  1867. #define VALID_DIRECTDRAW_PTR( ptr ) VALIDEX_DIRECTDRAW_PTR( ptr )
  1868. #define VALID_DIRECTDRAWFACTORY2_PTR( ptr ) VALIDEX_DIRECTDRAWFACTORY2_PTR( ptr )
  1869. #define VALID_DIRECTDRAWSURFACE_PTR( ptr ) VALIDEX_DIRECTDRAWSURFACE_PTR( ptr )
  1870. #define VALID_DIRECTDRAWPALETTE_PTR( ptr ) VALIDEX_DIRECTDRAWPALETTE_PTR( ptr )
  1871. #define VALID_DIRECTDRAWCLIPPER_PTR( ptr ) VALIDEX_DIRECTDRAWCLIPPER_PTR( ptr )
  1872. #define VALID_DDSURFACEDESC_PTR( ptr ) \
  1873. (!IsBadWritePtr( ptr, sizeof( DDSURFACEDESC ) ) && \
  1874. (ptr->dwSize == sizeof( DDSURFACEDESC )))
  1875. #define VALID_DDSURFACEDESC2_PTR( ptr ) \
  1876. (!IsBadWritePtr( ptr, sizeof( DDSURFACEDESC2 ) ) && \
  1877. (ptr->dwSize == sizeof( DDSURFACEDESC2 )))
  1878. #define VALID_DDVIDEOPORTDESC_PTR( ptr ) \
  1879. (!IsBadWritePtr( ptr, sizeof( DDVIDEOPORTDESC ) ) && \
  1880. (ptr->dwSize == sizeof( DDVIDEOPORTDESC )) )
  1881. #define VALID_DDVIDEOPORTCAPS_PTR( ptr ) \
  1882. (!IsBadWritePtr( ptr, sizeof( DDVIDEOPORTCAPS ) ) && \
  1883. (ptr->dwSize == sizeof( DDVIDEOPORTCAPS )) )
  1884. #define VALID_DDVIDEOPORTINFO_PTR( ptr ) \
  1885. (!IsBadWritePtr( ptr, sizeof( DDVIDEOPORTINFO ) ) && \
  1886. (ptr->dwSize == sizeof( DDVIDEOPORTINFO )) )
  1887. #define VALID_DDVIDEOPORTBANDWIDTH_PTR( ptr ) \
  1888. (!IsBadWritePtr( ptr, sizeof( DDVIDEOPORTBANDWIDTH ) ) && \
  1889. (ptr->dwSize == sizeof( DDVIDEOPORTBANDWIDTH )) )
  1890. #define VALID_DDVIDEOPORTSTATUS_PTR( ptr ) \
  1891. (!IsBadWritePtr( ptr, sizeof( DDVIDEOPORTSTATUS ) ) && \
  1892. (ptr->dwSize == sizeof( DDVIDEOPORTSTATUS )) )
  1893. #define VALID_DDVIDEOPORTNOTIFY_PTR( ptr ) \
  1894. (!IsBadWritePtr( ptr, sizeof( DDVIDEOPORTNOTIFY ) ) )
  1895. #define VALID_DDCOLORCONTROL_PTR( ptr ) \
  1896. (!IsBadWritePtr( ptr, sizeof( DDCOLORCONTROL ) ) && \
  1897. (ptr->dwSize == sizeof( DDCOLORCONTROL )) )
  1898. #define VALID_DDKERNELCAPS_PTR( ptr ) \
  1899. (!IsBadWritePtr( ptr, sizeof( DDKERNELCAPS ) ) && \
  1900. (ptr->dwSize == sizeof( DDKERNELCAPS )) )
  1901. #define VALID_DWORD_PTR( ptr ) \
  1902. (!IsBadWritePtr( ptr, sizeof( DWORD ) ))
  1903. #define VALID_BOOL_PTR( ptr ) \
  1904. (!IsBadWritePtr( ptr, sizeof( BOOL ) ))
  1905. #define VALID_HDC_PTR( ptr ) \
  1906. (!IsBadWritePtr( ptr, sizeof( HDC ) ))
  1907. #define VALID_DDPIXELFORMAT_PTR( ptr ) \
  1908. (!IsBadWritePtr( ptr, sizeof( DDPIXELFORMAT ) ) && \
  1909. (ptr->dwSize == sizeof( DDPIXELFORMAT )) )
  1910. #define VALID_DDCOLORKEY_PTR( ptr ) \
  1911. (!IsBadWritePtr( ptr, sizeof( DDCOLORKEY ) ) )
  1912. #define VALID_RGNDATA_PTR( ptr, size ) \
  1913. (!IsBadWritePtr( ptr, size ) )
  1914. #define VALID_RECT_PTR( ptr ) \
  1915. (!IsBadWritePtr( ptr, sizeof( RECT ) ) )
  1916. #define VALID_DDBLTFX_PTR( ptr ) \
  1917. (!IsBadWritePtr( ptr, sizeof( DDBLTFX ) ) && \
  1918. (ptr->dwSize == sizeof( DDBLTFX )) )
  1919. #define VALID_DDBLTBATCH_PTR( ptr ) \
  1920. (!IsBadWritePtr( ptr, sizeof( DDBLTBATCH ) ) )
  1921. #define VALID_DDOVERLAYFX_PTR( ptr ) \
  1922. (!IsBadWritePtr( ptr, sizeof( DDOVERLAYFX ) ) && \
  1923. (ptr->dwSize == sizeof( DDOVERLAYFX )) )
  1924. #define VALID_DDSCAPS_PTR( ptr ) \
  1925. (!IsBadWritePtr( ptr, sizeof( DDSCAPS ) ) )
  1926. #define VALID_DDSCAPS2_PTR( ptr ) \
  1927. (!IsBadWritePtr( ptr, sizeof( DDSCAPS2 ) ) )
  1928. #define VALID_PTR_PTR( ptr ) \
  1929. (!IsBadWritePtr( ptr, sizeof( LPVOID )) )
  1930. #define VALID_IID_PTR( ptr ) \
  1931. (!IsBadReadPtr( ptr, sizeof( IID )) )
  1932. #define VALID_HWND_PTR( ptr ) \
  1933. (!IsBadWritePtr( (LPVOID) ptr, sizeof( HWND )) )
  1934. #define VALID_VMEM_PTR( ptr ) \
  1935. (!IsBadWritePtr( (LPVOID) ptr, sizeof( VMEM )) )
  1936. #define VALID_POINTER_ARRAY( ptr, cnt ) \
  1937. (!IsBadWritePtr( ptr, sizeof( LPVOID ) * cnt ) )
  1938. #define VALID_PALETTEENTRY_ARRAY( ptr, cnt ) \
  1939. (!IsBadWritePtr( ptr, sizeof( PALETTEENTRY ) * cnt ) )
  1940. #define VALID_HANDLE_PTR( ptr ) \
  1941. (!IsBadWritePtr( ptr, sizeof( HANDLE )) )
  1942. #define VALID_DDCORECAPS_PTR( ptr ) \
  1943. (!IsBadWritePtr( ptr, sizeof( DDCORECAPS ) ) && \
  1944. (ptr->dwSize == sizeof( DDCORECAPS ) ) )
  1945. #define VALID_DDCAPS_PTR( ptr ) \
  1946. ( ( !IsBadWritePtr( ptr, sizeof( DWORD ) ) ) && \
  1947. ( !IsBadWritePtr( ptr, ptr->dwSize ) ) && \
  1948. ( ( ptr->dwSize == sizeof( DDCAPS_DX1 ) ) || \
  1949. ( ptr->dwSize == sizeof( DDCAPS_DX3 ) ) || \
  1950. ( ptr->dwSize == sizeof( DDCAPS_DX5 ) ) || \
  1951. ( ptr->dwSize == sizeof( DDCAPS_DX6 ) ) || \
  1952. ( ptr->dwSize == sizeof( DDCAPS_DX7 ) ) ) )
  1953. #define VALID_READ_DDSURFACEDESC_ARRAY( ptr, cnt ) \
  1954. (!IsBadReadPtr( ptr, sizeof( DDSURFACEDESC ) * 1 * cnt ) )
  1955. #define VALID_DWORD_ARRAY( ptr, cnt ) \
  1956. (!IsBadWritePtr( ptr, sizeof( DWORD ) * 1 * cnt ) )
  1957. #define VALID_GUID_PTR( ptr ) \
  1958. (!IsBadReadPtr( ptr, sizeof( GUID ) ) )
  1959. #define VALID_BYTE_ARRAY( ptr, cnt ) \
  1960. (!IsBadWritePtr( ptr, sizeof( BYTE ) * 1 * cnt ) )
  1961. #define VALID_PTR( ptr, size ) \
  1962. (!IsBadReadPtr( ptr, size) )
  1963. #define VALID_DDVIDEOPORT_PTR( ptr ) \
  1964. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DDVIDEOPORT_INT )) && \
  1965. ( (ptr->lpVtbl == &ddVideoPortCallbacks) || \
  1966. (ptr->lpVtbl == &ddVideoPortNotifyCallbacks)))
  1967. #define VALID_DDOPTSURFACEDESC_PTR( ptr ) \
  1968. (!IsBadWritePtr( ptr, sizeof( DDOPTSURFACEDESC ) ) && \
  1969. (ptr->dwSize == sizeof( DDOPTSURFACEDESC )))
  1970. #define VALID_DDMOTIONCOMP_PTR( ptr ) \
  1971. (!IsBadWritePtr( ptr, sizeof( DDRAWI_DDMOTIONCOMP_INT )) && \
  1972. (ptr->lpVtbl == &ddMotionCompCallbacks) )
  1973. #else
  1974. #define VALID_PTR( ptr, size ) 1
  1975. #define VALID_DIRECTDRAW_PTR( ptr ) 1
  1976. #define VALID_DIRECTDRAWFACTORY2_PTR( ptr ) 1
  1977. #define VALID_DIRECTDRAWSURFACE_PTR( ptr ) 1
  1978. #define VALID_DIRECTDRAWPALETTE_PTR( ptr ) 1
  1979. #define VALID_DIRECTDRAWCLIPPER_PTR( ptr ) 1
  1980. #define VALID_DDSURFACEDESC_PTR( ptr ) (ptr->dwSize == sizeof( DDSURFACEDESC ))
  1981. #define VALID_DDSURFACEDESC2_PTR( ptr ) (ptr->dwSize == sizeof( DDSURFACEDESC2 ))
  1982. #define VALID_DDVIDEOPORTDESC_PTR( ptr ) (ptr->dwSize == sizeof( DDVIDEOPORTDESC ))
  1983. #define VALID_DDVIDEOPORTCAPS_PTR( ptr ) (ptr->dwSize == sizeof( DDVIDEOPORTCAPS ))
  1984. #define VALID_DDVIDEOPORTINFO_PTR( ptr ) (ptr->dwSize == sizeof( DDVIDEOPORTINFO ))
  1985. #define VALID_DDVIDEOPORTBANDWIDTH_PTR( ptr ) (ptr->dwSize == sizeof( DDVIDEOPORTBANDWIDTH ))
  1986. #define VALID_DDVIDEOPORTSTATUS_PTR( ptr ) (ptr->dwSize == sizeof( DDVIDEOPORTSTATUS ))
  1987. #define VALID_DDVIDEOPORTNOTIFY_PTR( ptr ) 1
  1988. #define VALID_DDCOLORCONTROL_PTR( ptr ) (ptr->dwSize == sizeof( DDCOLORCONTROL ))
  1989. #define VALID_DDKERNELCAPS_PTR( ptr) (ptr->dwSize == sizeof( DDKERNELCAPS ))
  1990. #define VALID_DWORD_PTR( ptr ) 1
  1991. #define VALID_BOOL_PTR( ptr ) 1
  1992. #define VALID_HDC_PTR( ptr ) 1
  1993. #define VALID_DDPIXELFORMAT_PTR( ptr ) (ptr->dwSize == sizeof( DDPIXELFORMAT ))
  1994. #define VALID_DDCOLORKEY_PTR( ptr ) 1
  1995. #define VALID_RGNDATA_PTR( ptr ) 1
  1996. #define VALID_RECT_PTR( ptr ) 1
  1997. #define VALID_DDOVERLAYFX_PTR( ptr ) (ptr->dwSize == sizeof( DDOVERLAYFX ))
  1998. #define VALID_DDBLTFX_PTR( ptr ) (ptr->dwSize == sizeof( DDBLTFX ))
  1999. #define VALID_DDBLTBATCH_PTR( ptr ) 1
  2000. #define VALID_DDMASK_PTR( ptr ) 1
  2001. #define VALID_DDSCAPS_PTR( ptr ) 1
  2002. #define VALID_DDSCAPS2_PTR( ptr ) 1
  2003. #define VALID_PTR_PTR( ptr ) 1
  2004. #define VALID_IID_PTR( ptr ) 1
  2005. #define VALID_HWND_PTR( ptr ) 1
  2006. #define VALID_VMEM_PTR( ptr ) 1
  2007. #define VALID_POINTER_ARRAY( ptr, cnt ) 1
  2008. #define VALID_PALETTEENTRY_ARRAY( ptr, cnt ) 1
  2009. #define VALID_HANDLE_PTR( ptr ) 1
  2010. #define VALID_DDCORECAPS_PTR( ptr ) (ptr->dwSize == sizeof( DDCORECAPS )
  2011. #define VALID_DDCAPS_PTR( ptr ) \
  2012. ( ( ptr->dwSize == sizeof( DDCAPS_DX1 ) ) || \
  2013. ( ptr->dwSize == sizeof( DDCAPS_DX3 ) ) || \
  2014. ( ptr->dwSize == sizeof( DDCAPS_DX5 ) ) || \
  2015. ( ptr->dwSize == sizeof( DDCAPS_DX6 ) ) || \
  2016. ( ptr->dwSize == sizeof( DDCAPS_DX7 ) ) )
  2017. #define VALID_READ_DDSURFACEDESC_ARRAY( ptr, cnt ) 1
  2018. #define VALID_DWORD_ARRAY( ptr, cnt ) 1
  2019. #define VALID_GUID_PTR( ptr ) 1
  2020. #define VALID_BYTE_ARRAY( ptr, cnt ) 1
  2021. #define VALID_DDVIDEOPORT_PTR( ptr ) 1
  2022. #define VALID_DDOPTSURFACEDESC_PTR( ptr ) (ptr->dwSize == sizeof( DDOPTSURFACEDESC ))
  2023. #define VALID_DDMOTIONCOMP_PTR( ptr ) 1
  2024. #endif
  2025. /*
  2026. * All global (i.e. cross-process) values now reside in an instance of the following structure.
  2027. * This instance is in its own shared data section.
  2028. */
  2029. #undef GLOBALS_IN_STRUCT
  2030. #ifdef GLOBALS_IN_STRUCT
  2031. #define GLOBAL_STORAGE_CLASS
  2032. typedef struct
  2033. {
  2034. #else
  2035. #define GLOBAL_STORAGE_CLASS extern
  2036. #endif
  2037. /*
  2038. * This member should stay at the top in order to guarantee that it be intialized to zero
  2039. * -see dllmain.c 's instance of this structure
  2040. */
  2041. GLOBAL_STORAGE_CLASS DWORD dwRefCnt;
  2042. GLOBAL_STORAGE_CLASS DWORD dwLockCount;
  2043. GLOBAL_STORAGE_CLASS DWORD dwFakeCurrPid;
  2044. GLOBAL_STORAGE_CLASS DWORD dwGrimReaperPid;
  2045. GLOBAL_STORAGE_CLASS LPDDWINDOWINFO lpWindowInfo; // the list of WINDOWINFO structures
  2046. GLOBAL_STORAGE_CLASS LPDDRAWI_DIRECTDRAW_INT lpDriverObjectList;
  2047. GLOBAL_STORAGE_CLASS LPDDRAWI_DIRECTDRAW_LCL lpDriverLocalList;
  2048. GLOBAL_STORAGE_CLASS volatile DWORD dwMarker;
  2049. /*
  2050. * This is the globally maintained list of clippers not owned by any
  2051. * DirectDraw object. All clippers created with DirectDrawClipperCreate
  2052. * are placed on this list. Those created by IDirectDraw_CreateClipper
  2053. * are placed on the clipper list of thier owning DirectDraw object.
  2054. *
  2055. * The objects on this list are NOT released when an app's DirectDraw
  2056. * object is released. They remain alive until explictly released or
  2057. * the app. dies.
  2058. */
  2059. GLOBAL_STORAGE_CLASS LPDDRAWI_DDRAWCLIPPER_INT lpGlobalClipperList;
  2060. GLOBAL_STORAGE_CLASS HINSTANCE hModule;
  2061. GLOBAL_STORAGE_CLASS LPATTACHED_PROCESSES lpAttachedProcesses;
  2062. GLOBAL_STORAGE_CLASS BOOL bFirstTime;
  2063. #ifdef DEBUG
  2064. GLOBAL_STORAGE_CLASS int iDLLCSCnt;
  2065. GLOBAL_STORAGE_CLASS int iWin16Cnt;
  2066. #endif
  2067. /*
  2068. * Winnt specific global statics
  2069. */
  2070. /*
  2071. *Hel globals:
  2072. */
  2073. // used to count how many drivers are currently using the HEL
  2074. GLOBAL_STORAGE_CLASS DWORD dwHELRefCnt;
  2075. #ifdef WINNT
  2076. GLOBAL_STORAGE_CLASS LPDCISURFACEINFO gpdci;
  2077. #endif
  2078. #ifdef DEBUG
  2079. // these are used by myCreateSurface
  2080. GLOBAL_STORAGE_CLASS int gcSurfMem; // surface memory in bytes
  2081. GLOBAL_STORAGE_CLASS int gcSurf; // number of surfaces
  2082. #endif
  2083. GLOBAL_STORAGE_CLASS DWORD dwHelperPid;
  2084. #ifdef WINNT
  2085. GLOBAL_STORAGE_CLASS HANDLE hExclusiveModeMutex;
  2086. GLOBAL_STORAGE_CLASS HANDLE hCheckExclusiveModeMutex;
  2087. #endif
  2088. #ifdef GLOBALS_IN_STRUCT
  2089. } GLOBALS;
  2090. /*
  2091. * And this is the pointer to the globals. Each process has an instance (contained in dllmain.c)
  2092. */
  2093. //extern GLOBALS * gp;
  2094. extern GLOBALS g_s;
  2095. #endif //globals in struct
  2096. /*
  2097. * IMPORTANT NOTE: This function validates the HAL information passed to us from the driver.
  2098. * It is vital that we code this check so that we will pass HAL information structures
  2099. * larger than the ones we know about so that new drivers can work with old DirectDraws.
  2100. */
  2101. #define VALIDEX_DDHALINFO_PTR( ptr ) \
  2102. ( ( ( ( ptr )->dwSize == sizeof( DDHALINFO_V1 ) ) || \
  2103. ( ( ptr )->dwSize == DDHALINFOSIZE_V2 ) || \
  2104. ( ( ptr )->dwSize >= sizeof( DDHALINFO ) ) ) && \
  2105. !IsBadWritePtr( ( ptr ), ( UINT ) ( ( ptr )->dwSize ) ) )
  2106. #define VALIDEX_STR_PTR( ptr, len ) \
  2107. (!IsBadReadPtr( ptr, 1 ) && (lstrlen( ptr ) <len) )
  2108. #define VALIDEX_DDSURFACEDESC_PTR( ptr ) \
  2109. (!IsBadWritePtr( ptr, sizeof( DDSURFACEDESC ) ) && \
  2110. (ptr->dwSize == sizeof( DDSURFACEDESC )) )
  2111. #define VALIDEX_DDSURFACEDESC2_PTR( ptr ) \
  2112. (!IsBadWritePtr( ptr, sizeof( DDSURFACEDESC2 ) ) && \
  2113. (ptr->dwSize == sizeof( DDSURFACEDESC2 )) )
  2114. // Internal flags required to create special DX8 surfaces
  2115. #define DX8SFLAG_DX8 0x00000001
  2116. #define DX8SFLAG_ISLOST 0x00000002
  2117. #define DX8SFLAG_ISLIGHTWEIGHT 0x00000004
  2118. #define DX8SFLAG_IMAGESURF 0x00000008
  2119. /* Turn on D3D stats collection for Debug builds HERE */
  2120. #define COLLECTSTATS DBG
  2121. #ifdef __cplusplus
  2122. } // extern "C"
  2123. #endif
  2124. #endif