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.

175 lines
4.8 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Image information.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2001-2002.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef __IMAGE_HPP__
  9. #define __IMAGE_HPP__
  10. #define UNKNOWN_IMAGE_NAME "Unknown_Module"
  11. enum IMAGE_SYM_STATE
  12. {
  13. ISS_UNKNOWN,
  14. ISS_MATCHED,
  15. ISS_MISMATCHED_SYMBOLS,
  16. ISS_UNKNOWN_TIMESTAMP,
  17. ISS_UNKNOWN_CHECKSUM,
  18. ISS_BAD_CHECKSUM
  19. };
  20. enum INAME
  21. {
  22. INAME_IMAGE_PATH,
  23. INAME_IMAGE_PATH_TAIL,
  24. INAME_MODULE,
  25. };
  26. // Special value meaning all images for some functions which
  27. // accept image base qualifiers.
  28. #define IMAGE_BASE_ALL ((ULONG64)-1)
  29. struct MODULE_ALIAS_LIST
  30. {
  31. ULONG Length;
  32. PCSTR* Aliases;
  33. PCSTR BaseModule;
  34. };
  35. enum
  36. {
  37. MODALIAS_KERNEL,
  38. MODALIAS_HAL,
  39. MODALIAS_KDCOM,
  40. MODALIAS_COUNT
  41. };
  42. extern MODULE_ALIAS_LIST g_AliasLists[];
  43. MODULE_ALIAS_LIST* FindModuleAliasList(PCSTR ImageName,
  44. PBOOL NameInList);
  45. //----------------------------------------------------------------------------
  46. //
  47. // ImageInfo.
  48. //
  49. //----------------------------------------------------------------------------
  50. #define MAX_MODULE 64
  51. class ImageInfo
  52. {
  53. public:
  54. ImageInfo(ProcessInfo* Process, PSTR ImagePath, ULONG64 Base, BOOL Link);
  55. ~ImageInfo(void);
  56. ProcessInfo* m_Process;
  57. ImageInfo* m_Next;
  58. ULONG m_Linked:1;
  59. ULONG m_Unloaded:1;
  60. ULONG m_FileIsDemandMapped:1;
  61. ULONG m_MapAlreadyFailed:1;
  62. ULONG m_CorImage:1;
  63. ULONG m_UserMode:1;
  64. HANDLE m_File;
  65. DWORD64 m_BaseOfImage;
  66. DWORD m_SizeOfImage;
  67. DWORD m_CheckSum;
  68. DWORD m_TimeDateStamp;
  69. IMAGE_SYM_STATE m_SymState;
  70. CHAR m_ModuleName[MAX_MODULE];
  71. CHAR m_OriginalModuleName[MAX_MODULE];
  72. CHAR m_ImagePath[MAX_IMAGE_PATH];
  73. // Executable image mapping information for images
  74. // mapped with minidumps.
  75. CHAR m_MappedImagePath[MAX_IMAGE_PATH];
  76. PVOID m_MappedImageBase;
  77. class MappedMemoryMap* m_MemMap;
  78. ULONG m_TlsIndex;
  79. ULONG m_MachineType;
  80. void DeleteResources(BOOL FullDelete);
  81. BOOL LoadExecutableImageMemory(MappedMemoryMap* MemMap, BOOL Verbose);
  82. void UnloadExecutableImageMemory(void);
  83. BOOL DemandLoadImageMemory(BOOL CheckIncomplete, BOOL Verbose);
  84. HRESULT GetTlsIndex(void);
  85. ULONG GetMachineTypeFromHeader(void);
  86. ULONG CvRegToMachine(CV_HREG_e CvReg);
  87. void OutputVersionInformation(void);
  88. void ValidateSymbolLoad(PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 DefLoad);
  89. HRESULT FindSysAssert(ULONG64 Offset,
  90. PSTR FileName,
  91. ULONG FileNameChars,
  92. PULONG Line,
  93. PSTR AssertText,
  94. ULONG AssertTextChars);
  95. ULONG GetMachineType(void)
  96. {
  97. if (m_MachineType != IMAGE_FILE_MACHINE_UNKNOWN)
  98. {
  99. return m_MachineType;
  100. }
  101. else
  102. {
  103. return GetMachineTypeFromHeader();
  104. }
  105. }
  106. void ReloadSymbols(void);
  107. void FillModuleParameters(PDEBUG_MODULE_PARAMETERS Params);
  108. private:
  109. BOOL MapImageRegion(MappedMemoryMap* MemMap,
  110. PVOID FileMapping,
  111. ULONG Rva, ULONG Size, ULONG RawDataOffset,
  112. BOOL AllowOverlap);
  113. };
  114. PSTR UnknownImageName(ULONG64 ImageBase, PSTR Buffer, ULONG BufferChars);
  115. PSTR ValidateImagePath(PSTR ImagePath, ULONG ImagePathChars,
  116. ULONG64 ImageBase,
  117. PSTR AnsiBuffer, ULONG AnsiBufferChars);
  118. PSTR ConvertAndValidateImagePathW(PWSTR ImagePath, ULONG ImagePathChars,
  119. ULONG64 ImageBase,
  120. PSTR AnsiBuffer, ULONG AnsiBufferChars);
  121. PSTR PrepareImagePath(PSTR ImagePath);
  122. PVOID
  123. FindImageFile(IN ProcessInfo* Process,
  124. IN PCSTR ImagePath,
  125. IN ULONG SizeOfImage,
  126. IN ULONG CheckSum,
  127. IN ULONG TimeDateStamp,
  128. OUT HANDLE* FileHandle,
  129. OUT PSTR MappedImagePath);
  130. BOOL DemandLoadReferencedImageMemory(ProcessInfo* Process,
  131. ULONG64 Addr, ULONG Size);
  132. BOOL
  133. GetModnameFromImage(ProcessInfo* Process,
  134. ULONG64 BaseOfDll,
  135. HANDLE File,
  136. LPSTR Name,
  137. ULONG NameSize,
  138. BOOL SearchExportFirst);
  139. BOOL
  140. GetHeaderInfo(IN ProcessInfo* Process,
  141. IN ULONG64 BaseOfDll,
  142. OUT LPDWORD CheckSum,
  143. OUT LPDWORD TimeDateStamp,
  144. OUT LPDWORD SizeOfImage);
  145. #endif // #ifndef __IMAGE_HPP__