331
344
#define RTLDR_ENUM_SYMBOL_FLAGS_ALL RT_BIT(1)
349
* Debug info type (as far the loader can tell).
351
typedef enum RTLDRDBGINFOTYPE
353
/** The invalid 0 value. */
354
RTLDRDBGINFOTYPE_INVALID = 0,
355
/** Unknown debug info format. */
356
RTLDRDBGINFOTYPE_UNKNOWN,
358
RTLDRDBGINFOTYPE_STABS,
359
/** Debug With Arbitrary Record Format (DWARF). */
360
RTLDRDBGINFOTYPE_DWARF,
361
/** Microsoft Codeview debug info. */
362
RTLDRDBGINFOTYPE_CODEVIEW,
363
/** Watcom debug info. */
364
RTLDRDBGINFOTYPE_WATCOM,
365
/** IBM High Level Language debug info.. */
366
RTLDRDBGINFOTYPE_HLL,
367
/** The end of the valid debug info values (exclusive). */
368
RTLDRDBGINFOTYPE_END,
369
/** Blow the type up to 32-bits. */
370
RTLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff
374
* Debug info enumerator callback.
376
* @returns VINF_SUCCESS to continue the enumeration. Any other status code
377
* will cause RTLdrEnumDbgInfo to immediately return with that status.
379
* @param hLdrMod The module handle.
380
* @param iDbgInfo The debug info ordinal number / id.
381
* @param enmType The debug info type.
382
* @param iMajorVer The major version number of the debug info format.
383
* -1 if unknow - implies invalid iMinorVer.
384
* @param iMinorVer The minor version number of the debug info format.
385
* -1 when iMajorVer is -1.
386
* @param pszPartNm The name of the debug info part, NULL if not
388
* @param offFile The file offset *if* this type has one specific
389
* location in the executable image file. This is -1
390
* if there isn't any specific file location.
391
* @param LinkAddress The link address of the debug info if it's
392
* loadable. NIL_RTLDRADDR if not loadable.
393
* @param cb The size of the debug information. -1 is used if
394
* this isn't applicable.
395
* @param pszExtFile This points to the name of an external file
396
* containing the debug info. This is NULL if there
397
* isn't any external file.
398
* @param pvUser The user parameter specified to RTLdrEnumDbgInfo.
400
typedef DECLCALLBACK(int) FNRTLDRENUMDBG(RTLDRMOD hLdrMod, uint32_t iDbgInfo, RTLDRDBGINFOTYPE enmType,
401
uint16_t iMajorVer, uint16_t iMinorVer, const char *pszPartNm,
402
RTFOFF offFile, RTLDRADDR LinkAddress, RTLDRADDR cb,
403
const char *pszExtFile, void *pvUser);
404
/** Pointer to a debug info enumerator callback. */
405
typedef FNRTLDRENUMDBG *PFNRTLDRENUMDBG;
408
* Enumerate the debug info contained in the executable image.
410
* @returns IPRT status code or whatever pfnCallback returns.
412
* @param hLdrMod The module handle.
413
* @param pvBits Optional pointer to bits returned by
414
* RTLdrGetBits(). This can be used by some module
415
* interpreters to reduce memory consumption.
416
* @param pfnCallback The callback function.
417
* @param pvUser The user argument.
419
RTDECL(int) RTLdrEnumDbgInfo(RTLDRMOD hLdrMod, const void *pvBits, PFNRTLDRENUMDBG pfnCallback, void *pvUser);
425
typedef struct RTLDRSEG
427
/** The segment name. (Might not be zero terminated!) */
429
/** The length of the segment name. */
431
/** The flat selector to use for the segment (i.e. data/code).
432
* Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
434
/** The 16-bit selector to use for the segment.
435
* Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
437
/** Segment flags. */
439
/** The segment protection (RTMEM_PROT_XXX). */
441
/** The size of the segment. */
443
/** The required segment alignment.
444
* The to 0 if the segment isn't supposed to be mapped. */
446
/** The link address.
447
* Set to NIL_RTLDRADDR if the segment isn't supposed to be mapped or if
448
* the image doesn't have link addresses. */
449
RTLDRADDR LinkAddress;
450
/** File offset of the segment.
451
* Set to -1 if no file backing (like BSS). */
453
/** Size of the file bits of the segment.
454
* Set to -1 if no file backing (like BSS). */
456
/** The relative virtual address when mapped.
457
* Set to NIL_RTLDRADDR if the segment isn't supposed to be mapped. */
459
/** The size of the segment including the alignment gap up to the next segment when mapped.
460
* This is set to NIL_RTLDRADDR if not implemented. */
463
/** Pointer to a loader segment. */
464
typedef RTLDRSEG *PRTLDRSEG;
465
/** Pointer to a read only loader segment. */
466
typedef RTLDRSEG const *PCRTLDRSEG;
469
/** @name Segment flags
471
/** The segment is 16-bit. When not set the default of the target architecture is assumed. */
472
#define RTLDRSEG_FLAG_16BIT UINT32_C(1)
473
/** The segment requires a 16-bit selector alias. (OS/2) */
474
#define RTLDRSEG_FLAG_OS2_ALIAS16 UINT32_C(2)
475
/** Conforming segment (x86 weirdness). (OS/2) */
476
#define RTLDRSEG_FLAG_OS2_CONFORM UINT32_C(4)
477
/** IOPL (ring-2) segment. (OS/2) */
478
#define RTLDRSEG_FLAG_OS2_IOPL UINT32_C(8)
482
* Segment enumerator callback.
484
* @returns VINF_SUCCESS to continue the enumeration. Any other status code
485
* will cause RTLdrEnumSegments to immediately return with that
488
* @param hLdrMod The module handle.
489
* @param pSeg The segment information.
490
* @param pvUser The user parameter specified to RTLdrEnumSegments.
492
typedef DECLCALLBACK(int) FNRTLDRENUMSEGS(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser);
493
/** Pointer to a segment enumerator callback. */
494
typedef FNRTLDRENUMSEGS *PFNRTLDRENUMSEGS;
497
* Enumerate the debug info contained in the executable image.
499
* @returns IPRT status code or whatever pfnCallback returns.
501
* @param hLdrMod The module handle.
502
* @param pfnCallback The callback function.
503
* @param pvUser The user argument.
505
RTDECL(int) RTLdrEnumSegments(RTLDRMOD hLdrMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser);
508
* Converts a link address to a segment:offset address.
510
* @returns IPRT status code.
512
* @param hLdrMod The module handle.
513
* @param LinkAddress The link address to convert.
514
* @param piSeg Where to return the segment index.
515
* @param poffSeg Where to return the segment offset.
517
RTDECL(int) RTLdrLinkAddressToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, uint32_t *piSeg, PRTLDRADDR poffSeg);
520
* Converts a link address to an image relative virtual address (RVA).
522
* @returns IPRT status code.
524
* @param hLdrMod The module handle.
525
* @param LinkAddress The link address to convert.
526
* @param pRva Where to return the RVA.
528
RTDECL(int) RTLdrLinkAddressToRva(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva);
531
* Converts an image relative virtual address (RVA) to a segment:offset.
533
* @returns IPRT status code.
535
* @param hLdrMod The module handle.
536
* @param Rva The link address to convert.
537
* @param piSeg Where to return the segment index.
538
* @param poffSeg Where to return the segment offset.
540
RTDECL(int) RTLdrSegOffsetToRva(RTLDRMOD hLdrMod, uint32_t iSeg, RTLDRADDR offSeg, PRTLDRADDR pRva);
543
* Converts a segment:offset into an image relative virtual address (RVA).
545
* @returns IPRT status code.
547
* @param hLdrMod The module handle.
548
* @param iSeg The segment index.
549
* @param offSeg The segment offset.
550
* @param pRva Where to return the RVA.
552
RTDECL(int) RTLdrRvaToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg);