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.

183 lines
4.7 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // General utility functions.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997-2001.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef _UTIL_H_
  9. #define _UTIL_H_
  10. extern PCSTR g_DefaultLogFileName;
  11. extern char g_OpenLogFileName[];
  12. extern BOOL g_OpenLogFileAppended;
  13. extern int g_LogFile;
  14. extern BOOL g_DisableErrorPrint;
  15. ULONG CheckUserInterrupt(void);
  16. LONG MappingExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo);
  17. void RemoveDelChar(PSTR pBuffer);
  18. ULONGLONG HexValue(ULONG);
  19. void HexList(PUCHAR, ULONG *, ULONG);
  20. void AsciiList(PSTR, ULONG *);
  21. #define STRV_SPACE_IS_SEPARATOR 0x00000001
  22. #define STRV_TRIM_TRAILING_SPACE 0x00000002
  23. #define STRV_ALLOW_ESCAPED_CHARACTERS 0x00000004
  24. #define STRV_COMPRESS_ESCAPED_CHARACTERS 0x00000008
  25. #define STRV_ESCAPED_CHARACTERS \
  26. (STRV_ALLOW_ESCAPED_CHARACTERS | STRV_COMPRESS_ESCAPED_CHARACTERS)
  27. PSTR BufferStringValue(PSTR* Buf, ULONG Flags, PCHAR Save);
  28. PSTR StringValue(ULONG Flags, PCHAR Save);
  29. void CompressEscapes(PSTR Str);
  30. void DECLSPEC_NORETURN ReportError(ULONG Code, PCSTR* Desc);
  31. #define error(Code) ReportError(Code, NULL)
  32. void OpenLogFile(PCSTR File, BOOL Append);
  33. void fnLogOpen(BOOL Append);
  34. void fnLogClose(void);
  35. void lprintf(PCSTR Str);
  36. PSTR PrepareImagePath(PSTR ImagePath);
  37. CHAR* AddImage(PMODULE_INFO_ENTRY ModEntry, BOOL ForceSymbolLoad);
  38. void
  39. DelImage(
  40. PPROCESS_INFO pProcess,
  41. PDEBUG_IMAGE_INFO pImage
  42. );
  43. BOOL DelImageByName(PPROCESS_INFO Process, PCSTR Name, INAME Which);
  44. BOOL DelImageByBase(PPROCESS_INFO pProcess, ULONG64 Base);
  45. void DelImages(PPROCESS_INFO Process);
  46. #define SYMADDR_FORCE 0x00000001
  47. #define SYMADDR_LABEL 0x00000002
  48. #define SYMADDR_SOURCE 0x00000004
  49. void
  50. OutputSymAddr(
  51. ULONG64 Offset,
  52. ULONG Flags
  53. );
  54. void
  55. OutputLineAddr(
  56. ULONG64 Offset,
  57. PCSTR Format
  58. );
  59. LPSTR
  60. FormatMachineAddr64(
  61. MachineInfo* Machine,
  62. ULONG64 Addr
  63. );
  64. #define FormatAddr64(Addr) FormatMachineAddr64(g_TargetMachine, Addr)
  65. LPSTR
  66. FormatDisp64(
  67. ULONG64 addr
  68. );
  69. //
  70. // Output that can be displayed about the current register set.
  71. //
  72. void OutCurInfo(ULONG Flags, ULONG AllMask, ULONG RegMask);
  73. // Items displayed if the flag is given.
  74. // Display symbol nearest PC.
  75. #define OCI_SYMBOL 0x00000001
  76. // Display disassembly at PC.
  77. #define OCI_DISASM 0x00000002
  78. // Items which may be displayed if the flag is given. Other global
  79. // settings ultimately control whether information is displayed or not;
  80. // these flags indicate whether such output is allowed or not. Each
  81. // of these flags also has a FORCE bit to force display regardless of
  82. // the global settings.
  83. // Allow registers to be displayed.
  84. #define OCI_ALLOW_REG 0x00000004
  85. // Allow display of source code and/or source line.
  86. #define OCI_ALLOW_SOURCE 0x00000008
  87. // Allow EA memory to be displayed during disasm.
  88. #define OCI_ALLOW_EA 0x00000010
  89. // Force all output to be shown regardless of global settings.
  90. #define OCI_FORCE_ALL 0x80000000
  91. // Force display of registers.
  92. #define OCI_FORCE_REG 0x40000000
  93. // Force source output.
  94. #define OCI_FORCE_SOURCE 0x20000000
  95. // Force display of EA memory during disasm.
  96. #define OCI_FORCE_EA 0x10000000
  97. // Don't check for running state.
  98. #define OCI_IGNORE_STATE 0x08000000
  99. BOOL
  100. __inline
  101. ConvertQwordsToDwords(
  102. PULONG64 Qwords,
  103. PULONG Dwords,
  104. ULONG Count
  105. )
  106. {
  107. BOOL rval = TRUE;
  108. while (Count--) {
  109. rval = rval && (*Qwords >> 32) == 0;
  110. *Dwords++ = (ULONG)*Qwords++;
  111. }
  112. return rval;
  113. }
  114. DWORD
  115. NetworkPathCheck(
  116. LPCSTR PathList
  117. );
  118. #define ALL_ID_LIST 0xffffffff
  119. ULONG GetIdList (void);
  120. HRESULT ChangePath(PSTR* Path, PCSTR New, BOOL Append, ULONG SymNotify);
  121. PSTR FindPathElement(PSTR Path, ULONG Element, PSTR* EltEnd);
  122. void CheckPath(PCSTR Path);
  123. HRESULT ChangeString(PSTR* Str, PULONG StrLen, PCSTR New);
  124. BOOL LoadExecutableImageMemory(PDEBUG_IMAGE_INFO Image);
  125. BOOL UnloadExecutableImageMemory(PDEBUG_IMAGE_INFO Image);
  126. void
  127. ExceptionRecordTo64(PEXCEPTION_RECORD Rec,
  128. PEXCEPTION_RECORD64 Rec64);
  129. void
  130. ExceptionRecord64To(PEXCEPTION_RECORD64 Rec64,
  131. PEXCEPTION_RECORD Rec);
  132. void
  133. MemoryBasicInformationTo64(PMEMORY_BASIC_INFORMATION Mbi,
  134. PMEMORY_BASIC_INFORMATION64 Mbi64);
  135. void
  136. MemoryBasicInformation32To64(PMEMORY_BASIC_INFORMATION32 Mbi32,
  137. PMEMORY_BASIC_INFORMATION64 Mbi64);
  138. void
  139. DebugEvent32To64(LPDEBUG_EVENT32 Event32,
  140. LPDEBUG_EVENT64 Event64);
  141. LPSTR
  142. TimeToStr(ULONG TimeDateStamp);
  143. PCSTR PathTail(PCSTR Path);
  144. BOOL MatchPathTails(PCSTR Path1, PCSTR Path2);
  145. #endif // #ifndef _UTIL_H_