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.

111 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. heap.c
  5. Abstract:
  6. This module implements verification functions for
  7. NT heap management interfaces.
  8. Author:
  9. Silviu Calinoiu (SilviuC) 7-Mar-2001
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #include "verifier.h"
  14. #include "support.h"
  15. #define AVRFP_DIRTY_STACK_FREQUENCY 1
  16. LONG AVrfpDirtyStackCounter;
  17. //NTSYSAPI
  18. PVOID
  19. NTAPI
  20. AVrfpRtlAllocateHeap(
  21. IN PVOID HeapHandle,
  22. IN ULONG Flags,
  23. IN SIZE_T Size
  24. )
  25. {
  26. PVOID Result;
  27. Result = RtlAllocateHeap (HeapHandle,
  28. Flags,
  29. Size);
  30. if (Result) {
  31. HeapLogCall (Result, Size);
  32. }
  33. if ((InterlockedIncrement(&AVrfpDirtyStackCounter) % AVRFP_DIRTY_STACK_FREQUENCY) == 0) {
  34. AVrfpDirtyThreadStack ();
  35. }
  36. return Result;
  37. }
  38. //NTSYSAPI
  39. BOOLEAN
  40. NTAPI
  41. AVrfpRtlFreeHeap(
  42. IN PVOID HeapHandle,
  43. IN ULONG Flags,
  44. IN PVOID BaseAddress
  45. )
  46. {
  47. BOOLEAN Result;
  48. Result = RtlFreeHeap (HeapHandle,
  49. Flags,
  50. BaseAddress);
  51. if (Result) {
  52. HeapLogCall (BaseAddress, 0);
  53. }
  54. if ((InterlockedIncrement(&AVrfpDirtyStackCounter) % AVRFP_DIRTY_STACK_FREQUENCY) == 0) {
  55. AVrfpDirtyThreadStack ();
  56. }
  57. return Result;
  58. }
  59. //NTSYSAPI
  60. PVOID
  61. NTAPI
  62. AVrfpRtlReAllocateHeap(
  63. IN PVOID HeapHandle,
  64. IN ULONG Flags,
  65. IN PVOID BaseAddress,
  66. IN SIZE_T Size
  67. )
  68. {
  69. PVOID Result;
  70. Result = RtlReAllocateHeap (HeapHandle,
  71. Flags,
  72. BaseAddress,
  73. Size);
  74. if (Result) {
  75. HeapLogCall (BaseAddress, 0);
  76. HeapLogCall (Result, Size);
  77. }
  78. if ((InterlockedIncrement(&AVrfpDirtyStackCounter) % AVRFP_DIRTY_STACK_FREQUENCY) == 0) {
  79. AVrfpDirtyThreadStack ();
  80. }
  81. return Result;
  82. }