Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
ts::RomImage Class Reference

Read-only access to SCCore.dll as a data file. More...

#include <tabulasonora/rom_image.hpp>

Public Member Functions

 RomImage (RomImage &&) noexcept
RomImageoperator= (RomImage &&) noexcept
 RomImage (const RomImage &)=delete
RomImageoperator= (const RomImage &)=delete
 ~RomImage ()
const std::string & path () const noexcept
 Path, or descriptive name, the image was opened from.
std::int64_t length () const noexcept
 Length of the file in bytes.
const TableManifestmanifest () const noexcept
 The offset map these reads are interpreted through.
void read (std::int64_t file_offset, std::span< std::uint8_t > destination) const
 Reads into a caller-supplied buffer, filling it completely.
std::vector< std::uint8_t > read (std::int64_t file_offset, std::size_t length) const
 Reads length bytes starting at file_offset.
std::vector< std::uint8_t > read (const TableEntry &entry) const
 Reads the bytes of one cached table, exactly entry.size long.
std::uint32_t read_pe_timestamp () const
 Reads the COFF TimeDateStamp from the PE header, or 0 if the file is not a PE image.
std::string compute_sha256 () const
 Computes the SHA-256 of the whole file as lower-case hex.

Static Public Member Functions

static RomImage open (const std::string &path, RomVerification verification=RomVerification::full, const TableManifest *manifest=nullptr)
 Opens and verifies an SCCore.dll.
static RomImage from_memory (std::span< const std::uint8_t > image, RomVerification verification=RomVerification::full, const TableManifest *manifest=nullptr, std::string name="<memory>")
 Wraps an SCCore.dll already held in memory, and verifies it.

Detailed Description

Read-only access to SCCore.dll as a data file.

The DLL is never loaded as code — no LoadLibrary, no dlopen, no native dependency. It is opened as a plain file and sliced at the offsets recorded in TableManifest, which is what lets this engine stay portable and run on hosts the original plugin never supported.

A file image reads positionally (pread) rather than through a memory map, so no 27 MB copy is ever resident. A host without a filesystem supplies the bytes instead; see from_memory.

Constructor & Destructor Documentation

◆ RomImage() [1/2]

ts::RomImage::RomImage ( RomImage && )
noexcept

◆ RomImage() [2/2]

ts::RomImage::RomImage ( const RomImage & )
delete

◆ ~RomImage()

ts::RomImage::~RomImage ( )

Member Function Documentation

◆ open()

RomImage ts::RomImage::open ( const std::string & path,
RomVerification verification = RomVerification::full,
const TableManifest * manifest = nullptr )
staticnodiscard

Opens and verifies an SCCore.dll.

Throws RomIdentityError if the file is not the pinned build, or std::runtime_error if it cannot be opened. The manifest defaults to the embedded one.

◆ from_memory()

RomImage ts::RomImage::from_memory ( std::span< const std::uint8_t > image,
RomVerification verification = RomVerification::full,
const TableManifest * manifest = nullptr,
std::string name = "<memory>" )
staticnodiscard

Wraps an SCCore.dll already held in memory, and verifies it.

Nothing is copied — the memory is read in place — so the caller must keep it alive and unchanged for as long as the image is used, exactly as a file image needs its handle open.

◆ operator=() [1/2]

RomImage & ts::RomImage::operator= ( RomImage && )
noexcept

◆ operator=() [2/2]

RomImage & ts::RomImage::operator= ( const RomImage & )
delete

◆ path()

const std::string & ts::RomImage::path ( ) const
inlinenodiscardnoexcept

Path, or descriptive name, the image was opened from.

◆ length()

std::int64_t ts::RomImage::length ( ) const
inlinenodiscardnoexcept

Length of the file in bytes.

◆ manifest()

const TableManifest & ts::RomImage::manifest ( ) const
inlinenodiscardnoexcept

The offset map these reads are interpreted through.

◆ read() [1/3]

void ts::RomImage::read ( std::int64_t file_offset,
std::span< std::uint8_t > destination ) const

Reads into a caller-supplied buffer, filling it completely.

Throws std::runtime_error if the file ends before the buffer is filled.

◆ read() [2/3]

std::vector< std::uint8_t > ts::RomImage::read ( std::int64_t file_offset,
std::size_t length ) const
nodiscard

Reads length bytes starting at file_offset.

◆ read() [3/3]

std::vector< std::uint8_t > ts::RomImage::read ( const TableEntry & entry) const
nodiscard

Reads the bytes of one cached table, exactly entry.size long.

◆ read_pe_timestamp()

std::uint32_t ts::RomImage::read_pe_timestamp ( ) const
nodiscard

Reads the COFF TimeDateStamp from the PE header, or 0 if the file is not a PE image.

◆ compute_sha256()

std::string ts::RomImage::compute_sha256 ( ) const
nodiscard

Computes the SHA-256 of the whole file as lower-case hex.


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