Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

static int kldrModPEDoMap ( PKLDRMODPE  pModPE,
unsigned  fForReal 
) [static]

Performs the mapping of the image.

This can be used to do the internal mapping as well as the user requested mapping. fForReal indicates which is desired.

Returns:
0 on success, non-zero OS or kLdr status code on failure.
Parameters:
pModPE The interpreter module instance
fForReal If set, do the user mapping. if clear, do the internal mapping.

Definition at line 567 of file kLdrModPE.c.

References KLDRMOD::aSegments, KLDRMOD::cSegments, KLDRMOD::enmType, KLDR_ERR_ADDRESS_OVERFLOW, KLDRTYPE_EXECUTABLE_FIXED, KLDRTYPE_SHARED_LIBRARY_FIXED, KLDRSEG::LinkAddress, KLDRSEG::MapAddress, NIL_KLDRADDR, NULL, KLDRMODPE::pMod, KLDRMOD::pRdr, KLDRMODPE::pvBits, KLDRMODPE::pvMapping, and KLDRSEG::RVA.

Referenced by kldrModPEBitsAndBaseAddress(), and kldrModPEMap().

{
    PKLDRMOD    pMod = pModPE->pMod;
    KBOOL       fFixed;
    void       *pvBase;
    int         rc;
    KU32        i;

    /*
     * Map it.
     */
    /* fixed image? */
    fFixed = fForReal
          && (   pMod->enmType == KLDRTYPE_EXECUTABLE_FIXED
              || pMod->enmType == KLDRTYPE_SHARED_LIBRARY_FIXED);
    if (!fFixed)
        pvBase = NULL;
    else
    {
        pvBase = (void *)(KUPTR)pMod->aSegments[0].LinkAddress;
        if ((KUPTR)pvBase != pMod->aSegments[0].LinkAddress)
            return KLDR_ERR_ADDRESS_OVERFLOW;
    }

    /* try do the prepare */
    rc = kRdrMap(pMod->pRdr, &pvBase, pMod->cSegments, pMod->aSegments, fFixed);
    if (rc)
        return rc;

    /*
     * Update the segments with their map addresses.
     */
    if (fForReal)
    {
        for (i = 0; i < pMod->cSegments; i++)
        {
            if (pMod->aSegments[i].RVA != NIL_KLDRADDR)
                pMod->aSegments[i].MapAddress = (KUPTR)pvBase + (KUPTR)pMod->aSegments[i].RVA;
        }
        pModPE->pvMapping = pvBase;
    }
    else
        pModPE->pvBits = pvBase;
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index