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

static int kldrModPEGetBits ( PKLDRMOD  pMod,
void *  pvBits,
KLDRADDR  BaseAddress,
void *  pvUser 
) [static]

Gets the module bits.

The module interpreter will fill a mapping allocated by the caller with the module bits reallocated to the specified address.

0 on succes, non-zero OS or kLdr status code on failure.
pMod The module.
pvBits Where to put the bits.
BaseAddress The base address that should correspond to the first byte in pvBits upon return.
pfnGetImport The callback ufor resolving external (imported) symbols.
pvUser The callback user argument.

Definition at line 1909 of file kLdrModPE.c.

References KLDRSEG::Alignment, KLDRMOD::aSegments, KLDRSEG::cbFile, KLDRMOD::cSegments, KLDRMODPE::Hdrs, kldrModPERelocateBits(), KLDRSEG::LinkAddress, NIL_KLDRADDR, KLDRSEG::offFile, KLDRMOD::pRdr, and KLDRMOD::pvData.

    PKLDRMODPE  pModPE = (PKLDRMODPE)pMod->pvData;
    KU32        i;
    int         rc;

     * Zero the entire buffer first to simplify things.
    kHlpMemSet(pvBits, 0, pModPE->Hdrs.OptionalHeader.SizeOfImage);

     * Iterate the segments and read the data within them.
    for (i = 0; i < pMod->cSegments; i++)
        /* skip it? */
        if (    pMod->aSegments[i].cbFile == -1
            ||  pMod->aSegments[i].offFile == -1
            ||  pMod->aSegments[i].LinkAddress == NIL_KLDRADDR
            ||  !pMod->aSegments[i].Alignment)
        rc = kRdrRead(pMod->pRdr,
                         (KU8 *)pvBits + (pMod->aSegments[i].LinkAddress - pModPE->Hdrs.OptionalHeader.ImageBase),
        if (rc)
            return rc;

     * Perform relocations.
    return kldrModPERelocateBits(pMod, pvBits, BaseAddress, pModPE->Hdrs.OptionalHeader.ImageBase, pfnGetImport, pvUser);


Generated by  Doxygen 1.6.0   Back to index