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.

162 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. entrypt.h
  5. Abstract:
  6. The interface to the entry point module.
  7. Author:
  8. 16-Jun-1995 t-orig
  9. Revision History:
  10. --*/
  11. #ifndef _ENTRYPT_H_
  12. #define _ENTRYPT_H_
  13. //
  14. // Time to wait, in milliseconds, to sleep before retrying a memory
  15. // allocation which failed due to lack of free pages.
  16. //
  17. #define CPU_WAIT_FOR_MEMORY_TIME 200
  18. //
  19. // Number of times to retry memory allocations
  20. //
  21. #define CPU_MAX_ALLOCATION_RETRIES 4
  22. // Note: if BOTH is defined, than the code compiled will allow one to
  23. // retrieve an entry point structure from either an intel or native
  24. // address. If both is not defined, than an entry point structure
  25. // can only be retrieved from an intel address. Defining both
  26. // increases the cost (time and space) of most operation by a
  27. // factor of 2.
  28. //#define BOTH
  29. // Set this to 1 if you suspect there is a heap corruption which is
  30. // trashing the red-black trees. It creates a second red-black tree
  31. // which mirrors the first, and walks both trees frequently to ensure
  32. // they actually match. Since the checking mechanism uses NT asserts,
  33. // this only works on a checked NT build using a checked CPU.
  34. #define DBG_DUAL_TREES 0
  35. //
  36. // This timestamp is bumped whenever an entrypoint is added, split, or
  37. // when all entrypoits are flushed. It an be used to determine if
  38. // the entrypoints need to be re-searched afte switching from an Mrsw
  39. // reader to an Mrsw Writer.
  40. //
  41. extern DWORD EntrypointTimestamp;
  42. // The Entry Point Structure
  43. typedef struct _entryPoint {
  44. PVOID intelStart;
  45. PVOID intelEnd;
  46. PVOID nativeStart;
  47. PVOID nativeEnd;
  48. USHORT FlagsNeeded;
  49. struct _entryPoint *SubEP;
  50. #ifdef CODEGEN_PROFILE
  51. ULONG SequenceNumber;
  52. ULONG ExecutionCount;
  53. ULONG CreationTime;
  54. #endif
  55. } ENTRYPOINT, *PENTRYPOINT;
  56. // The colors
  57. typedef enum {RED, BLACK} COL;
  58. // The EPNODE structure
  59. typedef struct _epNode
  60. {
  61. ENTRYPOINT ep;
  62. struct _epNode *intelLeft;
  63. struct _epNode *intelRight;
  64. struct _epNode *intelParent;
  65. COL intelColor;
  66. #ifdef BOTH
  67. struct _epNode *nativeLeft;
  68. struct _epNode *nativeRight;
  69. struct _epNode *nativeParent;
  70. COL riscColor;
  71. #endif
  72. #if DBG_DUAL_TREES
  73. struct _epNode *dual;
  74. #endif
  75. } EPNODE, *PEPNODE;
  76. // Prototypes
  77. INT
  78. initializeEntryPointModule(
  79. void
  80. );
  81. PENTRYPOINT
  82. EPFromIntelAddr(
  83. PVOID intelAddr
  84. );
  85. PENTRYPOINT
  86. GetNextEPFromIntelAddr(
  87. PVOID intelAddr
  88. );
  89. VOID
  90. FlushEntrypoints(
  91. VOID
  92. );
  93. #ifdef BOTH
  94. PENTRYPOINT
  95. EPFromNativeAddr(
  96. PVOID nativeAddr
  97. );
  98. #endif
  99. INT
  100. insertEntryPoint(
  101. PEPNODE pNewEntryPoint
  102. );
  103. INT
  104. removeEntryPoint(
  105. PEPNODE pEP
  106. );
  107. PVOID
  108. EPAlloc(
  109. DWORD cb
  110. );
  111. VOID
  112. EPFree(
  113. VOID
  114. );
  115. INT
  116. initEPAlloc(
  117. VOID
  118. );
  119. BOOLEAN
  120. IsIntelRangeInCache(
  121. PVOID Addr,
  122. DWORD Length
  123. );
  124. #endif