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.

73 lines
2.1 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: common.h
  3. *
  4. * Copyright (c) 1985-91, Microsoft Corporation
  5. *
  6. * History:
  7. \***************************************************************************/
  8. #ifndef _COMMON_
  9. #define _COMMON_
  10. extern HANDLE ghHeap;
  11. #ifdef _DEBUG_PRINT
  12. #define _DBGERROR 0x00000001
  13. #define _DBGWARNING 0x00000002
  14. #define _DBGVERBOSE 0x00000004
  15. #define _DBGALL 0xFFFFFFFF
  16. extern ULONG gThDebugFlag;
  17. #define DBGERROR(_params_) {if (gThDebugFlag & _DBGERROR)DbgPrint _params_ ; }
  18. #define DBGWARNING(_params_) {if (gThDebugFlag & _DBGWARNING)DbgPrint _params_ ; }
  19. #define DBGVERBOSE(_params_) {if (gThDebugFlag & _DBGVERBOSE)DbgPrint _params_ ; }
  20. #define DBGPRINT(_params_) DbgPrint _params_
  21. #else
  22. #define DBGERROR(_params_)
  23. #define DBGWARNING(_params_)
  24. #define DBGVERBOSE(_params_)
  25. #define DBGPRINT(_params_)
  26. #endif
  27. // misc defines
  28. //
  29. #define SUCCESS(s) ((s) == ERROR_SUCCESS)
  30. #define NO_SUCCESS(s) ((s) != ERROR_SUCCESS)
  31. #define ThAlloc( cbSize ) HeapAlloc( ghHeap, HEAP_ZERO_MEMORY, (cbSize));
  32. #define ThFree( pv ) HeapFree( ghHeap, 0, (pv));
  33. #define ThReAlloc( pv, cbSize) HeapReAlloc( ghHeap, 0, (pv), (cbSize));
  34. #ifdef _DEBUG
  35. #define MAX_PROCINFO 16
  36. typedef struct _tagBLOCKINFO {
  37. struct _tagBLOCKINFO *pbiNext;
  38. BYTE *pb; // Start of block
  39. ULONG ulSize; // Length of block
  40. BOOL fReferenced; // Ever referenced
  41. PROCESS_INFORMATION ProcInfo[MAX_PROCINFO];
  42. } BLOCKINFO, *PBLOCKINFO;
  43. BOOL fCreateBlockInfo(BYTE *pbNew, ULONG cbSizeNew);
  44. VOID FreeBlockInfo(BYTE *pbToFree);
  45. VOID UpdateBlockInfo(BYTE *pbOld, BYTE *pbNew, ULONG cbSizeNew);
  46. ULONG sizeofBlock(BYTE *pb);
  47. VOID ClearMemoryRefs(VOID);
  48. VOID NoteMemoryRef(VOID *pv);
  49. VOID CheckMemoryRefs(VOID);
  50. BOOL fValidPointer(VOID *pv, ULONG cbSize);
  51. #define bThNewGarbage 0xA3
  52. #define bThOldGarbage 0xA4
  53. #define bThFreeGarbage 0xA5
  54. #define bThDebugByte 0xE1
  55. #define sizeofDebugByte 1
  56. #else
  57. #define sizeofDebugByte 0
  58. #endif
  59. #endif // _COMMON_