bool DelayImpDirWrapper::loadNextEntry(size_t cntr)
{
    DelayImpEntryWrapper* imp = new DelayImpEntryWrapper(m_PE, this, cntr);
    if (!imp || !imp->getPtr()) {
        delete imp;
        return false;
    }
    // TODO! do it in proper way!
    bool isOk = false;
    uint64_t offset = imp->getNumValue(DelayImpEntryWrapper::NAME, &isOk);
    if (!isOk || offset == 0) {
        delete imp;
        return false;
    }
        //printf("Name = %s\n", imp->getName().c_str());
    entries.push_back(imp);
    return true;
}
Esempio n. 2
0
bool DelayImpDirWrapper::wrap()
{
    clear();

    uint64_t cntr = 0;
    if (!m_Exe || !getDataDirectory(m_Exe)) {
        if (this->importsCount == cntr) return false;
        this->importsCount = cntr;
        return true;
    }

    const uint32_t LIMIT = DelayImpDirWrapper::EntriesLimit;//(-1);
    DelayImpEntryWrapper* imp = NULL;
    bool isNext = false;

    for (cntr = 0; cntr < DelayImpDirWrapper::EntriesLimit; cntr++) {
        isNext = false;

        imp = new DelayImpEntryWrapper(m_Exe, this, cntr);
        if (!imp || !imp->getPtr()) break;

        // TODO! do it in proper way!
        bool isOk = false;
        uint64_t offset = imp->getNumValue(DelayImpEntryWrapper::NAME, &isOk);
        if (!isOk || offset == 0) {
            //will be deleted at the end
            break;
        }
        //printf("Name = %s\n", imp->getName().c_str());
        entries.push_back(imp);
        isNext = true;
    }
    if (!isNext) delete imp;


    if (this->importsCount == cntr) return false;
    this->importsCount = cntr;
    return true;
}