Пример #1
0
    std::vector<Section*> get_executable_section(std::ifstream &file)
    {
        std::vector<Section*> exc_sect;

        for(iter_rp_section it = sections.begin(); it != sections.end(); ++it)
        {
            if((*it)->flags & S_ATTR_PURE_INSTRUCTIONS || (*it)->flags & S_ATTR_SOME_INSTRUCTIONS)
            {
                Section *s = new Section(
                    (char*)(*it)->sectname,
                    (*it)->offset,
                    (*it)->addr,
                    (*it)->size
                );

                if(s == NULL)
                    RAISE_EXCEPTION("Cannot allocate s");
                
                s->dump(file);

                s->set_props(Section::Executable);

                exc_sect.push_back(s);
            }
        }
        return exc_sect;
    }
Пример #2
0
    std::vector<Section*> get_executable_section(std::ifstream &file) const
    {
        std::vector<Section*> exec_sections;

        for(iter_elf_phdr it = elfProgramHeaders.begin(); it != elfProgramHeaders.end(); ++it)
        {
            if((*it)->p_flags & 1)
            {
                Section *sec = new (std::nothrow) Section(
                    type_to_str((*it)->p_type).c_str(),
                    (*it)->p_offset,
                    (*it)->p_vaddr,
                    (*it)->p_filesz
                );

                if(sec == NULL)
                    RAISE_EXCEPTION("Cannot alocate a section");
                
                sec->dump(file);
                sec->set_props(Section::Executable);

                exec_sections.push_back(sec);
            }
        }

        return exec_sections;
    }
Пример #3
0
Файл: pe.cpp Проект: haofree/rp
std::vector<Section*> PE::get_executables_section(std::ifstream & file)
{
    std::vector<Section*> exec_sections;

    for(std::vector<RP_IMAGE_SECTION_HEADER*>::iterator it = m_pPELayout->imgSectionHeaders.begin();
        it != m_pPELayout->imgSectionHeaders.end();
        ++it)
    {
        if((*it)->Characteristics & RP_IMAGE_SCN_MEM_EXECUTE)
        {
            Section *tmp = new (std::nothrow) Section(
                (*it)->get_name().c_str(),
                (*it)->PointerToRawData,
                /* in the PE, this field is a RVA, so we need to add it the image base to have a VA */
                m_pPELayout->get_image_base() + (*it)->VirtualAddress,
                (*it)->SizeOfRawData
            );

            if(tmp == NULL)
                RAISE_EXCEPTION("Cannot allocate a section");
            
            tmp->dump(file);

            tmp->set_props(Section::Executable);

            exec_sections.push_back(tmp);
        }
    }
    return exec_sections;
}
Пример #4
0
std::vector<Section*> Raw::get_executables_section(std::ifstream & file)
{
    std::vector<Section*> executable_sections;

    unsigned long long raw_file_size = get_file_size(file);
    
    /* It is a raw file -> we have only one "virtual" section */
    Section *sect = new (std::nothrow) Section(
        ".raw",
        0,
        0,
        raw_file_size
    );

    if(sect == NULL)
        RAISE_EXCEPTION("Cannot allocate sect");
    
    sect->dump(file);
    sect->set_props(Section::Executable);

    executable_sections.push_back(sect);
    
    return executable_sections;
}