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.

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