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.

91 lines
2.9 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1993.
  5. //
  6. // File: d:\win40ct\comtools\h\ctmem.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 27-Oct-93 DarrylA Created.
  15. // 1-May-94 DeanE Added VDATEHEAP macros
  16. // 8-Aug-95 ChrisAB Changed VDATEHEAP to raise an
  17. // exception instead of DebugBreak()
  18. //
  19. //----------------------------------------------------------------------
  20. #ifndef _CTMEM_HXX_
  21. #define _CTMEM_HXX_
  22. // Use dwCtValidateHeap to determine what happens when heap corruption
  23. // is detected. If set to 0x00000001, a STATUS_INTERNAL_DB_CORRUPTION
  24. // exception is raised. If set to 0x00000002, an OutputDebugMessage is
  25. // given. If anything else, no action is taken. Either set it
  26. // explicitly in your own code, or edit it in the debugger.
  27. // Default value is 0x00000001.
  28. extern DWORD dwCtValidateHeap;
  29. #ifdef _CAIRO_
  30. #include <except.hxx>
  31. #else
  32. // this is from except.h
  33. typedef enum _FAIL_BEHAVIOR
  34. {
  35. NullOnFail,
  36. ExceptOnFail
  37. } FAIL_BEHAVIOR;
  38. #endif
  39. void * __cdecl operator new(unsigned int nSize, FAIL_BEHAVIOR enfb);
  40. void * __cdecl operator new(unsigned int nSize);
  41. void __cdecl operator delete(void *pbData);
  42. void * __cdecl CtRealloc(void * memBlock,
  43. unsigned int nSize, FAIL_BEHAVIOR enfb);
  44. void * __cdecl CtRealloc(void * memBlock,
  45. unsigned int nSize);
  46. //
  47. // The following two functions are used as the cover functions for
  48. // IMalloc Alloc and Free calls which has the capability of sifting
  49. // the test code.
  50. //
  51. VOID FAR* IMallocAllocCtm(DWORD dwMemctx, ULONG ulCb);
  52. VOID IMallocFreeCtm(DWORD dwMemctx, void FAR* pv);
  53. VOID FAR* IMallocReallocCtm(DWORD dwMemctx, void FAR* pv, ULONG ulCb);
  54. // From cairole\ih\valid.h
  55. #if defined(WIN32) && !defined(_CHICAGO_) && !defined(_MAC)
  56. #define CT_EXCEPTION_HEAP (0x0C000001L)
  57. extern DWORD dwCtExceptionCode;
  58. #define VDATEHEAP() \
  59. if(!HeapValidate(GetProcessHeap(),0,0)) \
  60. { \
  61. if (0x00000001 == dwCtValidateHeap) \
  62. { \
  63. RaiseException(dwCtExceptionCode,0,0,0); \
  64. } \
  65. else \
  66. if (0x00000002 == dwCtValidateHeap) \
  67. { \
  68. OutputDebugStringW(L"FAIL - HeapValidate detects corrupt heap!"); \
  69. } \
  70. }
  71. #else
  72. #define VDATEHEAP()
  73. #endif // defined(WIN32) && !defined(_CHICAGO_) && !defined(_MAC)
  74. #endif // _CTMEM_HXX_