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

109 lines
3.5 KiB

  1. //--------------------------------------------------------------------------;
  2. //
  3. // File: dxvalid.h
  4. //
  5. // Copyright (c) 1996 Microsoft Corporation. All Rights Reserved.
  6. //
  7. // Abstract:
  8. // This header contains common parameter validate macros for DirectX.
  9. //
  10. // History:
  11. // 02/14/96 angusm Initial version
  12. // 03/05/96 angusm added VALIDEX_GUID_PTR
  13. //
  14. //--------------------------------------------------------------------------;
  15. // _________________________________________________________________________
  16. // VALIDEX_xxx
  17. // macros are the same for debug and retail
  18. #define VALIDEX_PTR( ptr, size ) \
  19. (!IsBadReadPtr( ptr, size) )
  20. #define VALIDEX_GUID_PTR( ptr ) \
  21. (!IsBadReadPtr( ptr, sizeof( GUID ) ) )
  22. #define VALIDEX_IID_PTR( ptr ) \
  23. (!IsBadReadPtr( ptr, sizeof( IID )) )
  24. #define VALIDEX_PTR_PTR( ptr ) \
  25. (!IsBadWritePtr( ptr, sizeof( LPVOID )) )
  26. #define VALIDEX_CODE_PTR( ptr ) \
  27. (!IsBadCodePtr( (LPVOID) ptr ) )
  28. // _________________________________________________________________________
  29. // VALID_xxx
  30. // macros that check memory allocated and sent as API parameters
  31. #ifndef DEBUG
  32. #define FAST_CHECKING
  33. #endif
  34. #ifndef FAST_CHECKING
  35. #define VALID_BOOL_PTR( ptr ) \
  36. (!IsBadWritePtr( ptr, sizeof( BOOL ) ))
  37. #define VALID_DDCOLORKEY_PTR( ptr ) \
  38. (!IsBadWritePtr( ptr, sizeof( DDCOLORKEY ) ) )
  39. #define VALID_RGNDATA_PTR( ptr ) \
  40. (!IsBadWritePtr( ptr, sizeof( RGNDATA ) ) )
  41. #define VALID_RECT_PTR( ptr ) \
  42. (!IsBadWritePtr( ptr, sizeof( RECT ) ) )
  43. #define VALID_PTR_PTR( ptr ) \
  44. (!IsBadWritePtr( ptr, sizeof( LPVOID )) )
  45. #define VALID_IID_PTR( ptr ) \
  46. (!IsBadReadPtr( ptr, sizeof( IID )) )
  47. #define VALID_HWND_PTR( ptr ) \
  48. (!IsBadWritePtr( (LPVOID) ptr, sizeof( HWND )) )
  49. #define VALID_VMEM_PTR( ptr ) \
  50. (!IsBadWritePtr( (LPVOID) ptr, sizeof( VMEM )) )
  51. #define VALID_POINTER_ARRAY( ptr, cnt ) \
  52. (!IsBadWritePtr( ptr, sizeof( LPVOID ) * cnt ) )
  53. #define VALID_HANDLE_PTR( ptr ) \
  54. (!IsBadWritePtr( ptr, sizeof( HANDLE )) )
  55. #define VALID_DWORD_ARRAY( ptr, cnt ) \
  56. (!IsBadWritePtr( ptr, sizeof( DWORD ) * cnt ) )
  57. #define VALID_GUID_PTR( ptr ) \
  58. (!IsBadReadPtr( ptr, sizeof( GUID ) ) )
  59. #define VALID_BYTE_ARRAY( ptr, cnt ) \
  60. (!IsBadWritePtr( ptr, sizeof( BYTE ) * cnt ) )
  61. #define VALID_PTR( ptr, size ) \
  62. (!IsBadReadPtr( ptr, size) )
  63. #else
  64. #define VALID_PTR( ptr, size ) 1
  65. #define VALID_DIRECTDRAW_PTR( ptr ) 1
  66. #define VALID_DIRECTDRAWSURFACE_PTR( ptr ) 1
  67. #define VALID_DIRECTDRAWPALETTE_PTR( ptr ) 1
  68. #define VALID_DIRECTDRAWCLIPPER_PTR( ptr ) 1
  69. #define VALID_DDSURFACEDESC_PTR( ptr ) (ptr->dwSize == sizeof( DDSURFACEDESC ))
  70. #define VALID_BOOL_PTR( ptr ) 1
  71. #define VALID_HDC_PTR( ptr ) 1
  72. #define VALID_DDPIXELFORMAT_PTR( ptr ) (ptr->dwSize == sizeof( DDPIXELFORMAT ))
  73. #define VALID_DDCOLORKEY_PTR( ptr ) 1
  74. #define VALID_RGNDATA_PTR( ptr ) 1
  75. #define VALID_RECT_PTR( ptr ) 1
  76. #define VALID_DDOVERLAYFX_PTR( ptr ) (ptr->dwSize == sizeof( DDOVERLAYFX ))
  77. #define VALID_DDBLTFX_PTR( ptr ) (ptr->dwSize == sizeof( DDBLTFX ))
  78. #define VALID_DDBLTBATCH_PTR( ptr ) 1
  79. #define VALID_DDMASK_PTR( ptr ) 1
  80. #define VALID_DDSCAPS_PTR( ptr ) 1
  81. #define VALID_PTR_PTR( ptr ) 1
  82. #define VALID_IID_PTR( ptr ) 1
  83. #define VALID_HWND_PTR( ptr ) 1
  84. #define VALID_VMEM_PTR( ptr ) 1
  85. #define VALID_POINTER_ARRAY( ptr, cnt ) 1
  86. #define VALID_PALETTEENTRY_ARRAY( ptr, cnt ) 1
  87. #define VALID_HANDLE_PTR( ptr ) 1
  88. #define VALID_DDCAPS_PTR( ptr ) (ptr->dwSize == sizeof( DDCAPS ))
  89. #define VALID_READ_DDSURFACEDESC_ARRAY( ptr, cnt ) 1
  90. #define VALID_DWORD_ARRAY( ptr, cnt ) 1
  91. #define VALID_GUID_PTR( ptr ) 1
  92. #define VALID_BYTE_ARRAY( ptr, cnt ) 1
  93. #endif