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.

477 lines
17 KiB

  1. // shapi.h - Public API to the Symbol Handler
  2. //
  3. // This file contains all types and APIs that are defined by
  4. // the Symbol Handler and are publicly accessible by other
  5. // components.
  6. //
  7. // Before including this file, you must include cvtypes.h.
  8. // The master copy of this file resides in the CVINC project.
  9. // All Microsoft projects are required to use the master copy without
  10. // modification. Modification of the master version or a copy
  11. // without consultation with all parties concerned is extremely
  12. // risky.
  13. #ifndef _VC_VER_INC
  14. #include "..\include\vcver.h"
  15. #endif
  16. #include <tchar.h>
  17. #ifndef SH_API
  18. #define SH_API
  19. #define DECL_STR(n, v, s) n = v,
  20. typedef enum { // Error returns from some SH functions
  21. #include "sherror.h"
  22. } SHE;
  23. #undef DECL_STR
  24. enum {
  25. sopNone = 0,
  26. sopData = 1,
  27. sopStack = 2,
  28. sopReg = 4,
  29. sopLab = 8,
  30. sopFcn = 16,
  31. sopExact = 32
  32. };
  33. typedef short SOP; // Symbol OPtions
  34. typedef enum {
  35. fstNone,
  36. fstSymbol,
  37. fstPublic
  38. } FST; // Function Symbol Type
  39. typedef enum {
  40. fcdUnknown,
  41. fcdNear,
  42. fcdFar,
  43. fcdData
  44. } FCD; // Function Call Distance (near/far/unknown)
  45. typedef enum {
  46. fptUnknown,
  47. fptPresent,
  48. fptOmitted
  49. } FPT; // Frame Pointer Type
  50. typedef struct _ODR {
  51. FST fst;
  52. FCD fcd;
  53. FPT fpt;
  54. WORD cbProlog;
  55. DWORD dwDeltaOff;
  56. LSZ lszName;
  57. } ODR; // OSDebug Return type
  58. typedef ODR *LPODR;
  59. typedef enum {
  60. astNone,
  61. astAddress,
  62. astRegister,
  63. astBaseOff
  64. } AST; // Assembler symbol return Types
  65. typedef struct _ASR {
  66. AST ast;
  67. union {
  68. struct {
  69. FCD fcd;
  70. ADDR addr;
  71. };
  72. WORD ireg;
  73. OFFSET off;
  74. };
  75. } ASR; // Assembler Symbol Return structure
  76. typedef ASR *LPASR;
  77. typedef HEMI SHEMI;
  78. typedef BOOL SHFLAG; // A TRUE/FALSE flag var
  79. typedef SHFLAG * PSHFLAG;
  80. typedef SEGMENT SHSEG; // A segment/selector value
  81. typedef UOFFSET SHOFF; // An offset value
  82. typedef void * HVOID; // Generic handle type
  83. typedef HIND HMOD; // A module handle
  84. typedef HIND HGRP; // A group handle (sub group of module
  85. // currently either a seg or filename)
  86. typedef HVOID HPROC; // A handle to a procedure
  87. typedef HVOID HBLK; // A handle to a block.
  88. typedef HVOID HSF; // A handle to source file table
  89. typedef HIND HEXE; // An Executable file handle
  90. typedef HVOID HTYPE; // A handle to a type
  91. typedef HVOID HSYM; // A handle to a symbol
  92. typedef HIND HPDS; // A handle to a process
  93. typedef HSYM * PHSYM;
  94. typedef CV_typ_t THIDX;
  95. typedef struct CXT {
  96. ADDR addr;
  97. HMOD hMod;
  98. HGRP hGrp;
  99. HPROC hProc;
  100. HBLK hBlk;
  101. } CXT; // General Symbol context pkt
  102. typedef CXT *PCXT;
  103. typedef struct CXF {
  104. CXT cxt;
  105. #if 0
  106. FRAME Frame;
  107. #else
  108. HFRAME hFrame;
  109. #endif
  110. } CXF; // Symbol context pkt locked to a frame ptr
  111. typedef CXF *PCXF;
  112. typedef enum {
  113. SHFar,
  114. SHNear
  115. } SHCALL;
  116. typedef struct SHREG {
  117. DWORD hReg;
  118. union {
  119. unsigned char Byte1;
  120. struct {
  121. unsigned short Byte2;
  122. unsigned short Byte2High;
  123. };
  124. struct {
  125. unsigned long Byte4;
  126. unsigned long Byte4High;
  127. };
  128. double Byte8;
  129. unsigned __int64 Byte8i;
  130. FLOAT10 Byte10;
  131. };
  132. } SHREG;
  133. typedef SHREG *PSHREG;
  134. typedef struct _SLP {
  135. ADDR addr;
  136. SHOFF cb;
  137. } SLP; // Source Line Pair (used by SLCAddrFromLine)
  138. typedef SLP * LPSLP;
  139. // structure defining parameters of symbol to be searched for. The address
  140. // of this structure is passed on the the EE's symbol compare routine. Any
  141. // additional data required by the EE's routine must follow this structure.
  142. typedef struct _SSTR { // string with length byte and pointer to data
  143. LPB lpName; // pointer to the string itself
  144. unsigned char cb; // length byte
  145. unsigned char searchmask; // mask to control symbol searching
  146. unsigned short symtype; // symbol types to be checked
  147. unsigned char * pRE; // pointer to regular expression
  148. } SSTR;
  149. typedef SSTR *LPSSTR;
  150. #define SSTR_proc 0x0001 // compare only procs with correct type
  151. #define SSTR_data 0x0002 // compare only global data with correct type
  152. #define SSTR_RE 0x0004 // compare using regular expression
  153. #define SSTR_NoHash 0x0008 // do a linear search of the table
  154. #define SSTR_symboltype 0x0010 // pass only symbols of symtype to the
  155. // comparison function.
  156. #define SSTR_FuzzyPublic 0x0020 // Ignore leading _, .. or trailing @xxx
  157. #define SHpCXTFrompCXF(a) (&((a)->cxt))
  158. //#define SHpFrameFrompCXF(a) (&(a)->Frame)
  159. #define SHhFrameFrompCXF(a) ((a)->hFrame)
  160. #define SHHMODFrompCXT(a) ((a)->hMod)
  161. #define SHHPROCFrompCXT(a) ((a)->hProc)
  162. #define SHHBLKFrompCXT(a) ((a)->hBlk)
  163. #define SHpADDRFrompCXT(a) (&((a)->addr))
  164. #define SHPAddrFromPCxf(a) (SHpADDRFrompCXT(SHpCXTFrompCXF(a)))
  165. #define SHIsCXTMod(a) ((a)->hMod && !(a)->hProc && !(a)->hBlk)
  166. #define SHIsCXTProc(a) ((a)->hMod && (a)->hProc && !(a)->hBlk)
  167. #define SHIsCXTBlk(a) ((a)->hMod && (a)->hProc && (a)->hBlk)
  168. #define SHHGRPFrompCXT(a) ((a)->hGrp)
  169. // Used by comparison functions
  170. //
  171. // Structure to cross-check validity of .dbg file
  172. // against the image.
  173. //
  174. // The values are returned to the caller so that the
  175. // caller can format the error message.
  176. typedef struct _VLDCHK {
  177. //
  178. // Values from image
  179. DWORD ImgTimeDateStamp;
  180. DWORD ImgCheckSum;
  181. //
  182. // Values from sym file
  183. DWORD SymTimeDateStamp;
  184. DWORD SymCheckSum;
  185. } VLDCHK;
  186. typedef VLDCHK *LPVLDCHK;
  187. typedef VLDCHK *PVLDCHK;
  188. // comparison prototype
  189. typedef SHFLAG (FAR PASCAL *PFNCMP) (HVOID, HVOID, LSZ, SHFLAG);
  190. typedef SHE (FAR PASCAL *PFNVALIDATEEXE) (INT, PVLDCHK);
  191. typedef BOOL (FAR PASCAL *PFNVALIDATEDEBUGINFOFILE) (LPCSTR szFile, ULONG * errcode );
  192. #define LPFNSYM WINAPI *
  193. #define LPFNSYMC CDECL *
  194. #if 0
  195. typedef struct omap_tag {
  196. DWORD rva;
  197. DWORD rvaTo;
  198. } OMAP, *POMAP, *LPOMAP;
  199. #else
  200. typedef POMAP LPOMAP;
  201. #endif
  202. typedef struct {
  203. DWORD Offset;
  204. DWORD Size;
  205. DWORD Flags;
  206. } SECSTART, *LPSECSTART;
  207. typedef struct _tagDEBUGDATA {
  208. union {
  209. PIMAGE_RUNTIME_FUNCTION_ENTRY lpRtf; // Runtime function table - fpo or pdata
  210. PFPO_DATA lpFpo;
  211. };
  212. DWORD cRtf; // Count of rtf entries
  213. PIMAGE_RUNTIME_FUNCTION_ENTRY lpOriginalRtf; // Original pdata address
  214. LPOMAP lpOmapFrom; // Omap table - From Source
  215. DWORD cOmapFrom; // Count of omap entries - From Source
  216. LPOMAP lpOmapTo; // Omap table - To Source
  217. DWORD cOmapTo; // Count of omap entries - To Source
  218. LPSECSTART lpSecStart; // Original section table (pre-Lego)
  219. // SHE she; // Remember any load errors
  220. } DEBUGDATA, *LPDEBUGDATA;
  221. #if 0
  222. // get rid of this for compatibility with pdb.h
  223. typedef struct _tagSEARCHDEBUGINFO {
  224. DWORD cb; // doubles as version detection
  225. BOOL fMainDebugFile; // indicates "core" or "ancilliary" file
  226. // eg: main.exe has main.pdb and foo.lib->foo.pdb
  227. LSZ szMod; // exe/dll
  228. LSZ szLib; // lib if appropriate
  229. LSZ szObj; // object file
  230. LSZ * rgszTriedThese; // list of ones that were tried,
  231. // NULL terminated list of LSZ's
  232. _TCHAR szValidatedFile[_MAX_PATH]; // output of validated filename,
  233. PFNVALIDATEDEBUGINFOFILE
  234. pfnValidateDebugInfoFile; // validation function
  235. } SEARCHDEBUGINFO, *PSEARCHDEBUGINFO;
  236. #endif
  237. typedef struct _KNF {
  238. int cb;
  239. PVOID (LPFNSYM lpfnMHAlloc) (UINT);
  240. PVOID (LPFNSYM lpfnMHRealloc) (PVOID, UINT);
  241. VOID (LPFNSYM lpfnMHFree) (PVOID);
  242. PVOID (LPFNSYM lpfnMHAllocHuge) (LONG, UINT);
  243. VOID (LPFNSYM lpfnMHFreeHuge) (PVOID);
  244. HDEP (LPFNSYM lpfnMMAllocHmem) (UINT);
  245. VOID (LPFNSYM lpfnMMFreeHmem) (HDEP);
  246. PVOID (LPFNSYM lpfnMMLock) (HDEP);
  247. VOID (LPFNSYM lpfnMMUnlock) (HDEP);
  248. HLLI (LPFNSYM lpfnLLInit) (DWORD, LLF, LPFNKILLNODE, LPFNFCMPNODE);
  249. HLLE (LPFNSYM lpfnLLCreate) (HLLI);
  250. VOID (LPFNSYM lpfnLLAdd) (HLLI, HLLE);
  251. VOID (LPFNSYM lpfnLLAddHead) (HLLI, HLLE);
  252. VOID (LPFNSYM lpfnLLInsert) (HLLI, HLLE, DWORD);
  253. BOOL (LPFNSYM lpfnLLDelete) (HLLI, HLLE);
  254. BOOL (LPFNSYM lpfnLLRemove) (HLLI, HLLE);
  255. DWORD (LPFNSYM lpfnLLDestroy) (HLLI);
  256. HLLE (LPFNSYM lpfnLLNext) (HLLI, HLLE);
  257. HLLE (LPFNSYM lpfnLLFind) (HLLI, HLLE, PVOID, DWORD);
  258. HLLE (LPFNSYM lpfnLLLast) (HLLI);
  259. DWORD (LPFNSYM lpfnLLSize) (HLLI);
  260. PVOID (LPFNSYM lpfnLLLock) (HLLE);
  261. VOID (LPFNSYM lpfnLLUnlock) (HLLE);
  262. BOOL (LPFNSYM lpfnLBPrintf) (LPCH, LPCH, DWORD);
  263. BOOL (LPFNSYM lpfnLBQuit) (DWORD);
  264. UINT (LPFNSYM lpfnSYOpen) (LSZ);
  265. VOID (LPFNSYM lpfnSYClose) (UINT);
  266. UINT (LPFNSYM lpfnSYReadFar) (UINT, LPB, UINT);
  267. LONG (LPFNSYM lpfnSYSeek) (UINT, LONG, UINT);
  268. int (LPFNSYM lpfnSYFixupAddr) (PADDR);
  269. int (LPFNSYM lpfnSYUnFixupAddr)(PADDR);
  270. UINT (LPFNSYM lpfnSYProcessor) (DWORD);
  271. // Added/Changed for NT merge.
  272. // VOID (LPFNSYM lpfn_searchenv) (LSZ, LSZ, LSZ);
  273. // UINT (LPFNSYMC lpfnsprintf) (LSZ, LSZ, ...);
  274. // VOID (LPFNSYM lpfn_splitpath) (LSZ, LSZ, LSZ, LSZ, LSZ);
  275. // LSZ (LPFNSYM lpfn_fullpath) (LSZ, LSZ, UINT);
  276. // VOID (LPFNSYM lpfn_makepath) (LSZ, LSZ, LSZ, LSZ, LSZ);
  277. // UINT (LPFNSYM lpfnstat) (LSZ, LPCH);
  278. LONG (LPFNSYM lpfnSYTell) (UINT);
  279. UINT (LPFNSYM lpfnSYFindExeFile) (LSZ, LSZ, UINT, PVLDCHK, PFNVALIDATEEXE, SHE *);
  280. VOID (LPFNSYM lpfnLoadedSymbols) (SHE, LSZ);
  281. BOOL (LPFNSYM lpfnSYGetDefaultShe) (LSZ, SHE *);
  282. // Added for separate type pool work
  283. BOOL (LPFNSYM pfnSYFindDebugInfoFile) ( PSEARCHDEBUGINFO );
  284. BOOL (WINAPI * lpfnGetRegistryRoot) ( LPTSTR, LPDWORD );
  285. #ifdef NT_BUILD_ONLY
  286. // Added for WinDbg back port
  287. BOOL (LPFNSYM lpfnSetProfileString)(LPCSTR, LPCSTR);
  288. BOOL (LPFNSYM lpfnGetProfileString)(LPCSTR, LPSTR, ULONG, ULONG *);
  289. #endif
  290. } KNF; // KerNel Functions exported to the Symbol Handler
  291. typedef KNF *LPKNF;
  292. typedef struct _SHF {
  293. int cb;
  294. HPDS (LPFNSYM pSHCreateProcess) (VOID);
  295. VOID (LPFNSYM pSHSetHpid) (HPID);
  296. BOOL (LPFNSYM pSHDeleteProcess) (HPDS);
  297. HPDS (LPFNSYM pSHChangeProcess) (HPDS);
  298. SHE (LPFNSYM pSHAddDll) (LSZ, BOOL); // Changed for NT
  299. SHE (LPFNSYM pSHAddDllsToProcess) (VOID);
  300. SHE (LPFNSYM pSHLoadDll) (LSZ, BOOL);
  301. VOID (LPFNSYM pSHUnloadDll) (HEXE);
  302. UOFFSET (LPFNSYM pSHGetDebugStart) (HSYM);
  303. LSZ (LPFNSYM pSHGetSymName) (HSYM, LSZ);
  304. BOOL (LPFNSYM pSHAddrFromHsym) (PADDR, HSYM); // Changed for NT
  305. HMOD (LPFNSYM pSHHModGetNextGlobal) (HEXE *, HMOD);
  306. int (LPFNSYM pSHModelFromAddr) (PADDR, LPW, LPB, UOFFSET *);
  307. int (LPFNSYM pSHPublicNameToAddr) (PADDR, PADDR, LSZ, PFNCMP);
  308. LSZ (LPFNSYM pSHGetSymbol) (LPADDR, LPADDR, SOP, LPODR);
  309. BOOL (LPFNSYM pSHGetPublicAddr) (PADDR, LSZ);
  310. BOOL (LPFNSYM pSHIsLabel) (HSYM);
  311. VOID (LPFNSYM pSHSetDebuggeeDir) (LSZ);
  312. // VOID (LPFNSYM pSHSetUserDir) (LSZ); // Deleted for NT
  313. BOOL (LPFNSYM pSHAddrToLabel) (PADDR, LSZ);
  314. int (LPFNSYM pSHGetSymLoc) (HSYM, LSZ, UINT, PCXT);
  315. BOOL (LPFNSYM pSHFIsAddrNonVirtual) (PADDR);
  316. BOOL (LPFNSYM pSHIsFarProc) (HSYM);
  317. HEXE (LPFNSYM pSHGetNextExe) (HEXE);
  318. HEXE (LPFNSYM pSHHexeFromHmod) (HMOD);
  319. HMOD (LPFNSYM pSHGetNextMod) (HEXE, HMOD);
  320. PCXT (LPFNSYM pSHGetCxtFromHmod) (HMOD, PCXT);
  321. PCXT (LPFNSYM pSHSetCxt) (PADDR, PCXT);
  322. PCXT (LPFNSYM pSHSetCxtMod) (PADDR, PCXT);
  323. HSYM (LPFNSYM pSHFindNameInGlobal) (HSYM,
  324. PCXT,
  325. LPSSTR,
  326. SHFLAG,
  327. PFNCMP,
  328. PCXT
  329. );
  330. HSYM (LPFNSYM pSHFindNameInContext) (HSYM,
  331. PCXT,
  332. LPSSTR,
  333. SHFLAG,
  334. PFNCMP,
  335. PCXT
  336. );
  337. HSYM (LPFNSYM pSHGoToParent) (PCXT, PCXT);
  338. HSYM (LPFNSYM pSHHsymFromPcxt) (PCXT);
  339. HSYM (LPFNSYM pSHNextHsym) (HMOD, HSYM);
  340. PCXF (LPFNSYM pSHGetFuncCXF) (PADDR, PCXF);
  341. LPCH (LPFNSYM pSHGetModName) (HMOD);
  342. LPCH (LPFNSYM pSHGetExeName) (HEXE);
  343. HEXE (LPFNSYM pSHGethExeFromName) (LPCH);
  344. UOFF32 (LPFNSYM pSHGetNearestHsym) (PADDR, HMOD, int, PHSYM);
  345. SHFLAG (LPFNSYM pSHIsInProlog) (PCXT);
  346. SHFLAG (LPFNSYM pSHIsAddrInCxt) (PCXT, PADDR);
  347. SHFLAG (LPFNSYM pSHCompareRE) (LPCH, LPCH, BOOL);
  348. BOOL (LPFNSYM pSHFindSymbol) (LSZ, PADDR, LPASR);
  349. UOFF32 (LPFNSYM pPHGetNearestHsym) (PADDR, HEXE, PHSYM);
  350. HSYM (LPFNSYM pPHFindNameInPublics) (HSYM, HEXE, LPSSTR, SHFLAG, PFNCMP);
  351. HTYPE (LPFNSYM pTHGetTypeFromIndex) (HMOD, THIDX);
  352. HTYPE (LPFNSYM pTHGetNextType) (HMOD, HTYPE);
  353. PVOID (LPFNSYM pSHLpGSNGetTable) (HEXE);
  354. BOOL (LPFNSYM pSHCanDisplay) (HSYM);
  355. // Source Line handler API Exports
  356. BOOL (LPFNSYM pSLLineFromAddr) (LPADDR, LPDWORD, SHOFF *, SHOFF *);
  357. BOOL (LPFNSYM pSLFLineToAddr) (HSF, DWORD, LPADDR, SHOFF *, DWORD *);
  358. LPCH (LPFNSYM pSLNameFromHsf) (HSF);
  359. LPCH (LPFNSYM pSLNameFromHmod) (HMOD, WORD);
  360. BOOL (LPFNSYM pSLFQueryModSrc) (HMOD);
  361. HMOD (LPFNSYM pSLHmodFromHsf) (HEXE, HSF);
  362. HSF (LPFNSYM pSLHsfFromPcxt) (PCXT);
  363. HSF (LPFNSYM pSLHsfFromFile) (HMOD, LSZ);
  364. int (LPFNSYM pSLCAddrFromLine) (HEXE, HMOD, LSZ, WORD, LPSLP *);
  365. VOID (LPFNSYM pSHFree) (PVOID);
  366. VOID (LPFNSYM pSHUnloadSymbolHandler)(BOOL);
  367. // REVIEW: piersh
  368. #ifdef NT_BUILD_ONLY
  369. SHE (LPFNSYM pSHGetExeTimeStamp) (LPSTR, ULONG *);
  370. #else
  371. SHE (LPFNSYM pSHGetExeTimeStamp) (LPSTR, ULONG* Time, ULONG* Check);
  372. #endif
  373. VOID (LPFNSYM pSHPdbNameFromExe) (LSZ, LSZ, UINT);
  374. LPVOID (LPFNSYM pSHGetDebugData) (HEXE);
  375. BOOL (LPFNSYM pSHIsThunk) (HSYM);
  376. HSYM (LPFNSYM pSHFindSymInExe) (HEXE, LPSSTR, BOOL);
  377. HSYM (LPFNSYM pSHFindSLink32) (PCXT);
  378. BOOL (LPFNSYM pSHIsDllLoaded) (HEXE);
  379. // Entries added for NT work.
  380. LSZ (LPFNSYM pSHGetModule) (PADDR, LSZ);
  381. PCXT (LPFNSYM pSHGetCxtFromHexe) (HEXE, PCXT);
  382. LPCH (LPFNSYM pSHGetModNameFromHexe) (HEXE);
  383. LPCH (LPFNSYM pSHGetSymFName) (HEXE);
  384. HEXE (LPFNSYM pSHGethExeFromModuleName) (LPCH);
  385. LSZ (LPFNSYM pSHLszGetErrorText) (SHE);
  386. BOOL (LPFNSYM pSHWantSymbols) (HEXE);
  387. HSYM (LPFNSYM pSHFindNameInTypes) ( PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT );
  388. // Entries added for separate type pools work
  389. BOOL (LPFNSYM pTHAreTypesEqual) (HMOD, CV_typ_t, CV_typ_t);
  390. // New work
  391. BOOL (LPFNSYM pSHSymbolsLoaded)(HEXE, SHE *);
  392. BOOL (LPFNSYM pSHSymbolsLoadError)(HEXE, SHE *);
  393. SHE (LPFNSYM pSHUnloadSymbols)(HEXE);
  394. } SHF; // Symbol Handler Functions
  395. typedef SHF *LPSHF;
  396. // FNSHINIT is the prototype for the SHInit function
  397. typedef BOOL EXPCALL FNSHINIT(LPSHF *, LPKNF);
  398. typedef FNSHINIT * LPFNSHINIT;
  399. typedef FNSHINIT * PFNSHINIT;
  400. typedef BOOL (* LPFNSHUNINIT)(VOID);
  401. typedef BOOL (* LPFNSHSTARTBACKGROUND)(VOID);
  402. typedef BOOL (* LPFNSHSTOPBACKGROUND)(VOID);
  403. // This is the only SH function that's actually exported from the DLL
  404. FNSHINIT SHInit;
  405. #endif // SH_API