56 std::string name =
"<memory>");
65 [[nodiscard]] const std::
string&
path() const noexcept {
return path_; }
68 [[nodiscard]] std::int64_t
length() const noexcept {
return length_; }
76 void read(std::int64_t file_offset, std::span<std::uint8_t> destination)
const;
79 [[nodiscard]] std::vector<std::uint8_t>
read(std::int64_t file_offset,
98 virtual ~Source() =
default;
99 [[nodiscard]]
virtual std::int64_t
length() const noexcept = 0;
101 [[nodiscard]] virtual std::
size_t read(std::span<std::uint8_t> destination,
102 std::int64_t offset) const = 0;
113 std::unique_ptr<Source> source_;
115 std::int64_t length_ = 0;
RomIdentityError(const std::string &message)
Definition rom_image.hpp:28
const std::string & path() const noexcept
Path, or descriptive name, the image was opened from.
Definition rom_image.hpp:65
std::int64_t length() const noexcept
Length of the file in bytes.
Definition rom_image.hpp:68
RomImage(RomImage &&) noexcept
const TableManifest & manifest() const noexcept
The offset map these reads are interpreted through.
Definition rom_image.hpp:71
std::string compute_sha256() const
Computes the SHA-256 of the whole file as lower-case hex.
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.
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::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.
void read(std::int64_t file_offset, std::span< std::uint8_t > destination) const
Reads into a caller-supplied buffer, filling it completely.
The machine-readable map of everything the engine needs out of SCCore.dll: the pinned build identity,...
Definition table_manifest.hpp:94
Definition control_decode.hpp:7
@ none
Not XG, or an XG address this engine does nothing with.
Definition control_decode.hpp:94
RomVerification
How strictly RomImage::open checks that the file is the pinned build.
Definition rom_image.hpp:16
@ quick
Verify size and PE timestamp but skip the SHA-256. Faster; use only in tight loops.
Definition rom_image.hpp:20
@ full
Verify size, PE timestamp and the full SHA-256. The default, and the only safe choice.
Definition rom_image.hpp:18
One static table sliced byte-for-byte out of the DLL.
Definition table_manifest.hpp:38