RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Linker::Buffer Class Reference

A buffer that can be used to read and store data from a file. More...

#include <buffer.h>

Inheritance diagram for Linker::Buffer:
Linker::Image Linker::Contents Linker::Section Linker::TableSection< GOTEntry > Linker::TableSection< TableEntryType > Linker::GlobalOffsetTable

Public Member Functions

 Buffer (size_t size)
 
 Buffer (const std::vector< uint8_t > &data)
 
offset_t ImageSize () const override
 Retrieves size of stored data.
 
void Resize (offset_t new_size)
 Resize buffer.
 
void Append (std::vector< uint8_t > &additional_data)
 Append data to buffer.
 
virtual void ReadFile (Reader &rd)
 Overwrites buffer data with contents of reader.
 
void ReadFileRemaining (Reader &rd)
 Overwrites buffer data with contents of reader.
 
void ReadFile (Reader &rd, offset_t count)
 Overwrites buffer data with contents of reader.
 
offset_t WriteFile (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 (Writer &wr, offset_t count, offset_t offset=0) const=0
 Writes data of non-zero filled sections.
 
virtual offset_t WriteFile (Writer &wr) const
 Writes data of non-zero filled sections.
 
- Public Member Functions inherited from Linker::Image
std::shared_ptr< const ImageAsImage () 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)
 
- Public Member Functions inherited from Linker::Contents
std::shared_ptr< ImageAsImage ()
 Retrieves a randomly accessible image.
 

Static Public Member Functions

static std::shared_ptr< BufferReadFromFile (Reader &rd)
 Creates a buffer containing the remaining data in the reader.
 
static std::shared_ptr< BufferReadFromFile (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
 

Detailed Description

A buffer that can be used to read and store data from a file.

Member Function Documentation

◆ ImageSize()

offset_t Buffer::ImageSize ( ) const
overridevirtual

Retrieves size of stored data.

Implements Linker::Contents.

◆ ReadData()

size_t Buffer::ReadData ( size_t bytes,
offset_t offset,
void * buffer ) const
overridevirtual

Attempts to fill a buffer with data.

Parameters
bytesThe (maximum) number of bytes to place in buffer
offsetThe offset in the image to start reading the data
bufferA byte buffer
Returns
Actual number of bytes copied into buffer

Implements Linker::Image.

Reimplemented in Linker::Section.

◆ ReadFile() [1/2]

void Buffer::ReadFile ( Reader & rd)
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 >.

◆ ReadFile() [2/2]

void Buffer::ReadFile ( 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

◆ ReadFileRemaining()

void Buffer::ReadFileRemaining ( Reader & rd)

Overwrites buffer data with contents of reader.

All the remaining bytes are read, the buffer is expanded if needed but not shrank

◆ ReadFromFile()

std::shared_ptr< Buffer > Buffer::ReadFromFile ( Reader & rd,
offset_t count )
static

Creates a buffer containing the specified amount of bytes from the reader.

If less data is available, the buffer will be shorter

◆ WriteFile() [1/3]

offset_t Contents::WriteFile ( Writer & wr) const
virtual

Writes data of non-zero filled sections.

Reimplemented from Linker::Contents.

Reimplemented in Linker::Section, Linker::TableSection< TableEntryType >, and Linker::TableSection< GOTEntry >.

◆ WriteFile() [2/3]

offset_t Buffer::WriteFile ( Writer & wr,
offset_t count,
offset_t offset = 0 ) const
overridevirtual

◆ WriteFile() [3/3]

virtual offset_t Linker::Contents::WriteFile ( Writer & wr,
offset_t count,
offset_t offset = 0 ) const
virtual

The documentation for this class was generated from the following files: