Changeset 2848 for trunk/kLdr/kLdr.h
- Timestamp:
- Nov 2, 2006, 1:08:16 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/kLdr.h
r2847 r2848 53 53 /** @defgroup grp_kLdrRdr kLdrRdr - The file provider 54 54 * @{ */ 55 56 /** The kLdr address type. */ 57 typedef uint64_t KLDRADDR; 58 /** Pointer to a kLdr address. */ 59 typedef KLDRADDR *PKLDRADDR; 60 /** Pointer to a const kLdr address. */ 61 typedef const KLDRADDR *PCKLDRADDR; 62 63 /** NIL address. */ 64 #define NIL_KLDRADDR (~(uint64_t)0) 65 66 /** The kLdr size type. */ 67 typedef uint64_t KLDRSIZE; 68 /** Pointer to a kLdr size. */ 69 typedef KLDRSIZE *PKLDRSIZE; 70 /** Pointer to a const kLdr size. */ 71 typedef const KLDRSIZE *PCKLDRSIZE; 72 73 55 74 56 75 /** … … 268 287 typedef struct KLDRSTACKINFO 269 288 { 289 /** The base address of the stack (sub) segment. 290 * Set this to NIL_KLDRADDR if the module doesn't include any stack segment. */ 291 KLDRADDR Address; 270 292 /** The base address of the stack (sub) segment, link address. 271 * Set this to ~(uintmax_t)0 if the module doesn't include any stack (sub)segment. */ 272 uintmax_t uLinkAddress; 273 /** The base address of the stack (sub) segment, actual load address. 274 * Set this to ~(uintmax_t)0 if the module doesn't include any stack (sub)segment or if 275 * the module isn't mapped (loaded) yet. */ 276 uintmax_t uLoadAddress; 293 * Set this to NIL_KLDRADDR if the module doesn't include any stack (sub)segment. */ 294 KLDRADDR LinkAddress; 277 295 /** The stack size of the main thread. 278 296 * If no stack (sub)segment in the module, this is the stack size of the main thread. 279 297 * If the module doesn't contain this kind of information this field will be set to 0. */ 280 uintmax_tcbStack;298 KLDRSIZE cbStack; 281 299 /** The stack size of non-main threads. 282 300 * If the module doesn't contain this kind of information this field will be set to 0. */ 283 uintmax_t cbStackThread; 284 } KLDRSTACKINFO, *PKLDRSTACKINFO; 301 KLDRSIZE cbStackThread; 302 } KLDRSTACKINFO; 303 /** Pointer to stack information. */ 304 typedef KLDRSTACKINFO *PKLDRSTACKINFO; 305 /** Pointer to const stack information. */ 306 typedef const KLDRSTACKINFO *PCKLDRSTACKINFO; 285 307 286 308 … … 295 317 const char *pszName; 296 318 /** The size of the segment. */ 297 uintmax_tcb;319 KLDRSIZE cb; 298 320 /** The link time load address. */ 299 uintmax_t LinkAddress; 300 /** The actual load address (if loaded). */ 301 uintmax_t LoadAddress; 321 KLDRADDR LinkAddress; 322 /** The address the segment was mapped at by kLdrModMap(). 323 * Set to NIL_KLDRADDR if not mapped. */ 324 KLDRADDR MapAddress; 302 325 /** The segment protection. */ 303 326 KLDRPROT enmProt; 304 } KLDRSEG, *PKLDRSEG; 327 } KLDRSEG; 328 /** Pointer to a loader segment. */ 329 typedef KLDRSEG *PKLDRSEG; 330 /** Pointer to a loader segment. */ 331 typedef const KLDRSEG *PCKLDRSEG; 305 332 306 333 … … 513 540 514 541 /** Special base address value alias for the link address. */ 515 #define KLDRMOD_BASEADDRESS_LINK (~( uintmax_t)1)542 #define KLDRMOD_BASEADDRESS_LINK (~(KLDRADDR)1) 516 543 /** Special base address value alias for the actual load address (must be mapped). */ 517 #define KLDRMOD_BASEADDRESS_MAP (~(uintmax_t)2) 544 #define KLDRMOD_BASEADDRESS_MAP (~(KLDRADDR)2) 545 546 /** Special import module ordinal value used to indicate that there is no 547 * specific module associated with the requested symbol. */ 548 #define NIL_KLDRMOD_IMPORT (~(uint32_t)0) 549 550 /** Special symbol ordinal value used to indicate that the symbol 551 * only has a string name. */ 552 #define NIL_KLDRMOD_SYM_ORDINAL (~(uint32_t)0) 553 518 554 519 555 /** @name Load symbol kind flags. 520 556 * @{ */ 521 557 /** The bitness doesn't matter. */ 522 #define KLDRSYMKIND_NO_BIT 0x00000000558 #define KLDRSYMKIND_NO_BIT 0x00000000 523 559 /** 16-bit symbol. */ 524 #define KLDRSYMKIND_16BIT 0x00000001560 #define KLDRSYMKIND_16BIT 0x00000001 525 561 /** 32-bit symbol. */ 526 #define KLDRSYMKIND_32BIT 0x00000002562 #define KLDRSYMKIND_32BIT 0x00000002 527 563 /** 64-bit symbol. */ 528 #define KLDRSYMKIND_64BIT 0x00000003564 #define KLDRSYMKIND_64BIT 0x00000003 529 565 /** Mask out the bit.*/ 530 #define KLDRSYMKIND_BIT_MASK 0x00000003566 #define KLDRSYMKIND_BIT_MASK 0x00000003 531 567 /** We don't know the type of symbol. */ 532 #define KLDRSYMKIND_NO_TYPE 0x00000000568 #define KLDRSYMKIND_NO_TYPE 0x00000000 533 569 /** The symbol is a code object (method/function/procedure/whateveryouwannacallit). */ 534 #define KLDRSYMKIND_CODE 0x00000010570 #define KLDRSYMKIND_CODE 0x00000010 535 571 /** The symbol is a data object. */ 536 #define KLDRSYMKIND_DATA 0x00000020572 #define KLDRSYMKIND_DATA 0x00000020 537 573 /** Mask out the symbol type. */ 538 #define KLDRSYMKIND_TYPE_MASK 0x00000030574 #define KLDRSYMKIND_TYPE_MASK 0x00000030 539 575 /** Valid symbol kind mask. */ 540 #define KLDRSYMKIND_MASK 0x00000033576 #define KLDRSYMKIND_MASK 0x00000033 541 577 /** @} */ 542 578 … … 544 580 * @{ */ 545 581 /** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */ 546 #define KLDRMOD_ENUM_SYMBOL_FLAGS_ALL 0x00000001 547 /** @} */ 548 549 550 typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, const char *pszModule, const char *pszSymbol, uint32_t uSymbol, 551 uintmax_t *pValue, uint32_t *pfKind, void *pvModuleUser, void *pvUser); 582 #define KLDRMOD_ENUM_SYMS_FLAGS_ALL 0x00000001 583 /** @} */ 584 585 586 /** 587 * Callback for resolving imported symbols when applying fixups. 588 * 589 * @returns 0 on success and *pValue and *pfKind filled. 590 * @returns Non-zero OS specific or kLdr status code on failure. 591 * 592 * @param pMod The module which fixups are begin applied. 593 * @param iImport The import module ordinal number or NIL_KLDRMOD_IMPORT. 594 * @param uSymbol The symbol ordinal number or NIL_KLDRMOD_SYM_ORDINAL. 595 * @param pszSymbol The symbol name. Can be NULL if uSymbol isn't nil. 596 * @param puValue Where to store the symbol value. 597 * @param pfKind Where to store the symbol kind flags. 598 * @param pvUser The user parameter specified to the relocation function. 599 */ 600 typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, uint32_t iImport, uint32_t uSymbol, const char *pszSymbol, 601 PKLDRADDR puValue, uint32_t *pfKind, void *pvUser); 602 /** Pointer to a import callback. */ 552 603 typedef FNKLDRMODGETIMPORT *PFNKLDRMODGETIMPORT; 553 typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, const char *pszSymbol, unsigned uSymbol, uintmax_t Value, uint32_t fKind, void *pvUser); 604 605 /** 606 * Symbol enumerator callback. 607 * 608 * @returns 0 if enumeration should continue. 609 * @returns non-zero if the enumeration should stop. This status code is the returned by kLdrModEnumSymbols(). 610 * 611 * @param pMod The module which symbols are being enumerated.s 612 * @param uSymbol The symbol ordinal number or NIL_KLDRMOD_SYM_ORDINAL. 613 * @param pszSymbol The symbol name. This can be NULL if there is a symbol ordinal. 614 * This can also be an empty string if the symbol doesn't have a name 615 * or it's name has been stripped. 616 * @param uValue The symbol value. 617 * @param fKind The symbol kind flags. 618 * @param pvUser The user parameter specified to kLdrModEnumSymbols(). 619 */ 620 typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, uint32_t uSymbol, const char *pszSymbol, 621 KLDRADDR uValue, uint32_t fKind, void *pvUser); 622 /** Pointer to a symbol enumerator callback. */ 554 623 typedef FNKLDRMODENUMSYMS *PFNKLDRMODENUMSYMS; 555 624 … … 558 627 int kLdrModOpenNative(const char *pszFilename, PPKLDRMOD ppMod); 559 628 int kLdrModClose(PKLDRMOD pMod); 560 int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, uintmax_t BaseAddress, const char *pszSymbol, uintmax_t *pValue, uint32_t *pfKind); 561 int kLdrModEnumSymbols(PKLDRMOD pMod, unsigned fFlags, const void *pvBits, uintmax_t BaseAddress, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 562 int kLdrModGetImport(PKLDRMOD pMod, uint32_t iImport, const char *pszName, size_t cchName); 563 int32_t kLdrModNumberOfImports(PKLDRMOD pMod); 629 630 int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t uSymbol, 631 const char *pszSymbol, PKLDRADDR puValue, uint32_t *pfKind); 632 int kLdrModEnumSymbols(PKLDRMOD pMod, uint32_t fFlags, const void *pvBits, KLDRADDR BaseAddress, 633 PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 634 int kLdrModGetImport(PKLDRMOD pMod, void *pvBits, uint32_t iImport, const char *pszName, size_t cchName); 635 int32_t kLdrModNumberOfImports(PKLDRMOD pMod, void *pvBits); 636 int kLdrModCanExecuteOn(PKLDRMOD pMod, void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu); 637 int kLdrModGetStackInfo(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo); 638 int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 639 size_t kLdrModSize(PKLDRMOD pMod); 640 641 /** @name Operations On The Internally Managed Mapping 642 * @{ */ 564 643 int kLdrModMap(PKLDRMOD pMod); 565 644 int kLdrModUnmap(PKLDRMOD pMod); 566 int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);567 size_t kLdrModSize(PKLDRMOD pMod);568 int kLdrModGetBits(PKLDRMOD pMod, void *pvBits, uintmax_t BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);569 int kLdrModRelocateBits(PKLDRMOD pMod, void *pvBits, uintmax_t NewBaseAddress, uintmax_t OldBaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);570 int kLdrModCanExecuteOn(PKLDRMOD pMod, KLDRARCH enmArch, KLDRCPU enmCpu);571 int kLdrModGetStackInfo(PKLDRMOD pMod, PKLDRSTACKINFO pStackInfo);572 int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, void *pvBits, uintmax_t uBaseAddress, uintmax_t *puValue);573 645 int kLdrModAllocTLS(PKLDRMOD pMod); 574 646 void kLdrModFreeTLS(PKLDRMOD pMod); 575 647 int kLdrModReload(PKLDRMOD pMod); 648 int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 576 649 int kLdrModCallInit(PKLDRMOD pMod); 577 650 int kLdrModCallTerm(PKLDRMOD pMod); 578 651 int kLdrModCallThread(PKLDRMOD pMod, unsigned fAttachingOrDetaching); 652 /** @} */ 653 654 /** @name Operations On The Externally Managed Mappings 655 * @{ */ 656 int kLdrModGetBits(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 657 int kLdrModRelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress, 658 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 659 /** @} */ 579 660 580 661 /** @} */ … … 781 862 /** Buffer overflow. */ 782 863 #define KLDR_ERR_BUFFER_OVERFLOW (KLDR_ERR_BASE + 45) 864 /** The specified ARCH+CPU isn't compatible with image. */ 865 #define KLDR_ERR_ARCH_CPU_NOT_COMPATIBLE (KLDR_ERR_BASE + 45) 783 866 784 867 /** Encountered a bad fixup. */
Note:
See TracChangeset
for help on using the changeset viewer.