Changeset 2851 for trunk/kLdr/kLdr.h


Ignore:
Timestamp:
Nov 2, 2006, 4:21:54 AM (19 years ago)
Author:
bird
Message:

kLdrMod done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdr.h

    r2850 r2851  
    532532
    533533
    534 /**
    535  * Loader module.
     534/** Pointer to a module interpreter method table. */
     535typedef struct KLDRMODOPS *PKLDRMODOPS;
     536/** Pointer to const module interpreter methods table. */
     537typedef const struct KLDRMODOPS *PCKLDRMODOPS;
     538
     539/**
     540 * Module interpreter instance.
     541 * All members are read only unless you're kLdrMod or the module interpreter.
    536542 */
    537543typedef struct KLDRMOD
     
    560566    /** The number of segments in the module. */
    561567    uint32_t            cSegments;
     568    /** Pointer to the loader methods.
     569     * Not meant for calling directly thru! */
     570    PCKLDRMODOPS        pOps;
    562571    /** The module data. */
    563572    void               *pvData;
     
    565574    KLDRSEG             aSegments[1];
    566575} KLDRMOD, *PKLDRMOD, **PPKLDRMOD;
     576
     577/** The magic for KLDRMOD::u32Magic. (Kosuke Fujishima) */
     578#define KLDRMOD_MAGIC   0x19640707
    567579
    568580
     
    712724                            PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
    713725/** @} */
     726
     727
     728/**
     729 * The loader module operation.
     730 */
     731typedef struct KLDRMODOPS
     732{
     733    /** The name of this module interpreter. */
     734    const char         *pszName;
     735    /** Pointer to the next module interpreter. */
     736    PCKLDRMODOPS        pNext;
     737
     738    /**
     739     * Create a loader module instance interpreting the executable image found
     740     * in the specified file provider instance.
     741     *
     742     * @returns 0 on success and *ppMod pointing to a module instance.
     743     *          On failure, a non-zero OS specific error code is returned.
     744     * @param   pOps            Pointer to the registered method table.
     745     * @param   pRdr            The file provider instance to use.
     746     * @param   offNewHdr       The offset of the new header in MZ files. -1 if not found.
     747     * @param   ppMod           Where to store the module instance pointer.
     748     */
     749    int (* pfnCreate)(PCKLDRMODOPS pOps, PKLDRRDR pRdr, off_t offNewHdr, PPKLDRMOD ppMod);
     750    /**
     751     * Destroys an loader module instance.
     752     *
     753     * The caller is responsible for calling kLdrModUnmap() and kLdrFreeTLS() first.
     754     *
     755     * @returns 0 on success, non-zero on failure. The module instance state
     756     *          is unknown on failure, it's best not to touch it.
     757     * @param   pMod    The module.
     758     */
     759    int (* pfnDestroy)(PKLDRMOD pMod);
     760
     761    /** @copydoc kLdrModQuerySymbol */
     762    int (* pfnQuerySymbol)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t uSymbol,
     763                           const char *pszSymbol, PKLDRADDR puValue, uint32_t *pfKind);
     764    /** @copydoc kLdrModEnumSymbols */
     765    int (* pfnEnumSymbols)(PKLDRMOD pMod, uint32_t fFlags, const void *pvBits, KLDRADDR BaseAddress,
     766                           PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
     767    /** @copydoc kLdrModGetImport */
     768    int (* pfnGetImport)(PKLDRMOD pMod, void *pvBits, uint32_t iImport, const char *pszName, size_t cchName);
     769    /** @copydoc kLdrModNumberOfImports */
     770    int32_t (* pfnNumberOfImports)(PKLDRMOD pMod, void *pvBits);
     771    /** @copydoc kLdrModCanExecuteOn */
     772    int (* pfnCanExecuteOn)(PKLDRMOD pMod, void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);
     773    /** @copydoc kLdrModGetStackInfo */
     774    int (* pfnGetStackInfo)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);
     775    /** @copydoc kLdrModQueryMainEntrypoint */
     776    int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);
     777    /** @copydoc kLdrModEnumDbgInfo */
     778    int (* pfnEnumDbgInfo)(PKLDRMOD pMod, void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);
     779    /** @copydoc kLdrModHasDbgInfo */
     780    int (* pfnHasDbgInfo)(PKLDRMOD pMod, void *pvBits);
     781    /** @copydoc kLdrModMap */
     782    int (* pfnMap)(PKLDRMOD pMod);
     783    /** @copydoc kLdrModUnmap */
     784    int (* pfnUnmap)(PKLDRMOD pMod);
     785    /** @copydoc kLdrModAllocTLS */
     786    int (* pfnAllocTLS)(PKLDRMOD pMod);
     787    /** @copydoc kLdrModFreeTLS */
     788    void (* pfnFreeTLS)(PKLDRMOD pMod);
     789    /** @copydoc kLdrModReload */
     790    int (* pfnReload)(PKLDRMOD pMod);
     791    /** @copydoc kLdrModFixupMapping */
     792    int (* pfnFixupMapping)(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
     793    /** @copydoc kLdrModCallInit */
     794    int (* pfnCallInit)(PKLDRMOD pMod);
     795    /** @copydoc kLdrModCallTerm */
     796    int (* pfnCallTerm)(PKLDRMOD pMod);
     797    /** @copydoc kLdrModCallThread */
     798    int (* pfnCallThread)(PKLDRMOD pMod, unsigned fAttachingOrDetaching);
     799    /** @copydoc kLdrModSize */
     800    size_t (* pfnSize)(PKLDRMOD pMod);
     801    /** @copydoc kLdrModGetBits */
     802    int (* pfnGetBits)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
     803    /** @copydoc kLdrModRelocateBits */
     804    int (* pfnRelocateBits)(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
     805                            PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
     806    /** Dummy which should be assigned a non-zero value. */
     807    uint32_t uEndOfStructure;
     808} KLDRMODOPS;
    714809
    715810
Note: See TracChangeset for help on using the changeset viewer.