From c889a8af3f71897a1d12dd4642cb45f33529ad39 Mon Sep 17 00:00:00 2001 From: emoose Date: Tue, 15 Jun 2021 22:28:09 +0100 Subject: [PATCH] [CPU] Load alt-title-ids XEX header into XexModule::opt_alternate_title_ids_ --- src/xenia/cpu/xex_module.cc | 10 ++++++++++ src/xenia/cpu/xex_module.h | 7 +++++++ src/xenia/kernel/util/xex2_info.h | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 70861aa7e..83fbc2139 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -966,6 +966,16 @@ bool XexModule::LoadContinue() { return false; } + // Parse any "unsafe" headers into safer variants + xex2_opt_generic_u32* alternate_titleids; + if (GetOptHeader(xex2_header_keys::XEX_HEADER_ALTERNATE_TITLE_IDS, + &alternate_titleids)) { + auto count = alternate_titleids->count(); + for (uint32_t i = 0; i < count; i++) { + opt_alternate_title_ids_.push_back(alternate_titleids->values[i]); + } + } + // Scan and find the low/high addresses. // All code sections are continuous, so this should be easy. auto heap = memory()->LookupHeap(base_address_); diff --git a/src/xenia/cpu/xex_module.h b/src/xenia/cpu/xex_module.h index 9834a675f..cd8fc49c5 100644 --- a/src/xenia/cpu/xex_module.h +++ b/src/xenia/cpu/xex_module.h @@ -107,6 +107,10 @@ class XexModule : public xe::cpu::Module { return retval; } + std::vector opt_alternate_title_ids() const { + return opt_alternate_title_ids_; + } + const uint32_t base_address() const { return base_address_; } const bool is_dev_kit() const { return is_dev_kit_; } @@ -198,6 +202,9 @@ class XexModule : public xe::cpu::Module { import_libs_; // pre-loaded import libraries for ease of use std::vector pe_sections_; + // XEX_HEADER_ALTERNATE_TITLE_IDS loaded into a safe std::vector + std::vector opt_alternate_title_ids_; + uint8_t session_key_[0x10]; bool is_dev_kit_ = false; diff --git a/src/xenia/kernel/util/xex2_info.h b/src/xenia/kernel/util/xex2_info.h index a5b5e5a33..6b77476d8 100644 --- a/src/xenia/kernel/util/xex2_info.h +++ b/src/xenia/kernel/util/xex2_info.h @@ -529,6 +529,13 @@ struct xex2_import_library { } }; +struct xex2_opt_generic_u32 { + xe::be size; + xe::be values[1]; + + uint32_t count() const { return (size - 4) / 4; } +}; + struct xex2_opt_header { xe::be key; // 0x0