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.

164 lines
3.0 KiB

  1. #ifndef _VIEW_H_
  2. #define _VIEW_H_
  3. //
  4. // Constant declarations
  5. //
  6. #define X86_BREAKPOINT 0xcc
  7. #define MAX_MAP_SIZE 0x80000000
  8. #define MAP_STRIDE_BITS 10
  9. typedef enum
  10. {
  11. None = 0,
  12. Call,
  13. Jump,
  14. Map,
  15. ThreadStart,
  16. } BPType;
  17. //
  18. // Structure definitions
  19. //
  20. typedef struct _VIEWCHAIN
  21. {
  22. BOOL bMapped;
  23. BOOL bTraced;
  24. BPType bpType;
  25. DWORD dwAddress;
  26. DWORD dwMapExtreme;
  27. BYTE jByteReplaced;
  28. struct _VIEWCHAIN *pNext;
  29. } VIEWCHAIN, *PVIEWCHAIN;
  30. //
  31. // Macros
  32. //
  33. #define WRITEBYTE(x, y) \
  34. { \
  35. { \
  36. DWORD dwOldProtect; \
  37. \
  38. VirtualProtect((LPVOID)(x), \
  39. sizeof(BYTE), \
  40. PAGE_READWRITE, \
  41. &dwOldProtect); \
  42. *(PBYTE)(x) = (y); \
  43. } \
  44. \
  45. }
  46. #define WRITEWORD(x, y) \
  47. { \
  48. { \
  49. DWORD dwOldProtect; \
  50. \
  51. VirtualProtect((LPVOID)(x), \
  52. sizeof(WORD), \
  53. PAGE_READWRITE, \
  54. &dwOldProtect); \
  55. *(WORD *)(x) = (y); \
  56. } \
  57. \
  58. }
  59. /*
  60. #define WRITEBYTE(x, y) \
  61. { \
  62. __try \
  63. { \
  64. *(PBYTE)(x) = (y); \
  65. } \
  66. __except(EXCEPTION_EXECUTE_HANDLER) \
  67. { \
  68. DWORD dwOldProtect; \
  69. \
  70. VirtualProtect((LPVOID)(x), \
  71. sizeof(BYTE), \
  72. PAGE_READWRITE, \
  73. &dwOldProtect); \
  74. *(PBYTE)(x) = (y); \
  75. } \
  76. \
  77. }
  78. #define WRITEWORD(x, y) \
  79. { \
  80. __try \
  81. { \
  82. *(WORD *)(x) = (y); \
  83. } \
  84. __except(EXCEPTION_EXECUTE_HANDLER) \
  85. { \
  86. DWORD dwOldProtect; \
  87. \
  88. VirtualProtect((LPVOID)(x), \
  89. sizeof(WORD), \
  90. PAGE_READWRITE, \
  91. &dwOldProtect); \
  92. *(WORD *)(x) = (y); \
  93. } \
  94. \
  95. }
  96. */
  97. //
  98. // Structure definitions
  99. //
  100. typedef struct _TAGGEDADDRESS
  101. {
  102. DWORD dwAddress;
  103. WORD wBytesReplaced;
  104. struct _TAGGEDADDRESS *pNext;
  105. } TAGGEDADDRESS, *PTAGGEDADDRESS;
  106. typedef struct _BRANCHADDRESS
  107. {
  108. DWORD dwAddress;
  109. struct _BRANCHADDRESS *pNext;
  110. } BRANCHADDRESS, *PBRANCHADDRESS;
  111. //
  112. // Function definitions
  113. //
  114. PVIEWCHAIN
  115. AddViewToMonitor(DWORD dwAddress,
  116. BPType bpType);
  117. BOOL
  118. InitializeViewData(VOID);
  119. PVIEWCHAIN
  120. RestoreAddressFromView(DWORD dwAddress,
  121. BOOL bResetData);
  122. PVIEWCHAIN
  123. FindMappedView(DWORD dwAddress);
  124. PVIEWCHAIN
  125. FindView(DWORD dwAddress);
  126. BOOL
  127. MapCode(PVIEWCHAIN pvMap);
  128. BOOL
  129. PushBranch(DWORD dwAddress);
  130. DWORD
  131. PopBranch(VOID);
  132. BOOL
  133. AddTaggedAddress(DWORD dwAddress);
  134. BOOL
  135. RestoreTaggedAddresses(VOID);
  136. VOID
  137. LockMapper(VOID);
  138. VOID
  139. UnlockMapper(VOID);
  140. #endif //_VIEW_H_