#pragma once #include #include #include #include #include #define XED_ENCODER extern "C" { #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: /// /// section protections structure... /// struct iff_prot_t { /// /// the raw characteristics of the original binary file... /// std::uint64_t characteristics; /// /// bit field structure containing IL version of characteristics... /// union { struct { std::uint32_t is_executable : 1; std::uint32_t is_writable : 1; std::uint32_t is_discardable : 1; }; std::uint32_t flags; } prot; }; /// /// 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; /// /// vector of raw bytes containing the original bytes of this section... /// std::vector< std::uint8_t > raw; /// /// IL and native characteristics of a section... /// contains information such as: is the section executable, /// writable, and or discardable? /// iff_prot_t characteristics; /// /// a vector containing every single instruction of this section... /// std::vector< xed_decoded_inst_t > instrs; }; /// /// 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 ); } /// /// 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