#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/zucchini/disassembler_ztf.h"
#include <algorithm>
#include <cmath>
#include <iterator>
#include <limits>
#include <numeric>
#include "base/check_op.h"
#include "base/memory/raw_ref.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "components/zucchini/algorithm.h"
#include "components/zucchini/buffer_source.h"
#include "components/zucchini/buffer_view.h"
#include "components/zucchini/io_utils.h"
namespace zucchini {
namespace {
constexpr uint8_t kDelimiter = …;
constexpr int kHeaderMagicSize = …;
constexpr int kFooterMagicSize = …;
constexpr int kTotalMagicSize = …;
constexpr int kNumConstCharInAbs = …;
constexpr int kNumConstCharInRel = …;
struct ZtfConfig { … };
template <DisassemblerZtf::ReferencePool pool>
constexpr ZtfConfig MakeZtfConfig(uint8_t digits) { … }
class ZtfParser { … };
class ZtfWriter { … };
template <typename T>
class ZtfReferenceReader : public ReferenceReader { … };
template <typename T>
class ZtfReferenceWriter : public ReferenceWriter { … };
bool ReadZtfHeader(ConstBufferView image) { … }
}
ZtfTranslator::ZtfTranslator() { … }
ZtfTranslator::~ZtfTranslator() = default;
bool ZtfTranslator::Init(ConstBufferView image) { … }
bool ZtfTranslator::IsValid(ztf::LineCol lc) const { … }
bool ZtfTranslator::IsValid(offset_t offset, ztf::DeltaLineCol dlc) const { … }
offset_t ZtfTranslator::LineColToOffset(ztf::LineCol lc) const { … }
std::optional<ztf::LineCol> ZtfTranslator::OffsetToLineCol(
offset_t offset) const { … }
std::vector<offset_t>::const_iterator ZtfTranslator::SearchForRange(
offset_t offset) const { … }
offset_t ZtfTranslator::LineLength(uint16_t line) const { … }
DisassemblerZtf::DisassemblerZtf() : … { … }
DisassemblerZtf::~DisassemblerZtf() = default;
bool DisassemblerZtf::QuickDetect(ConstBufferView image) { … }
ExecutableType DisassemblerZtf::GetExeType() const { … }
std::string DisassemblerZtf::GetExeTypeString() const { … }
std::vector<ReferenceGroup> DisassemblerZtf::MakeReferenceGroups() const { … }
template <uint8_t digits, DisassemblerZtf::ReferencePool pool>
std::unique_ptr<ReferenceReader> DisassemblerZtf::MakeReadAbs(offset_t lo,
offset_t hi) { … }
template <uint8_t digits, DisassemblerZtf::ReferencePool pool>
std::unique_ptr<ReferenceReader> DisassemblerZtf::MakeReadRel(offset_t lo,
offset_t hi) { … }
template <uint8_t digits, DisassemblerZtf::ReferencePool pool>
std::unique_ptr<ReferenceWriter> DisassemblerZtf::MakeWriteAbs(
MutableBufferView image) { … }
template <uint8_t digits, DisassemblerZtf::ReferencePool pool>
std::unique_ptr<ReferenceWriter> DisassemblerZtf::MakeWriteRel(
MutableBufferView image) { … }
bool DisassemblerZtf::Parse(ConstBufferView image) { … }
}