[XDBF] Added option to read XTHD section
This will be useful as it contains title id and version
This commit is contained in:
parent
c7c5aed948
commit
0368e06b71
|
@ -23,6 +23,7 @@ constexpr fourcc_t kXdbfSignatureXcxt = make_fourcc("XCXT");
|
||||||
constexpr fourcc_t kXdbfSignatureXvc2 = make_fourcc("XVC2");
|
constexpr fourcc_t kXdbfSignatureXvc2 = make_fourcc("XVC2");
|
||||||
constexpr fourcc_t kXdbfSignatureXmat = make_fourcc("XMAT");
|
constexpr fourcc_t kXdbfSignatureXmat = make_fourcc("XMAT");
|
||||||
constexpr fourcc_t kXdbfSignatureXsrc = make_fourcc("XSRC");
|
constexpr fourcc_t kXdbfSignatureXsrc = make_fourcc("XSRC");
|
||||||
|
constexpr fourcc_t kXdbfSignatureXthd = make_fourcc("XTHD");
|
||||||
|
|
||||||
constexpr uint64_t kXdbfIdTitle = 0x8000;
|
constexpr uint64_t kXdbfIdTitle = 0x8000;
|
||||||
constexpr uint64_t kXdbfIdXstc = 0x58535443;
|
constexpr uint64_t kXdbfIdXstc = 0x58535443;
|
||||||
|
@ -32,6 +33,7 @@ constexpr uint64_t kXdbfIdXctx = 0x58435854;
|
||||||
constexpr uint64_t kXdbfIdXvc2 = 0x58564332;
|
constexpr uint64_t kXdbfIdXvc2 = 0x58564332;
|
||||||
constexpr uint64_t kXdbfIdXmat = 0x584D4154;
|
constexpr uint64_t kXdbfIdXmat = 0x584D4154;
|
||||||
constexpr uint64_t kXdbfIdXsrc = 0x58535243;
|
constexpr uint64_t kXdbfIdXsrc = 0x58535243;
|
||||||
|
constexpr uint64_t kXdbfIdXthd = 0x58544844;
|
||||||
|
|
||||||
XdbfWrapper::XdbfWrapper(const uint8_t* data, size_t data_size)
|
XdbfWrapper::XdbfWrapper(const uint8_t* data, size_t data_size)
|
||||||
: data_(data), data_size_(data_size) {
|
: data_(data), data_size_(data_size) {
|
||||||
|
@ -241,6 +243,23 @@ const uint8_t* XdbfWrapper::ReadXLast(uint32_t& compressed_size,
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XdbfTitleHeaderData XdbfWrapper::GetTitleInformation() const {
|
||||||
|
auto xlast_table = GetEntry(XdbfSection::kMetadata, kXdbfIdXthd);
|
||||||
|
if (!xlast_table) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto xlast_head =
|
||||||
|
reinterpret_cast<const XdbfSectionHeader*>(xlast_table.buffer);
|
||||||
|
assert_true(xlast_head->magic == kXdbfSignatureXthd);
|
||||||
|
assert_true(xlast_head->version == 1);
|
||||||
|
|
||||||
|
const XdbfTitleHeaderData* ptr = reinterpret_cast<const XdbfTitleHeaderData*>(
|
||||||
|
xlast_table.buffer + sizeof(XdbfSectionHeader));
|
||||||
|
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
XdbfAchievementTableEntry XdbfWrapper::GetAchievement(const uint32_t id) const {
|
XdbfAchievementTableEntry XdbfWrapper::GetAchievement(const uint32_t id) const {
|
||||||
const auto achievements = GetAchievements();
|
const auto achievements = GetAchievements();
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,20 @@ struct XdbfStringTableEntry {
|
||||||
};
|
};
|
||||||
static_assert_size(XdbfStringTableEntry, 4);
|
static_assert_size(XdbfStringTableEntry, 4);
|
||||||
|
|
||||||
|
struct XdbfTitleHeaderData {
|
||||||
|
xe::be<uint32_t> title_id;
|
||||||
|
xe::be<uint32_t> title_type;
|
||||||
|
xe::be<uint16_t> major;
|
||||||
|
xe::be<uint16_t> minor;
|
||||||
|
xe::be<uint16_t> build;
|
||||||
|
xe::be<uint16_t> revision;
|
||||||
|
xe::be<uint32_t> padding_0;
|
||||||
|
xe::be<uint32_t> padding_1;
|
||||||
|
xe::be<uint32_t> padding_2;
|
||||||
|
xe::be<uint32_t> padding_3;
|
||||||
|
};
|
||||||
|
static_assert_size(XdbfTitleHeaderData, 32);
|
||||||
|
|
||||||
struct XdbfContextTableEntry {
|
struct XdbfContextTableEntry {
|
||||||
xe::be<uint32_t> id;
|
xe::be<uint32_t> id;
|
||||||
xe::be<uint16_t> unk1;
|
xe::be<uint16_t> unk1;
|
||||||
|
@ -183,6 +197,7 @@ class XdbfWrapper {
|
||||||
std::vector<XdbfPropertyTableEntry> GetProperties() const;
|
std::vector<XdbfPropertyTableEntry> GetProperties() const;
|
||||||
std::vector<XdbfContextTableEntry> GetContexts() const;
|
std::vector<XdbfContextTableEntry> GetContexts() const;
|
||||||
|
|
||||||
|
XdbfTitleHeaderData GetTitleInformation() const;
|
||||||
XdbfAchievementTableEntry GetAchievement(const uint32_t id) const;
|
XdbfAchievementTableEntry GetAchievement(const uint32_t id) const;
|
||||||
XdbfPropertyTableEntry GetProperty(const uint32_t id) const;
|
XdbfPropertyTableEntry GetProperty(const uint32_t id) const;
|
||||||
XdbfContextTableEntry GetContext(const uint32_t id) const;
|
XdbfContextTableEntry GetContext(const uint32_t id) const;
|
||||||
|
|
Loading…
Reference in New Issue