diff --git a/src/xenia/kernel/util/xdbf_utils.cc b/src/xenia/kernel/util/xdbf_utils.cc index afd2747f6..6fa4c8fee 100644 --- a/src/xenia/kernel/util/xdbf_utils.cc +++ b/src/xenia/kernel/util/xdbf_utils.cc @@ -23,6 +23,7 @@ constexpr fourcc_t kXdbfSignatureXcxt = make_fourcc("XCXT"); constexpr fourcc_t kXdbfSignatureXvc2 = make_fourcc("XVC2"); constexpr fourcc_t kXdbfSignatureXmat = make_fourcc("XMAT"); constexpr fourcc_t kXdbfSignatureXsrc = make_fourcc("XSRC"); +constexpr fourcc_t kXdbfSignatureXthd = make_fourcc("XTHD"); constexpr uint64_t kXdbfIdTitle = 0x8000; constexpr uint64_t kXdbfIdXstc = 0x58535443; @@ -32,6 +33,7 @@ constexpr uint64_t kXdbfIdXctx = 0x58435854; constexpr uint64_t kXdbfIdXvc2 = 0x58564332; constexpr uint64_t kXdbfIdXmat = 0x584D4154; constexpr uint64_t kXdbfIdXsrc = 0x58535243; +constexpr uint64_t kXdbfIdXthd = 0x58544844; XdbfWrapper::XdbfWrapper(const uint8_t* data, size_t data_size) : data_(data), data_size_(data_size) { @@ -241,6 +243,23 @@ const uint8_t* XdbfWrapper::ReadXLast(uint32_t& compressed_size, return ptr; } +XdbfTitleHeaderData XdbfWrapper::GetTitleInformation() const { + auto xlast_table = GetEntry(XdbfSection::kMetadata, kXdbfIdXthd); + if (!xlast_table) { + return {}; + } + + auto xlast_head = + reinterpret_cast(xlast_table.buffer); + assert_true(xlast_head->magic == kXdbfSignatureXthd); + assert_true(xlast_head->version == 1); + + const XdbfTitleHeaderData* ptr = reinterpret_cast( + xlast_table.buffer + sizeof(XdbfSectionHeader)); + + return *ptr; +} + XdbfAchievementTableEntry XdbfWrapper::GetAchievement(const uint32_t id) const { const auto achievements = GetAchievements(); diff --git a/src/xenia/kernel/util/xdbf_utils.h b/src/xenia/kernel/util/xdbf_utils.h index 42f4ff691..d48b3898b 100644 --- a/src/xenia/kernel/util/xdbf_utils.h +++ b/src/xenia/kernel/util/xdbf_utils.h @@ -75,6 +75,20 @@ struct XdbfStringTableEntry { }; static_assert_size(XdbfStringTableEntry, 4); +struct XdbfTitleHeaderData { + xe::be title_id; + xe::be title_type; + xe::be major; + xe::be minor; + xe::be build; + xe::be revision; + xe::be padding_0; + xe::be padding_1; + xe::be padding_2; + xe::be padding_3; +}; +static_assert_size(XdbfTitleHeaderData, 32); + struct XdbfContextTableEntry { xe::be id; xe::be unk1; @@ -183,6 +197,7 @@ class XdbfWrapper { std::vector GetProperties() const; std::vector GetContexts() const; + XdbfTitleHeaderData GetTitleInformation() const; XdbfAchievementTableEntry GetAchievement(const uint32_t id) const; XdbfPropertyTableEntry GetProperty(const uint32_t id) const; XdbfContextTableEntry GetContext(const uint32_t id) const;