void display(VerbosityLevel lvl = VERBOSE_LEVEL_1) const { PortableExecutableLayout::display(lvl); imgNtHeaders.display(lvl); if(lvl > VERBOSE_LEVEL_1) { for(iter_sect_header it = imgSectionHeaders.begin(); it != imgSectionHeaders.end(); ++it) (*it)->display(); } }
void fill_nt_structures(std::ifstream &file) { /* Remember where the caller was in the file */ std::streampos off = file.tellg(); file.seekg(imgDosHeader.e_lfanew, std::ios::beg); file.read((char*)&imgNtHeaders, get_nt_headers_size()); file.seekg(imgDosHeader.e_lfanew, std::ios::beg); /* This offset is relative to the NT Header, do not forget to move the file pointer on it */ file.seekg(imgNtHeaders.get_offset_first_section(), std::ios::cur); for(unsigned int i = 0; i < imgNtHeaders.FileHeader.NumberOfSections; ++i) { std::shared_ptr<RP_IMAGE_SECTION_HEADER> pImgSectionHeader = std::make_shared<RP_IMAGE_SECTION_HEADER>(); file.read((char*)pImgSectionHeader.get(), get_image_section_header_size()); imgSectionHeaders.push_back(pImgSectionHeader); } file.seekg(off); }
void fill_nt_structures(std::ifstream &file) { /* Remember where the caller was in the file */ std::streampos off = file.tellg(); file.seekg(imgDosHeader.e_lfanew, std::ios::beg); file.read((char*)&imgNtHeaders, get_nt_headers_size()); file.seekg(imgDosHeader.e_lfanew, std::ios::beg); /* This offset is relative to the NT Header, do not forget to move the file pointer on it */ file.seekg(imgNtHeaders.get_offset_first_section(), std::ios::cur); for(unsigned int i = 0; i < imgNtHeaders.FileHeader.NumberOfSections; ++i) { RP_IMAGE_SECTION_HEADER* pImgSectionHeader = new (std::nothrow) RP_IMAGE_SECTION_HEADER; if(pImgSectionHeader == NULL) RAISE_EXCEPTION("Cannot allocate memory for pImgSectionHeader"); file.read((char*)pImgSectionHeader, get_image_section_header_size()); imgSectionHeaders.push_back(pImgSectionHeader); } file.seekg(off); }