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

static int kldrModPEFixupMapping ( PKLDRMOD  pMod,
PFNKLDRMODGETIMPORT  pfnGetImport,
void *  pvUser 
) [static]

Fixup the mapping made by kLdrModMap().

The caller is only responsible for not calling this function more than once without doing kLDrModReload() inbetween.

Returns:
0 on success, non-zero OS or kLdr status code on failure.
Parameters:
pMod The module.
pfnGetImport The callback for resolving external (imported) symbols.
pvUser The callback user argument.

Definition at line 1337 of file kLdrModPE.c.

References KLDRMOD::aSegments, KLDRMOD::cSegments, KLDRMODPE::Hdrs, KLDR_ERR_NOT_MAPPED, kldrModPEDoFixups(), kldrModPEDoImports(), KLDRMOD::pRdr, KLDRMOD::pvData, and KLDRMODPE::pvMapping.

{
    PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData;
    int rc, rc2;

    /*
     * Mapped?
     */
    if (!pModPE->pvMapping)
        return KLDR_ERR_NOT_MAPPED;

    /*
     * Before doing anything we'll have to make all pages writable.
     */
    rc = kRdrProtect(pMod->pRdr, (void *)pModPE->pvMapping, pMod->cSegments, pMod->aSegments, 1 /* unprotect */);
    if (rc)
        return rc;

    /*
     * Apply base relocations.
     */
    rc = kldrModPEDoFixups(pModPE, (void *)pModPE->pvMapping, (KUPTR)pModPE->pvMapping,
                           pModPE->Hdrs.OptionalHeader.ImageBase);

    /*
     * Resolve imports.
     */
    if (!rc)
        rc = kldrModPEDoImports(pModPE, (void *)pModPE->pvMapping, pfnGetImport, pvUser);

    /*
     * Restore protection.
     */
    rc2 = kRdrProtect(pMod->pRdr, (void *)pModPE->pvMapping, pMod->cSegments, pMod->aSegments, 0 /* protect */);
    if (!rc && rc2)
        rc = rc2;
    return rc;
}


Generated by  Doxygen 1.6.0   Back to index