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

static int kldrModPEBitsAndBaseAddress ( PKLDRMODPE  pModPE,
const void **  ppvBits,
PKLDRADDR  pBaseAddress 
) [static]

Gets usable bits and the right base address.

Returns:
0 on success.

A non-zero status code if the BaseAddress isn't right or some problem is encountered featch in a temp mapping the bits.

Parameters:
pModPE The interpreter module instance
ppvBits The bits address, IN & OUT.
pBaseAddress The base address, IN & OUT. Optional.

Definition at line 663 of file kLdrModPE.c.

References KLDRMOD::aSegments, KLDRMODPE::Hdrs, KLDRMOD_BASEADDRESS_LINK, KLDRMOD_BASEADDRESS_MAP, KLDRMODPE_ASSERT, kldrModPEDoMap(), KLDRSEG::MapAddress, KLDRMODPE::pMod, KLDRMODPE::pvBits, and KLDRMODPE::pvMapping.

Referenced by kldrModPEEnumDbgInfo(), kldrModPEEnumSymbols(), kldrModPEGetImport(), kldrModPENumberOfImports(), kldrModPEQueryMainEntrypoint(), and kldrModPEQuerySymbol().

{
    int rc = 0;

    /*
     * Correct the base address.
     *
     * We don't use the base address for interpreting the bits in this
     * interpreter, which makes things relativly simple.
     */
    if (pBaseAddress)
    {
        if (*pBaseAddress == KLDRMOD_BASEADDRESS_MAP)
            *pBaseAddress = pModPE->pMod->aSegments[0].MapAddress;
        else if (*pBaseAddress == KLDRMOD_BASEADDRESS_LINK)
            *pBaseAddress = pModPE->Hdrs.OptionalHeader.ImageBase;
    }

    /*
     * Get bits.
     */
    if (ppvBits && !*ppvBits)
    {
        if (pModPE->pvMapping)
            *ppvBits = pModPE->pvMapping;
        else if (pModPE->pvBits)
            *ppvBits = pModPE->pvBits;
        else
        {
            /* create an internal mapping. */
            rc = kldrModPEDoMap(pModPE, 0 /* not for real */);
            if (rc)
                return rc;
            KLDRMODPE_ASSERT(pModPE->pvBits);
            *ppvBits = pModPE->pvBits;
        }
    }

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index