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.

1031 lines
21 KiB

  1. //
  2. // defines for symbol file searching
  3. //
  4. #include <dbgimage.h>
  5. // this private API is in msdia20-msvcrt.lib
  6. HRESULT
  7. __cdecl
  8. CompareRE(
  9. const wchar_t* pStr,
  10. const wchar_t* pRE,
  11. BOOL fCase
  12. );
  13. #define SYMBOL_PATH "_NT_SYMBOL_PATH"
  14. #define ALTERNATE_SYMBOL_PATH "_NT_ALT_SYMBOL_PATH"
  15. #define SYMBOL_SERVER "_NT_SYMBOL_SERVER"
  16. #define SYMSRV "SYMSRV"
  17. #define WINDIR "windir"
  18. #define DEBUG_TOKEN "DBGHELP_TOKEN"
  19. #define HASH_MODULO 253
  20. #define OMAP_SYM_EXTRA 1024
  21. #define CPP_EXTRA 2
  22. #define OMAP_SYM_STRINGS (OMAP_SYM_EXTRA * 256)
  23. #define TMP_SYM_LEN 4096
  24. // Possibly truncates and sign-extends a value to 64 bits.
  25. #define EXTEND64(Val) ((ULONG64)(LONG64)(LONG)(Val))
  26. //
  27. // structures
  28. //
  29. typedef struct _LOADED_MODULE {
  30. PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback32;
  31. PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback64;
  32. PVOID Context;
  33. } LOADED_MODULE, *PLOADED_MODULE;
  34. #define SYMF_DUPLICATE 0x80000000
  35. #define SYMF_OMAP_GENERATED 0x00000001
  36. #define SYMF_OMAP_MODIFIED 0x00000002
  37. #ifndef _DBGHELP_USER_GENERATED_SYMBOLS_NOTSUPPORTED
  38. #define SYMF_USER_GENERATED 0x00000004
  39. #endif // !_DBGHELP_USER_GENERATED_SYMBOLS_NOTSUPPORTED
  40. typedef struct _SYMBOL_ENTRY {
  41. struct _SYMBOL_ENTRY *Next;
  42. DWORD Size;
  43. DWORD Flags;
  44. DWORD64 Address;
  45. LPSTR Name;
  46. ULONG NameLength;
  47. ULONG Segment;
  48. ULONG64 Offset;
  49. ULONG TypeIndex;
  50. ULONG64 ModBase;
  51. ULONG Register;
  52. } SYMBOL_ENTRY, *PSYMBOL_ENTRY;
  53. typedef struct _SECTION_START {
  54. ULONG64 Offset;
  55. DWORD Size;
  56. DWORD Flags;
  57. } SECTION_START, *PSECTION_START;
  58. //
  59. // source file and line number information
  60. //
  61. typedef struct _SOURCE_LINE {
  62. DWORD64 Addr;
  63. DWORD Line;
  64. } SOURCE_LINE, *PSOURCE_LINE;
  65. typedef struct _SOURCE_ENTRY {
  66. struct _SOURCE_ENTRY *Next;
  67. struct _SOURCE_ENTRY *Prev;
  68. DWORD64 MinAddr;
  69. DWORD64 MaxAddr;
  70. LPSTR File;
  71. DWORD Lines;
  72. PSOURCE_LINE LineInfo;
  73. ULONG ModuleId;
  74. } SOURCE_ENTRY, *PSOURCE_ENTRY;
  75. //
  76. // Error values for failed symbol load
  77. //
  78. #define SYMLOAD_OK 0x0000
  79. #define SYMLOAD_PDBUNMATCHED 0x0001
  80. #define SYMLOAD_PDBNOTFOUND 0x0002
  81. #define SYMLOAD_DBGNOTFOUND 0x0003
  82. #define SYMLOAD_OTHERERROR 0x0004
  83. #define SYMLOAD_OUTOFMEMORY 0x0005
  84. #define SYMLOAD_HEADERPAGEDOUT 0x0006
  85. #define SYMLOAD_PDBERRORMASK 0xff00
  86. #define SYMLOAD_DEFERRED 0x80000000
  87. //
  88. // module flags
  89. //
  90. #define MIF_DEFERRED_LOAD 0x00000001
  91. #define MIF_NO_SYMBOLS 0x00000002
  92. #define MIF_ROM_IMAGE 0x00000004
  93. // for ImageSrc and PdbSrc elements
  94. typedef enum {
  95. srcNone = 0,
  96. srcSearchPath,
  97. srcImagePath,
  98. srcDbgPath,
  99. srcSymSrv,
  100. srcCVRec,
  101. srcHandle,
  102. srcMemory
  103. };
  104. typedef struct _MODULE_ENTRY {
  105. LIST_ENTRY ListEntry;
  106. ULONG64 BaseOfDll;
  107. ULONG DllSize;
  108. ULONG TimeDateStamp;
  109. ULONG CheckSum;
  110. USHORT MachineType;
  111. CHAR ModuleName[64];
  112. CHAR AliasName[64];
  113. PSTR ImageName;
  114. PSTR LoadedImageName;
  115. PSTR LoadedPdbName;
  116. ULONG ImageType;
  117. ULONG ImageSrc;
  118. ULONG PdbSrc;
  119. PSYMBOL_ENTRY symbolTable;
  120. LPSTR SymStrings;
  121. PSYMBOL_ENTRY NameHashTable[HASH_MODULO];
  122. ULONG numsyms;
  123. ULONG MaxSyms;
  124. ULONG StringSize;
  125. SYM_TYPE SymType;
  126. PDB * pdb;
  127. DBI * dbi;
  128. GSI * gsi;
  129. GSI * globals;
  130. TPI * ptpi;
  131. PIMAGE_SECTION_HEADER SectionHdrs;
  132. ULONG NumSections;
  133. PFPO_DATA pFpoData; // pointer to fpo data (x86)
  134. PFPO_DATA pFpoDataOmap; // pointer to fpo data (x86)
  135. PIMGHLP_RVA_FUNCTION_DATA pExceptionData; // pointer to pdata (risc)
  136. PVOID pPData; // pdata acquired from pdb
  137. PVOID pXData; // xdata acquired from pdb
  138. ULONG dwEntries; // # of fpo or pdata recs
  139. ULONG cPData; // number of pdb pdata entries
  140. ULONG cXData; // number of pdb xdata entries
  141. ULONG cbPData; // size of pdb xdata blob
  142. ULONG cbXData; // size of pdb xdata blob
  143. POMAP pOmapFrom; // pointer to omap data
  144. ULONG cOmapFrom; // count of omap entries
  145. POMAP pOmapTo; // pointer to omap data
  146. ULONG cOmapTo; // count of omap entries
  147. SYMBOL_ENTRY TmpSym; // used only for pdb symbols
  148. SYMBOL_INFO si; // used for dia symbols
  149. UCHAR siName[2048]; // must be contiguous with si
  150. ULONG Flags;
  151. HANDLE hFile;
  152. PIMAGE_SECTION_HEADER OriginalSectionHdrs;
  153. ULONG OriginalNumSections;
  154. PSOURCE_ENTRY SourceFiles;
  155. PSOURCE_ENTRY SourceFilesTail;
  156. HANDLE hProcess;
  157. ULONG64 InProcImageBase;
  158. BOOL fInProcHeader;
  159. DWORD dsExceptions;
  160. Mod *mod;
  161. USHORT imod;
  162. PBYTE pPdbSymbols;
  163. DWORD cbPdbSymbols;
  164. ULONG SymLoadError;
  165. ULONG code; // used to pass back info to wrappers
  166. PVOID dia;
  167. CHAR SrcFile[_MAX_PATH + 1];
  168. DWORD CallerFlags;
  169. MODLOAD_DATA mld;
  170. PVOID CallerData;
  171. } MODULE_ENTRY, *PMODULE_ENTRY;
  172. typedef VOID DBG_CONTEXT, *PDBG_CONTEXT;
  173. #ifdef USE_CACHE
  174. #define CACHE_BLOCK 40
  175. #define CACHE_SIZE CACHE_BLOCK*CACHE_BLOCK
  176. typedef struct _DIA_LARGE_DATA {
  177. BOOL Used;
  178. ULONG Index;
  179. ULONG LengthUsed;
  180. CHAR Bytes[500];
  181. } DIA_LARGE_DATA, *PDIA_LARGE_DATA;
  182. #define DIACH_ULVAL 0
  183. #define DIACH_ULLVAL 1
  184. #define DIACH_PLVAL 2
  185. typedef struct _DIA_CACHE_DATA {
  186. ULONG type;
  187. union {
  188. ULONG ulVal;
  189. ULONGLONG ullVal;
  190. PDIA_LARGE_DATA plVal;
  191. };
  192. } DIA_CACHE_DATA, *PDIA_CACHE_DATA;
  193. typedef struct _DIA_CACHE_ENTRY {
  194. ULONG Age;
  195. union {
  196. struct {
  197. ULONG TypeId;
  198. IMAGEHLP_SYMBOL_TYPE_INFO DataType;
  199. } s;
  200. ULONGLONG SearchId;
  201. };
  202. ULONGLONG Module;
  203. DIA_CACHE_DATA Data;
  204. } DIA_CACHE_ENTRY, *PDIA_CACHE_ENTRY;
  205. #endif // USE_CACHE
  206. typedef struct _PROCESS_ENTRY {
  207. LIST_ENTRY ListEntry;
  208. LIST_ENTRY ModuleList;
  209. ULONG Count;
  210. HANDLE hProcess;
  211. DWORD pid;
  212. LPSTR SymbolSearchPath;
  213. PSYMBOL_REGISTERED_CALLBACK pCallbackFunction32;
  214. PSYMBOL_REGISTERED_CALLBACK64 pCallbackFunction64;
  215. ULONG64 CallbackUserContext;
  216. PSYMBOL_FUNCENTRY_CALLBACK pFunctionEntryCallback32;
  217. PSYMBOL_FUNCENTRY_CALLBACK64 pFunctionEntryCallback64;
  218. ULONG64 FunctionEntryUserContext;
  219. PIMAGEHLP_CONTEXT pContext;
  220. IMAGEHLP_STACK_FRAME StackFrame;
  221. PMODULE_ENTRY ipmi;
  222. #ifdef USE_CACHE
  223. DIA_LARGE_DATA DiaLargeData[2*CACHE_BLOCK];
  224. DIA_CACHE_ENTRY DiaCache[CACHE_SIZE];
  225. #endif // USE_CACHE
  226. } PROCESS_ENTRY, *PPROCESS_ENTRY;
  227. // debug trace facility
  228. int
  229. WINAPIV
  230. _pprint(
  231. PPROCESS_ENTRY ProcessEntry,
  232. LPSTR Format,
  233. ...
  234. );
  235. int
  236. WINAPIV
  237. _peprint(
  238. PPROCESS_ENTRY ProcessEntry,
  239. LPSTR Format,
  240. ...
  241. );
  242. int
  243. WINAPIV
  244. _dprint(
  245. LPSTR format,
  246. ...
  247. );
  248. int
  249. WINAPIV
  250. _eprint(
  251. LPSTR Format,
  252. ...
  253. );
  254. #define dprint ((g.SymOptions & SYMOPT_DEBUG) == SYMOPT_DEBUG)&&_dprint
  255. #define eprint ((g.SymOptions & SYMOPT_DEBUG) == SYMOPT_DEBUG)&&_eprint
  256. #define cprint _dprint
  257. #define pprint ((g.SymOptions & SYMOPT_DEBUG) == SYMOPT_DEBUG)&&_pprint
  258. #define peprint ((g.SymOptions & SYMOPT_DEBUG) == SYMOPT_DEBUG)&&_peprint
  259. #define pcprint _pprint
  260. BOOL
  261. WINAPIV
  262. evtprint(
  263. PPROCESS_ENTRY pe,
  264. DWORD severity,
  265. DWORD code,
  266. PVOID object,
  267. LPSTR format,
  268. ...
  269. );
  270. BOOL
  271. traceAddr(
  272. DWORD64 addr
  273. );
  274. BOOL
  275. traceName(
  276. PCHAR name
  277. );
  278. BOOL
  279. traceSubName(
  280. PCHAR name
  281. );
  282. // for use with cvtype.h
  283. typedef SYMTYPE *SYMPTR;
  284. __inline
  285. DWORD64
  286. GetIP(
  287. PPROCESS_ENTRY pe
  288. )
  289. {
  290. return pe->StackFrame.InstructionOffset;
  291. }
  292. typedef struct _PDB_INFO {
  293. CHAR Signature[4]; // "NBxx"
  294. ULONG Offset; // always zero
  295. ULONG sig;
  296. ULONG age;
  297. CHAR PdbName[_MAX_PATH];
  298. } PDB_INFO, *PPDB_INFO;
  299. #define n_name N.ShortName
  300. #define n_zeroes N.Name.Short
  301. #define n_nptr N.LongName[1]
  302. #define n_offset N.Name.Long
  303. //
  304. // internal prototypes
  305. //
  306. BOOL
  307. IsImageMachineType64(
  308. DWORD MachineType
  309. );
  310. void
  311. InitModuleEntry(
  312. PMODULE_ENTRY mi
  313. );
  314. PMODULE_ENTRY
  315. GetModFromAddr(
  316. PPROCESS_ENTRY pe,
  317. IN DWORD64 addr
  318. );
  319. DWORD_PTR
  320. GetPID(
  321. HANDLE hProcess
  322. );
  323. DWORD
  324. GetProcessModules(
  325. HANDLE hProcess,
  326. PINTERNAL_GET_MODULE InternalGetModule,
  327. PVOID Context
  328. );
  329. BOOL
  330. InternalGetModule(
  331. HANDLE hProcess,
  332. LPSTR ModuleName,
  333. DWORD64 ImageBase,
  334. DWORD ImageSize,
  335. PVOID Context
  336. );
  337. VOID
  338. FreeModuleEntry(
  339. PPROCESS_ENTRY pe,
  340. PMODULE_ENTRY mi
  341. );
  342. PPROCESS_ENTRY
  343. FindProcessEntry(
  344. HANDLE hProcess
  345. );
  346. PPROCESS_ENTRY
  347. FindFirstProcessEntry(
  348. );
  349. VOID
  350. GetSymName(
  351. PIMAGE_SYMBOL Symbol,
  352. PUCHAR StringTable,
  353. LPSTR s,
  354. DWORD size
  355. );
  356. BOOL
  357. ProcessOmapSymbol(
  358. PMODULE_ENTRY mi,
  359. PSYMBOL_ENTRY sym
  360. );
  361. DWORD64
  362. ConvertOmapFromSrc(
  363. PMODULE_ENTRY mi,
  364. DWORD64 addr,
  365. LPDWORD bias
  366. );
  367. DWORD64
  368. ConvertOmapToSrc(
  369. PMODULE_ENTRY mi,
  370. DWORD64 addr,
  371. LPDWORD bias,
  372. BOOL fBackup
  373. );
  374. POMAP
  375. GetOmapFromSrcEntry(
  376. PMODULE_ENTRY mi,
  377. DWORD64 addr
  378. );
  379. VOID
  380. DumpOmapForModule(
  381. PMODULE_ENTRY mi
  382. );
  383. VOID
  384. ProcessOmapForModule(
  385. PMODULE_ENTRY mi,
  386. PIMGHLP_DEBUG_DATA pIDD
  387. );
  388. BOOL
  389. LoadCoffSymbols(
  390. HANDLE hProcess,
  391. PMODULE_ENTRY mi,
  392. PIMGHLP_DEBUG_DATA pIDD
  393. );
  394. BOOL
  395. LoadCodeViewSymbols(
  396. HANDLE hProcess,
  397. PMODULE_ENTRY mi,
  398. PIMGHLP_DEBUG_DATA pIDD
  399. );
  400. ULONG
  401. LoadExportSymbols(
  402. PMODULE_ENTRY mi,
  403. PIMGHLP_DEBUG_DATA pIDD
  404. );
  405. PMODULE_ENTRY
  406. GetModuleForPC(
  407. PPROCESS_ENTRY ProcessEntry,
  408. DWORD64 dwPcAddr,
  409. BOOL ExactMatch
  410. );
  411. PSYMBOL_ENTRY
  412. GetSymFromAddr(
  413. DWORD64 dwAddr,
  414. PDWORD64 pqwDisplacement,
  415. PMODULE_ENTRY mi
  416. );
  417. LPSTR
  418. StringDup(
  419. LPSTR str
  420. );
  421. DWORD64
  422. InternalLoadModule(
  423. IN HANDLE hProcess,
  424. IN PSTR ImageName,
  425. IN PSTR ModuleName,
  426. IN DWORD64 BaseOfDll,
  427. IN DWORD SizeOfDll,
  428. IN HANDLE hFile,
  429. IN PMODLOAD_DATA data,
  430. IN DWORD flags
  431. );
  432. DWORD
  433. ComputeHash(
  434. LPSTR lpname,
  435. ULONG cb
  436. );
  437. PSYMBOL_ENTRY
  438. FindSymbolByName(
  439. PPROCESS_ENTRY pe,
  440. PMODULE_ENTRY mi,
  441. LPSTR SymName
  442. );
  443. PFPO_DATA
  444. SwSearchFpoData(
  445. DWORD key,
  446. PFPO_DATA base,
  447. DWORD num
  448. );
  449. PIMGHLP_RVA_FUNCTION_DATA
  450. GetFunctionEntryFromDebugInfo (
  451. PPROCESS_ENTRY ProcessEntry,
  452. DWORD64 ControlPc
  453. );
  454. PIMAGE_FUNCTION_ENTRY
  455. LookupFunctionEntryAxp32 (
  456. HANDLE hProcess,
  457. DWORD ControlPc
  458. );
  459. PIMAGE_FUNCTION_ENTRY64
  460. LookupFunctionEntryAxp64 (
  461. HANDLE hProcess,
  462. DWORD64 ControlPc
  463. );
  464. PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY
  465. LookupFunctionEntryIa64 (
  466. HANDLE hProcess,
  467. DWORD64 ControlPc
  468. );
  469. _PIMAGE_RUNTIME_FUNCTION_ENTRY
  470. LookupFunctionEntryAmd64 (
  471. HANDLE hProcess,
  472. DWORD64 ControlPc
  473. );
  474. BOOL
  475. LoadedModuleEnumerator(
  476. HANDLE hProcess,
  477. LPSTR ModuleName,
  478. DWORD64 ImageBase,
  479. DWORD ImageSize,
  480. PLOADED_MODULE lm
  481. );
  482. BOOL
  483. load(
  484. IN HANDLE hProcess,
  485. IN PMODULE_ENTRY mi
  486. );
  487. LPSTR
  488. symfmt(
  489. LPSTR DstName,
  490. LPSTR SrcName,
  491. ULONG Length
  492. );
  493. BOOL
  494. MatchSymName(
  495. LPSTR matchName,
  496. LPSTR symName
  497. );
  498. BOOL
  499. strcmpre(
  500. LPSTR pStr,
  501. LPSTR pRE,
  502. BOOL fCase
  503. );
  504. PIMAGEHLP_SYMBOL
  505. symcpy32(
  506. PIMAGEHLP_SYMBOL External,
  507. PSYMBOL_ENTRY Internal
  508. );
  509. PIMAGEHLP_SYMBOL64
  510. symcpy64(
  511. PIMAGEHLP_SYMBOL64 External,
  512. PSYMBOL_ENTRY Internal
  513. );
  514. BOOL
  515. SympConvertSymbol32To64(
  516. PIMAGEHLP_SYMBOL Symbol32,
  517. PIMAGEHLP_SYMBOL64 Symbol64
  518. );
  519. BOOL
  520. SympConvertSymbol64To32(
  521. PIMAGEHLP_SYMBOL64 Symbol64,
  522. PIMAGEHLP_SYMBOL Symbol32
  523. );
  524. BOOL
  525. SympConvertLine32To64(
  526. PIMAGEHLP_LINE Line32,
  527. PIMAGEHLP_LINE64 Line64
  528. );
  529. BOOL
  530. SympConvertLine64To32(
  531. PIMAGEHLP_LINE64 Line64,
  532. PIMAGEHLP_LINE Line32
  533. );
  534. BOOL
  535. SympConvertAnsiModule32ToUnicodeModule32(
  536. PIMAGEHLP_MODULE A_Symbol32,
  537. PIMAGEHLP_MODULEW W_Symbol32
  538. );
  539. BOOL
  540. SympConvertUnicodeModule32ToAnsiModule32(
  541. PIMAGEHLP_MODULEW W_Symbol32,
  542. PIMAGEHLP_MODULE A_Symbol32
  543. );
  544. BOOL
  545. SympConvertAnsiModule64ToUnicodeModule64(
  546. PIMAGEHLP_MODULE64 A_Symbol64,
  547. PIMAGEHLP_MODULEW64 W_Symbol64
  548. );
  549. BOOL
  550. SympConvertUnicodeModule64ToAnsiModule64(
  551. PIMAGEHLP_MODULEW64 W_Symbol64,
  552. PIMAGEHLP_MODULE64 A_Symbol64
  553. );
  554. BOOL
  555. CopySymbolEntryFromSymbolInfo(
  556. PSYMBOL_ENTRY se,
  557. PSYMBOL_INFO si
  558. );
  559. PMODULE_ENTRY
  560. FindModule(
  561. HANDLE hModule,
  562. PPROCESS_ENTRY ProcessEntry,
  563. LPSTR ModuleName,
  564. BOOL fLoad
  565. );
  566. BOOL
  567. ToggleFailCriticalErrors(
  568. BOOL reset
  569. );
  570. DWORD
  571. fnGetFileAttributes(
  572. LPCTSTR lpFileName
  573. );
  574. #define SetCriticalErrorMode() ToggleFailCriticalErrors(FALSE)
  575. #define ResetCriticalErrorMode() ToggleFailCriticalErrors(TRUE)
  576. #define fileexists(path) (fnGetFileAttributes(path) != 0xFFFFFFFF)
  577. LPSTR
  578. SymUnDNameInternal(
  579. LPSTR UnDecName,
  580. DWORD UnDecNameLength,
  581. LPSTR DecName,
  582. DWORD MaxDecNameLength,
  583. DWORD MachineType,
  584. BOOL IsPublic
  585. );
  586. BOOL
  587. GetLineFromAddr(
  588. PMODULE_ENTRY mi,
  589. DWORD64 Addr,
  590. PDWORD Displacement,
  591. PIMAGEHLP_LINE64 Line
  592. );
  593. BOOL
  594. FindLineByName(
  595. PMODULE_ENTRY mi,
  596. LPSTR FileName,
  597. DWORD LineNumber,
  598. PLONG Displacement,
  599. PIMAGEHLP_LINE64 Line
  600. );
  601. BOOL
  602. AddLinesForCoff(
  603. PMODULE_ENTRY mi,
  604. PIMAGE_SYMBOL allSymbols,
  605. DWORD numberOfSymbols,
  606. PIMAGE_LINENUMBER LineNumbers
  607. );
  608. BOOL
  609. AddLinesForOmfSourceModule(
  610. PMODULE_ENTRY mi,
  611. BYTE *Base,
  612. OMFSourceModule *OmfSrcMod,
  613. PVOID PdbModule
  614. );
  615. PSOURCE_ENTRY
  616. FindNextSourceEntryForFile(
  617. PMODULE_ENTRY mi,
  618. LPSTR File,
  619. PSOURCE_ENTRY SearchFrom
  620. );
  621. PSOURCE_ENTRY
  622. FindPrevSourceEntryForFile(
  623. PMODULE_ENTRY mi,
  624. LPSTR File,
  625. PSOURCE_ENTRY SearchFrom
  626. );
  627. BOOL
  628. __stdcall
  629. ReadInProcMemory(
  630. HANDLE hProcess,
  631. DWORD64 addr,
  632. PVOID buf,
  633. DWORD bytes,
  634. DWORD *bytesread
  635. );
  636. BOOL
  637. GetPData(
  638. HANDLE hp,
  639. PMODULE_ENTRY mi
  640. );
  641. BOOL
  642. GetXData(
  643. HANDLE hp,
  644. PMODULE_ENTRY mi
  645. );
  646. PVOID
  647. GetXDataFromBase(
  648. HANDLE hp,
  649. DWORD64 base,
  650. ULONG_PTR* size
  651. );
  652. PVOID
  653. GetUnwindInfoFromSymbols(
  654. HANDLE hProcess,
  655. DWORD64 ModuleBase,
  656. ULONG UnwindInfoAddress,
  657. ULONG_PTR* Size
  658. );
  659. VOID
  660. SympSendDebugString(
  661. PPROCESS_ENTRY ProcessEntry,
  662. LPSTR String
  663. );
  664. BOOL
  665. DoEnumCallback(
  666. PPROCESS_ENTRY pe,
  667. PSYMBOL_INFO pSymInfo,
  668. ULONG SymSize,
  669. PROC EnumCallback,
  670. PVOID UserContext,
  671. BOOL Use64,
  672. BOOL UsesUnicode
  673. );
  674. #ifdef __cpluspluss
  675. extern "C" {
  676. #endif
  677. BOOL
  678. MatchSymbolName(
  679. PSYMBOL_ENTRY sym,
  680. LPSTR SymName
  681. );
  682. BOOL
  683. LoadSymbols(
  684. HANDLE hp,
  685. PMODULE_ENTRY mi,
  686. DWORD flags
  687. );
  688. // flags parameter to LoadSymbols
  689. #define LS_QUALIFIED 0x1
  690. #define LS_LOAD_LINES 0x2
  691. #define LS_JUST_TEST 0x4
  692. #define LS_FAIL_IF_LOADED 0x8
  693. // flags indicate Next or Previous for many functions
  694. #define NP_NEXT 1
  695. #define NP_PREV -1
  696. BOOL
  697. DoSymbolCallback (
  698. PPROCESS_ENTRY ProcessEntry,
  699. ULONG CallbackType,
  700. IN PMODULE_ENTRY mi,
  701. PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 idsl64,
  702. LPSTR FileName
  703. );
  704. BOOL
  705. DoCallback(
  706. PPROCESS_ENTRY pe,
  707. ULONG type,
  708. PVOID data
  709. );
  710. #define lengthof(a) (sizeof(a) / sizeof(a[0]))
  711. BOOL
  712. wcs2ansi(
  713. PWSTR pwsz,
  714. PSTR psz,
  715. DWORD pszlen
  716. );
  717. BOOL
  718. ansi2wcs(
  719. PSTR psz,
  720. PWSTR pwsz,
  721. DWORD pwszlen
  722. );
  723. PWSTR AnsiToUnicode(PSTR);
  724. PSTR UnicodeToAnsi(PWSTR);
  725. #if 0
  726. BOOL CopyAnsiToUnicode(PWSTR, PSTR, DWORD);
  727. BOOL CopyUnicodeToAnsi(PSTR, PWSTR, DWORD);
  728. #endif
  729. BOOL
  730. LookupRegID (
  731. IN ULONG CVReg,
  732. IN ULONG MachineType,
  733. OUT PULONG pDbgReg
  734. );
  735. ULONG
  736. GetAddressFromOffset(
  737. PMODULE_ENTRY mi,
  738. ULONG section,
  739. ULONG64 Offset,
  740. PULONG64 pAddress
  741. );
  742. VOID
  743. AddSourceEntry(
  744. PMODULE_ENTRY mi,
  745. PSOURCE_ENTRY Src
  746. );
  747. BOOL
  748. diaInit(
  749. VOID
  750. );
  751. void
  752. diaRelease(
  753. PVOID dia
  754. );
  755. BOOL
  756. diaOpenPdb(
  757. PIMGHLP_DEBUG_DATA pIDD
  758. );
  759. BOOL
  760. diaEnumSourceFiles(
  761. IN PMODULE_ENTRY mi,
  762. IN PCHAR mask,
  763. IN PSYM_ENUMSOURCFILES_CALLBACK cbSrcFiles,
  764. IN PVOID context
  765. );
  766. BOOL
  767. diaGetPData(
  768. PMODULE_ENTRY mi
  769. );
  770. BOOL
  771. diaGetXData(
  772. PMODULE_ENTRY mi
  773. );
  774. PSYMBOL_ENTRY
  775. diaFindSymbolByName(
  776. PPROCESS_ENTRY pe,
  777. PMODULE_ENTRY mi,
  778. LPSTR SymName
  779. );
  780. BOOL
  781. diaEnumerateSymbols(
  782. IN PPROCESS_ENTRY pe,
  783. IN PMODULE_ENTRY mi,
  784. IN LPSTR mask,
  785. IN PROC callback,
  786. IN PVOID UserContext,
  787. IN BOOL Use64,
  788. IN BOOL CallBackUsesUnicode
  789. );
  790. PSYMBOL_ENTRY
  791. diaGetSymFromAddr(
  792. DWORD64 dwAddr,
  793. PMODULE_ENTRY mi,
  794. PDWORD64 disp
  795. );
  796. BOOL
  797. diaGetLineFromAddr(
  798. PMODULE_ENTRY mi,
  799. DWORD64 addr,
  800. PDWORD displacement,
  801. PIMAGEHLP_LINE64 Line
  802. );
  803. BOOL
  804. diaGetLineNextPrev(
  805. PMODULE_ENTRY mi,
  806. PIMAGEHLP_LINE64 line,
  807. DWORD direction
  808. );
  809. #define diaGetLineNext(mi, line) diaGetLineNextPrev(mi, line, NP_NEXT);
  810. #define diaGetLinePrev(mi, line) diaGetLineNextPrev(mi, line, NP_PREV);
  811. BOOL
  812. diaGetLineFromName(
  813. PMODULE_ENTRY mi,
  814. LPSTR filename,
  815. DWORD linenumber,
  816. PLONG displacement,
  817. PIMAGEHLP_LINE64 line
  818. );
  819. PSYMBOL_ENTRY
  820. diaGetSymNextPrev(
  821. PMODULE_ENTRY mi,
  822. DWORD64 addr,
  823. int direction
  824. );
  825. DWORD
  826. diaVersion(
  827. VOID
  828. );
  829. BOOL
  830. diaSetModFromIP(
  831. PPROCESS_ENTRY pe
  832. );
  833. HRESULT
  834. diaGetSymbolInfo(
  835. IN HANDLE hProcess,
  836. IN DWORD64 ModBase,
  837. IN ULONG TypeId,
  838. IN IMAGEHLP_SYMBOL_TYPE_INFO GetType,
  839. OUT PVOID pInfo
  840. );
  841. BOOL
  842. diaGetTiForUDT(
  843. PMODULE_ENTRY ModuleEntry,
  844. LPSTR name,
  845. PSYMBOL_INFO psi
  846. );
  847. BOOL
  848. diaEnumUDT(
  849. PMODULE_ENTRY ModuleEntry,
  850. LPSTR name,
  851. PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  852. PVOID EnumContext
  853. );
  854. BOOL
  855. diaGetFrameData(
  856. IN HANDLE Process,
  857. IN ULONGLONG Offset,
  858. OUT interface IDiaFrameData** FrameData
  859. );
  860. DWORD
  861. mdSet(
  862. PMODULE_DATA md,
  863. DWORD id,
  864. DWORD hint,
  865. DWORD src
  866. );
  867. BOOL
  868. InitOutputString(
  869. PCHAR sz
  870. );
  871. BOOL
  872. TestOutputString(
  873. PCHAR sz
  874. );
  875. #ifdef __cpluspluss
  876. }
  877. #endif