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.

261 lines
12 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // User-mode minidump OS call provider interfaces.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2002.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef __UMINIPROV_HPP__
  9. #define __UMINIPROV_HPP__
  10. class MiniDumpProviderCallbacks
  11. {
  12. public:
  13. virtual HRESULT EnumMemory(ULONG64 Offset, ULONG Size) = 0;
  14. };
  15. class MiniDumpSystemProvider
  16. {
  17. public:
  18. virtual void Release(void) = 0;
  19. virtual HRESULT GetCurrentTimeDate(OUT PULONG TimeDate) = 0;
  20. virtual HRESULT GetCpuType(OUT PULONG Type,
  21. OUT PBOOL BackingStore) = 0;
  22. virtual HRESULT GetCpuInfo(OUT PUSHORT Architecture,
  23. OUT PUSHORT Level,
  24. OUT PUSHORT Revision,
  25. OUT PUCHAR NumberOfProcessors,
  26. OUT union _CPU_INFORMATION* Info) = 0;
  27. virtual void GetContextSizes(OUT PULONG Size,
  28. OUT PULONG RegScanStart,
  29. OUT PULONG RegScanCount) = 0;
  30. virtual void GetPointerSize(OUT PULONG Size) = 0;
  31. virtual void GetPageSize(OUT PULONG Size) = 0;
  32. virtual void GetFunctionTableSizes(OUT PULONG TableSize,
  33. OUT PULONG EntrySize) = 0;
  34. virtual void GetInstructionWindowSize(OUT PULONG Size) = 0;
  35. virtual HRESULT GetOsInfo(OUT PULONG PlatformId,
  36. OUT PULONG Major,
  37. OUT PULONG Minor,
  38. OUT PULONG BuildNumber,
  39. OUT PUSHORT ProductType,
  40. OUT PUSHORT SuiteMask) = 0;
  41. virtual HRESULT GetOsCsdString(OUT PWSTR Buffer,
  42. IN ULONG BufferChars) = 0;
  43. virtual HRESULT OpenMapping(IN PCWSTR FilePath,
  44. OUT PULONG Size,
  45. OUT PWSTR LongPath,
  46. IN ULONG LongPathChars,
  47. OUT PVOID* Mapping) = 0;
  48. virtual void CloseMapping(PVOID Mapping) = 0;
  49. virtual HRESULT GetImageHeaderInfo(IN HANDLE Process,
  50. IN PCWSTR FilePath,
  51. IN ULONG64 ImageBase,
  52. OUT PULONG Size,
  53. OUT PULONG CheckSum,
  54. OUT PULONG TimeDateStamp) = 0;
  55. virtual HRESULT GetImageVersionInfo(IN HANDLE Process,
  56. IN PCWSTR FilePath,
  57. IN ULONG64 ImageBase,
  58. OUT VS_FIXEDFILEINFO* Info) = 0;
  59. virtual HRESULT GetImageDebugRecord(IN HANDLE Process,
  60. IN PCWSTR FilePath,
  61. IN ULONG64 ImageBase,
  62. IN ULONG RecordType,
  63. OUT OPTIONAL PVOID Data,
  64. IN OUT PULONG DataLen) = 0;
  65. virtual HRESULT EnumImageDataSections(IN HANDLE Process,
  66. IN PCWSTR FilePath,
  67. IN ULONG64 ImageBase,
  68. IN MiniDumpProviderCallbacks*
  69. Callback) = 0;
  70. virtual HRESULT OpenThread(IN ULONG DesiredAccess,
  71. IN BOOL InheritHandle,
  72. IN ULONG ThreadId,
  73. OUT PHANDLE Handle) = 0;
  74. virtual void CloseThread(IN HANDLE Handle) = 0;
  75. virtual ULONG GetCurrentThreadId(void) = 0;
  76. virtual ULONG SuspendThread(IN HANDLE Thread) = 0;
  77. virtual ULONG ResumeThread(IN HANDLE Thread) = 0;
  78. virtual HRESULT GetThreadContext(IN HANDLE Thread,
  79. OUT PVOID Context,
  80. IN ULONG ContextSize,
  81. OUT PULONG64 CurrentPc,
  82. OUT PULONG64 CurrentStack,
  83. OUT PULONG64 CurrentStore) = 0;
  84. virtual HRESULT GetTeb(IN HANDLE Thread,
  85. OUT PULONG64 Offset,
  86. OUT PULONG Size) = 0;
  87. virtual HRESULT GetThreadInfo(IN HANDLE Process,
  88. IN HANDLE Thread,
  89. OUT PULONG64 Teb,
  90. OUT PULONG SizeOfTeb,
  91. OUT PULONG64 StackBase,
  92. OUT PULONG64 StackLimit,
  93. OUT PULONG64 StoreBase,
  94. OUT PULONG64 StoreLimit) = 0;
  95. virtual HRESULT GetPeb(IN HANDLE Process,
  96. OUT PULONG64 Offset,
  97. OUT PULONG Size) = 0;
  98. virtual HRESULT GetProcessTimes(IN HANDLE Process,
  99. OUT LPFILETIME Create,
  100. OUT LPFILETIME User,
  101. OUT LPFILETIME Kernel) = 0;
  102. // Returns success if any data is read.
  103. virtual HRESULT ReadVirtual(IN HANDLE Process,
  104. IN ULONG64 Offset,
  105. OUT PVOID Buffer,
  106. IN ULONG Request,
  107. OUT PULONG Done) = 0;
  108. virtual HRESULT ReadAllVirtual(IN HANDLE Process,
  109. IN ULONG64 Offset,
  110. OUT PVOID Buffer,
  111. IN ULONG Request) = 0;
  112. virtual HRESULT QueryVirtual(IN HANDLE Process,
  113. IN ULONG64 Offset,
  114. OUT PULONG64 Base,
  115. OUT PULONG64 Size,
  116. OUT PULONG Protect,
  117. OUT PULONG State,
  118. OUT PULONG Type) = 0;
  119. virtual HRESULT StartProcessEnum(IN HANDLE Process,
  120. IN ULONG ProcessId) = 0;
  121. virtual HRESULT EnumThreads(OUT PULONG ThreadId) = 0;
  122. virtual HRESULT EnumModules(OUT PULONG64 Base,
  123. OUT PWSTR Path,
  124. IN ULONG PathChars) = 0;
  125. virtual HRESULT EnumFunctionTables(OUT PULONG64 MinAddress,
  126. OUT PULONG64 MaxAddress,
  127. OUT PULONG64 BaseAddress,
  128. OUT PULONG EntryCount,
  129. OUT PVOID RawTable,
  130. IN ULONG RawTableSize,
  131. OUT PVOID* RawEntryHandle) = 0;
  132. virtual HRESULT EnumFunctionTableEntries(IN PVOID RawTable,
  133. IN ULONG RawTableSize,
  134. IN PVOID RawEntryHandle,
  135. OUT PVOID RawEntries,
  136. IN ULONG RawEntriesSize) = 0;
  137. virtual HRESULT EnumFunctionTableEntryMemory(IN ULONG64 TableBase,
  138. IN PVOID RawEntries,
  139. IN ULONG Index,
  140. OUT PULONG64 Start,
  141. OUT PULONG Size) = 0;
  142. virtual HRESULT EnumUnloadedModules(OUT PWSTR Path,
  143. IN ULONG PathChars,
  144. OUT PULONG64 BaseOfModule,
  145. OUT PULONG SizeOfModule,
  146. OUT PULONG CheckSum,
  147. OUT PULONG TimeDateStamp) = 0;
  148. virtual void FinishProcessEnum(void) = 0;
  149. virtual HRESULT StartHandleEnum(IN HANDLE Process,
  150. IN ULONG ProcessId,
  151. OUT PULONG Count) = 0;
  152. virtual HRESULT EnumHandles(OUT PULONG64 Handle,
  153. OUT PULONG Attributes,
  154. OUT PULONG GrantedAccess,
  155. OUT PULONG HandleCount,
  156. OUT PULONG PointerCount,
  157. OUT PWSTR TypeName,
  158. IN ULONG TypeNameChars,
  159. OUT PWSTR ObjectName,
  160. IN ULONG ObjectNameChars) = 0;
  161. virtual void FinishHandleEnum(void) = 0;
  162. virtual HRESULT EnumPebMemory(IN HANDLE Process,
  163. IN ULONG64 PebOffset,
  164. IN ULONG PebSize,
  165. IN MiniDumpProviderCallbacks* Callback) = 0;
  166. virtual HRESULT EnumTebMemory(IN HANDLE Process,
  167. IN HANDLE Thread,
  168. IN ULONG64 TebOffset,
  169. IN ULONG TebSize,
  170. IN MiniDumpProviderCallbacks* Callback) = 0;
  171. virtual HRESULT GetCorDataAccess(IN PWSTR AccessDllName,
  172. IN struct ICorDataAccessServices*
  173. Services,
  174. OUT struct ICorDataAccess**
  175. Access) = 0;
  176. virtual void ReleaseCorDataAccess(IN struct ICorDataAccess*
  177. Access) = 0;
  178. };
  179. class MiniDumpOutputProvider
  180. {
  181. public:
  182. virtual void Release(void) = 0;
  183. // S_OK return indicates this provider can stream an
  184. // arbitrary amount of data. Any other return indicates this
  185. // provider requires a size bound.
  186. virtual HRESULT SupportsStreaming(void) = 0;
  187. // MaxSize of zero indicates no size information available.
  188. virtual HRESULT Start(IN ULONG64 MaxSize) = 0;
  189. // Uses Win32 FILE_ defines for How.
  190. virtual HRESULT Seek(IN ULONG How,
  191. IN LONG64 Amount,
  192. OUT OPTIONAL PULONG64 NewOffset) = 0;
  193. // WriteAll must write the entire request to succeed.
  194. virtual HRESULT WriteAll(IN PVOID Buffer,
  195. IN ULONG Request) = 0;
  196. virtual void Finish(void) = 0;
  197. };
  198. class MiniDumpAllocationProvider
  199. {
  200. public:
  201. virtual void Release(void) = 0;
  202. // Allocated memory is always zero-filled.
  203. virtual PVOID Alloc(ULONG Size) = 0;
  204. virtual PVOID Realloc(PVOID Mem, ULONG NewSize) = 0;
  205. virtual void Free(PVOID Mem) = 0;
  206. };
  207. extern "C"
  208. {
  209. HRESULT WINAPI
  210. MiniDumpCreateLiveSystemProvider(OUT MiniDumpSystemProvider** Prov);
  211. HRESULT WINAPI
  212. MiniDumpCreateFileOutputProvider(IN HANDLE FileHandle,
  213. OUT MiniDumpOutputProvider** Prov);
  214. HRESULT WINAPI
  215. MiniDumpCreateLiveAllocationProvider(OUT MiniDumpAllocationProvider** Prov);
  216. HRESULT
  217. WINAPI
  218. MiniDumpProvideDump(
  219. IN HANDLE hProcess,
  220. IN DWORD ProcessId,
  221. IN MiniDumpSystemProvider* SysProv,
  222. IN MiniDumpOutputProvider* OutProv,
  223. IN MiniDumpAllocationProvider* AllocProv,
  224. IN ULONG DumpType,
  225. IN CONST struct _MINIDUMP_EXCEPTION_INFORMATION64* ExceptionParam, OPTIONAL
  226. IN CONST struct _MINIDUMP_USER_STREAM_INFORMATION* UserStreamParam, OPTIONAL
  227. IN CONST struct _MINIDUMP_CALLBACK_INFORMATION* CallbackParam OPTIONAL
  228. );
  229. };
  230. #endif // #ifndef __UMINIPROV_HPP__