#include void llo::s1::dctor_pe_t::generate( lloiff_t &iff ) { std::for_each( sections, sections + section_count, [ & ]( const win::section_header_t §ion_header ) { llo::lloiff_t::iff_section_t iff_section{ std::string( section_header.name.to_string() ), { img.data() + section_header.ptr_raw_data, img.data() + section_header.ptr_raw_data + section_header.size_raw_data } }; const auto &prots = section_header.prots; iff_section.characteristics.prot = { prots.mem_execute, prots.mem_write, prots.mem_discardable }; iff_section.characteristics.characteristics = section_header.prots.flags; // if the section is writable then we want to disassamble the entire section... if ( iff_section.characteristics.prot.is_executable && iff_section.raw.data() ) { std::uint32_t offset = 0u; xed_error_enum_t err; xed_decoded_inst_t instr; xed_state_t istate{ XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b }; xed_decoded_inst_zero_set_mode( &instr, &istate ); // keep looping over the section, lower the number of bytes each time... while ( ( err = xed_decode( &instr, iff_section.raw.data() + offset, iff_section.raw.size() - offset ) ) == XED_ERROR_NONE ) { offset += xed_decoded_inst_get_length( &instr ); iff_section.instrs.push_back( instr ); // need to set this so that instr can be used to decode again... xed_decoded_inst_zero_set_mode( &instr, &istate ); } std::printf( "> err = %d, offset = %d, size = %d\n", err, offset, iff_section.raw.size() ); } iff.sections.emplace_back( iff_section ); } ); // run symbol loader pass... this could be pdb, map, etc... if ( symbol_loader ) symbol_loader->load( iff ); }