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.

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