|
RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
|
A buffer that can be used to read and store data from a file. More...
#include <buffer.h>
Public Member Functions | |
| Buffer (size_t size) | |
| Buffer (const std::vector< uint8_t > &data) | |
| offset_t | ImageSize () const override |
| Retrieves the offset of the byte after the last one belonging to this format from the first one. | |
| void | Resize (offset_t new_size) |
| Resize buffer. | |
| virtual offset_t | Expand (offset_t new_size) |
| Increases the size of the buffer by the specified amount. | |
| virtual offset_t | WriteData (size_t bytes, offset_t offset, const void *buffer) |
| Writes data into the buffer image. | |
| virtual offset_t | WriteWord (size_t bytes, offset_t offset, uint64_t value, EndianType endiantype) |
| Append data to buffer. | |
| offset_t | WriteWord (size_t bytes, offset_t offset, uint64_t value) |
| Writes a value into the buffer image. | |
| offset_t | WriteWord (size_t bytes, uint64_t value, EndianType endiantype) |
| Writes a value at the current end of the buffer. | |
| offset_t | WriteWord (size_t bytes, uint64_t value) |
| Writes value at the current end of the buffer. | |
| virtual offset_t | Append (const void *new_data, size_t length) |
| Appends data at the end of a buffer. | |
| offset_t | Append (const char *new_data) |
| Appends data at the end of a buffer. | |
| offset_t | Append (std::vector< uint8_t > &additional_data) |
| Appends data at the end of a buffer. | |
| virtual void | ReadFile (const std::shared_ptr< Reader > &rd) |
| Overwrites buffer data with contents of reader. | |
| void | ReadFileRemaining (const std::shared_ptr< Reader > &rd) |
| Overwrites buffer data with contents of reader. | |
| void | ReadFile (const std::shared_ptr< Reader > &rd, offset_t count) |
| Overwrites buffer data with contents of reader. | |
| offset_t | WriteFile (const std::shared_ptr< Writer > &wr, offset_t count, offset_t offset=0) const override |
| Writes data of non-zero filled sections. | |
| size_t | ReadData (size_t bytes, offset_t offset, void *buffer) const override |
| Attempts to fill a buffer with data. | |
| virtual offset_t | WriteFile (const std::shared_ptr< Writer > &wr) const=0 |
| Writes data of non-zero filled sections. | |
Public Member Functions inherited from Linker::Image | |
| std::shared_ptr< const Image > | AsImage () const override |
| Retrieves a randomly accessible image. | |
| uint64_t | ReadUnsigned (size_t bytes, offset_t offset, EndianType endiantype) const |
| Reads an unsigned number at a specific offset. | |
| uint64_t | ReadUnsigned (size_t bytes, offset_t offset) const |
| Reads an unsigned number at a specific offset with the default endianness. | |
| int64_t | ReadSigned (size_t bytes, offset_t offset, EndianType endiantype) const |
| Reads a signed number at a specific offset. | |
| int64_t | ReadSigned (size_t bytes, offset_t offset) const |
| Reads a signed number at a specific offset with the default endianness. | |
| int | GetByte (offset_t offset) const |
| Retrieve byte at a certain offset (optional, might not be defined) | |
| offset_t | WriteFile (const std::shared_ptr< Writer > &wr) const override |
| Writes data of non-zero filled sections. | |
| virtual offset_t | WriteFile (const std::shared_ptr< Writer > &wr) const=0 |
| Writes data of non-zero filled sections. | |
Public Member Functions inherited from Linker::Contents | |
| std::shared_ptr< Image > | AsImage () |
| Retrieves a randomly accessible image. | |
Static Public Member Functions | |
| static std::shared_ptr< Buffer > | ReadFromFile (const std::shared_ptr< Reader > &rd) |
| Creates a buffer containing the remaining data in the reader. | |
| static std::shared_ptr< Buffer > | ReadFromFile (const std::shared_ptr< Reader > &rd, offset_t count) |
| Creates a buffer containing the specified amount of bytes from the reader. | |
Protected Attributes | |
| std::vector< uint8_t > | data |
Friends | |
| class | Section |
| class | Contents |
A buffer that can be used to read and store data from a file.
|
virtual |
Appends data at the end of a buffer.
| new_data | Pointer to data to append |
| length | Number of bytes of data to load from pointer and insert into buffer |
Reimplemented in Linker::Section.
|
virtual |
Increases the size of the buffer by the specified amount.
| new_size | The new size for the buffer. If it is smaller than the current size, nothing is changed. |
Reimplemented in Linker::Section.
|
overridevirtual |
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Implements Linker::Contents.
|
overridevirtual |
Attempts to fill a buffer with data.
| bytes | The (maximum) number of bytes to place in buffer |
| offset | The offset in the image to start reading the data |
| buffer | A byte buffer |
Implements Linker::Image.
Reimplemented in Linker::Section, Linker::TableSection< TableEntryType >, and Linker::TableSection< GOTEntry >.
|
virtual |
Overwrites buffer data with contents of reader.
Note that only as many bytes are read in as the size of the buffer.
Reimplemented in Linker::Section, Linker::Section, Linker::TableSection< TableEntryType >, and Linker::TableSection< GOTEntry >.
| void Buffer::ReadFile | ( | const std::shared_ptr< Reader > & | rd, |
| offset_t | count | ||
| ) |
Overwrites buffer data with contents of reader.
Exactly the specified amount is read, the buffer is expanded if needed but not shrank
| void Buffer::ReadFileRemaining | ( | const std::shared_ptr< Reader > & | rd | ) |
Overwrites buffer data with contents of reader.
All the remaining bytes are read, the buffer is expanded if needed but not shrank
|
static |
Creates a buffer containing the specified amount of bytes from the reader.
If less data is available, the buffer will be shorter
|
virtual |
Writes data into the buffer image.
Reimplemented in Linker::Section.
|
virtual |
Writes data of non-zero filled sections.
Implements Linker::Contents.
Reimplemented in Linker::Section, Linker::TableSection< GOTEntry >, Linker::TableSection< GOTEntry >, Linker::TableSection< TableEntryType >, and Linker::TableSection< TableEntryType >.
|
overridevirtual |
Writes data of non-zero filled sections.
Reimplemented from Linker::Image.
Reimplemented in Linker::TableSection< TableEntryType >, Linker::TableSection< GOTEntry >, Linker::Section, Linker::TableSection< TableEntryType >, and Linker::TableSection< GOTEntry >.
| offset_t Buffer::WriteWord | ( | size_t | bytes, |
| offset_t | offset, | ||
| uint64_t | value | ||
| ) |
Writes a value into the buffer image.
|
virtual |
Append data to buffer.
Writes a value into the buffer image
Reimplemented in Linker::Section.
| offset_t Buffer::WriteWord | ( | size_t | bytes, |
| uint64_t | value | ||
| ) |
Writes value at the current end of the buffer.
| offset_t Buffer::WriteWord | ( | size_t | bytes, |
| uint64_t | value, | ||
| EndianType | endiantype | ||
| ) |
Writes a value at the current end of the buffer.