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.

138 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. hctytools.h
  5. Abstract:
  6. Contains the definitions used by hcttools.c
  7. Environment:
  8. User mode
  9. Revision History:
  10. 05-Sep-1997 : Jason Allor (jasonall)
  11. --*/
  12. #include "windows.h"
  13. #include "stdlib.h"
  14. #include "stdio.h"
  15. #include "tchar.h"
  16. #ifndef _MYTOOLS_H
  17. #define _MYTOOLS_H
  18. #define MAX_ERROR_LEN 256
  19. #define RETURN_CHAR1 0x0d
  20. #define RETURN_CHAR2 0x0a
  21. #define SPACE 0x20
  22. BOOL __MALLOC(IN OUT void **ppv,
  23. IN size_t size,
  24. IN PCHAR cszFile,
  25. IN UINT iLine);
  26. void __FREE(IN void **pv);
  27. VOID CheckAllocs();
  28. VOID InitializeMemoryManager();
  29. #ifdef DEBUG
  30. typedef struct _BLOCKINFO
  31. {
  32. struct _BLOCKINFO *pbiNext;
  33. BYTE *pb;
  34. size_t size;
  35. BOOL boolReferenced;
  36. UINT iLine;
  37. CHAR cszFile[MAX_PATH];
  38. } BLOCKINFO, *PBLOCKINFO;
  39. #define Ptrless(pLeft, pRight) ((pLeft < (pRight))
  40. #define PtrGrtr(pLeft, pRight) ((pLeft) > (pRight))
  41. #define PtrEqual(pLeft, pRight) ((pLeft) == (pRight))
  42. #define PtrLessEq(pLeft, pRight) ((pLeft) <= (pRight))
  43. #define PtrGrtrEq(pLeft, pRight) ((pLeft) >= (pRight))
  44. void MyAssert(PCHAR, unsigned);
  45. BOOL CreateBlockInfo(OUT PBYTE pbNew,
  46. IN size_t sizeNew,
  47. IN PCHAR cszFile,
  48. IN UINT iLine);
  49. void UpdateBlockInfo(PBYTE pbOld, PBYTE pbNew, size_t sizeNew);
  50. size_t SizeOfBlock(PBYTE pb);
  51. void ClearMemoryRegs();
  52. void NoteMemoryRef(PVOID pv);
  53. void CheckMemoryRefs();
  54. BOOL ValidPointer(PVOID pv, size_t size);
  55. #define GARBAGE 0xCC // used for shredding memory during Malloc and Free
  56. #endif
  57. //
  58. // Define __ASSERT macro
  59. //
  60. #ifdef DEBUG
  61. #define __ASSERT(f) \
  62. if (f) \
  63. {} \
  64. else \
  65. MyAssert(__FILE__, __LINE__)
  66. #else
  67. #define __ASSERT(f)
  68. #endif
  69. //
  70. // Define __Malloc macro. This gives the MALLOC function
  71. // the file name and line number of the line calling MyMalloc
  72. //
  73. #define __Malloc(one, two) __MALLOC(one, two, __FILE__, __LINE__)
  74. //
  75. // Define the __Free macro. This is only here for consistency with __Malloc
  76. //
  77. #define __Free(one) __FREE(one)
  78. BOOL StrNCmp(IN PTCHAR tszString1,
  79. IN PTCHAR tszString2,
  80. IN ULONG ulLength);
  81. BOOL StrCmp(IN PTCHAR tszString1,
  82. IN PTCHAR tszString2);
  83. PWCHAR AnsiToUnicode(IN PCHAR cszAnsi,
  84. OUT PWCHAR wszUnicode,
  85. IN ULONG ulSize);
  86. PCHAR UnicodeToAnsi(IN PWCHAR wszUnicode,
  87. OUT PCHAR cszAnsi,
  88. IN ULONG ulSize);
  89. PTCHAR ConvertAnsi(IN PCHAR cszAnsi,
  90. IN OUT PWCHAR wszUnicode,
  91. IN ULONG ulSize);
  92. PTCHAR ConvertUnicode(IN PWCHAR wszUnicode,
  93. IN OUT PCHAR cszAnsi,
  94. IN ULONG ulSize);
  95. PTCHAR ErrorMsg(IN ULONG ulError,
  96. IN PTCHAR tszBuffer);
  97. #endif // _MYTOOLS_H