#pragma once #include #include #include #include #include #include namespace llo { /// /// lloiff class which contains all of the information for representing a file format in a IL format... /// class lloiff_t { public: /// /// iff section struct containing IL information about a section... /// struct iff_section_t { /// /// section name, hashed so that there can be multiple... /// llo::utils::hash_t< std::string > section_name; /// /// section protections... /// struct prot_t { /// /// section protection types... /// enum prot_e : std::uint16_t { none = 0b0000, executable = 0b0001, writeable = 0b0010 }; /// /// IL section protections (writeable/executable)... /// prot_e prots; /// /// opaque value containing the native characteristics... /// std::uint64_t native; /// /// returns true if section is executable... /// /// bool is_executable() { return ( prots & prot_e::executable ); } /// /// returns true if section is writable... /// /// bool is_writable() { return ( prots & prot_e::writeable ); } }; /// /// section protections and characteristics /// prot_t protections; /// /// vector of symbols for this section... /// std::vector< std::shared_ptr< llo::symbol::symbol_base_t > > symbols; /// /// vector of raw bytes containing the original bytes of this section... /// std::vector< std::uint8_t > raw; }; /// /// explicit constructor, must pass a name and the original file as a vector of bytes... /// /// name for this iff object... /// vector of raw bytes containing the original file... explicit lloiff_t( const std::string &name, const std::vector< std::uint8_t > &raw ) : name( name ), raw( raw ) { } /// /// makes a shared pointer containing a llo::lloiff_t... /// /// name of the file... /// vector of bytes containing the raw file... /// returns a shared pointer of the new object... static std::shared_ptr< llo::lloiff_t > make( const std::string &name, const std::vector< std::uint8_t > &raw ) { return std::make_shared< llo::lloiff_t >( name, raw ); } /// /// entry point, where code execution begins.... /// this is lifted from the underlying file format... /// std::shared_ptr< disposition_t > entry; /// /// name of the iff file, hashed so there can be unique objects... /// llo::utils::hash_t< std::string > name; /// /// vector of iff sections... /// std::vector< iff_section_t > sections; /// /// vector of bytes containing the entire original file... /// std::vector< std::uint8_t > raw; /// /// some file formats contain multiple other files inside of them such as LIB... /// which is just an archive of OBJ's... /// std::vector< std::shared_ptr< llo::lloiff_t > > children; }; } // namespace llo