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.

142 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dbgmem.h
  5. Abstract:
  6. This module contains memory debug function prototypes and macros.
  7. Author:
  8. Jim Stewart January 8, 1997
  9. Revision History:
  10. Ofer Bar ( oferbar ) Oct 1, 1996 - Revision II changes
  11. --*/
  12. #ifdef DBG
  13. //
  14. // define the amount of symbol info to keep per function in the stack trace.
  15. //
  16. #define MAX_FUNCTION_INFO_SIZE 20
  17. typedef struct {
  18. DWORD_PTR Displacement; // displacement into the function
  19. UCHAR Buff[MAX_FUNCTION_INFO_SIZE]; // name of function on call stack
  20. } CALLER_SYM, *PCALLER_SYM;
  21. //
  22. // NOTE:
  23. // If you change the structure of MEM_TRACKER, please make sure it's size
  24. // aligned to 8-byte boundary
  25. //
  26. #define NCALLERS 5
  27. typedef struct {
  28. LIST_ENTRY Linkage;
  29. PSZ szFile;
  30. ULONG nLine;
  31. ULONG nSize;
  32. ULONG ulAllocNum;
  33. CALLER_SYM Callers[NCALLERS];
  34. ULONG ulCheckSum;
  35. ULONG ulPad; // To make the struct aligned to 8-byte
  36. } MEM_TRACKER, *PMEM_TRACKER;
  37. BOOL
  38. InitDebugMemory(
  39. );
  40. VOID
  41. DeInitDebugMemory(
  42. );
  43. VOID
  44. UpdateCheckBytes(
  45. IN PMEM_TRACKER TrackMem
  46. );
  47. BOOL
  48. FCheckCheckBytes(
  49. IN PMEM_TRACKER TrackMem
  50. );
  51. BOOL
  52. FCheckAllocatedMemory();
  53. VOID
  54. AddPamem(
  55. IN PMEM_TRACKER TrackMem
  56. );
  57. VOID
  58. RemovePamem(
  59. IN PMEM_TRACKER TrackMem
  60. );
  61. VOID
  62. GetCallStack(
  63. IN PCALLER_SYM pdwCaller,
  64. IN int cSkip,
  65. IN int cFind
  66. );
  67. PVOID
  68. AllocMemory(
  69. IN DWORD nSize,
  70. IN BOOL Calloc,
  71. IN PSZ szFileName,
  72. IN DWORD nLine
  73. );
  74. PVOID
  75. ReAllocMemory(
  76. IN PVOID pvOld,
  77. IN DWORD nSizeNew,
  78. IN PSZ szFileName,
  79. IN DWORD nLine
  80. );
  81. VOID
  82. FreeMemory(
  83. IN PVOID pv,
  84. IN PSZ szFileName,
  85. IN DWORD nLine
  86. );
  87. BOOL
  88. DumpAllocatedMemory();
  89. BOOL
  90. SearchAllocatedMemory(
  91. IN PSZ szFile,
  92. IN DWORD nLine
  93. );
  94. VOID
  95. Trace(
  96. IN DWORD Severity,
  97. IN const CHAR *Format,
  98. IN ...
  99. );
  100. BOOL
  101. ControlCTermination(
  102. IN DWORD ControlType
  103. );
  104. #endif // #ifdef DBG
  105.