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.

103 lines
3.6 KiB

  1. /*
  2. * glheap.h
  3. *
  4. * Private definitions for GLHEAP facility
  5. *
  6. * Copyright (C) 1994 Microsoft Corporation
  7. */
  8. #ifndef _GLHEAP_H_
  9. #define _GLHEAP_H_
  10. #ifndef __GLHEAP_H_
  11. #include "_glheap.h"
  12. #endif
  13. #if defined (WIN32) && !defined (MAC) && !defined(_WIN64)
  14. #define HEAPMON
  15. #endif
  16. #define chDefaultFill ((BYTE)0xFE)
  17. #define NCALLERS 20
  18. typedef struct LH LH, * PLH, ** PPLH;
  19. typedef struct LHBLK LHBLK, * PLHBLK, ** PPLHBLK;
  20. #ifdef HEAPMON
  21. typedef BOOL (APIENTRY HEAPMONPROC)(PLH plh, ULONG ulFlags);
  22. typedef HEAPMONPROC FAR *LPHEAPMONPROC;
  23. typedef BOOL (APIENTRY GETSYMNAMEPROC)(DWORD, LPSTR, LPSTR, DWORD FAR *);
  24. typedef GETSYMNAMEPROC FAR *LPGETSYMNAMEPROC;
  25. #define HEAPMON_LOAD ((ULONG) 0x00000001)
  26. #define HEAPMON_UNLOAD ((ULONG) 0x00000002)
  27. #define HEAPMON_PING ((ULONG) 0x00000003)
  28. #endif
  29. #define HEAP_USE_VIRTUAL ((ULONG) 0x00000001)
  30. #define HEAP_DUMP_LEAKS ((ULONG) 0x00000002)
  31. #define HEAP_ASSERT_LEAKS ((ULONG) 0x00000004)
  32. #define HEAP_FILL_MEM ((ULONG) 0x00000008)
  33. #define HEAP_HEAP_MONITOR ((ULONG) 0x00000010)
  34. #define HEAP_USE_VIRTUAL_4 ((ULONG) 0x00000020)
  35. #define HEAP_FAILURES_ENABLED ((ULONG) 0x00000040)
  36. #define HEAP_LOCAL ((ULONG) 0x10000000)
  37. #define HEAP_GLOBAL ((ULONG) 0x20000000)
  38. typedef void (__cdecl *LPLHSETNAME)(LPVOID, char *, ...);
  39. struct LHBLK
  40. {
  41. HLH hlh; // Heap this block was allocated on
  42. PLHBLK plhblkPrev; // Pointer to the previous allocation this heap
  43. PLHBLK plhblkNext; // Pointer to the next allocation this heap
  44. TCHAR szName[128]; // We can name blocks allocated on a heap
  45. ULONG ulAllocNum; // Allocation number (Id) for this block
  46. ULONG ulSize; // Number of bytes the client requested
  47. FARPROC pfnCallers[NCALLERS]; // Call stack during this allocation
  48. LPVOID pv; // Pointer to the client data
  49. };
  50. struct LH
  51. {
  52. LPLHSETNAME pfnSetName; // Pointer to LH_SetNameFn function
  53. _HLH _hlhData; // The underlying heap that we alloc data from
  54. _HLH _hlhBlks; // The underlying heap that we alloc lhblks from
  55. PLH pNext; // Pointer to the next heap in a list of heaps
  56. TCHAR szHeapName[32]; // We can name our heaps for display purposes
  57. ULONG ulAllocNum; // Allocation number this heap since Open
  58. PLHBLK plhblkHead; // Link-list of allocations on this heap
  59. ULONG ulFlags; // Combination of the HEAP_ flags above
  60. BYTE chFill; // Character to fill memory with
  61. #ifdef HEAPMON
  62. HINSTANCE hInstHeapMon; // DLL instance of the HeapMonitor DLL
  63. LPHEAPMONPROC pfnHeapMon; // Entry point into HeapMonitor DLL
  64. #endif
  65. #if defined(WIN32) && !defined(MAC)
  66. CRITICAL_SECTION cs; // Critcal section to protect access to heap
  67. #endif
  68. UINT uiFailBufSize; // If HEAP_FAILURES_ENABLED, this is the minimum size in
  69. // which failures occur. 1 means alloc's of any size fail.
  70. // 0 means never fail.
  71. ULONG ulFailInterval; // If HEAP_FAILURES_ENABLED, this is the period on which the
  72. // failures occur. 1 means every alloc will fail. 0 means never
  73. // fail.
  74. ULONG ulFailStart; // If HEAP_FAILURES_ENABLED, this is the allocation number that
  75. // the first failure will occur on. 1 means the first alloc. 0
  76. // means never start failing.
  77. // Put at end to avoid re-compile of World!
  78. #ifdef HEAPMON
  79. LPGETSYMNAMEPROC pfnGetSymName; // Resolve address to Symbol
  80. #endif
  81. };
  82. PLHBLK PvToPlhblk(HLH hlh, LPVOID pv);
  83. #define PlhblkToPv(pblk) ((LPVOID)((PLHBLK)(pblk)->pv))
  84. #define CbPlhblkClient(pblk) (((PLHBLK)(pblk))->ulSize)
  85. #define CbPvClient(hlh, pv) (CbPlhblkClient(PvToPlhblk(hlh, pv)))
  86. #define CbPvAlloc(hlh, pv) (CbPlhblkAlloc(PvToPlhblk(hlh, pv)))
  87. #endif