Changeset 2829 for trunk/kLdr/kLdr.h


Ignore:
Timestamp:
Oct 23, 2006, 7:04:04 PM (19 years ago)
Author:
bird
Message:

Mapping prototypes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdr.h

    r2827 r2829  
    5353 * @{ */
    5454
     55typedef enum KLDRPROT
     56{
     57    /** The usual invalid 0. */
     58    KLDRPROT_INVALID = 0,
     59    /** No access (page not present). */
     60    KLDRPROT_NOACCESS,
     61    /** Read only. */
     62    KLDRPROT_READONLY,
     63    /** Read & write. */
     64    KLDRPROT_READWRITE,
     65    /** Read & copy on write. */
     66    KLDRPROT_WRITECOPY,
     67    /** Execute only. */
     68    KLDRPROT_EXECUTE,
     69    /** Execute & read. */
     70    KLDRPROT_EXECUTE_READONLY,
     71    /** Execute, read & write. */
     72    KLDRPROT_EXECUTE_READWRITE,
     73    /** Execute, read & copy on write. */
     74    KLDRPROT_EXECUTE_WRITECOPY,
     75    /** The usual end value. (exclusive) */
     76    KLDRPROT_END,
     77    /** Blow the type up to 32-bits. */
     78    KLDRPROT_32BIT_HACK = 0x7fffffff
     79} KLDRPROT;
     80
     81
    5582/** Pointer to a file provider instance core. */
    5683typedef struct KLDRRDR *PKLDRRDR;
     
    106133     */
    107134    int     (* pfnAllUnmap)(PKLDRRDR pRdr, const void *pvBits);
    108 /** @todo generic mmap/MapViewOfFile */
    109135    /** Get the file size.
    110136     *
     
    125151     */
    126152    const char * (* pfnName)(PKLDRRDR pRdr);
     153    /**
     154     * Prepares a memory region to map file sections into.
     155     *
     156     * @returns 0 on success, OS specific error code on failure.
     157     * @param   pRdr        The file provider instance.
     158     * @param   ppv         If fFixed is set, *ppv contains the memory location which
     159     *                      the region should be based at. If fFixed is clear the OS
     160     *                      is free to choose the location.
     161     *                      On successful return *ppv contains address of the prepared
     162     *                      memory region.
     163     * @param   cb          The size of the memory region to prepare.
     164     * @param   fFixed      When set *ppv will contain the desired region address.
     165     *
     166     */
     167    int     (* pfnPrepare)(PKLDRRDR pRdr, void **ppv, size_t cb, unsigned fFixed);
     168    /**
     169     * Maps a section of the file into the memory region reserved by pfnPrepare.
     170     *
     171     * @returns 0 on success, OS specific error code on failure.
     172     * @param   pRdr        The file provider instance.
     173     * @param   pv          The address in the prepared region.
     174     * @param   cb          The size of the memory mapping.
     175     * @param   enmProt     The desired memory protection.
     176     * @param   offFile     The start of the raw file bytes.
     177     * @param   cbFile      The number of raw file bytes. This must be less or equal to cb.
     178     */
     179    int     (* pfnMap)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile);
     180    /**
     181     * Changes the page protection of a section mapped using pfnMap.
     182     *
     183     * This is typically used for applying fixups and similar.
     184     *
     185     * @returns 0 on success, OS specific error code on failure.
     186     * @param   pRdr        The file provider instance.
     187     * @param   pv          The address passed to pfnMap.
     188     * @param   cb          The size passed to pfnMap.
     189     * @param   enmProt     The desired memory protection.
     190     */
     191    int     (* pfnProtect)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt);
     192    /**
     193     * Unmaps a section of the file previously mapped using pfnMap.
     194     *
     195     * @returns 0 on success, OS specific error code on failure.
     196     * @param   pRdr        The file provider instance.
     197     * @param   pv          The address passed to pfnMap.
     198     * @param   cb          The size passed to pfnMap.
     199     */
     200    int     (* pfnUnmap)(PKLDRRDR pRdr, void *pv, size_t cb);
     201    /**
     202     * Releases the memory region prepared by pfnPrepare().
     203     *
     204     * Before calling this function, all sections mapped by pfnMap must first be unmapped by calling pfnUnmap.
     205     *
     206     * @returns 0 on success, OS specific error code on failure.
     207     * @param   pRdr        The file provider instance.
     208     * @param   pv          The address of the prepared region.
     209     * @param   cb          The size of the prepared region.
     210     */
     211    int     (* pfnUnprepare)(PKLDRRDR pRdr, void *pv, size_t cb);
     212    /**
     213     * We're done reading from the file but would like to keep file mappings.
     214     *
     215     * If the OS support closing the file handle while the file is mapped,
     216     * the reader should do so.
     217     *
     218     * @param   pRdr        The file provider instance.
     219     */
     220    void    (* pfnDone)(PKLDRRDR pRdr);
     221    /** The usual non-zero dummy that makes sure we've initialized all members. */
     222    uint32_t u32Dummy;
    127223} KLDRRDROPS;
    128224/** Pointer to file provider operations. */
Note: See TracChangeset for help on using the changeset viewer.