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

int kldrDyldModLoadPrerequisites ( PKLDRDYLDMOD  pMod,
const char *  pszPrefix,
const char *  pszSuffix,
KLDRDYLDSEARCH  enmSearch,
unsigned  fFlags 
)

Loads the prerequisite modules this module depends on.

To find each of the prerequisite modules this method calls kldrDyldGetPrerequisite() and it will make sure the modules are added to the load stack frame.

Returns:
0 on success, non-zero native OS or kLdr status code on failure. The state is changed to LOADED_PREREQUISITES or RELOADED_LOADED_PREREQUISITES.
Parameters:
pMod The module.
pszPrefix Prefix to use when searching.
pszSuffix Suffix to use when searching.
enmSearch Method to use when locating the module and any modules it may depend on.
fFlags Flags, a combintation of the KLDRYDLD_LOAD_FLAGS_* #defines.

Definition at line 739 of file kLdrDyldMod.c.

References KLDRDYLDMOD::cPrereqs, KLDRDYLDMOD::enmState, KERR_NO_MEMORY, kldrDyldGetPrerequisite(), KLDRDYLDMOD_ASSERT, kLdrModGetImport(), kLdrModNumberOfImports(), KLDRSTATE_LOADED_PREREQUISITES, KLDRSTATE_MAPPED, KLDRSTATE_RELOADED, KLDRSTATE_RELOADED_LOADED_PREREQUISITES, NULL, KLDRDYLDMOD::papPrereqs, and KLDRDYLDMOD::pMod.

Referenced by kldrDyldDoLoadPrerequisites().

{
    KI32    cPrereqs;
    KU32    i;
    int     rc = 0;

    /* sanity */
    switch (pMod->enmState)
    {
        case KLDRSTATE_MAPPED:
        case KLDRSTATE_RELOADED:
            break;
        default:
            KLDRDYLDMOD_ASSERT(!"invalid state");
            return -1;
    }

    /*
     * Query number of prerequiste modules and allocate the array.
     */
    cPrereqs = kLdrModNumberOfImports(pMod->pMod, NULL);
    kHlpAssert(cPrereqs >= 0);
    if (pMod->cPrereqs != cPrereqs)
    {
        KLDRDYLDMOD_ASSERT(!pMod->papPrereqs);
        pMod->papPrereqs = (PPKLDRDYLDMOD)kHlpAllocZ(sizeof(pMod->papPrereqs[0]) * cPrereqs);
        if (!pMod->papPrereqs)
            return KERR_NO_MEMORY;
        pMod->cPrereqs = cPrereqs;
    }
    else
        KLDRDYLDMOD_ASSERT(pMod->papPrereqs || !pMod->cPrereqs);

    /*
     * Iterate the prerequisites and load them.
     */
    for (i = 0; i < pMod->cPrereqs; i++)
    {
        static char s_szPrereq[260];
        PKLDRDYLDMOD pPrereqMod;

        KLDRDYLDMOD_ASSERT(pMod->papPrereqs[i] == NULL);
        rc = kLdrModGetImport(pMod->pMod, NULL, i, s_szPrereq, sizeof(s_szPrereq));
        if (rc)
            break;
        rc = kldrDyldGetPrerequisite(s_szPrereq, pszPrefix, pszSuffix, enmSearch, fFlags, pMod, &pPrereqMod);
        if (rc)
            break;
        pMod->papPrereqs[i] = pPrereqMod;
    }

    /* change the state regardless of what happend. */
    if (pMod->enmState == KLDRSTATE_MAPPED)
        pMod->enmState = KLDRSTATE_LOADED_PREREQUISITES;
    else
        pMod->enmState = KLDRSTATE_RELOADED_LOADED_PREREQUISITES;
    return rc;
}


Generated by  Doxygen 1.6.0   Back to index