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.

78 lines
2.5 KiB

  1. #ifndef _DBGMEMP_H
  2. #define _DBGMEMP_H
  3. #include <windows.h>
  4. #include <string.h>
  5. #include "cmn_debug.h" // For our local version of Assert()
  6. // Define ENABLE_DBG_HANDLES if you want to be enable the moveable block
  7. // portion of the memory allocator
  8. #undef ENABLE_DBG_HANDLES
  9. // The base allocator type
  10. typedef struct head /* Private memory block header */
  11. {
  12. DWORD dwTag; /* Block validation ID */
  13. struct head* pheadNext; /* Next in list of allocated blocks */
  14. int idBlock; /* Block "name" */
  15. DWORD cbBlock; /* Size of caller's memory block */
  16. int cLock; /* Lock count of object */
  17. LPBYTE pbBase; /* The VirtualAlloc'd block */
  18. } HEAD;
  19. #define HEAD_TAG ( MAKELONG( MAKEWORD('H','E'),MAKEWORD('A','D') ))
  20. #define PAD(a,n) ( ((a)+(n)-1) / (n) * (n) )
  21. // byte patterns for filling memory
  22. #define bNewGarbage 0xA3
  23. #define bOldGarbage 0xA4
  24. #define bFreeGarbage 0xA5
  25. #define bDebugByte 0xE1
  26. // Flags for enabling particular types of optional behavior
  27. // if fMove is true, blah blah
  28. // if fExtraReadPage is true, blah blah
  29. // if fPadBlocks is true, all memory allocations will be padded to 4-byte boundaries
  30. #define fMove FALSE
  31. #define fExtraReadPage FALSE
  32. #ifdef _M_ALPHA
  33. // Enable dword alignment (padding to 4 byte boundaries) for the Alpha
  34. #define fPadBlocks TRUE
  35. #else // not _M_ALPHA
  36. #define fPadBlocks FALSE
  37. #endif // _M_ALPHA
  38. // Protos that must be shared between our source files
  39. HEAD *GetBlockHeader(void*);
  40. LPVOID PvAllocateCore(UINT, DWORD);
  41. #ifdef ENABLE_DBG_HANDLES
  42. #define minGHandle 0xA0000000L
  43. #define cGHandles 0x4000L
  44. #define limGHandle (minGHandle+cGHandles)
  45. HGLOBAL WINAPI HgAllocateMoveable(UINT uFlags, DWORD cb);
  46. HGLOBAL WINAPI HgModifyMoveable(HGLOBAL hMem, DWORD cb, UINT uFlags);
  47. void **PpvFromHandle(HGLOBAL);
  48. #else // NOT ENABLE_DBG_HANDLES
  49. #define HgAllocateMoveable(a, b) (NULL)
  50. #define HgModifyMoveable(a, b, c) (NULL)
  51. #define PpvFromHandle(a) (NULL)
  52. #endif // ENABLE_DBG_HANDLES
  53. /* F A C T U A L H A N D L E */
  54. /*----------------------------------------------------------------------------
  55. %%Macro: FActualHandle
  56. Returns TRUE if the handle came from actual Global memory manager.
  57. ----------------------------------------------------------------------------*/
  58. #define FActualHandle(hMem) FALSE
  59. #endif // _DBGMEMP_H