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.

2542 lines
68 KiB

  1. /*++ BUILD Version: 0001 Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. dbghelp.h
  5. Abstract:
  6. This module defines the prototypes and constants required for the image
  7. help routines.
  8. Contains debugging support routines that are redistributable.
  9. Revision History:
  10. --*/
  11. #ifndef _DBGHELP_
  12. #define _DBGHELP_
  13. #if _MSC_VER > 1020
  14. #pragma once
  15. #endif
  16. // As a general principal always call the 64 bit version
  17. // of every API, if a choice exists. The 64 bit version
  18. // works great on 32 bit platforms, and is forward
  19. // compatible to 64 bit platforms.
  20. #ifdef _WIN64
  21. #ifndef _IMAGEHLP64
  22. #define _IMAGEHLP64
  23. #endif
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #ifdef _IMAGEHLP_SOURCE_
  29. #define IMAGEAPI __stdcall
  30. #define DBHLP_DEPRECIATED
  31. #else
  32. #define IMAGEAPI DECLSPEC_IMPORT __stdcall
  33. #define DBHLP_DEPRECIATED DECLSPEC_DEPRECATED
  34. #endif
  35. #define DBHLPAPI IMAGEAPI
  36. #define IMAGE_SEPARATION (64*1024)
  37. typedef struct _LOADED_IMAGE {
  38. PSTR ModuleName;
  39. HANDLE hFile;
  40. PUCHAR MappedAddress;
  41. #ifdef _IMAGEHLP64
  42. PIMAGE_NT_HEADERS64 FileHeader;
  43. #else
  44. PIMAGE_NT_HEADERS32 FileHeader;
  45. #endif
  46. PIMAGE_SECTION_HEADER LastRvaSection;
  47. ULONG NumberOfSections;
  48. PIMAGE_SECTION_HEADER Sections;
  49. ULONG Characteristics;
  50. BOOLEAN fSystemImage;
  51. BOOLEAN fDOSImage;
  52. LIST_ENTRY Links;
  53. ULONG SizeOfImage;
  54. } LOADED_IMAGE, *PLOADED_IMAGE;
  55. HANDLE
  56. IMAGEAPI
  57. FindDebugInfoFile (
  58. PSTR FileName,
  59. PSTR SymbolPath,
  60. PSTR DebugFilePath
  61. );
  62. typedef BOOL
  63. (CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(
  64. HANDLE FileHandle,
  65. PSTR FileName,
  66. PVOID CallerData
  67. );
  68. HANDLE
  69. IMAGEAPI
  70. FindDebugInfoFileEx (
  71. PSTR FileName,
  72. PSTR SymbolPath,
  73. PSTR DebugFilePath,
  74. PFIND_DEBUG_FILE_CALLBACK Callback,
  75. PVOID CallerData
  76. );
  77. typedef BOOL
  78. (CALLBACK *PFINDFILEINPATHCALLBACK)(
  79. PSTR filename,
  80. PVOID context
  81. );
  82. BOOL
  83. IMAGEAPI
  84. SymFindFileInPath(
  85. HANDLE hprocess,
  86. LPSTR SearchPath,
  87. LPSTR FileName,
  88. PVOID id,
  89. DWORD two,
  90. DWORD three,
  91. DWORD flags,
  92. LPSTR FilePath,
  93. PFINDFILEINPATHCALLBACK callback,
  94. PVOID context
  95. );
  96. HANDLE
  97. IMAGEAPI
  98. FindExecutableImage(
  99. PSTR FileName,
  100. PSTR SymbolPath,
  101. PSTR ImageFilePath
  102. );
  103. typedef BOOL
  104. (CALLBACK *PFIND_EXE_FILE_CALLBACK)(
  105. HANDLE FileHandle,
  106. PSTR FileName,
  107. PVOID CallerData
  108. );
  109. HANDLE
  110. IMAGEAPI
  111. FindExecutableImageEx(
  112. PSTR FileName,
  113. PSTR SymbolPath,
  114. PSTR ImageFilePath,
  115. PFIND_EXE_FILE_CALLBACK Callback,
  116. PVOID CallerData
  117. );
  118. PIMAGE_NT_HEADERS
  119. IMAGEAPI
  120. ImageNtHeader (
  121. IN PVOID Base
  122. );
  123. PVOID
  124. IMAGEAPI
  125. ImageDirectoryEntryToDataEx (
  126. IN PVOID Base,
  127. IN BOOLEAN MappedAsImage,
  128. IN USHORT DirectoryEntry,
  129. OUT PULONG Size,
  130. OUT PIMAGE_SECTION_HEADER *FoundHeader OPTIONAL
  131. );
  132. PVOID
  133. IMAGEAPI
  134. ImageDirectoryEntryToData (
  135. IN PVOID Base,
  136. IN BOOLEAN MappedAsImage,
  137. IN USHORT DirectoryEntry,
  138. OUT PULONG Size
  139. );
  140. PIMAGE_SECTION_HEADER
  141. IMAGEAPI
  142. ImageRvaToSection(
  143. IN PIMAGE_NT_HEADERS NtHeaders,
  144. IN PVOID Base,
  145. IN ULONG Rva
  146. );
  147. PVOID
  148. IMAGEAPI
  149. ImageRvaToVa(
  150. IN PIMAGE_NT_HEADERS NtHeaders,
  151. IN PVOID Base,
  152. IN ULONG Rva,
  153. IN OUT PIMAGE_SECTION_HEADER *LastRvaSection
  154. );
  155. // Symbol server exports
  156. typedef BOOL (*PSYMBOLSERVERPROC)(LPCSTR, LPCSTR, PVOID, DWORD, DWORD, LPSTR);
  157. typedef BOOL (*PSYMBOLSERVEROPENPROC)(VOID);
  158. typedef BOOL (*PSYMBOLSERVERCLOSEPROC)(VOID);
  159. typedef BOOL (*PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
  160. typedef BOOL (CALLBACK *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
  161. typedef UINT_PTR (*PSYMBOLSERVERGETOPTIONSPROC)();
  162. #define SSRVOPT_CALLBACK 0x01
  163. #define SSRVOPT_DWORD 0x02
  164. #define SSRVOPT_DWORDPTR 0x04
  165. #define SSRVOPT_GUIDPTR 0x08
  166. #define SSRVOPT_OLDGUIDPTR 0x10
  167. #define SSRVOPT_UNATTENDED 0x20
  168. #define SSRVOPT_RESET ((ULONG_PTR)-1)
  169. #define SSRVACTION_TRACE 1
  170. #ifndef _WIN64
  171. // This api won't be ported to Win64 - Fix your code.
  172. typedef struct _IMAGE_DEBUG_INFORMATION {
  173. LIST_ENTRY List;
  174. DWORD ReservedSize;
  175. PVOID ReservedMappedBase;
  176. USHORT ReservedMachine;
  177. USHORT ReservedCharacteristics;
  178. DWORD ReservedCheckSum;
  179. DWORD ImageBase;
  180. DWORD SizeOfImage;
  181. DWORD ReservedNumberOfSections;
  182. PIMAGE_SECTION_HEADER ReservedSections;
  183. DWORD ReservedExportedNamesSize;
  184. PSTR ReservedExportedNames;
  185. DWORD ReservedNumberOfFunctionTableEntries;
  186. PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries;
  187. DWORD ReservedLowestFunctionStartingAddress;
  188. DWORD ReservedHighestFunctionEndingAddress;
  189. DWORD ReservedNumberOfFpoTableEntries;
  190. PFPO_DATA ReservedFpoTableEntries;
  191. DWORD SizeOfCoffSymbols;
  192. PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
  193. DWORD ReservedSizeOfCodeViewSymbols;
  194. PVOID ReservedCodeViewSymbols;
  195. PSTR ImageFilePath;
  196. PSTR ImageFileName;
  197. PSTR ReservedDebugFilePath;
  198. DWORD ReservedTimeDateStamp;
  199. BOOL ReservedRomImage;
  200. PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory;
  201. DWORD ReservedNumberOfDebugDirectories;
  202. DWORD ReservedOriginalFunctionTableBaseAddress;
  203. DWORD Reserved[ 2 ];
  204. } IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;
  205. PIMAGE_DEBUG_INFORMATION
  206. IMAGEAPI
  207. MapDebugInformation(
  208. HANDLE FileHandle,
  209. PSTR FileName,
  210. PSTR SymbolPath,
  211. DWORD ImageBase
  212. );
  213. BOOL
  214. IMAGEAPI
  215. UnmapDebugInformation(
  216. PIMAGE_DEBUG_INFORMATION DebugInfo
  217. );
  218. #endif
  219. BOOL
  220. IMAGEAPI
  221. SearchTreeForFile(
  222. PSTR RootPath,
  223. PSTR InputPathName,
  224. PSTR OutputPathBuffer
  225. );
  226. BOOL
  227. IMAGEAPI
  228. MakeSureDirectoryPathExists(
  229. PCSTR DirPath
  230. );
  231. //
  232. // UnDecorateSymbolName Flags
  233. //
  234. #define UNDNAME_COMPLETE (0x0000) // Enable full undecoration
  235. #define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) // Remove leading underscores from MS extended keywords
  236. #define UNDNAME_NO_MS_KEYWORDS (0x0002) // Disable expansion of MS extended keywords
  237. #define UNDNAME_NO_FUNCTION_RETURNS (0x0004) // Disable expansion of return type for primary declaration
  238. #define UNDNAME_NO_ALLOCATION_MODEL (0x0008) // Disable expansion of the declaration model
  239. #define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) // Disable expansion of the declaration language specifier
  240. #define UNDNAME_NO_MS_THISTYPE (0x0020) // NYI Disable expansion of MS keywords on the 'this' type for primary declaration
  241. #define UNDNAME_NO_CV_THISTYPE (0x0040) // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration
  242. #define UNDNAME_NO_THISTYPE (0x0060) // Disable all modifiers on the 'this' type
  243. #define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) // Disable expansion of access specifiers for members
  244. #define UNDNAME_NO_THROW_SIGNATURES (0x0100) // Disable expansion of 'throw-signatures' for functions and pointers to functions
  245. #define UNDNAME_NO_MEMBER_TYPE (0x0200) // Disable expansion of 'static' or 'virtual'ness of members
  246. #define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) // Disable expansion of MS model for UDT returns
  247. #define UNDNAME_32_BIT_DECODE (0x0800) // Undecorate 32-bit decorated names
  248. #define UNDNAME_NAME_ONLY (0x1000) // Crack only the name for primary declaration;
  249. // return just [scope::]name. Does expand template params
  250. #define UNDNAME_NO_ARGUMENTS (0x2000) // Don't undecorate arguments to function
  251. #define UNDNAME_NO_SPECIAL_SYMS (0x4000) // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc)
  252. DWORD
  253. IMAGEAPI
  254. WINAPI
  255. UnDecorateSymbolName(
  256. PCSTR DecoratedName, // Name to undecorate
  257. PSTR UnDecoratedName, // If NULL, it will be allocated
  258. DWORD UndecoratedLength, // The maximym length
  259. DWORD Flags // See above.
  260. );
  261. //
  262. // these values are used for synthesized file types
  263. // that can be passed in as image headers instead of
  264. // the standard ones from ntimage.h
  265. //
  266. #define DBHHEADER_DEBUGDIRS 0x1
  267. typedef struct _DBGHELP_MODLOAD_DATA {
  268. DWORD ssize; // size of this struct
  269. DWORD ssig; // signature identifying the passed data
  270. PVOID data; // pointer to passed data
  271. DWORD size; // size of passed data
  272. DWORD flags; // options
  273. } MODLOAD_DATA, *PMODLOAD_DATA;
  274. //
  275. // StackWalking API
  276. //
  277. typedef enum {
  278. AddrMode1616,
  279. AddrMode1632,
  280. AddrModeReal,
  281. AddrModeFlat
  282. } ADDRESS_MODE;
  283. typedef struct _tagADDRESS64 {
  284. DWORD64 Offset;
  285. WORD Segment;
  286. ADDRESS_MODE Mode;
  287. } ADDRESS64, *LPADDRESS64;
  288. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  289. #define ADDRESS ADDRESS64
  290. #define LPADDRESS LPADDRESS64
  291. #else
  292. typedef struct _tagADDRESS {
  293. DWORD Offset;
  294. WORD Segment;
  295. ADDRESS_MODE Mode;
  296. } ADDRESS, *LPADDRESS;
  297. __inline
  298. void
  299. Address32To64(
  300. LPADDRESS a32,
  301. LPADDRESS64 a64
  302. )
  303. {
  304. a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset;
  305. a64->Segment = a32->Segment;
  306. a64->Mode = a32->Mode;
  307. }
  308. __inline
  309. void
  310. Address64To32(
  311. LPADDRESS64 a64,
  312. LPADDRESS a32
  313. )
  314. {
  315. a32->Offset = (ULONG)a64->Offset;
  316. a32->Segment = a64->Segment;
  317. a32->Mode = a64->Mode;
  318. }
  319. #endif
  320. //
  321. // This structure is included in the STACKFRAME structure,
  322. // and is used to trace through usermode callbacks in a thread's
  323. // kernel stack. The values must be copied by the kernel debugger
  324. // from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets.
  325. //
  326. //
  327. // New KDHELP structure for 64 bit system support.
  328. // This structure is preferred in new code.
  329. //
  330. typedef struct _KDHELP64 {
  331. //
  332. // address of kernel thread object, as provided in the
  333. // WAIT_STATE_CHANGE packet.
  334. //
  335. DWORD64 Thread;
  336. //
  337. // offset in thread object to pointer to the current callback frame
  338. // in kernel stack.
  339. //
  340. DWORD ThCallbackStack;
  341. //
  342. // offset in thread object to pointer to the current callback backing
  343. // store frame in kernel stack.
  344. //
  345. DWORD ThCallbackBStore;
  346. //
  347. // offsets to values in frame:
  348. //
  349. // address of next callback frame
  350. DWORD NextCallback;
  351. // address of saved frame pointer (if applicable)
  352. DWORD FramePointer;
  353. //
  354. // Address of the kernel function that calls out to user mode
  355. //
  356. DWORD64 KiCallUserMode;
  357. //
  358. // Address of the user mode dispatcher function
  359. //
  360. DWORD64 KeUserCallbackDispatcher;
  361. //
  362. // Lowest kernel mode address
  363. //
  364. DWORD64 SystemRangeStart;
  365. DWORD64 Reserved[8];
  366. } KDHELP64, *PKDHELP64;
  367. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  368. #define KDHELP KDHELP64
  369. #define PKDHELP PKDHELP64
  370. #else
  371. typedef struct _KDHELP {
  372. //
  373. // address of kernel thread object, as provided in the
  374. // WAIT_STATE_CHANGE packet.
  375. //
  376. DWORD Thread;
  377. //
  378. // offset in thread object to pointer to the current callback frame
  379. // in kernel stack.
  380. //
  381. DWORD ThCallbackStack;
  382. //
  383. // offsets to values in frame:
  384. //
  385. // address of next callback frame
  386. DWORD NextCallback;
  387. // address of saved frame pointer (if applicable)
  388. DWORD FramePointer;
  389. //
  390. // Address of the kernel function that calls out to user mode
  391. //
  392. DWORD KiCallUserMode;
  393. //
  394. // Address of the user mode dispatcher function
  395. //
  396. DWORD KeUserCallbackDispatcher;
  397. //
  398. // Lowest kernel mode address
  399. //
  400. DWORD SystemRangeStart;
  401. //
  402. // offset in thread object to pointer to the current callback backing
  403. // store frame in kernel stack.
  404. //
  405. DWORD ThCallbackBStore;
  406. DWORD Reserved[8];
  407. } KDHELP, *PKDHELP;
  408. __inline
  409. void
  410. KdHelp32To64(
  411. PKDHELP p32,
  412. PKDHELP64 p64
  413. )
  414. {
  415. p64->Thread = p32->Thread;
  416. p64->ThCallbackStack = p32->ThCallbackStack;
  417. p64->NextCallback = p32->NextCallback;
  418. p64->FramePointer = p32->FramePointer;
  419. p64->KiCallUserMode = p32->KiCallUserMode;
  420. p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher;
  421. p64->SystemRangeStart = p32->SystemRangeStart;
  422. }
  423. #endif
  424. typedef struct _tagSTACKFRAME64 {
  425. ADDRESS64 AddrPC; // program counter
  426. ADDRESS64 AddrReturn; // return address
  427. ADDRESS64 AddrFrame; // frame pointer
  428. ADDRESS64 AddrStack; // stack pointer
  429. ADDRESS64 AddrBStore; // backing store pointer
  430. PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
  431. DWORD64 Params[4]; // possible arguments to the function
  432. BOOL Far; // WOW far call
  433. BOOL Virtual; // is this a virtual frame?
  434. DWORD64 Reserved[3];
  435. KDHELP64 KdHelp;
  436. } STACKFRAME64, *LPSTACKFRAME64;
  437. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  438. #define STACKFRAME STACKFRAME64
  439. #define LPSTACKFRAME LPSTACKFRAME64
  440. #else
  441. typedef struct _tagSTACKFRAME {
  442. ADDRESS AddrPC; // program counter
  443. ADDRESS AddrReturn; // return address
  444. ADDRESS AddrFrame; // frame pointer
  445. ADDRESS AddrStack; // stack pointer
  446. PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
  447. DWORD Params[4]; // possible arguments to the function
  448. BOOL Far; // WOW far call
  449. BOOL Virtual; // is this a virtual frame?
  450. DWORD Reserved[3];
  451. KDHELP KdHelp;
  452. ADDRESS AddrBStore; // backing store pointer
  453. } STACKFRAME, *LPSTACKFRAME;
  454. #endif
  455. typedef
  456. BOOL
  457. (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
  458. HANDLE hProcess,
  459. DWORD64 qwBaseAddress,
  460. PVOID lpBuffer,
  461. DWORD nSize,
  462. LPDWORD lpNumberOfBytesRead
  463. );
  464. typedef
  465. PVOID
  466. (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
  467. HANDLE hProcess,
  468. DWORD64 AddrBase
  469. );
  470. typedef
  471. DWORD64
  472. (__stdcall *PGET_MODULE_BASE_ROUTINE64)(
  473. HANDLE hProcess,
  474. DWORD64 Address
  475. );
  476. typedef
  477. DWORD64
  478. (__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
  479. HANDLE hProcess,
  480. HANDLE hThread,
  481. LPADDRESS64 lpaddr
  482. );
  483. BOOL
  484. IMAGEAPI
  485. StackWalk64(
  486. DWORD MachineType,
  487. HANDLE hProcess,
  488. HANDLE hThread,
  489. LPSTACKFRAME64 StackFrame,
  490. PVOID ContextRecord,
  491. PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
  492. PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
  493. PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
  494. PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress
  495. );
  496. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  497. #define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64
  498. #define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64
  499. #define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64
  500. #define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64
  501. #define StackWalk StackWalk64
  502. #else
  503. typedef
  504. BOOL
  505. (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)(
  506. HANDLE hProcess,
  507. DWORD lpBaseAddress,
  508. PVOID lpBuffer,
  509. DWORD nSize,
  510. PDWORD lpNumberOfBytesRead
  511. );
  512. typedef
  513. PVOID
  514. (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(
  515. HANDLE hProcess,
  516. DWORD AddrBase
  517. );
  518. typedef
  519. DWORD
  520. (__stdcall *PGET_MODULE_BASE_ROUTINE)(
  521. HANDLE hProcess,
  522. DWORD Address
  523. );
  524. typedef
  525. DWORD
  526. (__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(
  527. HANDLE hProcess,
  528. HANDLE hThread,
  529. LPADDRESS lpaddr
  530. );
  531. BOOL
  532. IMAGEAPI
  533. StackWalk(
  534. DWORD MachineType,
  535. HANDLE hProcess,
  536. HANDLE hThread,
  537. LPSTACKFRAME StackFrame,
  538. PVOID ContextRecord,
  539. PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
  540. PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
  541. PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
  542. PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
  543. );
  544. #endif
  545. #define API_VERSION_NUMBER 9
  546. typedef struct API_VERSION {
  547. USHORT MajorVersion;
  548. USHORT MinorVersion;
  549. USHORT Revision;
  550. USHORT Reserved;
  551. } API_VERSION, *LPAPI_VERSION;
  552. LPAPI_VERSION
  553. IMAGEAPI
  554. ImagehlpApiVersion(
  555. VOID
  556. );
  557. LPAPI_VERSION
  558. IMAGEAPI
  559. ImagehlpApiVersionEx(
  560. LPAPI_VERSION AppVersion
  561. );
  562. DWORD
  563. IMAGEAPI
  564. GetTimestampForLoadedLibrary(
  565. HMODULE Module
  566. );
  567. //
  568. // typedefs for function pointers
  569. //
  570. typedef BOOL
  571. (CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(
  572. PSTR ModuleName,
  573. DWORD64 BaseOfDll,
  574. PVOID UserContext
  575. );
  576. typedef BOOL
  577. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(
  578. PSTR SymbolName,
  579. DWORD64 SymbolAddress,
  580. ULONG SymbolSize,
  581. PVOID UserContext
  582. );
  583. typedef BOOL
  584. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(
  585. PWSTR SymbolName,
  586. DWORD64 SymbolAddress,
  587. ULONG SymbolSize,
  588. PVOID UserContext
  589. );
  590. typedef BOOL
  591. (CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(
  592. PSTR ModuleName,
  593. DWORD64 ModuleBase,
  594. ULONG ModuleSize,
  595. PVOID UserContext
  596. );
  597. typedef BOOL
  598. (CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(
  599. HANDLE hProcess,
  600. ULONG ActionCode,
  601. ULONG64 CallbackData,
  602. ULONG64 UserContext
  603. );
  604. typedef
  605. PVOID
  606. (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(
  607. HANDLE hProcess,
  608. DWORD AddrBase,
  609. PVOID UserContext
  610. );
  611. typedef
  612. PVOID
  613. (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(
  614. HANDLE hProcess,
  615. ULONG64 AddrBase,
  616. ULONG64 UserContext
  617. );
  618. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  619. #define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64
  620. #define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64
  621. #define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W
  622. #define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64
  623. #define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64
  624. #define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64
  625. #else
  626. typedef BOOL
  627. (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
  628. PSTR ModuleName,
  629. ULONG BaseOfDll,
  630. PVOID UserContext
  631. );
  632. typedef BOOL
  633. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
  634. PSTR SymbolName,
  635. ULONG SymbolAddress,
  636. ULONG SymbolSize,
  637. PVOID UserContext
  638. );
  639. typedef BOOL
  640. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(
  641. PWSTR SymbolName,
  642. ULONG SymbolAddress,
  643. ULONG SymbolSize,
  644. PVOID UserContext
  645. );
  646. typedef BOOL
  647. (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
  648. PSTR ModuleName,
  649. ULONG ModuleBase,
  650. ULONG ModuleSize,
  651. PVOID UserContext
  652. );
  653. typedef BOOL
  654. (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
  655. HANDLE hProcess,
  656. ULONG ActionCode,
  657. PVOID CallbackData,
  658. PVOID UserContext
  659. );
  660. #endif
  661. //
  662. // symbol flags
  663. //
  664. #define SYMF_OMAP_GENERATED 0x00000001
  665. #define SYMF_OMAP_MODIFIED 0x00000002
  666. #ifndef _DBGHELP_USER_GENERATED_SYMBOLS_NOTSUPPORTED
  667. #define SYMF_USER_GENERATED 0x00000004
  668. #endif // !_DBGHELP_USER_GENERATED_SYMBOLS_NOTSUPPORTED
  669. #define SYMF_REGISTER 0x00000008
  670. #define SYMF_REGREL 0x00000010
  671. #define SYMF_FRAMEREL 0x00000020
  672. #define SYMF_PARAMETER 0x00000040
  673. #define SYMF_LOCAL 0x00000080
  674. #define SYMF_CONSTANT 0x00000100
  675. #define SYMF_EXPORT 0x00000200
  676. #define SYMF_FORWARDER 0x00000400
  677. #define SYMF_FUNCTION 0x00000800
  678. //
  679. // symbol type enumeration
  680. //
  681. typedef enum {
  682. SymNone = 0,
  683. SymCoff,
  684. SymCv,
  685. SymPdb,
  686. SymExport,
  687. SymDeferred,
  688. SymSym, // .sym file
  689. SymDia,
  690. NumSymTypes
  691. } SYM_TYPE;
  692. //
  693. // symbol data structure
  694. //
  695. typedef struct _IMAGEHLP_SYMBOL64 {
  696. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL64)
  697. DWORD64 Address; // virtual address including dll base address
  698. DWORD Size; // estimated size of symbol, can be zero
  699. DWORD Flags; // info about the symbols, see the SYMF defines
  700. DWORD MaxNameLength; // maximum size of symbol name in 'Name'
  701. CHAR Name[1]; // symbol name (null terminated string)
  702. } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
  703. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  704. #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
  705. #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
  706. #else
  707. typedef struct _IMAGEHLP_SYMBOL {
  708. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL)
  709. DWORD Address; // virtual address including dll base address
  710. DWORD Size; // estimated size of symbol, can be zero
  711. DWORD Flags; // info about the symbols, see the SYMF defines
  712. DWORD MaxNameLength; // maximum size of symbol name in 'Name'
  713. CHAR Name[1]; // symbol name (null terminated string)
  714. } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
  715. #endif
  716. //
  717. // module data structure
  718. //
  719. typedef struct _IMAGEHLP_MODULE64 {
  720. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
  721. DWORD64 BaseOfImage; // base load address of module
  722. DWORD ImageSize; // virtual size of the loaded module
  723. DWORD TimeDateStamp; // date/time stamp from pe header
  724. DWORD CheckSum; // checksum from the pe header
  725. DWORD NumSyms; // number of symbols in the symbol table
  726. SYM_TYPE SymType; // type of symbols loaded
  727. CHAR ModuleName[32]; // module name
  728. CHAR ImageName[256]; // image name
  729. CHAR LoadedImageName[256]; // symbol file name
  730. } IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
  731. typedef struct _IMAGEHLP_MODULE64W {
  732. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
  733. DWORD64 BaseOfImage; // base load address of module
  734. DWORD ImageSize; // virtual size of the loaded module
  735. DWORD TimeDateStamp; // date/time stamp from pe header
  736. DWORD CheckSum; // checksum from the pe header
  737. DWORD NumSyms; // number of symbols in the symbol table
  738. SYM_TYPE SymType; // type of symbols loaded
  739. WCHAR ModuleName[32]; // module name
  740. WCHAR ImageName[256]; // image name
  741. WCHAR LoadedImageName[256]; // symbol file name
  742. } IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
  743. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  744. #define IMAGEHLP_MODULE IMAGEHLP_MODULE64
  745. #define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64
  746. #define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64
  747. #define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64
  748. #else
  749. typedef struct _IMAGEHLP_MODULE {
  750. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE)
  751. DWORD BaseOfImage; // base load address of module
  752. DWORD ImageSize; // virtual size of the loaded module
  753. DWORD TimeDateStamp; // date/time stamp from pe header
  754. DWORD CheckSum; // checksum from the pe header
  755. DWORD NumSyms; // number of symbols in the symbol table
  756. SYM_TYPE SymType; // type of symbols loaded
  757. CHAR ModuleName[32]; // module name
  758. CHAR ImageName[256]; // image name
  759. CHAR LoadedImageName[256]; // symbol file name
  760. } IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
  761. typedef struct _IMAGEHLP_MODULEW {
  762. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE)
  763. DWORD BaseOfImage; // base load address of module
  764. DWORD ImageSize; // virtual size of the loaded module
  765. DWORD TimeDateStamp; // date/time stamp from pe header
  766. DWORD CheckSum; // checksum from the pe header
  767. DWORD NumSyms; // number of symbols in the symbol table
  768. SYM_TYPE SymType; // type of symbols loaded
  769. WCHAR ModuleName[32]; // module name
  770. WCHAR ImageName[256]; // image name
  771. WCHAR LoadedImageName[256]; // symbol file name
  772. } IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
  773. #endif
  774. //
  775. // source file line data structure
  776. //
  777. typedef struct _IMAGEHLP_LINE64 {
  778. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
  779. PVOID Key; // internal
  780. DWORD LineNumber; // line number in file
  781. PCHAR FileName; // full filename
  782. DWORD64 Address; // first instruction of line
  783. } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
  784. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  785. #define IMAGEHLP_LINE IMAGEHLP_LINE64
  786. #define PIMAGEHLP_LINE PIMAGEHLP_LINE64
  787. #else
  788. typedef struct _IMAGEHLP_LINE {
  789. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE)
  790. PVOID Key; // internal
  791. DWORD LineNumber; // line number in file
  792. PCHAR FileName; // full filename
  793. DWORD Address; // first instruction of line
  794. } IMAGEHLP_LINE, *PIMAGEHLP_LINE;
  795. #endif
  796. //
  797. // source file structure
  798. //
  799. typedef struct _SOURCEFILE {
  800. DWORD64 ModBase; // base address of loaded module
  801. PCHAR FileName; // full filename of source
  802. } SOURCEFILE, *PSOURCEFILE;
  803. //
  804. // data structures used for registered symbol callbacks
  805. //
  806. #define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
  807. #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
  808. #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
  809. #define CBA_SYMBOLS_UNLOADED 0x00000004
  810. #define CBA_DUPLICATE_SYMBOL 0x00000005
  811. #define CBA_READ_MEMORY 0x00000006
  812. #define CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007
  813. #define CBA_SET_OPTIONS 0x00000008
  814. #define CBA_EVENT 0x00000010
  815. #define CBA_DEBUG_INFO 0x10000000
  816. typedef struct _IMAGEHLP_CBA_READ_MEMORY {
  817. DWORD64 addr; // address to read from
  818. PVOID buf; // buffer to read to
  819. DWORD bytes; // amount of bytes to read
  820. DWORD *bytesread; // pointer to store amount of bytes read
  821. } IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;
  822. enum {
  823. sevInfo = 0,
  824. sevProblem,
  825. sevAttn,
  826. sevFatal,
  827. sevMax // unused
  828. };
  829. typedef struct _IMAGEHLP_CBA_EVENT {
  830. DWORD severity; // values from sevInfo to sevFatal
  831. DWORD code; // numerical code IDs the error
  832. PCHAR desc; // may contain a text description of the error
  833. PVOID object; // value dependant upon the error code
  834. } IMAGEHLP_CBA_EVENT, *PIMAGEHLP_CBA_EVENT;
  835. typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 {
  836. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
  837. DWORD64 BaseOfImage; // base load address of module
  838. DWORD CheckSum; // checksum from the pe header
  839. DWORD TimeDateStamp; // date/time stamp from pe header
  840. CHAR FileName[MAX_PATH]; // symbols file or image name
  841. BOOLEAN Reparse; // load failure reparse
  842. } IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
  843. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  844. #define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
  845. #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
  846. #else
  847. typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
  848. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD)
  849. DWORD BaseOfImage; // base load address of module
  850. DWORD CheckSum; // checksum from the pe header
  851. DWORD TimeDateStamp; // date/time stamp from pe header
  852. CHAR FileName[MAX_PATH]; // symbols file or image name
  853. BOOLEAN Reparse; // load failure reparse
  854. } IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
  855. #endif
  856. typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 {
  857. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64)
  858. DWORD NumberOfDups; // number of duplicates in the Symbol array
  859. PIMAGEHLP_SYMBOL64 Symbol; // array of duplicate symbols
  860. DWORD SelectedSymbol; // symbol selected (-1 to start)
  861. } IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64;
  862. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  863. #define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64
  864. #define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64
  865. #else
  866. typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
  867. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL)
  868. DWORD NumberOfDups; // number of duplicates in the Symbol array
  869. PIMAGEHLP_SYMBOL Symbol; // array of duplicate symbols
  870. DWORD SelectedSymbol; // symbol selected (-1 to start)
  871. } IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
  872. #endif
  873. //
  874. // options that are set/returned by SymSetOptions() & SymGetOptions()
  875. // these are used as a mask
  876. //
  877. #define SYMOPT_CASE_INSENSITIVE 0x00000001
  878. #define SYMOPT_UNDNAME 0x00000002
  879. #define SYMOPT_DEFERRED_LOADS 0x00000004
  880. #define SYMOPT_NO_CPP 0x00000008
  881. #define SYMOPT_LOAD_LINES 0x00000010
  882. #define SYMOPT_OMAP_FIND_NEAREST 0x00000020
  883. #define SYMOPT_LOAD_ANYTHING 0x00000040
  884. #define SYMOPT_IGNORE_CVREC 0x00000080
  885. #define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100
  886. #define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
  887. #define SYMOPT_EXACT_SYMBOLS 0x00000400
  888. #define SYMOPT_WILD_UNDERSCORE 0x00000800
  889. #define SYMOPT_USE_DEFAULTS 0x00001000
  890. #define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000
  891. #define SYMOPT_DEBUG 0x80000000
  892. DWORD
  893. IMAGEAPI
  894. SymSetOptions(
  895. IN DWORD SymOptions
  896. );
  897. DWORD
  898. IMAGEAPI
  899. SymGetOptions(
  900. VOID
  901. );
  902. BOOL
  903. IMAGEAPI
  904. SymCleanup(
  905. IN HANDLE hProcess
  906. );
  907. BOOL
  908. IMAGEAPI
  909. SymMatchString(
  910. IN LPSTR string,
  911. IN LPSTR expression,
  912. IN BOOL fCase
  913. );
  914. typedef BOOL
  915. (CALLBACK *PSYM_ENUMSOURCFILES_CALLBACK)(
  916. PSOURCEFILE pSourceFile,
  917. PVOID UserContext
  918. );
  919. BOOL
  920. IMAGEAPI
  921. SymEnumSourceFiles(
  922. IN HANDLE hProcess,
  923. IN ULONG64 ModBase,
  924. IN LPSTR Mask,
  925. IN PSYM_ENUMSOURCFILES_CALLBACK cbSrcFiles,
  926. IN PVOID UserContext
  927. );
  928. BOOL
  929. IMAGEAPI
  930. SymEnumerateModules64(
  931. IN HANDLE hProcess,
  932. IN PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback,
  933. IN PVOID UserContext
  934. );
  935. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  936. #define SymEnumerateModules SymEnumerateModules64
  937. #else
  938. BOOL
  939. IMAGEAPI
  940. SymEnumerateModules(
  941. IN HANDLE hProcess,
  942. IN PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,
  943. IN PVOID UserContext
  944. );
  945. #endif
  946. BOOL
  947. IMAGEAPI
  948. SymEnumerateSymbols64(
  949. IN HANDLE hProcess,
  950. IN DWORD64 BaseOfDll,
  951. IN PSYM_ENUMSYMBOLS_CALLBACK64 EnumSymbolsCallback,
  952. IN PVOID UserContext
  953. );
  954. BOOL
  955. IMAGEAPI
  956. SymEnumerateSymbolsW64(
  957. IN HANDLE hProcess,
  958. IN DWORD64 BaseOfDll,
  959. IN PSYM_ENUMSYMBOLS_CALLBACK64W EnumSymbolsCallback,
  960. IN PVOID UserContext
  961. );
  962. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  963. #define SymEnumerateSymbols SymEnumerateSymbols64
  964. #define SymEnumerateSymbolsW SymEnumerateSymbolsW64
  965. #else
  966. BOOL
  967. IMAGEAPI
  968. SymEnumerateSymbols(
  969. IN HANDLE hProcess,
  970. IN DWORD BaseOfDll,
  971. IN PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback,
  972. IN PVOID UserContext
  973. );
  974. BOOL
  975. IMAGEAPI
  976. SymEnumerateSymbolsW(
  977. IN HANDLE hProcess,
  978. IN DWORD BaseOfDll,
  979. IN PSYM_ENUMSYMBOLS_CALLBACKW EnumSymbolsCallback,
  980. IN PVOID UserContext
  981. );
  982. #endif
  983. BOOL
  984. IMAGEAPI
  985. EnumerateLoadedModules64(
  986. IN HANDLE hProcess,
  987. IN PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback,
  988. IN PVOID UserContext
  989. );
  990. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  991. #define EnumerateLoadedModules EnumerateLoadedModules64
  992. #else
  993. BOOL
  994. IMAGEAPI
  995. EnumerateLoadedModules(
  996. IN HANDLE hProcess,
  997. IN PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,
  998. IN PVOID UserContext
  999. );
  1000. #endif
  1001. PVOID
  1002. IMAGEAPI
  1003. SymFunctionTableAccess64(
  1004. HANDLE hProcess,
  1005. DWORD64 AddrBase
  1006. );
  1007. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1008. #define SymFunctionTableAccess SymFunctionTableAccess64
  1009. #else
  1010. PVOID
  1011. IMAGEAPI
  1012. SymFunctionTableAccess(
  1013. HANDLE hProcess,
  1014. DWORD AddrBase
  1015. );
  1016. #endif
  1017. BOOL
  1018. IMAGEAPI
  1019. SymGetModuleInfo64(
  1020. IN HANDLE hProcess,
  1021. IN DWORD64 qwAddr,
  1022. OUT PIMAGEHLP_MODULE64 ModuleInfo
  1023. );
  1024. BOOL
  1025. IMAGEAPI
  1026. SymGetModuleInfoW64(
  1027. IN HANDLE hProcess,
  1028. IN DWORD64 qwAddr,
  1029. OUT PIMAGEHLP_MODULEW64 ModuleInfo
  1030. );
  1031. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1032. #define SymGetModuleInfo SymGetModuleInfo64
  1033. #define SymGetModuleInfoW SymGetModuleInfoW64
  1034. #else
  1035. BOOL
  1036. IMAGEAPI
  1037. SymGetModuleInfo(
  1038. IN HANDLE hProcess,
  1039. IN DWORD dwAddr,
  1040. OUT PIMAGEHLP_MODULE ModuleInfo
  1041. );
  1042. BOOL
  1043. IMAGEAPI
  1044. SymGetModuleInfoW(
  1045. IN HANDLE hProcess,
  1046. IN DWORD dwAddr,
  1047. OUT PIMAGEHLP_MODULEW ModuleInfo
  1048. );
  1049. #endif
  1050. DWORD64
  1051. IMAGEAPI
  1052. SymGetModuleBase64(
  1053. IN HANDLE hProcess,
  1054. IN DWORD64 qwAddr
  1055. );
  1056. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1057. #define SymGetModuleBase SymGetModuleBase64
  1058. #else
  1059. DWORD
  1060. IMAGEAPI
  1061. SymGetModuleBase(
  1062. IN HANDLE hProcess,
  1063. IN DWORD dwAddr
  1064. );
  1065. #endif
  1066. BOOL
  1067. IMAGEAPI
  1068. SymGetSymNext64(
  1069. IN HANDLE hProcess,
  1070. IN OUT PIMAGEHLP_SYMBOL64 Symbol
  1071. );
  1072. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1073. #define SymGetSymNext SymGetSymNext64
  1074. #else
  1075. BOOL
  1076. IMAGEAPI
  1077. SymGetSymNext(
  1078. IN HANDLE hProcess,
  1079. IN OUT PIMAGEHLP_SYMBOL Symbol
  1080. );
  1081. #endif
  1082. BOOL
  1083. IMAGEAPI
  1084. SymGetSymPrev64(
  1085. IN HANDLE hProcess,
  1086. IN OUT PIMAGEHLP_SYMBOL64 Symbol
  1087. );
  1088. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1089. #define SymGetSymPrev SymGetSymPrev64
  1090. #else
  1091. BOOL
  1092. IMAGEAPI
  1093. SymGetSymPrev(
  1094. IN HANDLE hProcess,
  1095. IN OUT PIMAGEHLP_SYMBOL Symbol
  1096. );
  1097. #endif
  1098. BOOL
  1099. IMAGEAPI
  1100. SymGetLineFromAddr64(
  1101. IN HANDLE hProcess,
  1102. IN DWORD64 qwAddr,
  1103. OUT PDWORD pdwDisplacement,
  1104. OUT PIMAGEHLP_LINE64 Line
  1105. );
  1106. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1107. #define SymGetLineFromAddr SymGetLineFromAddr64
  1108. #else
  1109. BOOL
  1110. IMAGEAPI
  1111. SymGetLineFromAddr(
  1112. IN HANDLE hProcess,
  1113. IN DWORD dwAddr,
  1114. OUT PDWORD pdwDisplacement,
  1115. OUT PIMAGEHLP_LINE Line
  1116. );
  1117. #endif
  1118. BOOL
  1119. IMAGEAPI
  1120. SymGetLineFromName64(
  1121. IN HANDLE hProcess,
  1122. IN PSTR ModuleName,
  1123. IN PSTR FileName,
  1124. IN DWORD dwLineNumber,
  1125. OUT PLONG plDisplacement,
  1126. IN OUT PIMAGEHLP_LINE64 Line
  1127. );
  1128. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1129. #define SymGetLineFromName SymGetLineFromName64
  1130. #else
  1131. BOOL
  1132. IMAGEAPI
  1133. SymGetLineFromName(
  1134. IN HANDLE hProcess,
  1135. IN PSTR ModuleName,
  1136. IN PSTR FileName,
  1137. IN DWORD dwLineNumber,
  1138. OUT PLONG plDisplacement,
  1139. IN OUT PIMAGEHLP_LINE Line
  1140. );
  1141. #endif
  1142. BOOL
  1143. IMAGEAPI
  1144. SymGetLineNext64(
  1145. IN HANDLE hProcess,
  1146. IN OUT PIMAGEHLP_LINE64 Line
  1147. );
  1148. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1149. #define SymGetLineNext SymGetLineNext64
  1150. #else
  1151. BOOL
  1152. IMAGEAPI
  1153. SymGetLineNext(
  1154. IN HANDLE hProcess,
  1155. IN OUT PIMAGEHLP_LINE Line
  1156. );
  1157. #endif
  1158. BOOL
  1159. IMAGEAPI
  1160. SymGetLinePrev64(
  1161. IN HANDLE hProcess,
  1162. IN OUT PIMAGEHLP_LINE64 Line
  1163. );
  1164. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1165. #define SymGetLinePrev SymGetLinePrev64
  1166. #else
  1167. BOOL
  1168. IMAGEAPI
  1169. SymGetLinePrev(
  1170. IN HANDLE hProcess,
  1171. IN OUT PIMAGEHLP_LINE Line
  1172. );
  1173. #endif
  1174. BOOL
  1175. IMAGEAPI
  1176. SymMatchFileName(
  1177. IN PSTR FileName,
  1178. IN PSTR Match,
  1179. OUT PSTR *FileNameStop,
  1180. OUT PSTR *MatchStop
  1181. );
  1182. BOOL
  1183. IMAGEAPI
  1184. SymInitialize(
  1185. IN HANDLE hProcess,
  1186. IN PSTR UserSearchPath,
  1187. IN BOOL fInvadeProcess
  1188. );
  1189. BOOL
  1190. IMAGEAPI
  1191. SymGetSearchPath(
  1192. IN HANDLE hProcess,
  1193. OUT PSTR SearchPath,
  1194. IN DWORD SearchPathLength
  1195. );
  1196. BOOL
  1197. IMAGEAPI
  1198. SymSetSearchPath(
  1199. IN HANDLE hProcess,
  1200. IN PSTR SearchPath
  1201. );
  1202. DWORD64
  1203. IMAGEAPI
  1204. SymLoadModule64(
  1205. IN HANDLE hProcess,
  1206. IN HANDLE hFile,
  1207. IN PSTR ImageName,
  1208. IN PSTR ModuleName,
  1209. IN DWORD64 BaseOfDll,
  1210. IN DWORD SizeOfDll
  1211. );
  1212. DWORD64
  1213. IMAGEAPI
  1214. SymLoadModuleEx(
  1215. IN HANDLE hProcess,
  1216. IN HANDLE hFile,
  1217. IN PSTR ImageName,
  1218. IN PSTR ModuleName,
  1219. IN DWORD64 BaseOfDll,
  1220. IN DWORD DllSize,
  1221. IN PMODLOAD_DATA Data,
  1222. IN DWORD Flags
  1223. );
  1224. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1225. #define SymLoadModule SymLoadModule64
  1226. #else
  1227. DWORD
  1228. IMAGEAPI
  1229. SymLoadModule(
  1230. IN HANDLE hProcess,
  1231. IN HANDLE hFile,
  1232. IN PSTR ImageName,
  1233. IN PSTR ModuleName,
  1234. IN DWORD BaseOfDll,
  1235. IN DWORD SizeOfDll
  1236. );
  1237. #endif
  1238. BOOL
  1239. IMAGEAPI
  1240. SymUnloadModule64(
  1241. IN HANDLE hProcess,
  1242. IN DWORD64 BaseOfDll
  1243. );
  1244. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1245. #define SymUnloadModule SymUnloadModule64
  1246. #else
  1247. BOOL
  1248. IMAGEAPI
  1249. SymUnloadModule(
  1250. IN HANDLE hProcess,
  1251. IN DWORD BaseOfDll
  1252. );
  1253. #endif
  1254. BOOL
  1255. IMAGEAPI
  1256. SymUnDName64(
  1257. IN PIMAGEHLP_SYMBOL64 sym, // Symbol to undecorate
  1258. OUT PSTR UnDecName, // Buffer to store undecorated name in
  1259. IN DWORD UnDecNameLength // Size of the buffer
  1260. );
  1261. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1262. #define SymUnDName SymUnDName64
  1263. #else
  1264. BOOL
  1265. IMAGEAPI
  1266. SymUnDName(
  1267. IN PIMAGEHLP_SYMBOL sym, // Symbol to undecorate
  1268. OUT PSTR UnDecName, // Buffer to store undecorated name in
  1269. IN DWORD UnDecNameLength // Size of the buffer
  1270. );
  1271. #endif
  1272. BOOL
  1273. IMAGEAPI
  1274. SymRegisterCallback64(
  1275. IN HANDLE hProcess,
  1276. IN PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction,
  1277. IN ULONG64 UserContext
  1278. );
  1279. BOOL
  1280. IMAGEAPI
  1281. SymRegisterFunctionEntryCallback64(
  1282. IN HANDLE hProcess,
  1283. IN PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction,
  1284. IN ULONG64 UserContext
  1285. );
  1286. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1287. #define SymRegisterCallback SymRegisterCallback64
  1288. #define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64
  1289. #else
  1290. BOOL
  1291. IMAGEAPI
  1292. SymRegisterCallback(
  1293. IN HANDLE hProcess,
  1294. IN PSYMBOL_REGISTERED_CALLBACK CallbackFunction,
  1295. IN PVOID UserContext
  1296. );
  1297. BOOL
  1298. IMAGEAPI
  1299. SymRegisterFunctionEntryCallback(
  1300. IN HANDLE hProcess,
  1301. IN PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction,
  1302. IN PVOID UserContext
  1303. );
  1304. #endif
  1305. typedef struct _IMAGEHLP_SYMBOL_SRC {
  1306. DWORD sizeofstruct;
  1307. DWORD type;
  1308. char file[MAX_PATH];
  1309. } IMAGEHLP_SYMBOL_SRC, *PIMAGEHLP_SYMBOL_SRC;
  1310. typedef struct _MODULE_TYPE_INFO { // AKA TYPTYP
  1311. USHORT dataLength;
  1312. USHORT leaf;
  1313. BYTE data[1];
  1314. } MODULE_TYPE_INFO, *PMODULE_TYPE_INFO;
  1315. #define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT 1
  1316. #define IMAGEHLP_SYMBOL_INFO_REGISTER SYMF_REGISTER // 0x08
  1317. #define IMAGEHLP_SYMBOL_INFO_REGRELATIVE SYMF_REGREL // 0x10
  1318. #define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE SYMF_FRAMEREL // 0x20
  1319. #define IMAGEHLP_SYMBOL_INFO_PARAMETER SYMF_PARAMETER // 0x40
  1320. #define IMAGEHLP_SYMBOL_INFO_LOCAL SYMF_LOCAL // 0x80
  1321. #define IMAGEHLP_SYMBOL_INFO_CONSTANT SYMF_CONSTANT // 0x100
  1322. #define IMAGEHLP_SYMBOL_FUNCTION SYMF_FUNCTION // 0x800
  1323. typedef struct _SYMBOL_INFO {
  1324. ULONG SizeOfStruct;
  1325. ULONG TypeIndex; // Type Index of symbol
  1326. ULONG64 Reserved[2];
  1327. ULONG Reserved2;
  1328. ULONG Size;
  1329. ULONG64 ModBase; // Base Address of module comtaining this symbol
  1330. ULONG Flags;
  1331. ULONG64 Value; // Value of symbol, ValuePresent should be 1
  1332. ULONG64 Address; // Address of symbol including base address of module
  1333. ULONG Register; // register holding value or pointer to value
  1334. ULONG Scope; // scope of the symbol
  1335. ULONG Tag; // pdb classification
  1336. ULONG NameLen; // Actual length of name
  1337. ULONG MaxNameLen;
  1338. CHAR Name[1]; // Name of symbol
  1339. } SYMBOL_INFO, *PSYMBOL_INFO;
  1340. typedef struct _IMAGEHLP_STACK_FRAME
  1341. {
  1342. ULONG64 InstructionOffset;
  1343. ULONG64 ReturnOffset;
  1344. ULONG64 FrameOffset;
  1345. ULONG64 StackOffset;
  1346. ULONG64 BackingStoreOffset;
  1347. ULONG64 FuncTableEntry;
  1348. ULONG64 Params[4];
  1349. ULONG64 Reserved[5];
  1350. BOOL Virtual;
  1351. ULONG Reserved2;
  1352. } IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
  1353. typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT;
  1354. ULONG
  1355. IMAGEAPI
  1356. SymSetContext(
  1357. HANDLE hProcess,
  1358. PIMAGEHLP_STACK_FRAME StackFrame,
  1359. PIMAGEHLP_CONTEXT Context
  1360. );
  1361. BOOL
  1362. IMAGEAPI
  1363. SymFromAddr(
  1364. IN HANDLE hProcess,
  1365. IN DWORD64 Address,
  1366. OUT PDWORD64 Displacement,
  1367. IN OUT PSYMBOL_INFO Symbol
  1368. );
  1369. // While SymFromName will provide a symbol from a name,
  1370. // SymEnumSymbols can provide the same matching information
  1371. // for ALL symbols with a matching name, even regular
  1372. // expressions. That way you can search across modules
  1373. // and differentiate between identically named symbols.
  1374. BOOL
  1375. IMAGEAPI
  1376. SymFromName(
  1377. IN HANDLE hProcess,
  1378. IN LPSTR Name,
  1379. OUT PSYMBOL_INFO Symbol
  1380. );
  1381. typedef BOOL
  1382. (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(
  1383. PSYMBOL_INFO pSymInfo,
  1384. ULONG SymbolSize,
  1385. PVOID UserContext
  1386. );
  1387. BOOL
  1388. IMAGEAPI
  1389. SymEnumSymbols(
  1390. IN HANDLE hProcess,
  1391. IN ULONG64 BaseOfDll,
  1392. IN PCSTR Mask,
  1393. IN PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  1394. IN PVOID UserContext
  1395. );
  1396. typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO {
  1397. TI_GET_SYMTAG,
  1398. TI_GET_SYMNAME,
  1399. TI_GET_LENGTH,
  1400. TI_GET_TYPE,
  1401. TI_GET_TYPEID,
  1402. TI_GET_BASETYPE,
  1403. TI_GET_ARRAYINDEXTYPEID,
  1404. TI_FINDCHILDREN,
  1405. TI_GET_DATAKIND,
  1406. TI_GET_ADDRESSOFFSET,
  1407. TI_GET_OFFSET,
  1408. TI_GET_VALUE,
  1409. TI_GET_COUNT,
  1410. TI_GET_CHILDRENCOUNT,
  1411. TI_GET_BITPOSITION,
  1412. TI_GET_VIRTUALBASECLASS,
  1413. TI_GET_VIRTUALTABLESHAPEID,
  1414. TI_GET_VIRTUALBASEPOINTEROFFSET,
  1415. TI_GET_CLASSPARENTID,
  1416. TI_GET_NESTED,
  1417. TI_GET_SYMINDEX,
  1418. TI_GET_LEXICALPARENT,
  1419. TI_GET_ADDRESS,
  1420. TI_GET_THISADJUST,
  1421. } IMAGEHLP_SYMBOL_TYPE_INFO;
  1422. typedef struct _TI_FINDCHILDREN_PARAMS {
  1423. ULONG Count;
  1424. ULONG Start;
  1425. ULONG ChildId[1];
  1426. } TI_FINDCHILDREN_PARAMS;
  1427. BOOL
  1428. IMAGEAPI
  1429. SymGetTypeInfo(
  1430. IN HANDLE hProcess,
  1431. IN DWORD64 ModBase,
  1432. IN ULONG TypeId,
  1433. IN IMAGEHLP_SYMBOL_TYPE_INFO GetType,
  1434. OUT PVOID pInfo
  1435. );
  1436. BOOL
  1437. IMAGEAPI
  1438. SymEnumTypes(
  1439. IN HANDLE hProcess,
  1440. IN ULONG64 BaseOfDll,
  1441. IN PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  1442. IN PVOID UserContext
  1443. );
  1444. BOOL
  1445. IMAGEAPI
  1446. SymGetTypeFromName(
  1447. IN HANDLE hProcess,
  1448. IN ULONG64 BaseOfDll,
  1449. IN LPSTR Name,
  1450. OUT PSYMBOL_INFO Symbol
  1451. );
  1452. //
  1453. // Full user-mode dump creation.
  1454. //
  1455. typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
  1456. DWORD DataType,
  1457. PVOID* Data,
  1458. LPDWORD DataLength,
  1459. PVOID UserData
  1460. );
  1461. BOOL
  1462. WINAPI
  1463. DbgHelpCreateUserDump(
  1464. IN LPSTR FileName,
  1465. IN PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,
  1466. IN PVOID UserData
  1467. );
  1468. BOOL
  1469. WINAPI
  1470. DbgHelpCreateUserDumpW(
  1471. IN LPWSTR FileName,
  1472. IN PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,
  1473. IN PVOID UserData
  1474. );
  1475. // -----------------------------------------------------------------
  1476. // The following 4 legacy APIs are fully supported, but newer
  1477. // ones are recommended. SymFromName and SymFromAddr provide
  1478. // much more detailed info on the returned symbol.
  1479. BOOL
  1480. IMAGEAPI
  1481. SymGetSymFromAddr64(
  1482. IN HANDLE hProcess,
  1483. IN DWORD64 qwAddr,
  1484. OUT PDWORD64 pdwDisplacement,
  1485. OUT PIMAGEHLP_SYMBOL64 Symbol
  1486. );
  1487. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1488. #define SymGetSymFromAddr SymGetSymFromAddr64
  1489. #else
  1490. BOOL
  1491. IMAGEAPI
  1492. SymGetSymFromAddr(
  1493. IN HANDLE hProcess,
  1494. IN DWORD dwAddr,
  1495. OUT PDWORD pdwDisplacement,
  1496. OUT PIMAGEHLP_SYMBOL Symbol
  1497. );
  1498. #endif
  1499. // While following two APIs will provide a symbol from a name,
  1500. // SymEnumSymbols can provide the same matching information
  1501. // for ALL symbols with a matching name, even regular
  1502. // expressions. That way you can search across modules
  1503. // and differentiate between identically named symbols.
  1504. BOOL
  1505. IMAGEAPI
  1506. SymGetSymFromName64(
  1507. IN HANDLE hProcess,
  1508. IN PSTR Name,
  1509. OUT PIMAGEHLP_SYMBOL64 Symbol
  1510. );
  1511. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1512. #define SymGetSymFromName SymGetSymFromName64
  1513. #else
  1514. BOOL
  1515. IMAGEAPI
  1516. SymGetSymFromName(
  1517. IN HANDLE hProcess,
  1518. IN PSTR Name,
  1519. OUT PIMAGEHLP_SYMBOL Symbol
  1520. );
  1521. #endif
  1522. // -----------------------------------------------------------------
  1523. // The following APIs exist only for backwards compatibility
  1524. // with a pre-release version documented in an MSDN release.
  1525. // You should use SymFindFileInPath if you want to maintain
  1526. // future compatibility.
  1527. DBHLP_DEPRECIATED
  1528. BOOL
  1529. IMAGEAPI
  1530. FindFileInPath(
  1531. HANDLE hprocess,
  1532. LPSTR SearchPath,
  1533. LPSTR FileName,
  1534. PVOID id,
  1535. DWORD two,
  1536. DWORD three,
  1537. DWORD flags,
  1538. LPSTR FilePath
  1539. );
  1540. // You should use SymFindFileInPath if you want to maintain
  1541. // future compatibility.
  1542. DBHLP_DEPRECIATED
  1543. BOOL
  1544. IMAGEAPI
  1545. FindFileInSearchPath(
  1546. HANDLE hprocess,
  1547. LPSTR SearchPath,
  1548. LPSTR FileName,
  1549. DWORD one,
  1550. DWORD two,
  1551. DWORD three,
  1552. LPSTR FilePath
  1553. );
  1554. DBHLP_DEPRECIATED
  1555. BOOL
  1556. IMAGEAPI
  1557. SymEnumSym(
  1558. IN HANDLE hProcess,
  1559. IN ULONG64 BaseOfDll,
  1560. IN PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  1561. IN PVOID UserContext
  1562. );
  1563. #include <pshpack4.h>
  1564. #pragma warning(disable:4200) // Zero length array
  1565. #define MINIDUMP_SIGNATURE ('PMDM')
  1566. #define MINIDUMP_VERSION (42899)
  1567. typedef DWORD RVA;
  1568. typedef ULONG64 RVA64;
  1569. typedef struct _MINIDUMP_LOCATION_DESCRIPTOR {
  1570. ULONG32 DataSize;
  1571. RVA Rva;
  1572. } MINIDUMP_LOCATION_DESCRIPTOR;
  1573. typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 {
  1574. ULONG64 DataSize;
  1575. RVA64 Rva;
  1576. } MINIDUMP_LOCATION_DESCRIPTOR64;
  1577. typedef struct _MINIDUMP_MEMORY_DESCRIPTOR {
  1578. ULONG64 StartOfMemoryRange;
  1579. MINIDUMP_LOCATION_DESCRIPTOR Memory;
  1580. } MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR;
  1581. // DESCRIPTOR64 is used for full-memory minidumps where
  1582. // all of the raw memory is laid out sequentially at the
  1583. // end of the dump. There is no need for individual RVAs
  1584. // as the RVA is the base RVA plus the sum of the preceeding
  1585. // data blocks.
  1586. typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 {
  1587. ULONG64 StartOfMemoryRange;
  1588. ULONG64 DataSize;
  1589. } MINIDUMP_MEMORY_DESCRIPTOR64, *PMINIDUMP_MEMORY_DESCRIPTOR64;
  1590. typedef struct _MINIDUMP_HEADER {
  1591. ULONG32 Signature;
  1592. ULONG32 Version;
  1593. ULONG32 NumberOfStreams;
  1594. RVA StreamDirectoryRva;
  1595. ULONG32 CheckSum;
  1596. union {
  1597. ULONG32 Reserved;
  1598. ULONG32 TimeDateStamp;
  1599. };
  1600. ULONG64 Flags;
  1601. } MINIDUMP_HEADER, *PMINIDUMP_HEADER;
  1602. //
  1603. // The MINIDUMP_HEADER field StreamDirectoryRva points to
  1604. // an array of MINIDUMP_DIRECTORY structures.
  1605. //
  1606. typedef struct _MINIDUMP_DIRECTORY {
  1607. ULONG32 StreamType;
  1608. MINIDUMP_LOCATION_DESCRIPTOR Location;
  1609. } MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY;
  1610. typedef struct _MINIDUMP_STRING {
  1611. ULONG32 Length; // Length in bytes of the string
  1612. WCHAR Buffer [0]; // Variable size buffer
  1613. } MINIDUMP_STRING, *PMINIDUMP_STRING;
  1614. //
  1615. // The MINIDUMP_DIRECTORY field StreamType may be one of the following types.
  1616. // Types will be added in the future, so if a program reading the minidump
  1617. // header encounters a stream type it does not understand it should ignore
  1618. // the data altogether. Any tag above LastReservedStream will not be used by
  1619. // the system and is reserved for program-specific information.
  1620. //
  1621. typedef enum _MINIDUMP_STREAM_TYPE {
  1622. UnusedStream = 0,
  1623. ReservedStream0 = 1,
  1624. ReservedStream1 = 2,
  1625. ThreadListStream = 3,
  1626. ModuleListStream = 4,
  1627. MemoryListStream = 5,
  1628. ExceptionStream = 6,
  1629. SystemInfoStream = 7,
  1630. ThreadExListStream = 8,
  1631. Memory64ListStream = 9,
  1632. CommentStreamA = 10,
  1633. CommentStreamW = 11,
  1634. HandleDataStream = 12,
  1635. FunctionTableStream = 13,
  1636. UnloadedModuleListStream = 14,
  1637. MiscInfoStream = 15,
  1638. LastReservedStream = 0xffff
  1639. } MINIDUMP_STREAM_TYPE;
  1640. //
  1641. // The minidump system information contains processor and
  1642. // Operating System specific information.
  1643. //
  1644. #if defined(_MSC_VER)
  1645. #if _MSC_VER >= 800
  1646. #if _MSC_VER >= 1200
  1647. #pragma warning(push)
  1648. #endif
  1649. #pragma warning(disable:4201) /* Nameless struct/union */
  1650. #endif
  1651. #endif
  1652. typedef struct _MINIDUMP_SYSTEM_INFO {
  1653. //
  1654. // ProcessorArchitecture, ProcessorLevel and ProcessorRevision are all
  1655. // taken from the SYSTEM_INFO structure obtained by GetSystemInfo( ).
  1656. //
  1657. USHORT ProcessorArchitecture;
  1658. USHORT ProcessorLevel;
  1659. USHORT ProcessorRevision;
  1660. union {
  1661. USHORT Reserved0;
  1662. struct {
  1663. UCHAR NumberOfProcessors;
  1664. UCHAR ProductType;
  1665. };
  1666. };
  1667. //
  1668. // MajorVersion, MinorVersion, BuildNumber, PlatformId and
  1669. // CSDVersion are all taken from the OSVERSIONINFO structure
  1670. // returned by GetVersionEx( ).
  1671. //
  1672. ULONG32 MajorVersion;
  1673. ULONG32 MinorVersion;
  1674. ULONG32 BuildNumber;
  1675. ULONG32 PlatformId;
  1676. //
  1677. // RVA to a CSDVersion string in the string table.
  1678. //
  1679. RVA CSDVersionRva;
  1680. union {
  1681. ULONG32 Reserved1;
  1682. struct {
  1683. USHORT SuiteMask;
  1684. USHORT Reserved2;
  1685. };
  1686. };
  1687. //
  1688. // CPU information is obtained from one of two places.
  1689. //
  1690. // 1) On x86 computers, CPU_INFORMATION is obtained from the CPUID
  1691. // instruction. You must use the X86 portion of the union for X86
  1692. // computers.
  1693. //
  1694. // 2) On non-x86 architectures, CPU_INFORMATION is obtained by calling
  1695. // IsProcessorFeatureSupported().
  1696. //
  1697. union _CPU_INFORMATION {
  1698. //
  1699. // X86 platforms use CPUID function to obtain processor information.
  1700. //
  1701. struct {
  1702. //
  1703. // CPUID Subfunction 0, register EAX (VendorId [0]),
  1704. // EBX (VendorId [1]) and ECX (VendorId [2]).
  1705. //
  1706. ULONG32 VendorId [ 3 ];
  1707. //
  1708. // CPUID Subfunction 1, register EAX
  1709. //
  1710. ULONG32 VersionInformation;
  1711. //
  1712. // CPUID Subfunction 1, register EDX
  1713. //
  1714. ULONG32 FeatureInformation;
  1715. //
  1716. // CPUID, Subfunction 80000001, register EBX. This will only
  1717. // be obtained if the vendor id is "AuthenticAMD".
  1718. //
  1719. ULONG32 AMDExtendedCpuFeatures;
  1720. } X86CpuInfo;
  1721. //
  1722. // Non-x86 platforms use processor feature flags.
  1723. //
  1724. struct {
  1725. ULONG64 ProcessorFeatures [ 2 ];
  1726. } OtherCpuInfo;
  1727. } Cpu;
  1728. } MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO;
  1729. typedef union _CPU_INFORMATION CPU_INFORMATION, *PCPU_INFORMATION;
  1730. #if defined(_MSC_VER)
  1731. #if _MSC_VER >= 800
  1732. #if _MSC_VER >= 1200
  1733. #pragma warning(pop)
  1734. #else
  1735. #pragma warning(disable:4201) /* Nameless struct/union */
  1736. #endif
  1737. #endif
  1738. #endif
  1739. //
  1740. // The minidump thread contains standard thread
  1741. // information plus an RVA to the memory for this
  1742. // thread and an RVA to the CONTEXT structure for
  1743. // this thread.
  1744. //
  1745. //
  1746. // ThreadId must be 4 bytes on all architectures.
  1747. //
  1748. C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
  1749. typedef struct _MINIDUMP_THREAD {
  1750. ULONG32 ThreadId;
  1751. ULONG32 SuspendCount;
  1752. ULONG32 PriorityClass;
  1753. ULONG32 Priority;
  1754. ULONG64 Teb;
  1755. MINIDUMP_MEMORY_DESCRIPTOR Stack;
  1756. MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
  1757. } MINIDUMP_THREAD, *PMINIDUMP_THREAD;
  1758. //
  1759. // The thread list is a container of threads.
  1760. //
  1761. typedef struct _MINIDUMP_THREAD_LIST {
  1762. ULONG32 NumberOfThreads;
  1763. MINIDUMP_THREAD Threads [0];
  1764. } MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST;
  1765. typedef struct _MINIDUMP_THREAD_EX {
  1766. ULONG32 ThreadId;
  1767. ULONG32 SuspendCount;
  1768. ULONG32 PriorityClass;
  1769. ULONG32 Priority;
  1770. ULONG64 Teb;
  1771. MINIDUMP_MEMORY_DESCRIPTOR Stack;
  1772. MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
  1773. MINIDUMP_MEMORY_DESCRIPTOR BackingStore;
  1774. } MINIDUMP_THREAD_EX, *PMINIDUMP_THREAD_EX;
  1775. //
  1776. // The thread list is a container of threads.
  1777. //
  1778. typedef struct _MINIDUMP_THREAD_EX_LIST {
  1779. ULONG32 NumberOfThreads;
  1780. MINIDUMP_THREAD_EX Threads [0];
  1781. } MINIDUMP_THREAD_EX_LIST, *PMINIDUMP_THREAD_EX_LIST;
  1782. //
  1783. // The MINIDUMP_EXCEPTION is the same as EXCEPTION on Win64.
  1784. //
  1785. typedef struct _MINIDUMP_EXCEPTION {
  1786. ULONG32 ExceptionCode;
  1787. ULONG32 ExceptionFlags;
  1788. ULONG64 ExceptionRecord;
  1789. ULONG64 ExceptionAddress;
  1790. ULONG32 NumberParameters;
  1791. ULONG32 __unusedAlignment;
  1792. ULONG64 ExceptionInformation [ EXCEPTION_MAXIMUM_PARAMETERS ];
  1793. } MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION;
  1794. //
  1795. // The exception information stream contains the id of the thread that caused
  1796. // the exception (ThreadId), the exception record for the exception
  1797. // (ExceptionRecord) and an RVA to the thread context where the exception
  1798. // occured.
  1799. //
  1800. typedef struct MINIDUMP_EXCEPTION_STREAM {
  1801. ULONG32 ThreadId;
  1802. ULONG32 __alignment;
  1803. MINIDUMP_EXCEPTION ExceptionRecord;
  1804. MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
  1805. } MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM;
  1806. //
  1807. // The MINIDUMP_MODULE contains information about a
  1808. // a specific module. It includes the CheckSum and
  1809. // the TimeDateStamp for the module so the module
  1810. // can be reloaded during the analysis phase.
  1811. //
  1812. typedef struct _MINIDUMP_MODULE {
  1813. ULONG64 BaseOfImage;
  1814. ULONG32 SizeOfImage;
  1815. ULONG32 CheckSum;
  1816. ULONG32 TimeDateStamp;
  1817. RVA ModuleNameRva;
  1818. VS_FIXEDFILEINFO VersionInfo;
  1819. MINIDUMP_LOCATION_DESCRIPTOR CvRecord;
  1820. MINIDUMP_LOCATION_DESCRIPTOR MiscRecord;
  1821. ULONG64 Reserved0; // Reserved for future use.
  1822. ULONG64 Reserved1; // Reserved for future use.
  1823. } MINIDUMP_MODULE, *PMINIDUMP_MODULE;
  1824. //
  1825. // The minidump module list is a container for modules.
  1826. //
  1827. typedef struct _MINIDUMP_MODULE_LIST {
  1828. ULONG32 NumberOfModules;
  1829. MINIDUMP_MODULE Modules [ 0 ];
  1830. } MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST;
  1831. //
  1832. // Memory Ranges
  1833. //
  1834. typedef struct _MINIDUMP_MEMORY_LIST {
  1835. ULONG32 NumberOfMemoryRanges;
  1836. MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges [0];
  1837. } MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST;
  1838. typedef struct _MINIDUMP_MEMORY64_LIST {
  1839. ULONG64 NumberOfMemoryRanges;
  1840. RVA64 BaseRva;
  1841. MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges [0];
  1842. } MINIDUMP_MEMORY64_LIST, *PMINIDUMP_MEMORY64_LIST;
  1843. //
  1844. // Support for user supplied exception information.
  1845. //
  1846. typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
  1847. DWORD ThreadId;
  1848. PEXCEPTION_POINTERS ExceptionPointers;
  1849. BOOL ClientPointers;
  1850. } MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
  1851. //
  1852. // Support for capturing system handle state at the time of the dump.
  1853. //
  1854. typedef struct _MINIDUMP_HANDLE_DESCRIPTOR {
  1855. ULONG64 Handle;
  1856. RVA TypeNameRva;
  1857. RVA ObjectNameRva;
  1858. ULONG32 Attributes;
  1859. ULONG32 GrantedAccess;
  1860. ULONG32 HandleCount;
  1861. ULONG32 PointerCount;
  1862. } MINIDUMP_HANDLE_DESCRIPTOR, *PMINIDUMP_HANDLE_DESCRIPTOR;
  1863. typedef struct _MINIDUMP_HANDLE_DATA_STREAM {
  1864. ULONG32 SizeOfHeader;
  1865. ULONG32 SizeOfDescriptor;
  1866. ULONG32 NumberOfDescriptors;
  1867. ULONG32 Reserved;
  1868. } MINIDUMP_HANDLE_DATA_STREAM, *PMINIDUMP_HANDLE_DATA_STREAM;
  1869. //
  1870. // Support for capturing dynamic function table state at the time of the dump.
  1871. //
  1872. typedef struct _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR {
  1873. ULONG64 MinimumAddress;
  1874. ULONG64 MaximumAddress;
  1875. ULONG64 BaseAddress;
  1876. ULONG32 EntryCount;
  1877. ULONG32 SizeOfAlignPad;
  1878. } MINIDUMP_FUNCTION_TABLE_DESCRIPTOR, *PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
  1879. typedef struct _MINIDUMP_FUNCTION_TABLE_STREAM {
  1880. ULONG32 SizeOfHeader;
  1881. ULONG32 SizeOfDescriptor;
  1882. ULONG32 SizeOfNativeDescriptor;
  1883. ULONG32 SizeOfFunctionEntry;
  1884. ULONG32 NumberOfDescriptors;
  1885. ULONG32 SizeOfAlignPad;
  1886. } MINIDUMP_FUNCTION_TABLE_STREAM, *PMINIDUMP_FUNCTION_TABLE_STREAM;
  1887. //
  1888. // The MINIDUMP_UNLOADED_MODULE contains information about a
  1889. // a specific module that was previously loaded but no
  1890. // longer is. This can help with diagnosing problems where
  1891. // callers attempt to call code that is no longer loaded.
  1892. //
  1893. typedef struct _MINIDUMP_UNLOADED_MODULE {
  1894. ULONG64 BaseOfImage;
  1895. ULONG32 SizeOfImage;
  1896. ULONG32 CheckSum;
  1897. ULONG32 TimeDateStamp;
  1898. RVA ModuleNameRva;
  1899. } MINIDUMP_UNLOADED_MODULE, *PMINIDUMP_UNLOADED_MODULE;
  1900. //
  1901. // The minidump unloaded module list is a container for unloaded modules.
  1902. //
  1903. typedef struct _MINIDUMP_UNLOADED_MODULE_LIST {
  1904. ULONG32 SizeOfHeader;
  1905. ULONG32 SizeOfEntry;
  1906. ULONG32 NumberOfEntries;
  1907. } MINIDUMP_UNLOADED_MODULE_LIST, *PMINIDUMP_UNLOADED_MODULE_LIST;
  1908. //
  1909. // The miscellaneous information stream contains a variety
  1910. // of small pieces of information. A member is valid if
  1911. // it's within the available size and its corresponding
  1912. // bit is set.
  1913. //
  1914. #define MINIDUMP_MISC1_PROCESS_ID 0x00000001
  1915. #define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002
  1916. typedef struct _MINIDUMP_MISC_INFO {
  1917. ULONG32 SizeOfInfo;
  1918. ULONG32 Flags1;
  1919. ULONG32 ProcessId;
  1920. ULONG32 ProcessCreateTime;
  1921. ULONG32 ProcessUserTime;
  1922. ULONG32 ProcessKernelTime;
  1923. } MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO;
  1924. //
  1925. // Support for arbitrary user-defined information.
  1926. //
  1927. typedef struct _MINIDUMP_USER_RECORD {
  1928. ULONG32 Type;
  1929. MINIDUMP_LOCATION_DESCRIPTOR Memory;
  1930. } MINIDUMP_USER_RECORD, *PMINIDUMP_USER_RECORD;
  1931. typedef struct _MINIDUMP_USER_STREAM {
  1932. ULONG32 Type;
  1933. ULONG BufferSize;
  1934. PVOID Buffer;
  1935. } MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM;
  1936. typedef struct _MINIDUMP_USER_STREAM_INFORMATION {
  1937. ULONG UserStreamCount;
  1938. PMINIDUMP_USER_STREAM UserStreamArray;
  1939. } MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION;
  1940. //
  1941. // Callback support.
  1942. //
  1943. typedef enum _MINIDUMP_CALLBACK_TYPE {
  1944. ModuleCallback,
  1945. ThreadCallback,
  1946. ThreadExCallback,
  1947. IncludeThreadCallback,
  1948. IncludeModuleCallback,
  1949. } MINIDUMP_CALLBACK_TYPE;
  1950. typedef struct _MINIDUMP_THREAD_CALLBACK {
  1951. ULONG ThreadId;
  1952. HANDLE ThreadHandle;
  1953. CONTEXT Context;
  1954. ULONG SizeOfContext;
  1955. ULONG64 StackBase;
  1956. ULONG64 StackEnd;
  1957. } MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK;
  1958. typedef struct _MINIDUMP_THREAD_EX_CALLBACK {
  1959. ULONG ThreadId;
  1960. HANDLE ThreadHandle;
  1961. CONTEXT Context;
  1962. ULONG SizeOfContext;
  1963. ULONG64 StackBase;
  1964. ULONG64 StackEnd;
  1965. ULONG64 BackingStoreBase;
  1966. ULONG64 BackingStoreEnd;
  1967. } MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK;
  1968. typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK {
  1969. ULONG ThreadId;
  1970. } MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK;
  1971. typedef enum _THREAD_WRITE_FLAGS {
  1972. ThreadWriteThread = 0x0001,
  1973. ThreadWriteStack = 0x0002,
  1974. ThreadWriteContext = 0x0004,
  1975. ThreadWriteBackingStore = 0x0008,
  1976. ThreadWriteInstructionWindow = 0x0010,
  1977. ThreadWriteThreadData = 0x0020,
  1978. } THREAD_WRITE_FLAGS;
  1979. typedef struct _MINIDUMP_MODULE_CALLBACK {
  1980. PWCHAR FullPath;
  1981. ULONG64 BaseOfImage;
  1982. ULONG SizeOfImage;
  1983. ULONG CheckSum;
  1984. ULONG TimeDateStamp;
  1985. VS_FIXEDFILEINFO VersionInfo;
  1986. PVOID CvRecord;
  1987. ULONG SizeOfCvRecord;
  1988. PVOID MiscRecord;
  1989. ULONG SizeOfMiscRecord;
  1990. } MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK;
  1991. typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK {
  1992. ULONG64 BaseOfImage;
  1993. } MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK;
  1994. typedef enum _MODULE_WRITE_FLAGS {
  1995. ModuleWriteModule = 0x0001,
  1996. ModuleWriteDataSeg = 0x0002,
  1997. ModuleWriteMiscRecord = 0x0004,
  1998. ModuleWriteCvRecord = 0x0008,
  1999. ModuleReferencedByMemory = 0x0010
  2000. } MODULE_WRITE_FLAGS;
  2001. typedef struct _MINIDUMP_CALLBACK_INPUT {
  2002. ULONG ProcessId;
  2003. HANDLE ProcessHandle;
  2004. ULONG CallbackType;
  2005. union {
  2006. MINIDUMP_THREAD_CALLBACK Thread;
  2007. MINIDUMP_THREAD_EX_CALLBACK ThreadEx;
  2008. MINIDUMP_MODULE_CALLBACK Module;
  2009. MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
  2010. MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
  2011. };
  2012. } MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT;
  2013. typedef struct _MINIDUMP_CALLBACK_OUTPUT {
  2014. union {
  2015. ULONG ModuleWriteFlags;
  2016. ULONG ThreadWriteFlags;
  2017. };
  2018. } MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT;
  2019. //
  2020. // A normal minidump contains just the information
  2021. // necessary to capture stack traces for all of the
  2022. // existing threads in a process.
  2023. //
  2024. // A minidump with data segments includes all of the data
  2025. // sections from loaded modules in order to capture
  2026. // global variable contents. This can make the dump much
  2027. // larger if many modules have global data.
  2028. //
  2029. // A minidump with full memory includes all of the accessible
  2030. // memory in the process and can be very large. A minidump
  2031. // with full memory always has the raw memory data at the end
  2032. // of the dump so that the initial structures in the dump can
  2033. // be mapped directly without having to include the raw
  2034. // memory information.
  2035. //
  2036. // Stack and backing store memory can be filtered to remove
  2037. // data unnecessary for stack walking. This can improve
  2038. // compression of stacks and also deletes data that may
  2039. // be private and should not be stored in a dump.
  2040. // Memory can also be scanned to see what modules are
  2041. // referenced by stack and backing store memory to allow
  2042. // omission of other modules to reduce dump size.
  2043. // In either of these modes the ModuleReferencedByMemory flag
  2044. // is set for all modules referenced before the base
  2045. // module callbacks occur.
  2046. //
  2047. // On some operating systems a list of modules that were
  2048. // recently unloaded is kept in addition to the currently
  2049. // loaded module list. This information can be saved in
  2050. // the dump if desired.
  2051. //
  2052. // Stack and backing store memory can be scanned for referenced
  2053. // pages in order to pick up data referenced by locals or other
  2054. // stack memory. This can increase the size of a dump significantly.
  2055. //
  2056. // Module paths may contain undesired information such as user names
  2057. // or other important directory names so they can be stripped. This
  2058. // option reduces the ability to locate the proper image later
  2059. // and should only be used in certain situations.
  2060. //
  2061. // Complete operating system per-process and per-thread information can
  2062. // be gathered and stored in the dump.
  2063. //
  2064. // The virtual address space can be scanned for various types
  2065. // of memory to be included in the dump.
  2066. //
  2067. typedef enum _MINIDUMP_TYPE {
  2068. MiniDumpNormal = 0x0000,
  2069. MiniDumpWithDataSegs = 0x0001,
  2070. MiniDumpWithFullMemory = 0x0002,
  2071. MiniDumpWithHandleData = 0x0004,
  2072. MiniDumpFilterMemory = 0x0008,
  2073. MiniDumpScanMemory = 0x0010,
  2074. MiniDumpWithUnloadedModules = 0x0020,
  2075. MiniDumpWithIndirectlyReferencedMemory = 0x0040,
  2076. MiniDumpFilterModulePaths = 0x0080,
  2077. MiniDumpWithProcessThreadData = 0x0100,
  2078. MiniDumpWithPrivateReadWriteMemory = 0x0200,
  2079. } MINIDUMP_TYPE;
  2080. //
  2081. // The minidump callback should modify the FieldsToWrite parameter to reflect
  2082. // what portions of the specified thread or module should be written to the
  2083. // file.
  2084. //
  2085. typedef
  2086. BOOL
  2087. (WINAPI * MINIDUMP_CALLBACK_ROUTINE) (
  2088. IN PVOID CallbackParam,
  2089. IN CONST PMINIDUMP_CALLBACK_INPUT CallbackInput,
  2090. IN OUT PMINIDUMP_CALLBACK_OUTPUT CallbackOutput
  2091. );
  2092. typedef struct _MINIDUMP_CALLBACK_INFORMATION {
  2093. MINIDUMP_CALLBACK_ROUTINE CallbackRoutine;
  2094. PVOID CallbackParam;
  2095. } MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION;
  2096. //++
  2097. //
  2098. // PVOID
  2099. // RVA_TO_ADDR(
  2100. // PVOID Mapping,
  2101. // ULONG Rva
  2102. // )
  2103. //
  2104. // Routine Description:
  2105. //
  2106. // Map an RVA that is contained within a mapped file to it's associated
  2107. // flat address.
  2108. //
  2109. // Arguments:
  2110. //
  2111. // Mapping - Base address of mapped file containing the RVA.
  2112. //
  2113. // Rva - An Rva to fixup.
  2114. //
  2115. // Return Values:
  2116. //
  2117. // A pointer to the desired data.
  2118. //
  2119. //--
  2120. #define RVA_TO_ADDR(Mapping,Rva) ((PVOID)(((ULONG_PTR) (Mapping)) + (Rva)))
  2121. BOOL
  2122. WINAPI
  2123. MiniDumpWriteDump(
  2124. IN HANDLE hProcess,
  2125. IN DWORD ProcessId,
  2126. IN HANDLE hFile,
  2127. IN MINIDUMP_TYPE DumpType,
  2128. IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL
  2129. IN CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL
  2130. IN CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL
  2131. );
  2132. BOOL
  2133. WINAPI
  2134. MiniDumpReadDumpStream(
  2135. IN PVOID BaseOfDump,
  2136. IN ULONG StreamNumber,
  2137. OUT PMINIDUMP_DIRECTORY * Dir, OPTIONAL
  2138. OUT PVOID * StreamPointer, OPTIONAL
  2139. OUT ULONG * StreamSize OPTIONAL
  2140. );
  2141. #include <poppack.h>
  2142. #ifdef __cplusplus
  2143. }
  2144. #endif
  2145. #endif // _DBGHELP_