retdec
|
#include <image.h>
Public Member Functions | |
Image (const std::shared_ptr< retdec::fileformat::FileFormat > &fileFormat) | |
virtual bool | load ()=0 |
virtual retdec::utils::Endianness | getEndianness () const override |
virtual std::size_t | getNibbleLength () const override |
virtual std::size_t | getByteLength () const override |
virtual std::size_t | getWordLength () const override |
virtual std::size_t | getBytesPerWord () const override |
virtual std::size_t | getNumberOfNibblesInByte () const override |
virtual bool | hasMixedEndianForDouble () const override |
virtual bool | getXByte (std::uint64_t address, std::uint64_t x, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const override |
virtual bool | getXBytes (std::uint64_t address, std::uint64_t x, std::vector< std::uint8_t > &res) const override |
virtual bool | setXByte (std::uint64_t address, std::uint64_t x, std::uint64_t val, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) override |
virtual bool | setXBytes (std::uint64_t address, const std::vector< std::uint8_t > &res) override |
retdec::fileformat::FileFormat * | getFileFormat () |
const retdec::fileformat::FileFormat * | getFileFormat () const |
std::weak_ptr< retdec::fileformat::FileFormat > | getFileFormatWptr () const |
std::size_t | getNumberOfSegments () const |
const std::vector< std::unique_ptr< Segment > > & | getSegments () const |
std::uint64_t | getBaseAddress () const |
void | setBaseAddress (std::uint64_t baseAddress) |
bool | hasDataOnAddress (std::uint64_t address) const |
bool | hasDataInitializedOnAddress (std::uint64_t address) const |
bool | hasReadOnlyDataOnAddress (std::uint64_t address) const |
Test if there are some read-only data on provided address – address belongs to some read-only section or segment. More... | |
bool | hasSegmentOnAddress (std::uint64_t address) const |
bool | isPointer (std::uint64_t address, std::uint64_t *pointer=nullptr) const |
Segment * | getSegment (std::size_t index) |
Segment * | getSegment (const std::string &name) |
Segment * | getSegmentWithIndex (std::size_t index) |
Segment * | getSegmentFromAddress (std::uint64_t address) |
const Segment * | getSegment (std::size_t index) const |
const Segment * | getSegment (const std::string &name) const |
const Segment * | getSegmentWithIndex (std::size_t index) const |
const Segment * | getSegmentFromAddress (std::uint64_t address) const |
const Segment * | getEpSegment () |
std::pair< const std::uint8_t *, std::uint64_t > | getRawSegmentData (std::uint64_t address) const |
const std::string & | getStatusMessage () const |
const retdec::fileformat::LoaderErrorInfo & | getLoaderErrorInfo () const |
![]() | |
ByteValueStorage ()=default | |
virtual | ~ByteValueStorage ()=default |
Endianness | getInverseEndianness () const |
bool | isLittleEndian () const |
bool | isBigEndian () const |
bool | isUnknownEndian () const |
bool | hexToBig (std::string &str) const |
bool | hexToLittle (std::string &str) const |
bool | bitsToBig (std::string &str) const |
bool | bitsToLittle (std::string &str) const |
bool | bitsToBig (std::vector< unsigned char > &values) const |
bool | bitsToLittle (std::vector< unsigned char > &values) const |
bool | get1Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const |
bool | get2Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const |
bool | get4Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const |
bool | get8Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const |
bool | get10Byte (std::uint64_t address, long double &res) const |
bool | getWord (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const |
bool | getFloat (std::uint64_t address, float &res) const |
bool | getDouble (std::uint64_t address, double &res) const |
bool | set1Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN) |
bool | set2Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN) |
bool | set4Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN) |
bool | set8Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN) |
bool | set10Byte (std::uint64_t address, long double val) |
bool | setWord (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN) |
bool | setFloat (std::uint64_t address, float val) |
bool | setDouble (std::uint64_t address, double val) |
bool | getXByteArray (std::uint64_t address, std::uint64_t x, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const |
bool | get1ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const |
bool | get2ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const |
bool | get4ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const |
bool | get8ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const |
bool | get10ByteArray (std::uint64_t address, std::vector< long double > &res, std::size_t size) const |
bool | getWordArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t, Endianness e=Endianness::UNKNOWN) const |
bool | getFloatArray (std::uint64_t address, std::vector< float > &res, std::size_t size) const |
bool | getDoubleArray (std::uint64_t address, std::vector< double > &res, std::size_t size) const |
bool | getNTBS (std::uint64_t address, std::string &res, std::size_t size=0) const |
bool | getNTWS (std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const |
bool | getNTWSNice (std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const |
Protected Member Functions | |
Segment * | insertSegment (std::unique_ptr< Segment > segment) |
void | removeSegment (Segment *segment) |
void | nameSegment (Segment *segment) |
void | sortSegments () |
void | setStatusMessage (const std::string &message) |
![]() | |
bool | createValueFromBytes (const std::vector< std::uint8_t > &data, std::uint64_t &value, Endianness endian, std::uint64_t offset=0, std::uint64_t size=0) const |
bool | createBytesFromValue (std::uint64_t data, std::uint64_t x, std::vector< std::uint8_t > &value, Endianness endian) const |
bool | get10ByteImpl (const std::vector< std::uint8_t > &data, long double &res) const |
bool | getFloatImpl (const std::vector< std::uint8_t > &data, float &res) const |
bool | getDoubleImpl (const std::vector< std::uint8_t > &data, double &res) const |
bool | getNTBSImpl (const GetNByteFn &get1ByteFn, std::uint64_t address, std::string &res, std::size_t size) const |
bool | getNTWSImpl (const GetXByteFn &getXByteFn, std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const |
bool | getNTWSNiceImpl (const GetXByteFn &getXByteFn, std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const |
Private Member Functions | |
const Segment * | _getSegment (std::size_t index) const |
const Segment * | _getSegment (const std::string &name) const |
const Segment * | _getSegmentWithIndex (std::size_t index) const |
const Segment * | _getSegmentFromAddress (std::uint64_t address) const |
Private Attributes | |
std::shared_ptr< retdec::fileformat::FileFormat > | _fileFormat |
std::vector< std::unique_ptr< Segment > > | _segments |
std::uint64_t | _baseAddress |
NameGenerator | _namelessSegNameGen |
std::string | _statusMessage |
Additional Inherited Members | |
![]() | |
using | GetNByteFn = std::function< bool(std::uint64_t, std::uint64_t &, Endianness)> |
using | GetXByteFn = std::function< bool(std::uint64_t, std::uint64_t, std::uint64_t &, Endianness)> |
retdec::loader::Image::Image | ( | const std::shared_ptr< retdec::fileformat::FileFormat > & | fileFormat | ) |
|
private |
|
private |
|
private |
|
private |
std::uint64_t retdec::loader::Image::getBaseAddress | ( | ) | const |
Returns a base address where the address space is loaded.
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
const Segment * retdec::loader::Image::getEpSegment | ( | ) |
Returns the segment into which entry points address falls, if any exists.
retdec::fileformat::FileFormat * retdec::loader::Image::getFileFormat | ( | ) |
Returns the retdec::fileformat::FileFormat object associated with the loaded image, which contains static information about the file.
const retdec::fileformat::FileFormat * retdec::loader::Image::getFileFormat | ( | ) | const |
Returns the retdec::fileformat::FileFormat object associated with the loaded image, which contains static information about the file.
std::weak_ptr< retdec::fileformat::FileFormat > retdec::loader::Image::getFileFormatWptr | ( | ) | const |
Returns the retdec::fileformat::FileFormat object associated with the loaded image as weak pointer, which containers static information about the file.
const retdec::fileformat::LoaderErrorInfo & retdec::loader::Image::getLoaderErrorInfo | ( | ) | const |
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
std::size_t retdec::loader::Image::getNumberOfSegments | ( | ) | const |
Returns the number of the segments in the address space.
std::pair< const std::uint8_t *, std::uint64_t > retdec::loader::Image::getRawSegmentData | ( | std::uint64_t | address | ) | const |
Returns raw segment data together with its size. Caller should never access beyond pointer + size
(including). Size is calculated from the physical size of the segment. Returns pair of null pointer and 0 in case of an error.
address | Address to start from. |
Segment * retdec::loader::Image::getSegment | ( | const std::string & | name | ) |
Returns the segment with the provided name, if any exists.
name | Name of the segment. |
const Segment * retdec::loader::Image::getSegment | ( | const std::string & | name | ) | const |
Returns the segment with the provided name, if any exists.
name | Name of the segment. |
Segment * retdec::loader::Image::getSegment | ( | std::size_t | index | ) |
Returns the segment at the given index, if any exists.
index | Index of the segment. |
const Segment * retdec::loader::Image::getSegment | ( | std::size_t | index | ) | const |
Returns the segment at the given index, if any exists.
index | Index of the segment. |
Segment * retdec::loader::Image::getSegmentFromAddress | ( | std::uint64_t | address | ) |
Returns the segment into which provided address falls, if any exists.
address | The address to check. |
const Segment * retdec::loader::Image::getSegmentFromAddress | ( | std::uint64_t | address | ) | const |
Returns the segment into which provided address falls, if any exists.
address | The address to check. |
const std::vector< std::unique_ptr< Segment > > & retdec::loader::Image::getSegments | ( | ) | const |
Returns the all loaded segments in the image.
Segment * retdec::loader::Image::getSegmentWithIndex | ( | std::size_t | index | ) |
Returns the segment created from section/segment in section/program headers at specified index, if any exists.
index | Index of the section/segment in section/program headers. |
const Segment * retdec::loader::Image::getSegmentWithIndex | ( | std::size_t | index | ) | const |
Returns the segment created from section/segment in section/program headers at specified index, if any exists.
index | Index of the section/segment in section/program headers. |
const std::string & retdec::loader::Image::getStatusMessage | ( | ) | const |
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
|
overridevirtual |
Get integer (x bytes) located at provided address using the specified endian or default file endian
address | Address to get integer from |
x | Number of bytes for conversion |
res | Result integer |
e | Endian - if specified it is forced, otherwise file's endian is used |
true
if all is OK, false
otherwise) Implements retdec::utils::ByteValueStorage.
|
overridevirtual |
Get x bytes long byte array from specified address
address | Address to get array from |
x | Number of bytes for get |
res | Result array. |
true
if all is OK, false
otherwise) Implements retdec::utils::ByteValueStorage.
bool retdec::loader::Image::hasDataInitializedOnAddress | ( | std::uint64_t | address | ) | const |
Checks whether there are data on the provided address – address must belong to some segment and it cannot be BSS segment.
address | The address to check. |
bool retdec::loader::Image::hasDataOnAddress | ( | std::uint64_t | address | ) | const |
Checks whether there are data on the provided address – address must belong to some segment.
address | The address to check. |
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
bool retdec::loader::Image::hasReadOnlyDataOnAddress | ( | std::uint64_t | address | ) | const |
Test if there are some read-only data on provided address – address belongs to some read-only section or segment.
address | Address to test |
True
if there are read-only data for address, false
otherwisebool retdec::loader::Image::hasSegmentOnAddress | ( | std::uint64_t | address | ) | const |
Checks whether there is segment on the provided address – whether address falls into some of the segments.
address | The address to check. |
bool retdec::loader::Image::isPointer | ( | std::uint64_t | address, |
std::uint64_t * | pointer = nullptr |
||
) | const |
Find out, if there is a pointer (valid address) on the provided address
address | Address to check |
pointer | If not nullptr , and there is a pointer on address , then set the pointer value to where this parameter points. |
True
if pointer on address, false
otherwise
|
pure virtual |
Virtual method that should be overriden in every subclass of Image. Performs the logic of loading.
Implemented in retdec::loader::RawDataImage, retdec::loader::PeImage, retdec::loader::MachOImage, retdec::loader::IntelHexImage, retdec::loader::ElfImage, and retdec::loader::CoffImage.
|
protected |
|
protected |
void retdec::loader::Image::setBaseAddress | ( | std::uint64_t | baseAddress | ) |
Sets a base address for the address space.
baseAddress | Address to set. |
|
protected |
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
|
overridevirtual |
Implements retdec::utils::ByteValueStorage.
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |