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.

243 lines
5.1 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Symbol-handling routines.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997-2001.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef _NTSYM_H_
  9. #define _NTSYM_H_
  10. #define SYM_BUFFER_SIZE (sizeof(IMAGEHLP_SYMBOL64) + MAX_SYMBOL_LEN)
  11. #define MatchPattern(Str, Pat) \
  12. SymMatchString(Str, Pat, FALSE)
  13. extern DEBUG_STACK_FRAME g_LastRegFrame;
  14. // The scope buffer is only exposed so that it
  15. // can be looked at without requiring a function call.
  16. // Users of scope information should go through the
  17. // scope abstraction functions.
  18. extern DEBUG_SCOPE g_ScopeBuffer;
  19. extern LPSTR g_SymbolSearchPath;
  20. extern LPSTR g_ExecutableImageSearchPath;
  21. extern ULONG g_SymOptions;
  22. extern PIMAGEHLP_SYMBOL64 g_Sym;
  23. extern PIMAGEHLP_SYMBOL64 g_SymStart;
  24. extern ULONG g_NumUnloadedModules;
  25. void RefreshAllModules(void);
  26. void SetSymOptions(ULONG Options);
  27. BOOL IsImageMachineType64(DWORD MachineType);
  28. void
  29. CreateModuleNameFromPath(
  30. LPSTR szImagePath,
  31. LPSTR szModuleName
  32. );
  33. void
  34. fnListNear (
  35. ULONG64 addrStart
  36. );
  37. BOOL
  38. GetHeaderInfo(
  39. IN ULONG64 BaseOfDll,
  40. OUT LPDWORD CheckSum,
  41. OUT LPDWORD TimeDateStamp,
  42. OUT LPDWORD SizeOfImage
  43. );
  44. void
  45. GetSymbolStdCall (
  46. ULONG64 Offset,
  47. PCHAR Buffer,
  48. ULONG BufferLen,
  49. PULONG64 Displacement,
  50. PUSHORT StdCallParams
  51. );
  52. BOOL
  53. GetNearSymbol(
  54. ULONG64 Offset,
  55. PSTR Buffer,
  56. ULONG BufferLen,
  57. PULONG64 Disp,
  58. LONG Delta
  59. );
  60. BOOL ValidatePathComponent(PCSTR Part);
  61. void SetSymbolSearchPath(PPROCESS_INFO Process);
  62. void DeferSymbolLoad(PDEBUG_IMAGE_INFO);
  63. void LoadSymbols(PDEBUG_IMAGE_INFO);
  64. void UnloadSymbols(PDEBUG_IMAGE_INFO);
  65. BOOL IgnoreEnumeratedSymbol(class MachineInfo* Machine,
  66. PSYMBOL_INFO SymInfo);
  67. PCSTR
  68. PrependPrefixToSymbol( char PrefixedString[],
  69. PCSTR pString,
  70. PCSTR *RegString
  71. );
  72. ULONG
  73. GetOffsetFromSym(
  74. PCSTR String,
  75. PULONG64 Offset,
  76. PDEBUG_IMAGE_INFO* Image
  77. );
  78. void
  79. GetAdjacentSymOffsets(
  80. ULONG64 addrStart,
  81. PULONG64 prevOffset,
  82. PULONG64 nextOffset
  83. );
  84. void
  85. GetCurrentMemoryOffsets (
  86. PULONG64 pMemoryLow,
  87. PULONG64 pMemoryHigh
  88. );
  89. PDEBUG_IMAGE_INFO GetImageByIndex(PPROCESS_INFO Process, ULONG Index);
  90. PDEBUG_IMAGE_INFO GetImageByOffset(PPROCESS_INFO Process, ULONG64 Offset);
  91. PDEBUG_IMAGE_INFO GetImageByName(PPROCESS_INFO Process, PCSTR Name,
  92. INAME Which);
  93. BOOL
  94. GetModnameFromImage(
  95. ULONG64 BaseOfDll,
  96. HANDLE File,
  97. LPSTR Name,
  98. ULONG NameSize
  99. );
  100. typedef enum _DMT_FLAGS
  101. {
  102. DMT_SYM_IMAGE_FILE_NAME = 0x0000,
  103. DMT_ONLY_LOADED_SYMBOLS = 0x0001,
  104. DMT_ONLY_USER_SYMBOLS = 0x0002,
  105. DMT_ONLY_KERNEL_SYMBOLS = 0x0004,
  106. DMT_VERBOSE = 0x0008,
  107. DMT_SYM_FILE_NAME = 0x0010,
  108. DMT_MAPPED_IMAGE_NAME = 0x0020,
  109. DMT_IMAGE_PATH_NAME = 0x0040,
  110. DMT_IMAGE_TIMESTAMP = 0x0080,
  111. DMT_NO_SYMBOL_OUTPUT = 0x0100,
  112. } DMT_FLAGS;
  113. #define DMT_STANDARD DMT_SYM_FILE_NAME
  114. #define DMT_NAME_FLAGS \
  115. (DMT_SYM_IMAGE_FILE_NAME | DMT_SYM_FILE_NAME | DMT_MAPPED_IMAGE_NAME | \
  116. DMT_IMAGE_PATH_NAME)
  117. enum
  118. {
  119. DMT_NAME_SYM_IMAGE,
  120. DMT_NAME_SYM_FILE,
  121. DMT_NAME_MAPPED_IMAGE,
  122. DMT_NAME_IMAGE_PATH,
  123. DMT_NAME_COUNT
  124. };
  125. void
  126. DumpModuleTable(
  127. ULONG DMT_Flags,
  128. PSTR Pattern
  129. );
  130. void ParseDumpModuleTable(void);
  131. void ParseExamine(void);
  132. BOOL
  133. SymbolCallbackFunction(
  134. HANDLE hProcess,
  135. ULONG ActionCode,
  136. ULONG64 CallbackData,
  137. ULONG64 UserContext
  138. );
  139. BOOL
  140. TranslateAddress(
  141. IN ULONG Flags,
  142. IN ULONG RegId,
  143. IN OUT PULONG64 Address,
  144. OUT PULONG64 Value
  145. );
  146. BOOL SetCurrentScope(IN PDEBUG_STACK_FRAME ScopeFrame,
  147. IN OPTIONAL PVOID ScopeContext,
  148. IN ULONG ScopeContextSize);
  149. BOOL ResetCurrentScope(void);
  150. BOOL ResetCurrentScopeLazy(void);
  151. inline PDEBUG_SCOPE
  152. GetCurrentScope(void)
  153. {
  154. if (g_ScopeBuffer.State == ScopeDefaultLazy)
  155. {
  156. ResetCurrentScope();
  157. }
  158. return &g_ScopeBuffer;
  159. }
  160. inline PCROSS_PLATFORM_CONTEXT
  161. GetCurrentScopeContext(void)
  162. {
  163. if (g_ScopeBuffer.State == ScopeFromContext)
  164. {
  165. return &g_ScopeBuffer.Context;
  166. }
  167. else
  168. {
  169. return NULL;
  170. }
  171. }
  172. // Force lazy scope to be updated so that actual
  173. // scope data is available.
  174. #define RequireCurrentScope() \
  175. GetCurrentScope()
  176. inline void
  177. PushScope(PDEBUG_SCOPE Buffer)
  178. {
  179. *Buffer = g_ScopeBuffer;
  180. }
  181. inline void
  182. PopScope(PDEBUG_SCOPE Buffer)
  183. {
  184. g_ScopeBuffer = *Buffer;
  185. }
  186. #define LUM_OUTPUT 0x0001
  187. #define LUM_OUTPUT_VERBOSE 0x0002
  188. #define LUM_OUTPUT_TERSE 0x0004
  189. #define LUM_OUTPUT_TIMESTAMP 0x0008
  190. void ListUnloadedModules(ULONG Flags, PSTR Pattern);
  191. ULONG ModuleMachineType(PPROCESS_INFO Process, ULONG64 Offset);
  192. enum
  193. {
  194. FSC_NONE,
  195. FSC_FOUND,
  196. };
  197. ULONG IsInFastSyscall(ULONG64 Addr, PULONG64 Base);
  198. BOOL ShowFunctionParameters(PDEBUG_STACK_FRAME StackFrame,
  199. PSTR SymBuf, ULONG64 Displacement);
  200. #endif // #ifndef _NTSYM_H_