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.

114 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name :
  4. topobj.h
  5. Abstract:
  6. Base object handles default operations for all our objects and contains
  7. a central location for debugging entries
  8. Revision History:
  9. --*/
  10. #pragma once
  11. //
  12. // Global Memory Management Operators
  13. //
  14. #ifndef DRKDX
  15. inline void *__cdecl operator new(size_t sz)
  16. {
  17. void *ptr = DRALLOCATEPOOL(PagedPool, sz, DRGLOBAL_SUBTAG);
  18. return ptr;
  19. }
  20. inline void *__cdecl operator new(size_t sz, POOL_TYPE poolType)
  21. {
  22. void *ptr = DRALLOCATEPOOL(poolType, sz, DRGLOBAL_SUBTAG);
  23. return ptr;
  24. }
  25. inline void __cdecl operator delete( void *ptr )
  26. {
  27. DRFREEPOOL(ptr);
  28. }
  29. #endif // DRKDX
  30. class TopObj
  31. {
  32. private:
  33. BOOLEAN _IsValid;
  34. BYTE pad1;
  35. BYTE pad2;
  36. BYTE pad3;
  37. ULONG _ObjectType;
  38. #if DBG
  39. BOOLEAN _ForceTrace;
  40. BYTE pad4;
  41. BYTE pad5;
  42. BYTE pad6;
  43. #endif // DBG
  44. protected:
  45. virtual VOID SetValid(BOOLEAN IsValid = TRUE)
  46. {
  47. ASSERT(_magicNo == GOODMEMMAGICNUMBER);
  48. _IsValid = IsValid;
  49. }
  50. public:
  51. #if DBG
  52. ULONG _magicNo;
  53. PCHAR _ClassName;
  54. #define SetClassName(ClassName) _ClassName = (ClassName)
  55. #else // DBG
  56. #define SetClassName(ClassName)
  57. #endif // DBG
  58. //
  59. // IsValid function meaning is really defined by the individual object,
  60. // but one common use is to see if initialization succeeded
  61. //
  62. virtual BOOLEAN IsValid()
  63. {
  64. ASSERT(_magicNo == GOODMEMMAGICNUMBER);
  65. return _IsValid;
  66. }
  67. TopObj()
  68. {
  69. _IsValid = TRUE;
  70. _ObjectType = 0;
  71. SetClassName("TopObj");
  72. #if DBG
  73. _magicNo = GOODMEMMAGICNUMBER;
  74. #endif // DBG
  75. }
  76. virtual ~TopObj()
  77. {
  78. ASSERT(_magicNo == GOODMEMMAGICNUMBER);
  79. #if DBG
  80. memset(&_magicNo, BADMEM, sizeof(_magicNo));
  81. #endif // DBG
  82. }
  83. //
  84. // Memory Management Operators
  85. //
  86. inline void *__cdecl operator new(size_t sz, POOL_TYPE poolType=PagedPool)
  87. {
  88. void *ptr = DRALLOCATEPOOL(poolType, sz, DRTOPOBJ_SUBTAG);
  89. return ptr;
  90. }
  91. inline void __cdecl operator delete(void *ptr)
  92. {
  93. DRFREEPOOL(ptr);
  94. }
  95. };