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.

2120 lines
56 KiB

  1. /*++ BUILD Version: 0001 Increment this if a change has global effects
  2. Copyright (c) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. imagehlp.x
  5. Abstract:
  6. Used with hextract.exe, build imagehlp.h and dbghelp.h.
  7. As imagehlp.h, this module defines the prototypes and constants
  8. required for the image help routines.
  9. As dbghelp.h, it also contains debugging support routines that
  10. are redistributable.
  11. Revision History:
  12. --*/
  13. // HEXTRACT: begin_imagehlp begin_dbghelp hide_line
  14. // As a general principal always call the 64 bit version
  15. // of every API, if a choice exists. The 64 bit version
  16. // works great on 32 bit platforms, and is forward
  17. // compatible to 64 bit platforms.
  18. #ifdef _WIN64
  19. #ifndef _IMAGEHLP64
  20. #define _IMAGEHLP64
  21. #endif
  22. #endif
  23. // HEXTRACT: end_dbghelp hide_line
  24. #ifndef WINTRUST_H
  25. #include <wintrust.h>
  26. #endif
  27. // HEXTRACT: begin_dbghelp hide_line
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #ifdef _IMAGEHLP_SOURCE_
  32. #define IMAGEAPI __stdcall
  33. #define DBHLP_DEPRECIATED
  34. #else
  35. #define IMAGEAPI DECLSPEC_IMPORT __stdcall
  36. #define DBHLP_DEPRECIATED DECLSPEC_DEPRECATED
  37. #endif
  38. #define DBHLPAPI IMAGEAPI
  39. #define IMAGE_SEPARATION (64*1024)
  40. typedef struct _LOADED_IMAGE {
  41. PSTR ModuleName;
  42. HANDLE hFile;
  43. PUCHAR MappedAddress;
  44. #ifdef _IMAGEHLP64
  45. PIMAGE_NT_HEADERS64 FileHeader;
  46. #else
  47. PIMAGE_NT_HEADERS32 FileHeader;
  48. #endif
  49. PIMAGE_SECTION_HEADER LastRvaSection;
  50. ULONG NumberOfSections;
  51. PIMAGE_SECTION_HEADER Sections;
  52. ULONG Characteristics;
  53. BOOLEAN fSystemImage;
  54. BOOLEAN fDOSImage;
  55. LIST_ENTRY Links;
  56. ULONG SizeOfImage;
  57. } LOADED_IMAGE, *PLOADED_IMAGE;
  58. // HEXTRACT: end_dbghelp hide_line
  59. BOOL
  60. IMAGEAPI
  61. BindImage(
  62. IN PSTR ImageName,
  63. IN PSTR DllPath,
  64. IN PSTR SymbolPath
  65. );
  66. typedef enum _IMAGEHLP_STATUS_REASON {
  67. BindOutOfMemory,
  68. BindRvaToVaFailed,
  69. BindNoRoomInImage,
  70. BindImportModuleFailed,
  71. BindImportProcedureFailed,
  72. BindImportModule,
  73. BindImportProcedure,
  74. BindForwarder,
  75. BindForwarderNOT,
  76. BindImageModified,
  77. BindExpandFileHeaders,
  78. BindImageComplete,
  79. BindMismatchedSymbols,
  80. BindSymbolsNotUpdated
  81. } IMAGEHLP_STATUS_REASON;
  82. typedef
  83. BOOL
  84. (__stdcall *PIMAGEHLP_STATUS_ROUTINE)(
  85. IMAGEHLP_STATUS_REASON Reason,
  86. PSTR ImageName,
  87. PSTR DllName,
  88. ULONG_PTR Va,
  89. ULONG_PTR Parameter
  90. );
  91. BOOL
  92. IMAGEAPI
  93. BindImageEx(
  94. IN DWORD Flags,
  95. IN PSTR ImageName,
  96. IN PSTR DllPath,
  97. IN PSTR SymbolPath,
  98. IN PIMAGEHLP_STATUS_ROUTINE StatusRoutine
  99. );
  100. #define BIND_NO_BOUND_IMPORTS 0x00000001
  101. #define BIND_NO_UPDATE 0x00000002
  102. #define BIND_ALL_IMAGES 0x00000004
  103. #define BIND_CACHE_IMPORT_DLLS 0x00000008 // Cache dll's across
  104. // calls to BindImageEx
  105. // (same as NT 3.1->NT 4.0)
  106. BOOL
  107. IMAGEAPI
  108. ReBaseImage(
  109. IN PSTR CurrentImageName,
  110. IN PSTR SymbolPath,
  111. IN BOOL fReBase, // TRUE if actually rebasing, false if only summing
  112. IN BOOL fRebaseSysfileOk, // TRUE is system images s/b rebased
  113. IN BOOL fGoingDown, // TRUE if the image s/b rebased below the given base
  114. IN ULONG CheckImageSize, // Max size allowed (0 if don't care)
  115. OUT ULONG *OldImageSize, // Returned from the header
  116. OUT ULONG_PTR *OldImageBase, // Returned from the header
  117. OUT ULONG *NewImageSize, // Image size rounded to next separation boundary
  118. IN OUT ULONG_PTR *NewImageBase, // (in) Desired new address.
  119. // (out) Next address (actual if going down)
  120. IN ULONG TimeStamp // new timestamp for image, if non-zero
  121. );
  122. BOOL
  123. IMAGEAPI
  124. ReBaseImage64(
  125. IN PSTR CurrentImageName,
  126. IN PSTR SymbolPath,
  127. IN BOOL fReBase, // TRUE if actually rebasing, false if only summing
  128. IN BOOL fRebaseSysfileOk, // TRUE is system images s/b rebased
  129. IN BOOL fGoingDown, // TRUE if the image s/b rebased below the given base
  130. IN ULONG CheckImageSize, // Max size allowed (0 if don't care)
  131. OUT ULONG *OldImageSize, // Returned from the header
  132. OUT ULONG64 *OldImageBase, // Returned from the header
  133. OUT ULONG *NewImageSize, // Image size rounded to next separation boundary
  134. IN OUT ULONG64 *NewImageBase, // (in) Desired new address.
  135. // (out) Next address (actual if going down)
  136. IN ULONG TimeStamp // new timestamp for image, if non-zero
  137. );
  138. #define MAX_SYM_NAME 2000
  139. //
  140. // Define checksum return codes.
  141. //
  142. #define CHECKSUM_SUCCESS 0
  143. #define CHECKSUM_OPEN_FAILURE 1
  144. #define CHECKSUM_MAP_FAILURE 2
  145. #define CHECKSUM_MAPVIEW_FAILURE 3
  146. #define CHECKSUM_UNICODE_FAILURE 4
  147. // Define Splitsym flags.
  148. #define SPLITSYM_REMOVE_PRIVATE 0x00000001 // Remove CV types/symbols and Fixup debug
  149. // Used for creating .dbg files that ship
  150. // as part of the product.
  151. #define SPLITSYM_EXTRACT_ALL 0x00000002 // Extract all debug info from image.
  152. // Normally, FPO is left in the image
  153. // to allow stack traces through the code.
  154. // Using this switch is similar to linking
  155. // with -debug:none except the .dbg file
  156. // exists...
  157. #define SPLITSYM_SYMBOLPATH_IS_SRC 0x00000004 // The SymbolFilePath contains an alternate
  158. // path to locate the pdb.
  159. //
  160. // Define checksum function prototypes.
  161. //
  162. PIMAGE_NT_HEADERS
  163. IMAGEAPI
  164. CheckSumMappedFile (
  165. PVOID BaseAddress,
  166. DWORD FileLength,
  167. PDWORD HeaderSum,
  168. PDWORD CheckSum
  169. );
  170. DWORD
  171. IMAGEAPI
  172. MapFileAndCheckSumA (
  173. PSTR Filename,
  174. PDWORD HeaderSum,
  175. PDWORD CheckSum
  176. );
  177. DWORD
  178. IMAGEAPI
  179. MapFileAndCheckSumW (
  180. PWSTR Filename,
  181. PDWORD HeaderSum,
  182. PDWORD CheckSum
  183. );
  184. #ifdef UNICODE
  185. #define MapFileAndCheckSum MapFileAndCheckSumW
  186. #else
  187. #define MapFileAndCheckSum MapFileAndCheckSumA
  188. #endif // !UNICODE
  189. BOOL
  190. IMAGEAPI
  191. GetImageConfigInformation(
  192. PLOADED_IMAGE LoadedImage,
  193. PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigInformation
  194. );
  195. DWORD
  196. IMAGEAPI
  197. GetImageUnusedHeaderBytes(
  198. PLOADED_IMAGE LoadedImage,
  199. PDWORD SizeUnusedHeaderBytes
  200. );
  201. BOOL
  202. IMAGEAPI
  203. SetImageConfigInformation(
  204. PLOADED_IMAGE LoadedImage,
  205. PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigInformation
  206. );
  207. // Image Integrity API's
  208. #define CERT_PE_IMAGE_DIGEST_DEBUG_INFO 0x01
  209. #define CERT_PE_IMAGE_DIGEST_RESOURCES 0x02
  210. #define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO 0x04
  211. #define CERT_PE_IMAGE_DIGEST_NON_PE_INFO 0x08 // include data outside the PE image
  212. #define CERT_SECTION_TYPE_ANY 0xFF // Any Certificate type
  213. typedef PVOID DIGEST_HANDLE;
  214. typedef BOOL (WINAPI *DIGEST_FUNCTION) (DIGEST_HANDLE refdata, PBYTE pData, DWORD dwLength);
  215. BOOL
  216. IMAGEAPI
  217. ImageGetDigestStream(
  218. IN HANDLE FileHandle,
  219. IN DWORD DigestLevel,
  220. IN DIGEST_FUNCTION DigestFunction,
  221. IN DIGEST_HANDLE DigestHandle
  222. );
  223. BOOL
  224. IMAGEAPI
  225. ImageAddCertificate(
  226. IN HANDLE FileHandle,
  227. IN LPWIN_CERTIFICATE Certificate,
  228. OUT PDWORD Index
  229. );
  230. BOOL
  231. IMAGEAPI
  232. ImageRemoveCertificate(
  233. IN HANDLE FileHandle,
  234. IN DWORD Index
  235. );
  236. BOOL
  237. IMAGEAPI
  238. ImageEnumerateCertificates(
  239. IN HANDLE FileHandle,
  240. IN WORD TypeFilter,
  241. OUT PDWORD CertificateCount,
  242. IN OUT PDWORD Indices OPTIONAL,
  243. IN OUT DWORD IndexCount OPTIONAL
  244. );
  245. BOOL
  246. IMAGEAPI
  247. ImageGetCertificateData(
  248. IN HANDLE FileHandle,
  249. IN DWORD CertificateIndex,
  250. OUT LPWIN_CERTIFICATE Certificate,
  251. IN OUT PDWORD RequiredLength
  252. );
  253. BOOL
  254. IMAGEAPI
  255. ImageGetCertificateHeader(
  256. IN HANDLE FileHandle,
  257. IN DWORD CertificateIndex,
  258. IN OUT LPWIN_CERTIFICATE Certificateheader
  259. );
  260. PLOADED_IMAGE
  261. IMAGEAPI
  262. ImageLoad(
  263. PSTR DllName,
  264. PSTR DllPath
  265. );
  266. BOOL
  267. IMAGEAPI
  268. ImageUnload(
  269. PLOADED_IMAGE LoadedImage
  270. );
  271. BOOL
  272. IMAGEAPI
  273. MapAndLoad(
  274. PSTR ImageName,
  275. PSTR DllPath,
  276. PLOADED_IMAGE LoadedImage,
  277. BOOL DotDll,
  278. BOOL ReadOnly
  279. );
  280. BOOL
  281. IMAGEAPI
  282. UnMapAndLoad(
  283. PLOADED_IMAGE LoadedImage
  284. );
  285. BOOL
  286. IMAGEAPI
  287. TouchFileTimes (
  288. HANDLE FileHandle,
  289. PSYSTEMTIME pSystemTime
  290. );
  291. BOOL
  292. IMAGEAPI
  293. SplitSymbols (
  294. PSTR ImageName,
  295. PSTR SymbolsPath,
  296. PSTR SymbolFilePath,
  297. DWORD Flags // Combination of flags above
  298. );
  299. BOOL
  300. IMAGEAPI
  301. UpdateDebugInfoFile(
  302. PSTR ImageFileName,
  303. PSTR SymbolPath,
  304. PSTR DebugFilePath,
  305. PIMAGE_NT_HEADERS32 NtHeaders
  306. );
  307. BOOL
  308. IMAGEAPI
  309. UpdateDebugInfoFileEx(
  310. PSTR ImageFileName,
  311. PSTR SymbolPath,
  312. PSTR DebugFilePath,
  313. PIMAGE_NT_HEADERS32 NtHeaders,
  314. DWORD OldChecksum
  315. );
  316. // HEXTRACT: begin_dbghelp hide_line
  317. HANDLE
  318. IMAGEAPI
  319. FindDebugInfoFile (
  320. PSTR FileName,
  321. PSTR SymbolPath,
  322. PSTR DebugFilePath
  323. );
  324. typedef BOOL
  325. (CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(
  326. HANDLE FileHandle,
  327. PSTR FileName,
  328. PVOID CallerData
  329. );
  330. HANDLE
  331. IMAGEAPI
  332. FindDebugInfoFileEx (
  333. PSTR FileName,
  334. PSTR SymbolPath,
  335. PSTR DebugFilePath,
  336. PFIND_DEBUG_FILE_CALLBACK Callback,
  337. PVOID CallerData
  338. );
  339. typedef BOOL
  340. (CALLBACK *PFINDFILEINPATHCALLBACK)(
  341. PSTR filename,
  342. PVOID context
  343. );
  344. BOOL
  345. IMAGEAPI
  346. SymFindFileInPath(
  347. HANDLE hprocess,
  348. LPSTR SearchPath,
  349. LPSTR FileName,
  350. PVOID id,
  351. DWORD two,
  352. DWORD three,
  353. DWORD flags,
  354. LPSTR FilePath,
  355. PFINDFILEINPATHCALLBACK callback,
  356. PVOID context
  357. );
  358. HANDLE
  359. IMAGEAPI
  360. FindExecutableImage(
  361. PSTR FileName,
  362. PSTR SymbolPath,
  363. PSTR ImageFilePath
  364. );
  365. typedef BOOL
  366. (CALLBACK *PFIND_EXE_FILE_CALLBACK)(
  367. HANDLE FileHandle,
  368. PSTR FileName,
  369. PVOID CallerData
  370. );
  371. HANDLE
  372. IMAGEAPI
  373. FindExecutableImageEx(
  374. PSTR FileName,
  375. PSTR SymbolPath,
  376. PSTR ImageFilePath,
  377. PFIND_EXE_FILE_CALLBACK Callback,
  378. PVOID CallerData
  379. );
  380. PIMAGE_NT_HEADERS
  381. IMAGEAPI
  382. ImageNtHeader (
  383. IN PVOID Base
  384. );
  385. PVOID
  386. IMAGEAPI
  387. ImageDirectoryEntryToDataEx (
  388. IN PVOID Base,
  389. IN BOOLEAN MappedAsImage,
  390. IN USHORT DirectoryEntry,
  391. OUT PULONG Size,
  392. OUT PIMAGE_SECTION_HEADER *FoundHeader OPTIONAL
  393. );
  394. PVOID
  395. IMAGEAPI
  396. ImageDirectoryEntryToData (
  397. IN PVOID Base,
  398. IN BOOLEAN MappedAsImage,
  399. IN USHORT DirectoryEntry,
  400. OUT PULONG Size
  401. );
  402. PIMAGE_SECTION_HEADER
  403. IMAGEAPI
  404. ImageRvaToSection(
  405. IN PIMAGE_NT_HEADERS NtHeaders,
  406. IN PVOID Base,
  407. IN ULONG Rva
  408. );
  409. PVOID
  410. IMAGEAPI
  411. ImageRvaToVa(
  412. IN PIMAGE_NT_HEADERS NtHeaders,
  413. IN PVOID Base,
  414. IN ULONG Rva,
  415. IN OUT PIMAGE_SECTION_HEADER *LastRvaSection
  416. );
  417. // Symbol server exports
  418. typedef BOOL (*PSYMBOLSERVERPROC)(LPCSTR, LPCSTR, PVOID, DWORD, DWORD, LPSTR);
  419. typedef BOOL (*PSYMBOLSERVEROPENPROC)(VOID);
  420. typedef BOOL (*PSYMBOLSERVERCLOSEPROC)(VOID);
  421. typedef BOOL (*PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
  422. typedef BOOL (CALLBACK *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
  423. typedef UINT_PTR (*PSYMBOLSERVERGETOPTIONSPROC)();
  424. #define SSRVOPT_CALLBACK 0x01
  425. #define SSRVOPT_DWORD 0x02
  426. #define SSRVOPT_DWORDPTR 0x04
  427. #define SSRVOPT_GUIDPTR 0x08
  428. #define SSRVOPT_OLDGUIDPTR 0x10
  429. #define SSRVOPT_UNATTENDED 0x20
  430. #define SSRVOPT_RESET ((ULONG_PTR)-1)
  431. #define SSRVACTION_TRACE 1
  432. #ifndef _WIN64
  433. // This api won't be ported to Win64 - Fix your code.
  434. typedef struct _IMAGE_DEBUG_INFORMATION {
  435. LIST_ENTRY List;
  436. DWORD ReservedSize;
  437. PVOID ReservedMappedBase;
  438. USHORT ReservedMachine;
  439. USHORT ReservedCharacteristics;
  440. DWORD ReservedCheckSum;
  441. DWORD ImageBase;
  442. DWORD SizeOfImage;
  443. DWORD ReservedNumberOfSections;
  444. PIMAGE_SECTION_HEADER ReservedSections;
  445. DWORD ReservedExportedNamesSize;
  446. PSTR ReservedExportedNames;
  447. DWORD ReservedNumberOfFunctionTableEntries;
  448. PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries;
  449. DWORD ReservedLowestFunctionStartingAddress;
  450. DWORD ReservedHighestFunctionEndingAddress;
  451. DWORD ReservedNumberOfFpoTableEntries;
  452. PFPO_DATA ReservedFpoTableEntries;
  453. DWORD SizeOfCoffSymbols;
  454. PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
  455. DWORD ReservedSizeOfCodeViewSymbols;
  456. PVOID ReservedCodeViewSymbols;
  457. PSTR ImageFilePath;
  458. PSTR ImageFileName;
  459. PSTR ReservedDebugFilePath;
  460. DWORD ReservedTimeDateStamp;
  461. BOOL ReservedRomImage;
  462. PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory;
  463. DWORD ReservedNumberOfDebugDirectories;
  464. DWORD ReservedOriginalFunctionTableBaseAddress;
  465. DWORD Reserved[ 2 ];
  466. } IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;
  467. PIMAGE_DEBUG_INFORMATION
  468. IMAGEAPI
  469. MapDebugInformation(
  470. HANDLE FileHandle,
  471. PSTR FileName,
  472. PSTR SymbolPath,
  473. DWORD ImageBase
  474. );
  475. BOOL
  476. IMAGEAPI
  477. UnmapDebugInformation(
  478. PIMAGE_DEBUG_INFORMATION DebugInfo
  479. );
  480. #endif
  481. BOOL
  482. IMAGEAPI
  483. SearchTreeForFile(
  484. PSTR RootPath,
  485. PSTR InputPathName,
  486. PSTR OutputPathBuffer
  487. );
  488. BOOL
  489. IMAGEAPI
  490. MakeSureDirectoryPathExists(
  491. PCSTR DirPath
  492. );
  493. //
  494. // UnDecorateSymbolName Flags
  495. //
  496. #define UNDNAME_COMPLETE (0x0000) // Enable full undecoration
  497. #define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) // Remove leading underscores from MS extended keywords
  498. #define UNDNAME_NO_MS_KEYWORDS (0x0002) // Disable expansion of MS extended keywords
  499. #define UNDNAME_NO_FUNCTION_RETURNS (0x0004) // Disable expansion of return type for primary declaration
  500. #define UNDNAME_NO_ALLOCATION_MODEL (0x0008) // Disable expansion of the declaration model
  501. #define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) // Disable expansion of the declaration language specifier
  502. #define UNDNAME_NO_MS_THISTYPE (0x0020) // NYI Disable expansion of MS keywords on the 'this' type for primary declaration
  503. #define UNDNAME_NO_CV_THISTYPE (0x0040) // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration
  504. #define UNDNAME_NO_THISTYPE (0x0060) // Disable all modifiers on the 'this' type
  505. #define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) // Disable expansion of access specifiers for members
  506. #define UNDNAME_NO_THROW_SIGNATURES (0x0100) // Disable expansion of 'throw-signatures' for functions and pointers to functions
  507. #define UNDNAME_NO_MEMBER_TYPE (0x0200) // Disable expansion of 'static' or 'virtual'ness of members
  508. #define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) // Disable expansion of MS model for UDT returns
  509. #define UNDNAME_32_BIT_DECODE (0x0800) // Undecorate 32-bit decorated names
  510. #define UNDNAME_NAME_ONLY (0x1000) // Crack only the name for primary declaration;
  511. // return just [scope::]name. Does expand template params
  512. #define UNDNAME_NO_ARGUMENTS (0x2000) // Don't undecorate arguments to function
  513. #define UNDNAME_NO_SPECIAL_SYMS (0x4000) // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc)
  514. DWORD
  515. IMAGEAPI
  516. WINAPI
  517. UnDecorateSymbolName(
  518. PCSTR DecoratedName, // Name to undecorate
  519. PSTR UnDecoratedName, // If NULL, it will be allocated
  520. DWORD UndecoratedLength, // The maximym length
  521. DWORD Flags // See above.
  522. );
  523. //
  524. // these values are used for synthesized file types
  525. // that can be passed in as image headers instead of
  526. // the standard ones from ntimage.h
  527. //
  528. #define DBHHEADER_DEBUGDIRS 0x1
  529. typedef struct _DBGHELP_MODLOAD_DATA {
  530. DWORD ssize; // size of this struct
  531. DWORD ssig; // signature identifying the passed data
  532. PVOID data; // pointer to passed data
  533. DWORD size; // size of passed data
  534. DWORD flags; // options
  535. } MODLOAD_DATA, *PMODLOAD_DATA;
  536. //
  537. // StackWalking API
  538. //
  539. typedef enum {
  540. AddrMode1616,
  541. AddrMode1632,
  542. AddrModeReal,
  543. AddrModeFlat
  544. } ADDRESS_MODE;
  545. typedef struct _tagADDRESS64 {
  546. DWORD64 Offset;
  547. WORD Segment;
  548. ADDRESS_MODE Mode;
  549. } ADDRESS64, *LPADDRESS64;
  550. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  551. #define ADDRESS ADDRESS64
  552. #define LPADDRESS LPADDRESS64
  553. #else
  554. typedef struct _tagADDRESS {
  555. DWORD Offset;
  556. WORD Segment;
  557. ADDRESS_MODE Mode;
  558. } ADDRESS, *LPADDRESS;
  559. __inline
  560. void
  561. Address32To64(
  562. LPADDRESS a32,
  563. LPADDRESS64 a64
  564. )
  565. {
  566. a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset;
  567. a64->Segment = a32->Segment;
  568. a64->Mode = a32->Mode;
  569. }
  570. __inline
  571. void
  572. Address64To32(
  573. LPADDRESS64 a64,
  574. LPADDRESS a32
  575. )
  576. {
  577. a32->Offset = (ULONG)a64->Offset;
  578. a32->Segment = a64->Segment;
  579. a32->Mode = a64->Mode;
  580. }
  581. #endif
  582. //
  583. // This structure is included in the STACKFRAME structure,
  584. // and is used to trace through usermode callbacks in a thread's
  585. // kernel stack. The values must be copied by the kernel debugger
  586. // from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets.
  587. //
  588. //
  589. // New KDHELP structure for 64 bit system support.
  590. // This structure is preferred in new code.
  591. //
  592. typedef struct _KDHELP64 {
  593. //
  594. // address of kernel thread object, as provided in the
  595. // WAIT_STATE_CHANGE packet.
  596. //
  597. DWORD64 Thread;
  598. //
  599. // offset in thread object to pointer to the current callback frame
  600. // in kernel stack.
  601. //
  602. DWORD ThCallbackStack;
  603. //
  604. // offset in thread object to pointer to the current callback backing
  605. // store frame in kernel stack.
  606. //
  607. DWORD ThCallbackBStore;
  608. //
  609. // offsets to values in frame:
  610. //
  611. // address of next callback frame
  612. DWORD NextCallback;
  613. // address of saved frame pointer (if applicable)
  614. DWORD FramePointer;
  615. //
  616. // Address of the kernel function that calls out to user mode
  617. //
  618. DWORD64 KiCallUserMode;
  619. //
  620. // Address of the user mode dispatcher function
  621. //
  622. DWORD64 KeUserCallbackDispatcher;
  623. //
  624. // Lowest kernel mode address
  625. //
  626. DWORD64 SystemRangeStart;
  627. DWORD64 Reserved[8];
  628. } KDHELP64, *PKDHELP64;
  629. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  630. #define KDHELP KDHELP64
  631. #define PKDHELP PKDHELP64
  632. #else
  633. typedef struct _KDHELP {
  634. //
  635. // address of kernel thread object, as provided in the
  636. // WAIT_STATE_CHANGE packet.
  637. //
  638. DWORD Thread;
  639. //
  640. // offset in thread object to pointer to the current callback frame
  641. // in kernel stack.
  642. //
  643. DWORD ThCallbackStack;
  644. //
  645. // offsets to values in frame:
  646. //
  647. // address of next callback frame
  648. DWORD NextCallback;
  649. // address of saved frame pointer (if applicable)
  650. DWORD FramePointer;
  651. //
  652. // Address of the kernel function that calls out to user mode
  653. //
  654. DWORD KiCallUserMode;
  655. //
  656. // Address of the user mode dispatcher function
  657. //
  658. DWORD KeUserCallbackDispatcher;
  659. //
  660. // Lowest kernel mode address
  661. //
  662. DWORD SystemRangeStart;
  663. //
  664. // offset in thread object to pointer to the current callback backing
  665. // store frame in kernel stack.
  666. //
  667. DWORD ThCallbackBStore;
  668. DWORD Reserved[8];
  669. } KDHELP, *PKDHELP;
  670. __inline
  671. void
  672. KdHelp32To64(
  673. PKDHELP p32,
  674. PKDHELP64 p64
  675. )
  676. {
  677. p64->Thread = p32->Thread;
  678. p64->ThCallbackStack = p32->ThCallbackStack;
  679. p64->NextCallback = p32->NextCallback;
  680. p64->FramePointer = p32->FramePointer;
  681. p64->KiCallUserMode = p32->KiCallUserMode;
  682. p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher;
  683. p64->SystemRangeStart = p32->SystemRangeStart;
  684. }
  685. #endif
  686. typedef struct _tagSTACKFRAME64 {
  687. ADDRESS64 AddrPC; // program counter
  688. ADDRESS64 AddrReturn; // return address
  689. ADDRESS64 AddrFrame; // frame pointer
  690. ADDRESS64 AddrStack; // stack pointer
  691. ADDRESS64 AddrBStore; // backing store pointer
  692. PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
  693. DWORD64 Params[4]; // possible arguments to the function
  694. BOOL Far; // WOW far call
  695. BOOL Virtual; // is this a virtual frame?
  696. DWORD64 Reserved[3];
  697. KDHELP64 KdHelp;
  698. } STACKFRAME64, *LPSTACKFRAME64;
  699. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  700. #define STACKFRAME STACKFRAME64
  701. #define LPSTACKFRAME LPSTACKFRAME64
  702. #else
  703. typedef struct _tagSTACKFRAME {
  704. ADDRESS AddrPC; // program counter
  705. ADDRESS AddrReturn; // return address
  706. ADDRESS AddrFrame; // frame pointer
  707. ADDRESS AddrStack; // stack pointer
  708. PVOID FuncTableEntry; // pointer to pdata/fpo or NULL
  709. DWORD Params[4]; // possible arguments to the function
  710. BOOL Far; // WOW far call
  711. BOOL Virtual; // is this a virtual frame?
  712. DWORD Reserved[3];
  713. KDHELP KdHelp;
  714. ADDRESS AddrBStore; // backing store pointer
  715. } STACKFRAME, *LPSTACKFRAME;
  716. #endif
  717. typedef
  718. BOOL
  719. (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
  720. HANDLE hProcess,
  721. DWORD64 qwBaseAddress,
  722. PVOID lpBuffer,
  723. DWORD nSize,
  724. LPDWORD lpNumberOfBytesRead
  725. );
  726. typedef
  727. PVOID
  728. (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
  729. HANDLE hProcess,
  730. DWORD64 AddrBase
  731. );
  732. typedef
  733. DWORD64
  734. (__stdcall *PGET_MODULE_BASE_ROUTINE64)(
  735. HANDLE hProcess,
  736. DWORD64 Address
  737. );
  738. typedef
  739. DWORD64
  740. (__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
  741. HANDLE hProcess,
  742. HANDLE hThread,
  743. LPADDRESS64 lpaddr
  744. );
  745. BOOL
  746. IMAGEAPI
  747. StackWalk64(
  748. DWORD MachineType,
  749. HANDLE hProcess,
  750. HANDLE hThread,
  751. LPSTACKFRAME64 StackFrame,
  752. PVOID ContextRecord,
  753. PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
  754. PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
  755. PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
  756. PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress
  757. );
  758. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  759. #define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64
  760. #define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64
  761. #define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64
  762. #define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64
  763. #define StackWalk StackWalk64
  764. #else
  765. typedef
  766. BOOL
  767. (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)(
  768. HANDLE hProcess,
  769. DWORD lpBaseAddress,
  770. PVOID lpBuffer,
  771. DWORD nSize,
  772. PDWORD lpNumberOfBytesRead
  773. );
  774. typedef
  775. PVOID
  776. (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(
  777. HANDLE hProcess,
  778. DWORD AddrBase
  779. );
  780. typedef
  781. DWORD
  782. (__stdcall *PGET_MODULE_BASE_ROUTINE)(
  783. HANDLE hProcess,
  784. DWORD Address
  785. );
  786. typedef
  787. DWORD
  788. (__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(
  789. HANDLE hProcess,
  790. HANDLE hThread,
  791. LPADDRESS lpaddr
  792. );
  793. BOOL
  794. IMAGEAPI
  795. StackWalk(
  796. DWORD MachineType,
  797. HANDLE hProcess,
  798. HANDLE hThread,
  799. LPSTACKFRAME StackFrame,
  800. PVOID ContextRecord,
  801. PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
  802. PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
  803. PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
  804. PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
  805. );
  806. #endif
  807. #define API_VERSION_NUMBER 9
  808. typedef struct API_VERSION {
  809. USHORT MajorVersion;
  810. USHORT MinorVersion;
  811. USHORT Revision;
  812. USHORT Reserved;
  813. } API_VERSION, *LPAPI_VERSION;
  814. LPAPI_VERSION
  815. IMAGEAPI
  816. ImagehlpApiVersion(
  817. VOID
  818. );
  819. LPAPI_VERSION
  820. IMAGEAPI
  821. ImagehlpApiVersionEx(
  822. LPAPI_VERSION AppVersion
  823. );
  824. DWORD
  825. IMAGEAPI
  826. GetTimestampForLoadedLibrary(
  827. HMODULE Module
  828. );
  829. //
  830. // typedefs for function pointers
  831. //
  832. typedef BOOL
  833. (CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(
  834. PSTR ModuleName,
  835. DWORD64 BaseOfDll,
  836. PVOID UserContext
  837. );
  838. typedef BOOL
  839. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(
  840. PSTR SymbolName,
  841. DWORD64 SymbolAddress,
  842. ULONG SymbolSize,
  843. PVOID UserContext
  844. );
  845. typedef BOOL
  846. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(
  847. PWSTR SymbolName,
  848. DWORD64 SymbolAddress,
  849. ULONG SymbolSize,
  850. PVOID UserContext
  851. );
  852. typedef BOOL
  853. (CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(
  854. PSTR ModuleName,
  855. DWORD64 ModuleBase,
  856. ULONG ModuleSize,
  857. PVOID UserContext
  858. );
  859. typedef BOOL
  860. (CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(
  861. HANDLE hProcess,
  862. ULONG ActionCode,
  863. ULONG64 CallbackData,
  864. ULONG64 UserContext
  865. );
  866. typedef
  867. PVOID
  868. (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(
  869. HANDLE hProcess,
  870. DWORD AddrBase,
  871. PVOID UserContext
  872. );
  873. typedef
  874. PVOID
  875. (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(
  876. HANDLE hProcess,
  877. ULONG64 AddrBase,
  878. ULONG64 UserContext
  879. );
  880. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  881. #define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64
  882. #define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64
  883. #define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W
  884. #define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64
  885. #define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64
  886. #define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64
  887. #else
  888. typedef BOOL
  889. (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
  890. PSTR ModuleName,
  891. ULONG BaseOfDll,
  892. PVOID UserContext
  893. );
  894. typedef BOOL
  895. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
  896. PSTR SymbolName,
  897. ULONG SymbolAddress,
  898. ULONG SymbolSize,
  899. PVOID UserContext
  900. );
  901. typedef BOOL
  902. (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(
  903. PWSTR SymbolName,
  904. ULONG SymbolAddress,
  905. ULONG SymbolSize,
  906. PVOID UserContext
  907. );
  908. typedef BOOL
  909. (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
  910. PSTR ModuleName,
  911. ULONG ModuleBase,
  912. ULONG ModuleSize,
  913. PVOID UserContext
  914. );
  915. typedef BOOL
  916. (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
  917. HANDLE hProcess,
  918. ULONG ActionCode,
  919. PVOID CallbackData,
  920. PVOID UserContext
  921. );
  922. #endif
  923. //
  924. // symbol flags
  925. //
  926. #define SYMF_OMAP_GENERATED 0x00000001
  927. #define SYMF_OMAP_MODIFIED 0x00000002
  928. #ifndef _DBGHELP_USER_GENERATED_SYMBOLS_NOTSUPPORTED
  929. #define SYMF_USER_GENERATED 0x00000004
  930. #endif // !_DBGHELP_USER_GENERATED_SYMBOLS_NOTSUPPORTED
  931. #define SYMF_REGISTER 0x00000008
  932. #define SYMF_REGREL 0x00000010
  933. #define SYMF_FRAMEREL 0x00000020
  934. #define SYMF_PARAMETER 0x00000040
  935. #define SYMF_LOCAL 0x00000080
  936. #define SYMF_CONSTANT 0x00000100
  937. #define SYMF_EXPORT 0x00000200
  938. #define SYMF_FORWARDER 0x00000400
  939. #define SYMF_FUNCTION 0x00000800
  940. //
  941. // symbol type enumeration
  942. //
  943. typedef enum {
  944. SymNone = 0,
  945. SymCoff,
  946. SymCv,
  947. SymPdb,
  948. SymExport,
  949. SymDeferred,
  950. SymSym, // .sym file
  951. SymDia,
  952. NumSymTypes
  953. } SYM_TYPE;
  954. //
  955. // symbol data structure
  956. //
  957. typedef struct _IMAGEHLP_SYMBOL64 {
  958. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL64)
  959. DWORD64 Address; // virtual address including dll base address
  960. DWORD Size; // estimated size of symbol, can be zero
  961. DWORD Flags; // info about the symbols, see the SYMF defines
  962. DWORD MaxNameLength; // maximum size of symbol name in 'Name'
  963. CHAR Name[1]; // symbol name (null terminated string)
  964. } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
  965. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  966. #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
  967. #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
  968. #else
  969. typedef struct _IMAGEHLP_SYMBOL {
  970. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL)
  971. DWORD Address; // virtual address including dll base address
  972. DWORD Size; // estimated size of symbol, can be zero
  973. DWORD Flags; // info about the symbols, see the SYMF defines
  974. DWORD MaxNameLength; // maximum size of symbol name in 'Name'
  975. CHAR Name[1]; // symbol name (null terminated string)
  976. } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
  977. #endif
  978. //
  979. // module data structure
  980. //
  981. typedef struct _IMAGEHLP_MODULE64 {
  982. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
  983. DWORD64 BaseOfImage; // base load address of module
  984. DWORD ImageSize; // virtual size of the loaded module
  985. DWORD TimeDateStamp; // date/time stamp from pe header
  986. DWORD CheckSum; // checksum from the pe header
  987. DWORD NumSyms; // number of symbols in the symbol table
  988. SYM_TYPE SymType; // type of symbols loaded
  989. CHAR ModuleName[32]; // module name
  990. CHAR ImageName[256]; // image name
  991. CHAR LoadedImageName[256]; // symbol file name
  992. } IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
  993. typedef struct _IMAGEHLP_MODULE64W {
  994. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
  995. DWORD64 BaseOfImage; // base load address of module
  996. DWORD ImageSize; // virtual size of the loaded module
  997. DWORD TimeDateStamp; // date/time stamp from pe header
  998. DWORD CheckSum; // checksum from the pe header
  999. DWORD NumSyms; // number of symbols in the symbol table
  1000. SYM_TYPE SymType; // type of symbols loaded
  1001. WCHAR ModuleName[32]; // module name
  1002. WCHAR ImageName[256]; // image name
  1003. WCHAR LoadedImageName[256]; // symbol file name
  1004. } IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
  1005. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1006. #define IMAGEHLP_MODULE IMAGEHLP_MODULE64
  1007. #define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64
  1008. #define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64
  1009. #define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64
  1010. #else
  1011. typedef struct _IMAGEHLP_MODULE {
  1012. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE)
  1013. DWORD BaseOfImage; // base load address of module
  1014. DWORD ImageSize; // virtual size of the loaded module
  1015. DWORD TimeDateStamp; // date/time stamp from pe header
  1016. DWORD CheckSum; // checksum from the pe header
  1017. DWORD NumSyms; // number of symbols in the symbol table
  1018. SYM_TYPE SymType; // type of symbols loaded
  1019. CHAR ModuleName[32]; // module name
  1020. CHAR ImageName[256]; // image name
  1021. CHAR LoadedImageName[256]; // symbol file name
  1022. } IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
  1023. typedef struct _IMAGEHLP_MODULEW {
  1024. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE)
  1025. DWORD BaseOfImage; // base load address of module
  1026. DWORD ImageSize; // virtual size of the loaded module
  1027. DWORD TimeDateStamp; // date/time stamp from pe header
  1028. DWORD CheckSum; // checksum from the pe header
  1029. DWORD NumSyms; // number of symbols in the symbol table
  1030. SYM_TYPE SymType; // type of symbols loaded
  1031. WCHAR ModuleName[32]; // module name
  1032. WCHAR ImageName[256]; // image name
  1033. WCHAR LoadedImageName[256]; // symbol file name
  1034. } IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
  1035. #endif
  1036. //
  1037. // source file line data structure
  1038. //
  1039. typedef struct _IMAGEHLP_LINE64 {
  1040. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
  1041. PVOID Key; // internal
  1042. DWORD LineNumber; // line number in file
  1043. PCHAR FileName; // full filename
  1044. DWORD64 Address; // first instruction of line
  1045. } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
  1046. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1047. #define IMAGEHLP_LINE IMAGEHLP_LINE64
  1048. #define PIMAGEHLP_LINE PIMAGEHLP_LINE64
  1049. #else
  1050. typedef struct _IMAGEHLP_LINE {
  1051. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE)
  1052. PVOID Key; // internal
  1053. DWORD LineNumber; // line number in file
  1054. PCHAR FileName; // full filename
  1055. DWORD Address; // first instruction of line
  1056. } IMAGEHLP_LINE, *PIMAGEHLP_LINE;
  1057. #endif
  1058. //
  1059. // source file structure
  1060. //
  1061. typedef struct _SOURCEFILE {
  1062. DWORD64 ModBase; // base address of loaded module
  1063. PCHAR FileName; // full filename of source
  1064. } SOURCEFILE, *PSOURCEFILE;
  1065. //
  1066. // data structures used for registered symbol callbacks
  1067. //
  1068. #define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
  1069. #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
  1070. #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
  1071. #define CBA_SYMBOLS_UNLOADED 0x00000004
  1072. #define CBA_DUPLICATE_SYMBOL 0x00000005
  1073. #define CBA_READ_MEMORY 0x00000006
  1074. #define CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007
  1075. #define CBA_SET_OPTIONS 0x00000008
  1076. #define CBA_EVENT 0x00000010
  1077. #define CBA_DEBUG_INFO 0x10000000
  1078. typedef struct _IMAGEHLP_CBA_READ_MEMORY {
  1079. DWORD64 addr; // address to read from
  1080. PVOID buf; // buffer to read to
  1081. DWORD bytes; // amount of bytes to read
  1082. DWORD *bytesread; // pointer to store amount of bytes read
  1083. } IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;
  1084. enum {
  1085. sevInfo = 0,
  1086. sevProblem,
  1087. sevAttn,
  1088. sevFatal,
  1089. sevMax // unused
  1090. };
  1091. typedef struct _IMAGEHLP_CBA_EVENT {
  1092. DWORD severity; // values from sevInfo to sevFatal
  1093. DWORD code; // numerical code IDs the error
  1094. PCHAR desc; // may contain a text description of the error
  1095. PVOID object; // value dependant upon the error code
  1096. } IMAGEHLP_CBA_EVENT, *PIMAGEHLP_CBA_EVENT;
  1097. typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 {
  1098. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
  1099. DWORD64 BaseOfImage; // base load address of module
  1100. DWORD CheckSum; // checksum from the pe header
  1101. DWORD TimeDateStamp; // date/time stamp from pe header
  1102. CHAR FileName[MAX_PATH]; // symbols file or image name
  1103. BOOLEAN Reparse; // load failure reparse
  1104. } IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
  1105. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1106. #define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
  1107. #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
  1108. #else
  1109. typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
  1110. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD)
  1111. DWORD BaseOfImage; // base load address of module
  1112. DWORD CheckSum; // checksum from the pe header
  1113. DWORD TimeDateStamp; // date/time stamp from pe header
  1114. CHAR FileName[MAX_PATH]; // symbols file or image name
  1115. BOOLEAN Reparse; // load failure reparse
  1116. } IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
  1117. #endif
  1118. typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 {
  1119. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64)
  1120. DWORD NumberOfDups; // number of duplicates in the Symbol array
  1121. PIMAGEHLP_SYMBOL64 Symbol; // array of duplicate symbols
  1122. DWORD SelectedSymbol; // symbol selected (-1 to start)
  1123. } IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64;
  1124. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1125. #define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64
  1126. #define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64
  1127. #else
  1128. typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
  1129. DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL)
  1130. DWORD NumberOfDups; // number of duplicates in the Symbol array
  1131. PIMAGEHLP_SYMBOL Symbol; // array of duplicate symbols
  1132. DWORD SelectedSymbol; // symbol selected (-1 to start)
  1133. } IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
  1134. #endif
  1135. //
  1136. // options that are set/returned by SymSetOptions() & SymGetOptions()
  1137. // these are used as a mask
  1138. //
  1139. #define SYMOPT_CASE_INSENSITIVE 0x00000001
  1140. #define SYMOPT_UNDNAME 0x00000002
  1141. #define SYMOPT_DEFERRED_LOADS 0x00000004
  1142. #define SYMOPT_NO_CPP 0x00000008
  1143. #define SYMOPT_LOAD_LINES 0x00000010
  1144. #define SYMOPT_OMAP_FIND_NEAREST 0x00000020
  1145. #define SYMOPT_LOAD_ANYTHING 0x00000040
  1146. #define SYMOPT_IGNORE_CVREC 0x00000080
  1147. #define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100
  1148. #define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
  1149. #define SYMOPT_EXACT_SYMBOLS 0x00000400
  1150. #define SYMOPT_WILD_UNDERSCORE 0x00000800
  1151. #define SYMOPT_USE_DEFAULTS 0x00001000
  1152. #define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000
  1153. #define SYMOPT_DEBUG 0x80000000
  1154. DWORD
  1155. IMAGEAPI
  1156. SymSetOptions(
  1157. IN DWORD SymOptions
  1158. );
  1159. DWORD
  1160. IMAGEAPI
  1161. SymGetOptions(
  1162. VOID
  1163. );
  1164. BOOL
  1165. IMAGEAPI
  1166. SymCleanup(
  1167. IN HANDLE hProcess
  1168. );
  1169. BOOL
  1170. IMAGEAPI
  1171. SymMatchString(
  1172. IN LPSTR string,
  1173. IN LPSTR expression,
  1174. IN BOOL fCase
  1175. );
  1176. typedef BOOL
  1177. (CALLBACK *PSYM_ENUMSOURCFILES_CALLBACK)(
  1178. PSOURCEFILE pSourceFile,
  1179. PVOID UserContext
  1180. );
  1181. BOOL
  1182. IMAGEAPI
  1183. SymEnumSourceFiles(
  1184. IN HANDLE hProcess,
  1185. IN ULONG64 ModBase,
  1186. IN LPSTR Mask,
  1187. IN PSYM_ENUMSOURCFILES_CALLBACK cbSrcFiles,
  1188. IN PVOID UserContext
  1189. );
  1190. BOOL
  1191. IMAGEAPI
  1192. SymEnumerateModules64(
  1193. IN HANDLE hProcess,
  1194. IN PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback,
  1195. IN PVOID UserContext
  1196. );
  1197. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1198. #define SymEnumerateModules SymEnumerateModules64
  1199. #else
  1200. BOOL
  1201. IMAGEAPI
  1202. SymEnumerateModules(
  1203. IN HANDLE hProcess,
  1204. IN PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,
  1205. IN PVOID UserContext
  1206. );
  1207. #endif
  1208. BOOL
  1209. IMAGEAPI
  1210. SymEnumerateSymbols64(
  1211. IN HANDLE hProcess,
  1212. IN DWORD64 BaseOfDll,
  1213. IN PSYM_ENUMSYMBOLS_CALLBACK64 EnumSymbolsCallback,
  1214. IN PVOID UserContext
  1215. );
  1216. BOOL
  1217. IMAGEAPI
  1218. SymEnumerateSymbolsW64(
  1219. IN HANDLE hProcess,
  1220. IN DWORD64 BaseOfDll,
  1221. IN PSYM_ENUMSYMBOLS_CALLBACK64W EnumSymbolsCallback,
  1222. IN PVOID UserContext
  1223. );
  1224. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1225. #define SymEnumerateSymbols SymEnumerateSymbols64
  1226. #define SymEnumerateSymbolsW SymEnumerateSymbolsW64
  1227. #else
  1228. BOOL
  1229. IMAGEAPI
  1230. SymEnumerateSymbols(
  1231. IN HANDLE hProcess,
  1232. IN DWORD BaseOfDll,
  1233. IN PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback,
  1234. IN PVOID UserContext
  1235. );
  1236. BOOL
  1237. IMAGEAPI
  1238. SymEnumerateSymbolsW(
  1239. IN HANDLE hProcess,
  1240. IN DWORD BaseOfDll,
  1241. IN PSYM_ENUMSYMBOLS_CALLBACKW EnumSymbolsCallback,
  1242. IN PVOID UserContext
  1243. );
  1244. #endif
  1245. BOOL
  1246. IMAGEAPI
  1247. EnumerateLoadedModules64(
  1248. IN HANDLE hProcess,
  1249. IN PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback,
  1250. IN PVOID UserContext
  1251. );
  1252. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1253. #define EnumerateLoadedModules EnumerateLoadedModules64
  1254. #else
  1255. BOOL
  1256. IMAGEAPI
  1257. EnumerateLoadedModules(
  1258. IN HANDLE hProcess,
  1259. IN PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,
  1260. IN PVOID UserContext
  1261. );
  1262. #endif
  1263. PVOID
  1264. IMAGEAPI
  1265. SymFunctionTableAccess64(
  1266. HANDLE hProcess,
  1267. DWORD64 AddrBase
  1268. );
  1269. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1270. #define SymFunctionTableAccess SymFunctionTableAccess64
  1271. #else
  1272. PVOID
  1273. IMAGEAPI
  1274. SymFunctionTableAccess(
  1275. HANDLE hProcess,
  1276. DWORD AddrBase
  1277. );
  1278. #endif
  1279. BOOL
  1280. IMAGEAPI
  1281. SymGetModuleInfo64(
  1282. IN HANDLE hProcess,
  1283. IN DWORD64 qwAddr,
  1284. OUT PIMAGEHLP_MODULE64 ModuleInfo
  1285. );
  1286. BOOL
  1287. IMAGEAPI
  1288. SymGetModuleInfoW64(
  1289. IN HANDLE hProcess,
  1290. IN DWORD64 qwAddr,
  1291. OUT PIMAGEHLP_MODULEW64 ModuleInfo
  1292. );
  1293. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1294. #define SymGetModuleInfo SymGetModuleInfo64
  1295. #define SymGetModuleInfoW SymGetModuleInfoW64
  1296. #else
  1297. BOOL
  1298. IMAGEAPI
  1299. SymGetModuleInfo(
  1300. IN HANDLE hProcess,
  1301. IN DWORD dwAddr,
  1302. OUT PIMAGEHLP_MODULE ModuleInfo
  1303. );
  1304. BOOL
  1305. IMAGEAPI
  1306. SymGetModuleInfoW(
  1307. IN HANDLE hProcess,
  1308. IN DWORD dwAddr,
  1309. OUT PIMAGEHLP_MODULEW ModuleInfo
  1310. );
  1311. #endif
  1312. DWORD64
  1313. IMAGEAPI
  1314. SymGetModuleBase64(
  1315. IN HANDLE hProcess,
  1316. IN DWORD64 qwAddr
  1317. );
  1318. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1319. #define SymGetModuleBase SymGetModuleBase64
  1320. #else
  1321. DWORD
  1322. IMAGEAPI
  1323. SymGetModuleBase(
  1324. IN HANDLE hProcess,
  1325. IN DWORD dwAddr
  1326. );
  1327. #endif
  1328. BOOL
  1329. IMAGEAPI
  1330. SymGetSymNext64(
  1331. IN HANDLE hProcess,
  1332. IN OUT PIMAGEHLP_SYMBOL64 Symbol
  1333. );
  1334. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1335. #define SymGetSymNext SymGetSymNext64
  1336. #else
  1337. BOOL
  1338. IMAGEAPI
  1339. SymGetSymNext(
  1340. IN HANDLE hProcess,
  1341. IN OUT PIMAGEHLP_SYMBOL Symbol
  1342. );
  1343. #endif
  1344. BOOL
  1345. IMAGEAPI
  1346. SymGetSymPrev64(
  1347. IN HANDLE hProcess,
  1348. IN OUT PIMAGEHLP_SYMBOL64 Symbol
  1349. );
  1350. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1351. #define SymGetSymPrev SymGetSymPrev64
  1352. #else
  1353. BOOL
  1354. IMAGEAPI
  1355. SymGetSymPrev(
  1356. IN HANDLE hProcess,
  1357. IN OUT PIMAGEHLP_SYMBOL Symbol
  1358. );
  1359. #endif
  1360. BOOL
  1361. IMAGEAPI
  1362. SymGetLineFromAddr64(
  1363. IN HANDLE hProcess,
  1364. IN DWORD64 qwAddr,
  1365. OUT PDWORD pdwDisplacement,
  1366. OUT PIMAGEHLP_LINE64 Line
  1367. );
  1368. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1369. #define SymGetLineFromAddr SymGetLineFromAddr64
  1370. #else
  1371. BOOL
  1372. IMAGEAPI
  1373. SymGetLineFromAddr(
  1374. IN HANDLE hProcess,
  1375. IN DWORD dwAddr,
  1376. OUT PDWORD pdwDisplacement,
  1377. OUT PIMAGEHLP_LINE Line
  1378. );
  1379. #endif
  1380. BOOL
  1381. IMAGEAPI
  1382. SymGetLineFromName64(
  1383. IN HANDLE hProcess,
  1384. IN PSTR ModuleName,
  1385. IN PSTR FileName,
  1386. IN DWORD dwLineNumber,
  1387. OUT PLONG plDisplacement,
  1388. IN OUT PIMAGEHLP_LINE64 Line
  1389. );
  1390. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1391. #define SymGetLineFromName SymGetLineFromName64
  1392. #else
  1393. BOOL
  1394. IMAGEAPI
  1395. SymGetLineFromName(
  1396. IN HANDLE hProcess,
  1397. IN PSTR ModuleName,
  1398. IN PSTR FileName,
  1399. IN DWORD dwLineNumber,
  1400. OUT PLONG plDisplacement,
  1401. IN OUT PIMAGEHLP_LINE Line
  1402. );
  1403. #endif
  1404. BOOL
  1405. IMAGEAPI
  1406. SymGetLineNext64(
  1407. IN HANDLE hProcess,
  1408. IN OUT PIMAGEHLP_LINE64 Line
  1409. );
  1410. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1411. #define SymGetLineNext SymGetLineNext64
  1412. #else
  1413. BOOL
  1414. IMAGEAPI
  1415. SymGetLineNext(
  1416. IN HANDLE hProcess,
  1417. IN OUT PIMAGEHLP_LINE Line
  1418. );
  1419. #endif
  1420. BOOL
  1421. IMAGEAPI
  1422. SymGetLinePrev64(
  1423. IN HANDLE hProcess,
  1424. IN OUT PIMAGEHLP_LINE64 Line
  1425. );
  1426. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1427. #define SymGetLinePrev SymGetLinePrev64
  1428. #else
  1429. BOOL
  1430. IMAGEAPI
  1431. SymGetLinePrev(
  1432. IN HANDLE hProcess,
  1433. IN OUT PIMAGEHLP_LINE Line
  1434. );
  1435. #endif
  1436. BOOL
  1437. IMAGEAPI
  1438. SymMatchFileName(
  1439. IN PSTR FileName,
  1440. IN PSTR Match,
  1441. OUT PSTR *FileNameStop,
  1442. OUT PSTR *MatchStop
  1443. );
  1444. BOOL
  1445. IMAGEAPI
  1446. SymInitialize(
  1447. IN HANDLE hProcess,
  1448. IN PSTR UserSearchPath,
  1449. IN BOOL fInvadeProcess
  1450. );
  1451. BOOL
  1452. IMAGEAPI
  1453. SymGetSearchPath(
  1454. IN HANDLE hProcess,
  1455. OUT PSTR SearchPath,
  1456. IN DWORD SearchPathLength
  1457. );
  1458. BOOL
  1459. IMAGEAPI
  1460. SymSetSearchPath(
  1461. IN HANDLE hProcess,
  1462. IN PSTR SearchPath
  1463. );
  1464. DWORD64
  1465. IMAGEAPI
  1466. SymLoadModule64(
  1467. IN HANDLE hProcess,
  1468. IN HANDLE hFile,
  1469. IN PSTR ImageName,
  1470. IN PSTR ModuleName,
  1471. IN DWORD64 BaseOfDll,
  1472. IN DWORD SizeOfDll
  1473. );
  1474. DWORD64
  1475. IMAGEAPI
  1476. SymLoadModuleEx(
  1477. IN HANDLE hProcess,
  1478. IN HANDLE hFile,
  1479. IN PSTR ImageName,
  1480. IN PSTR ModuleName,
  1481. IN DWORD64 BaseOfDll,
  1482. IN DWORD DllSize,
  1483. IN PMODLOAD_DATA Data,
  1484. IN DWORD Flags
  1485. );
  1486. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1487. #define SymLoadModule SymLoadModule64
  1488. #else
  1489. DWORD
  1490. IMAGEAPI
  1491. SymLoadModule(
  1492. IN HANDLE hProcess,
  1493. IN HANDLE hFile,
  1494. IN PSTR ImageName,
  1495. IN PSTR ModuleName,
  1496. IN DWORD BaseOfDll,
  1497. IN DWORD SizeOfDll
  1498. );
  1499. #endif
  1500. BOOL
  1501. IMAGEAPI
  1502. SymUnloadModule64(
  1503. IN HANDLE hProcess,
  1504. IN DWORD64 BaseOfDll
  1505. );
  1506. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1507. #define SymUnloadModule SymUnloadModule64
  1508. #else
  1509. BOOL
  1510. IMAGEAPI
  1511. SymUnloadModule(
  1512. IN HANDLE hProcess,
  1513. IN DWORD BaseOfDll
  1514. );
  1515. #endif
  1516. BOOL
  1517. IMAGEAPI
  1518. SymUnDName64(
  1519. IN PIMAGEHLP_SYMBOL64 sym, // Symbol to undecorate
  1520. OUT PSTR UnDecName, // Buffer to store undecorated name in
  1521. IN DWORD UnDecNameLength // Size of the buffer
  1522. );
  1523. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1524. #define SymUnDName SymUnDName64
  1525. #else
  1526. BOOL
  1527. IMAGEAPI
  1528. SymUnDName(
  1529. IN PIMAGEHLP_SYMBOL sym, // Symbol to undecorate
  1530. OUT PSTR UnDecName, // Buffer to store undecorated name in
  1531. IN DWORD UnDecNameLength // Size of the buffer
  1532. );
  1533. #endif
  1534. BOOL
  1535. IMAGEAPI
  1536. SymRegisterCallback64(
  1537. IN HANDLE hProcess,
  1538. IN PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction,
  1539. IN ULONG64 UserContext
  1540. );
  1541. BOOL
  1542. IMAGEAPI
  1543. SymRegisterFunctionEntryCallback64(
  1544. IN HANDLE hProcess,
  1545. IN PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction,
  1546. IN ULONG64 UserContext
  1547. );
  1548. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1549. #define SymRegisterCallback SymRegisterCallback64
  1550. #define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64
  1551. #else
  1552. BOOL
  1553. IMAGEAPI
  1554. SymRegisterCallback(
  1555. IN HANDLE hProcess,
  1556. IN PSYMBOL_REGISTERED_CALLBACK CallbackFunction,
  1557. IN PVOID UserContext
  1558. );
  1559. BOOL
  1560. IMAGEAPI
  1561. SymRegisterFunctionEntryCallback(
  1562. IN HANDLE hProcess,
  1563. IN PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction,
  1564. IN PVOID UserContext
  1565. );
  1566. #endif
  1567. typedef struct _IMAGEHLP_SYMBOL_SRC {
  1568. DWORD sizeofstruct;
  1569. DWORD type;
  1570. char file[MAX_PATH];
  1571. } IMAGEHLP_SYMBOL_SRC, *PIMAGEHLP_SYMBOL_SRC;
  1572. typedef struct _MODULE_TYPE_INFO { // AKA TYPTYP
  1573. USHORT dataLength;
  1574. USHORT leaf;
  1575. BYTE data[1];
  1576. } MODULE_TYPE_INFO, *PMODULE_TYPE_INFO;
  1577. #define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT 1
  1578. #define IMAGEHLP_SYMBOL_INFO_REGISTER SYMF_REGISTER // 0x08
  1579. #define IMAGEHLP_SYMBOL_INFO_REGRELATIVE SYMF_REGREL // 0x10
  1580. #define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE SYMF_FRAMEREL // 0x20
  1581. #define IMAGEHLP_SYMBOL_INFO_PARAMETER SYMF_PARAMETER // 0x40
  1582. #define IMAGEHLP_SYMBOL_INFO_LOCAL SYMF_LOCAL // 0x80
  1583. #define IMAGEHLP_SYMBOL_INFO_CONSTANT SYMF_CONSTANT // 0x100
  1584. #define IMAGEHLP_SYMBOL_FUNCTION SYMF_FUNCTION // 0x800
  1585. typedef struct _SYMBOL_INFO {
  1586. ULONG SizeOfStruct;
  1587. ULONG TypeIndex; // Type Index of symbol
  1588. ULONG64 Reserved[2];
  1589. ULONG Reserved2;
  1590. ULONG Size;
  1591. ULONG64 ModBase; // Base Address of module comtaining this symbol
  1592. ULONG Flags;
  1593. ULONG64 Value; // Value of symbol, ValuePresent should be 1
  1594. ULONG64 Address; // Address of symbol including base address of module
  1595. ULONG Register; // register holding value or pointer to value
  1596. ULONG Scope; // scope of the symbol
  1597. ULONG Tag; // pdb classification
  1598. ULONG NameLen; // Actual length of name
  1599. ULONG MaxNameLen;
  1600. CHAR Name[1]; // Name of symbol
  1601. } SYMBOL_INFO, *PSYMBOL_INFO;
  1602. typedef struct _IMAGEHLP_STACK_FRAME
  1603. {
  1604. ULONG64 InstructionOffset;
  1605. ULONG64 ReturnOffset;
  1606. ULONG64 FrameOffset;
  1607. ULONG64 StackOffset;
  1608. ULONG64 BackingStoreOffset;
  1609. ULONG64 FuncTableEntry;
  1610. ULONG64 Params[4];
  1611. ULONG64 Reserved[5];
  1612. BOOL Virtual;
  1613. ULONG Reserved2;
  1614. } IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
  1615. typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT;
  1616. ULONG
  1617. IMAGEAPI
  1618. SymSetContext(
  1619. HANDLE hProcess,
  1620. PIMAGEHLP_STACK_FRAME StackFrame,
  1621. PIMAGEHLP_CONTEXT Context
  1622. );
  1623. BOOL
  1624. IMAGEAPI
  1625. SymFromAddr(
  1626. IN HANDLE hProcess,
  1627. IN DWORD64 Address,
  1628. OUT PDWORD64 Displacement,
  1629. IN OUT PSYMBOL_INFO Symbol
  1630. );
  1631. // While SymFromName will provide a symbol from a name,
  1632. // SymEnumSymbols can provide the same matching information
  1633. // for ALL symbols with a matching name, even regular
  1634. // expressions. That way you can search across modules
  1635. // and differentiate between identically named symbols.
  1636. BOOL
  1637. IMAGEAPI
  1638. SymFromName(
  1639. IN HANDLE hProcess,
  1640. IN LPSTR Name,
  1641. OUT PSYMBOL_INFO Symbol
  1642. );
  1643. typedef BOOL
  1644. (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(
  1645. PSYMBOL_INFO pSymInfo,
  1646. ULONG SymbolSize,
  1647. PVOID UserContext
  1648. );
  1649. BOOL
  1650. IMAGEAPI
  1651. SymEnumSymbols(
  1652. IN HANDLE hProcess,
  1653. IN ULONG64 BaseOfDll,
  1654. IN PCSTR Mask,
  1655. IN PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  1656. IN PVOID UserContext
  1657. );
  1658. typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO {
  1659. TI_GET_SYMTAG,
  1660. TI_GET_SYMNAME,
  1661. TI_GET_LENGTH,
  1662. TI_GET_TYPE,
  1663. TI_GET_TYPEID,
  1664. TI_GET_BASETYPE,
  1665. TI_GET_ARRAYINDEXTYPEID,
  1666. TI_FINDCHILDREN,
  1667. TI_GET_DATAKIND,
  1668. TI_GET_ADDRESSOFFSET,
  1669. TI_GET_OFFSET,
  1670. TI_GET_VALUE,
  1671. TI_GET_COUNT,
  1672. TI_GET_CHILDRENCOUNT,
  1673. TI_GET_BITPOSITION,
  1674. TI_GET_VIRTUALBASECLASS,
  1675. TI_GET_VIRTUALTABLESHAPEID,
  1676. TI_GET_VIRTUALBASEPOINTEROFFSET,
  1677. TI_GET_CLASSPARENTID,
  1678. TI_GET_NESTED,
  1679. TI_GET_SYMINDEX,
  1680. TI_GET_LEXICALPARENT,
  1681. TI_GET_ADDRESS,
  1682. TI_GET_THISADJUST,
  1683. } IMAGEHLP_SYMBOL_TYPE_INFO;
  1684. typedef struct _TI_FINDCHILDREN_PARAMS {
  1685. ULONG Count;
  1686. ULONG Start;
  1687. ULONG ChildId[1];
  1688. } TI_FINDCHILDREN_PARAMS;
  1689. BOOL
  1690. IMAGEAPI
  1691. SymGetTypeInfo(
  1692. IN HANDLE hProcess,
  1693. IN DWORD64 ModBase,
  1694. IN ULONG TypeId,
  1695. IN IMAGEHLP_SYMBOL_TYPE_INFO GetType,
  1696. OUT PVOID pInfo
  1697. );
  1698. BOOL
  1699. IMAGEAPI
  1700. SymEnumTypes(
  1701. IN HANDLE hProcess,
  1702. IN ULONG64 BaseOfDll,
  1703. IN PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  1704. IN PVOID UserContext
  1705. );
  1706. BOOL
  1707. IMAGEAPI
  1708. SymGetTypeFromName(
  1709. IN HANDLE hProcess,
  1710. IN ULONG64 BaseOfDll,
  1711. IN LPSTR Name,
  1712. OUT PSYMBOL_INFO Symbol
  1713. );
  1714. //
  1715. // Full user-mode dump creation.
  1716. //
  1717. typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
  1718. DWORD DataType,
  1719. PVOID* Data,
  1720. LPDWORD DataLength,
  1721. PVOID UserData
  1722. );
  1723. BOOL
  1724. WINAPI
  1725. DbgHelpCreateUserDump(
  1726. IN LPSTR FileName,
  1727. IN PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,
  1728. IN PVOID UserData
  1729. );
  1730. BOOL
  1731. WINAPI
  1732. DbgHelpCreateUserDumpW(
  1733. IN LPWSTR FileName,
  1734. IN PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,
  1735. IN PVOID UserData
  1736. );
  1737. // -----------------------------------------------------------------
  1738. // The following 4 legacy APIs are fully supported, but newer
  1739. // ones are recommended. SymFromName and SymFromAddr provide
  1740. // much more detailed info on the returned symbol.
  1741. BOOL
  1742. IMAGEAPI
  1743. SymGetSymFromAddr64(
  1744. IN HANDLE hProcess,
  1745. IN DWORD64 qwAddr,
  1746. OUT PDWORD64 pdwDisplacement,
  1747. OUT PIMAGEHLP_SYMBOL64 Symbol
  1748. );
  1749. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1750. #define SymGetSymFromAddr SymGetSymFromAddr64
  1751. #else
  1752. BOOL
  1753. IMAGEAPI
  1754. SymGetSymFromAddr(
  1755. IN HANDLE hProcess,
  1756. IN DWORD dwAddr,
  1757. OUT PDWORD pdwDisplacement,
  1758. OUT PIMAGEHLP_SYMBOL Symbol
  1759. );
  1760. #endif
  1761. // While following two APIs will provide a symbol from a name,
  1762. // SymEnumSymbols can provide the same matching information
  1763. // for ALL symbols with a matching name, even regular
  1764. // expressions. That way you can search across modules
  1765. // and differentiate between identically named symbols.
  1766. BOOL
  1767. IMAGEAPI
  1768. SymGetSymFromName64(
  1769. IN HANDLE hProcess,
  1770. IN PSTR Name,
  1771. OUT PIMAGEHLP_SYMBOL64 Symbol
  1772. );
  1773. #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  1774. #define SymGetSymFromName SymGetSymFromName64
  1775. #else
  1776. BOOL
  1777. IMAGEAPI
  1778. SymGetSymFromName(
  1779. IN HANDLE hProcess,
  1780. IN PSTR Name,
  1781. OUT PIMAGEHLP_SYMBOL Symbol
  1782. );
  1783. #endif
  1784. // -----------------------------------------------------------------
  1785. // The following APIs exist only for backwards compatibility
  1786. // with a pre-release version documented in an MSDN release.
  1787. // You should use SymFindFileInPath if you want to maintain
  1788. // future compatibility.
  1789. DBHLP_DEPRECIATED
  1790. BOOL
  1791. IMAGEAPI
  1792. FindFileInPath(
  1793. HANDLE hprocess,
  1794. LPSTR SearchPath,
  1795. LPSTR FileName,
  1796. PVOID id,
  1797. DWORD two,
  1798. DWORD three,
  1799. DWORD flags,
  1800. LPSTR FilePath
  1801. );
  1802. // You should use SymFindFileInPath if you want to maintain
  1803. // future compatibility.
  1804. DBHLP_DEPRECIATED
  1805. BOOL
  1806. IMAGEAPI
  1807. FindFileInSearchPath(
  1808. HANDLE hprocess,
  1809. LPSTR SearchPath,
  1810. LPSTR FileName,
  1811. DWORD one,
  1812. DWORD two,
  1813. DWORD three,
  1814. LPSTR FilePath
  1815. );
  1816. DBHLP_DEPRECIATED
  1817. BOOL
  1818. IMAGEAPI
  1819. SymEnumSym(
  1820. IN HANDLE hProcess,
  1821. IN ULONG64 BaseOfDll,
  1822. IN PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  1823. IN PVOID UserContext
  1824. );
  1825. // HEXTRACT, end_imagehlp end_dbghelp hide_line