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.

169 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgnewp.hxx
  6. Abstract:
  7. Debug new private header file
  8. Author:
  9. Steve Kiraly (SteveKi) 23-June-1998
  10. Revision History:
  11. --*/
  12. #ifndef _DBGNEWP_HXX_
  13. #define _DBGNEWP_HXX_
  14. DEBUG_NS_BEGIN
  15. class TDebugNewTag;
  16. class TDebugNewAllocator
  17. {
  18. public:
  19. TDebugNewAllocator::
  20. TDebugNewAllocator(
  21. VOID
  22. );
  23. TDebugNewAllocator::
  24. ~TDebugNewAllocator(
  25. VOID
  26. );
  27. BOOL
  28. TDebugNewAllocator::
  29. bValid(
  30. VOID
  31. ) const;
  32. VOID
  33. TDebugNewAllocator::
  34. Initialize(
  35. IN UINT uSizeHint
  36. );
  37. VOID
  38. TDebugNewAllocator::
  39. Destroy(
  40. VOID
  41. );
  42. PVOID
  43. TDebugNewAllocator::
  44. Allocate(
  45. IN SIZE_T Size,
  46. IN PVOID pVoid,
  47. IN LPCTSTR pszFile,
  48. IN UINT uLine
  49. );
  50. VOID
  51. TDebugNewAllocator::
  52. Release(
  53. IN PVOID pVoid
  54. );
  55. VOID
  56. TDebugNewAllocator::
  57. Report(
  58. IN UINT uDevice,
  59. IN LPCTSTR pszConfiguration
  60. ) const;
  61. private:
  62. enum
  63. {
  64. kDataHeapSize = 4096,
  65. kTagHeapSize = 4096,
  66. kHeaderPattern = 0xAA,
  67. kTailPattern = 0xCC,
  68. kDataAllocPattern = 0xBB,
  69. kDataFreePattern = 0xFF,
  70. };
  71. enum ValidationErrorCode
  72. {
  73. kValidationErrorSuccess,
  74. kValidationErrorInvalidHeader,
  75. kValidationErrorInvalidTail,
  76. kValidationErrorInvalidTailSignature,
  77. kValidationErrorInvalidTailPointer,
  78. kValidationErrorInvalidHeaderPtr,
  79. kValidationErrorInvalidHeaderSignature,
  80. kValidationErrorInvalidTagEntry,
  81. kValidationHeapPointer,
  82. kValidationErrorNullPointer,
  83. kValidationErrorUnknown,
  84. };
  85. //
  86. // Structure placed before each allocation, used for
  87. // detecting leaks.
  88. //
  89. struct Header
  90. {
  91. PVOID pTag; // Pointer into tag data base
  92. PVOID pSignature; // Signature used for header overwrite detection.
  93. };
  94. //
  95. // Structure placed after each allocation, used for
  96. // allocation block overwrite.
  97. //
  98. struct Tail
  99. {
  100. PVOID pSignature; // Signature used for tail overwrite detection.
  101. };
  102. //
  103. // Copying and assignment are not defined.
  104. //
  105. TDebugNewAllocator::
  106. TDebugNewAllocator(
  107. const TDebugNewAllocator &rhs
  108. );
  109. const TDebugNewAllocator &
  110. TDebugNewAllocator::
  111. operator=(
  112. const TDebugNewAllocator &rhs
  113. );
  114. VOID
  115. TDebugNewAllocator::
  116. FillHeaderDataTailPattern(
  117. IN Header *pHeader,
  118. IN SIZE_T Size
  119. );
  120. ValidationErrorCode
  121. TDebugNewAllocator::
  122. ValidateHeaderDataTailPattern(
  123. IN PVOID pVoid,
  124. IN Header *pHeader
  125. );
  126. BOOL m_bValid;
  127. HANDLE m_hDataHeap;
  128. TDebugNewTag *m_pTag;
  129. };
  130. DEBUG_NS_END
  131. #endif // DBGNEWP_HXX