Changeset 2855 for trunk/kLdr/kLdr.h
- Timestamp:
- Nov 4, 2006, 3:30:19 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/kLdr.h
r2854 r2855 281 281 /** @defgroup grp_kLdrMod kLdrMod - The executable image intepreter 282 282 * @{ */ 283 284 285 /**286 * Debug info type (from the loader point of view).287 */288 typedef enum KLDRDBGINFOTYPE289 {290 /** The usual invalid enum value. */291 KLDRDBGINFOTYPE_INVALID = 0,292 /** Stabs. */293 KLDRDBGINFOTYPE_STABS,294 /** Debug With Arbitrary Record Format (DWARF). */295 KLDRDBGINFOTYPE_DWARF,296 /** Microsoft Codeview debug info. */297 KLDRDBGINFOTYPE_CODEVIEW,298 /** Watcom debug info. */299 KLDRDBGINFOTYPE_WATCOM,300 /** IBM High Level Language debug info.. */301 KLDRDBGINFOTYPE_HLL,302 /** The end of the valid debug info values (exclusive). */303 KLDRDBGINFOTYPE_END,304 /** Blow the type up to 32-bit. */305 KLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff306 } KLDRDBGINFOTYPE;307 /** Pointer to a kLdr debug info type. */308 typedef KLDRDBGINFOTYPE *PKLDRDBGINFOTYPE;309 310 311 /**312 * Stack information.313 */314 typedef struct KLDRSTACKINFO315 {316 /** The base address of the stack (sub) segment.317 * Set this to NIL_KLDRADDR if the module doesn't include any stack segment. */318 KLDRADDR Address;319 /** The base address of the stack (sub) segment, link address.320 * Set this to NIL_KLDRADDR if the module doesn't include any stack (sub)segment. */321 KLDRADDR LinkAddress;322 /** The stack size of the main thread.323 * If no stack (sub)segment in the module, this is the stack size of the main thread.324 * If the module doesn't contain this kind of information this field will be set to 0. */325 KLDRSIZE cbStack;326 /** The stack size of non-main threads.327 * If the module doesn't contain this kind of information this field will be set to 0. */328 KLDRSIZE cbStackThread;329 } KLDRSTACKINFO;330 /** Pointer to stack information. */331 typedef KLDRSTACKINFO *PKLDRSTACKINFO;332 /** Pointer to const stack information. */333 typedef const KLDRSTACKINFO *PCKLDRSTACKINFO;334 335 336 /**337 * Loader segment.338 */339 typedef struct KLDRSEG340 {341 /** Variable free to use for the kLdr user. */342 void *pvUser;343 /** The segment name. (Might not be zero terminated!) */344 const char *pchName;345 /** The length of the segment name. */346 uint32_t cchName;347 /** The size of the segment. */348 KLDRSIZE cb;349 /** The required segment alignment. */350 KLDRADDR Alignment;351 /** The link address.352 * Set to NIL_KLDRADDR if the segment isn't supposed to be mapped. */353 KLDRADDR LinkAddress;354 /** The address the segment was mapped at by kLdrModMap().355 * Set to NIL_KLDRADDR if not mapped. */356 KLDRADDR MapAddress;357 /** The segment protection. */358 KLDRPROT enmProt;359 } KLDRSEG;360 /** Pointer to a loader segment. */361 typedef KLDRSEG *PKLDRSEG;362 /** Pointer to a loader segment. */363 typedef const KLDRSEG *PCKLDRSEG;364 365 366 /**367 * Loader module format.368 */369 typedef enum KLDRFMT370 {371 /** The usual invalid 0 format. */372 KLDRFMT_INVALID = 0,373 /** The native OS loader. */374 KLDRFMT_NATIVE,375 /** The AOUT loader. */376 KLDRFMT_AOUT,377 /** The ELF loader. */378 KLDRFMT_ELF,379 /** The LX loader. */380 KLDRFMT_LX,381 /** The mach-o loader. */382 KLDRFMT_MACHO,383 /** The LX loader. */384 KLDRFMT_PE,385 /** The end of the valid format values (exclusive). */386 KLDRFMT_END,387 /** Hack to blow the type up to 32-bit. */388 KLDRFMT_32BIT_HACK = 0x7fffffff389 } KLDRFMT;390 391 392 /**393 * Loader module type.394 */395 typedef enum KLDRTYPE396 {397 /** The usual invalid 0 type. */398 KLDRTYPE_INVALID = 0,399 /** Object file. */400 KLDRTYPE_OBJECT,401 /** Executable module, fixed load address. */402 KLDRTYPE_EXECUTABLE_FIXED,403 /** Executable module, relocatable, non-fixed load address. */404 KLDRTYPE_EXECUTABLE_RELOCATABLE,405 /** Executable module, position independent code, non-fixed load address. */406 KLDRTYPE_EXECUTABLE_PIC,407 /** Shared library, fixed load address.408 * Typically a system library. */409 KLDRTYPE_SHARED_LIBRARY_FIXED,410 /** Shared library, relocatable, non-fixed load address. */411 KLDRTYPE_SHARED_LIBRARY_RELOCATABLE,412 /** Shared library, position independent code, non-fixed load address. */413 KLDRTYPE_SHARED_LIBRARY_PIC,414 /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */415 KLDRTYPE_FORWARDER_DLL,416 /** Core or dump. */417 KLDRTYPE_CORE,418 /** The end of the valid types values (exclusive). */419 KLDRTYPE_END,420 /** Hack to blow the type up to 32-bit. */421 KLDRTYPE_32BIT_HACK = 0x7fffffff422 } KLDRTYPE;423 424 283 425 284 /** … … 464 323 KLDRARCH_32BIT_HACK = 0x7fffffff 465 324 } KLDRARCH; 466 325 /** Pointer to a CPU architecture type. */ 326 typedef KLDRARCH *PKLDRARCH; 467 327 468 328 /** … … 484 344 KLDRCPU_I586_16, 485 345 KLDRCPU_I686_16, 346 KLDRCPU_P4_16, 347 KLDRCPU_CORE2_16, 486 348 KLDRCPU_K6_16, 487 349 KLDRCPU_K7_16, 488 350 KLDRCPU_K8_16, 351 KLDRCPU_FIRST_X86_16 = KLDRCPU_I8086, 352 KLDRCPU_LAST_X86_16 = KLDRCPU_K8_16, 489 353 /** @} */ 490 354 491 355 /** @name KLDRARCH_X86_32 492 356 * @{ */ 357 KLDRCPU_X86_32_BLEND, 493 358 KLDRCPU_I386, 494 359 KLDRCPU_I486, … … 501 366 KLDRCPU_K7, 502 367 KLDRCPU_K8_32, 368 KLDRCPU_FIRST_X86_32 = KLDRCPU_I386, 369 KLDRCPU_LAST_X86_32 = KLDRCPU_K8_32, 503 370 /** @} */ 504 371 505 372 /** @name KLDRARCH_AMD64 506 373 * @{ */ 374 KLDRCPU_AMD64_BLEND, 507 375 KLDRCPU_K8, 508 376 KLDRCPU_P4_64, 509 377 KLDRCPU_CORE2, 378 KLDRCPU_FIRST_AMD64 = KLDRCPU_K8, 379 KLDRCPU_LAST_AMD64 = KLDRCPU_CORE2, 510 380 /** @} */ 511 381 … … 515 385 KLDRCPU_32BIT_HACK = 0x7fffffff 516 386 } KLDRCPU; 387 /** Pointer to a CPU type. */ 388 typedef KLDRCPU *PKLDRCPU; 389 390 void kLdrGetArchCpu(PKLDRARCH penmArch, PKLDRCPU penmCpu); 391 int kLdrCompareCpus(KLDRARCH enmCodeArch, KLDRCPU enmCodeCpu, KLDRARCH enmArch, KLDRCPU enmCpu); 392 393 394 /** 395 * Debug info type (from the loader point of view). 396 */ 397 typedef enum KLDRDBGINFOTYPE 398 { 399 /** The usual invalid enum value. */ 400 KLDRDBGINFOTYPE_INVALID = 0, 401 /** Stabs. */ 402 KLDRDBGINFOTYPE_STABS, 403 /** Debug With Arbitrary Record Format (DWARF). */ 404 KLDRDBGINFOTYPE_DWARF, 405 /** Microsoft Codeview debug info. */ 406 KLDRDBGINFOTYPE_CODEVIEW, 407 /** Watcom debug info. */ 408 KLDRDBGINFOTYPE_WATCOM, 409 /** IBM High Level Language debug info.. */ 410 KLDRDBGINFOTYPE_HLL, 411 /** The end of the valid debug info values (exclusive). */ 412 KLDRDBGINFOTYPE_END, 413 /** Blow the type up to 32-bit. */ 414 KLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff 415 } KLDRDBGINFOTYPE; 416 /** Pointer to a kLdr debug info type. */ 417 typedef KLDRDBGINFOTYPE *PKLDRDBGINFOTYPE; 418 419 420 /** 421 * Stack information. 422 */ 423 typedef struct KLDRSTACKINFO 424 { 425 /** The base address of the stack (sub) segment. 426 * Set this to NIL_KLDRADDR if the module doesn't include any stack segment. */ 427 KLDRADDR Address; 428 /** The base address of the stack (sub) segment, link address. 429 * Set this to NIL_KLDRADDR if the module doesn't include any stack (sub)segment. */ 430 KLDRADDR LinkAddress; 431 /** The stack size of the main thread. 432 * If no stack (sub)segment in the module, this is the stack size of the main thread. 433 * If the module doesn't contain this kind of information this field will be set to 0. */ 434 KLDRSIZE cbStack; 435 /** The stack size of non-main threads. 436 * If the module doesn't contain this kind of information this field will be set to 0. */ 437 KLDRSIZE cbStackThread; 438 } KLDRSTACKINFO; 439 /** Pointer to stack information. */ 440 typedef KLDRSTACKINFO *PKLDRSTACKINFO; 441 /** Pointer to const stack information. */ 442 typedef const KLDRSTACKINFO *PCKLDRSTACKINFO; 443 444 445 /** 446 * Loader segment. 447 */ 448 typedef struct KLDRSEG 449 { 450 /** Variable free to use for the kLdr user. */ 451 void *pvUser; 452 /** The segment name. (Might not be zero terminated!) */ 453 const char *pchName; 454 /** The length of the segment name. */ 455 uint32_t cchName; 456 /** The size of the segment. */ 457 KLDRSIZE cb; 458 /** The required segment alignment. */ 459 KLDRADDR Alignment; 460 /** The link address. 461 * Set to NIL_KLDRADDR if the segment isn't supposed to be mapped. */ 462 KLDRADDR LinkAddress; 463 /** The address the segment was mapped at by kLdrModMap(). 464 * Set to NIL_KLDRADDR if not mapped. */ 465 KLDRADDR MapAddress; 466 /** The segment protection. */ 467 KLDRPROT enmProt; 468 } KLDRSEG; 469 /** Pointer to a loader segment. */ 470 typedef KLDRSEG *PKLDRSEG; 471 /** Pointer to a loader segment. */ 472 typedef const KLDRSEG *PCKLDRSEG; 473 474 475 /** 476 * Loader module format. 477 */ 478 typedef enum KLDRFMT 479 { 480 /** The usual invalid 0 format. */ 481 KLDRFMT_INVALID = 0, 482 /** The native OS loader. */ 483 KLDRFMT_NATIVE, 484 /** The AOUT loader. */ 485 KLDRFMT_AOUT, 486 /** The ELF loader. */ 487 KLDRFMT_ELF, 488 /** The LX loader. */ 489 KLDRFMT_LX, 490 /** The mach-o loader. */ 491 KLDRFMT_MACHO, 492 /** The LX loader. */ 493 KLDRFMT_PE, 494 /** The end of the valid format values (exclusive). */ 495 KLDRFMT_END, 496 /** Hack to blow the type up to 32-bit. */ 497 KLDRFMT_32BIT_HACK = 0x7fffffff 498 } KLDRFMT; 499 500 501 /** 502 * Loader module type. 503 */ 504 typedef enum KLDRTYPE 505 { 506 /** The usual invalid 0 type. */ 507 KLDRTYPE_INVALID = 0, 508 /** Object file. */ 509 KLDRTYPE_OBJECT, 510 /** Executable module, fixed load address. */ 511 KLDRTYPE_EXECUTABLE_FIXED, 512 /** Executable module, relocatable, non-fixed load address. */ 513 KLDRTYPE_EXECUTABLE_RELOCATABLE, 514 /** Executable module, position independent code, non-fixed load address. */ 515 KLDRTYPE_EXECUTABLE_PIC, 516 /** Shared library, fixed load address. 517 * Typically a system library. */ 518 KLDRTYPE_SHARED_LIBRARY_FIXED, 519 /** Shared library, relocatable, non-fixed load address. */ 520 KLDRTYPE_SHARED_LIBRARY_RELOCATABLE, 521 /** Shared library, position independent code, non-fixed load address. */ 522 KLDRTYPE_SHARED_LIBRARY_PIC, 523 /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */ 524 KLDRTYPE_FORWARDER_DLL, 525 /** Core or dump. */ 526 KLDRTYPE_CORE, 527 /** The end of the valid types values (exclusive). */ 528 KLDRTYPE_END, 529 /** Hack to blow the type up to 32-bit. */ 530 KLDRTYPE_32BIT_HACK = 0x7fffffff 531 } KLDRTYPE; 517 532 518 533 … … 704 719 int kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, 705 720 uint32_t fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 706 int kLdrModGetImport(PKLDRMOD pMod, void *pvBits, uint32_t iImport, constchar *pszName, size_t cchName);707 int32_t kLdrModNumberOfImports(PKLDRMOD pMod, void *pvBits);708 int kLdrModCanExecuteOn(PKLDRMOD pMod, void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);709 int kLdrModGetStackInfo(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);710 int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);721 int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName); 722 int32_t kLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits); 723 int kLdrModCanExecuteOn(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu); 724 int kLdrModGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo); 725 int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 711 726 /** Pointer to a debug info enumberator callback. */ 712 727 typedef FNKLDRENUMDBG *PFNKLDRENUMDBG; 713 int kLdrModEnumDbgInfo(PKLDRMOD pMod, void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);714 int kLdrModHasDbgInfo(PKLDRMOD pMod, void *pvBits);728 int kLdrModEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser); 729 int kLdrModHasDbgInfo(PKLDRMOD pMod, const void *pvBits); 715 730 716 731 /** @name Operations On The Internally Managed Mapping … … 777 792 PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 778 793 /** @copydoc kLdrModGetImport */ 779 int (* pfnGetImport)(PKLDRMOD pMod, void *pvBits, uint32_t iImport, constchar *pszName, size_t cchName);794 int (* pfnGetImport)(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName); 780 795 /** @copydoc kLdrModNumberOfImports */ 781 int32_t (* pfnNumberOfImports)(PKLDRMOD pMod, void *pvBits);796 int32_t (* pfnNumberOfImports)(PKLDRMOD pMod, const void *pvBits); 782 797 /** @copydoc kLdrModCanExecuteOn */ 783 int (* pfnCanExecuteOn)(PKLDRMOD pMod, void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);798 int (* pfnCanExecuteOn)(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu); 784 799 /** @copydoc kLdrModGetStackInfo */ 785 int (* pfnGetStackInfo)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);800 int (* pfnGetStackInfo)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo); 786 801 /** @copydoc kLdrModQueryMainEntrypoint */ 787 int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);802 int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 788 803 /** @copydoc kLdrModEnumDbgInfo */ 789 int (* pfnEnumDbgInfo)(PKLDRMOD pMod, void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);804 int (* pfnEnumDbgInfo)(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser); 790 805 /** @copydoc kLdrModHasDbgInfo */ 791 int (* pfnHasDbgInfo)(PKLDRMOD pMod, void *pvBits);806 int (* pfnHasDbgInfo)(PKLDRMOD pMod, const void *pvBits); 792 807 /** @copydoc kLdrModMap */ 793 808 int (* pfnMap)(PKLDRMOD pMod); … … 1033 1048 /** A memory allocation failed. */ 1034 1049 #define KLDR_ERR_NO_MEMORY (KLDR_ERR_BASE + 49) 1035 1050 /** The import ordinal was out of bounds. */ 1051 #define KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS (KLDR_ERR_BASE + 50) 1052 /** A forwarder chain was too long. */ 1053 #define KLDR_ERR_TOO_LONG_FORWARDER_CHAIN (KLDR_ERR_BASE + 51) 1036 1054 1037 1055 /** @name kLdrModPE status codes
Note:
See TracChangeset
for help on using the changeset viewer.