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

static KI32 kldrModPENumberOfImports ( PKLDRMOD  pMod,
const void *  pvBits 
) [static]

Get the number of import modules.

Returns:
The number of import modules. -1 if something really bad happens.
Parameters:
pMod The module.
pvBits Optional pointer to bits returned by kLdrModGetBits(). This can be used by some module interpreters to reduce memory consumption.

Definition at line 1075 of file kLdrModPE.c.

References KLDRMODPE::cImportModules, KLDRMODPE::Hdrs, KLDRMODPE_RVA2TYPE, kldrModPEBitsAndBaseAddress(), NULL, and KLDRMOD::pvData.

Referenced by kldrModPEDoForwarderQuery(), kldrModPEDoImports(), and kldrModPEGetImport().

{
    PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData;
    if (pModPE->cImportModules == ~(KU32)0)
    {
        /*
         * We'll have to walk the import descriptors to figure out their number.
         * First, make sure we've got mapped bits.
         */
        if (kldrModPEBitsAndBaseAddress(pModPE, &pvBits, NULL))
            return -1;
        pModPE->cImportModules = 0;
        if (    pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size
            &&  pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress)
        {
            const IMAGE_IMPORT_DESCRIPTOR  *pImpDesc;

            pImpDesc = KLDRMODPE_RVA2TYPE(pvBits,
                                          pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress,
                                          const IMAGE_IMPORT_DESCRIPTOR *);
            while (pImpDesc->Name && pImpDesc->FirstThunk)
            {
                pModPE->cImportModules++;
                pImpDesc++;
            }
        }
    }
    return pModPE->cImportModules;
}


Generated by  Doxygen 1.6.0   Back to index