decompiler
1.0.0
|
A simple raw binary loadimage. More...
#include <loadimage.hh>
Public Member Functions | |
RawLoadImage (const string &f) | |
RawLoadImage constructor. | |
void | attachToSpace (AddrSpace *id) |
Attach the raw image to a particular space. | |
void | open (void) |
Open the raw file for reading. More... | |
virtual | ~RawLoadImage (void) |
RawLoadImage destructor. | |
virtual void | loadFill (uint1 *ptr, int4 size, const Address &addr) |
Get data from the LoadImage. More... | |
virtual string | getArchType (void) const |
Get a string indicating the architecture type. More... | |
virtual void | adjustVma (long adjust) |
Adjust load addresses with a global offset. More... | |
Public Member Functions inherited from ghidra::LoadImage | |
LoadImage (const string &f) | |
LoadImage constructor. More... | |
virtual | ~LoadImage (void) |
LoadImage destructor. More... | |
const string & | getFileName (void) const |
Get the name of the LoadImage. More... | |
virtual void | openSymbols (void) const |
Prepare to read symbols. More... | |
virtual void | closeSymbols (void) const |
Stop reading symbols. More... | |
virtual bool | getNextSymbol (LoadImageFunc &record) const |
Get the next symbol record. More... | |
virtual void | openSectionInfo (void) const |
Prepare to read section info. More... | |
virtual void | closeSectionInfo (void) const |
Stop reading section info. More... | |
virtual bool | getNextSection (LoadImageSection &sec) const |
Get info on the next section. More... | |
virtual void | getReadonly (RangeList &list) const |
Return list of readonly address ranges. More... | |
uint1 * | load (int4 size, const Address &addr) |
Load a chunk of image. More... | |
Private Attributes | |
uintb | vma |
Address of first byte in the file. | |
ifstream * | thefile |
Main file stream for image. | |
uintb | filesize |
Total number of bytes in the loadimage/file. | |
AddrSpace * | spaceid |
Address space that the file bytes are mapped to. | |
Additional Inherited Members | |
Protected Attributes inherited from ghidra::LoadImage | |
string | filename |
Name of the loadimage. | |
A simple raw binary loadimage.
This is probably the simplest loadimage. Bytes from the image are read directly from a file stream. The address associated with each byte is determined by a single value, the vma, which is the address of the first byte in the file. No symbols or sections are supported
|
virtual |
Adjust load addresses with a global offset.
Most load image formats automatically encode information about the true loading address(es) for the data in the image. But if this is missing or incorrect, this routine can be used to make a global adjustment to the load address. Only one adjustment is made across all addresses in the image. The offset passed to this method is added to the stored or default value for any address queried in the image. This is most often used in a raw binary file format. In this case, the entire executable file is intended to be read straight into RAM, as one contiguous chunk, in order to be executed. In the absence of any other info, the first byte of the image file is loaded at offset 0. This method then would adjust the load address of the first byte.
adjust | is the offset amount to be added to default values |
Implements ghidra::LoadImage.
References ghidra::AddrSpace::addressToByte(), ghidra::AddrSpace::getWordSize(), spaceid, and vma.
Referenced by ghidra::RawBinaryArchitecture::buildLoader().
|
virtual |
Get a string indicating the architecture type.
The load image class is intended to be a generic front-end to the large variety of load formats in use. This method should return a string that identifies the particular architecture this particular image is intended to run on. It is currently the responsibility of any derived LoadImage class to establish a format for this string, but it should generally contain some indication of the operating system and the processor.
Implements ghidra::LoadImage.
|
virtual |
Get data from the LoadImage.
This is the core routine of a LoadImage. Given a particular address range, this routine retrieves the exact byte values that are stored at that address when the executable is loaded into RAM. The caller must supply a pre-allocated array of bytes where the returned bytes should be stored. If the requested address range does not exist in the image, or otherwise can't be retrieved, this method throws an DataUnavailError exception.
ptr | points to where the resulting bytes will be stored |
size | is the number of bytes to retrieve from the image |
addr | is the starting address of the bytes to retrieve |
Implements ghidra::LoadImage.
References filesize, ghidra::Address::getOffset(), ghidra::Address::getShortcut(), ghidra::Address::printRaw(), thefile, and vma.
void ghidra::RawLoadImage::open | ( | void | ) |
Open the raw file for reading.
The file is opened and its size immediately recovered.
References ghidra::LoadImage::filename, filesize, and thefile.
Referenced by ghidra::RawBinaryArchitecture::buildLoader().