diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 2e9daf0e0..4fed0907c 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -447,19 +447,15 @@ int XexModule::ApplyPatch(XexModule* module) { } } - // byteswap versions because of bitfields... - xex2_version source_ver, target_ver; - source_ver.value = - xe::byte_swap(patch_header->source_version.value); - - target_ver.value = - xe::byte_swap(patch_header->target_version.value); + auto& source_ver = patch_header->source_version; + auto& target_ver = patch_header->target_version; XELOGI( "XEX patch applied successfully: base version: %d.%d.%d.%d, new " "version: %d.%d.%d.%d", - source_ver.major, source_ver.minor, source_ver.build, source_ver.qfe, - target_ver.major, target_ver.minor, target_ver.build, target_ver.qfe); + source_ver.major(), source_ver.minor(), source_ver.build(), + source_ver.qfe(), target_ver.major(), target_ver.minor(), + target_ver.build(), target_ver.qfe()); } else { XELOGE("XEX patch application failed, error code %d", result_code); } diff --git a/src/xenia/cpu/xex_module.h b/src/xenia/cpu/xex_module.h index 9cf57cc6b..50ef4726c 100644 --- a/src/xenia/cpu/xex_module.h +++ b/src/xenia/cpu/xex_module.h @@ -39,8 +39,8 @@ class XexModule : public xe::cpu::Module { public: std::string name; uint32_t id; - xe_xex2_version_t version; - xe_xex2_version_t min_version; + xex2_version version; + xex2_version min_version; std::vector imports; }; struct SecurityInfoContext { diff --git a/src/xenia/kernel/user_module.cc b/src/xenia/kernel/user_module.cc index 3b25113c5..0d657e14a 100644 --- a/src/xenia/kernel/user_module.cc +++ b/src/xenia/kernel/user_module.cc @@ -551,16 +551,14 @@ void UserModule::Dump() { sb.AppendFormat(" %s - %d imports\n", name, (uint16_t)library->count); - // Manually byteswap these because of the bitfields. - xex2_version version, version_min; - version.value = xe::byte_swap(library->version.value); - version_min.value = - xe::byte_swap(library->version_min.value); - sb.AppendFormat(" Version: %d.%d.%d.%d\n", version.major, - version.minor, version.build, version.qfe); - sb.AppendFormat(" Min Version: %d.%d.%d.%d\n", version_min.major, - version_min.minor, version_min.build, - version_min.qfe); + auto& version = library->version; + auto& version_min = library->version_min; + + sb.AppendFormat(" Version: %d.%d.%d.%d\n", version.major(), + version.minor(), version.build(), version.qfe()); + sb.AppendFormat(" Min Version: %d.%d.%d.%d\n", + version_min.major(), version_min.minor(), + version_min.build(), version_min.qfe()); library_offset += library->size; } @@ -742,12 +740,13 @@ void UserModule::Dump() { if (library->imports.size() > 0) { sb.AppendFormat(" %s - %lld imports\n", library->name.c_str(), library->imports.size()); - sb.AppendFormat(" Version: %d.%d.%d.%d\n", library->version.major, - library->version.minor, library->version.build, - library->version.qfe); + sb.AppendFormat(" Version: %d.%d.%d.%d\n", library->version.major(), + library->version.minor(), library->version.build(), + library->version.qfe()); sb.AppendFormat(" Min Version: %d.%d.%d.%d\n", - library->min_version.major, library->min_version.minor, - library->min_version.build, library->min_version.qfe); + library->min_version.major(), + library->min_version.minor(), + library->min_version.build(), library->min_version.qfe()); sb.AppendFormat("\n"); // Counts. diff --git a/src/xenia/kernel/util/xex2_info.h b/src/xenia/kernel/util/xex2_info.h index 6203b18f2..52fc97576 100644 --- a/src/xenia/kernel/util/xex2_info.h +++ b/src/xenia/kernel/util/xex2_info.h @@ -14,16 +14,6 @@ #include "xenia/base/byte_order.h" -union xe_xex2_version_t { - uint32_t value; - struct { - uint32_t major : 4; - uint32_t minor : 4; - uint32_t build : 16; - uint32_t qfe : 8; - }; -}; - enum xe_pe_section_flags_e : uint32_t { kXEPESectionContainsCode = 0x00000020, kXEPESectionContainsDataInit = 0x00000040, @@ -371,14 +361,13 @@ struct xex2_opt_file_format_info { } compression_info; }; -union xex2_version { +struct xex2_version { xe::be value; - struct { - uint32_t major : 4; - uint32_t minor : 4; - uint32_t build : 16; - uint32_t qfe : 8; - }; + + uint32_t qfe() const { return value & 0xFF; } + uint32_t build() const { return (value >> 8) & 0xFFFF; } + uint32_t minor() const { return (value >> 24) & 0xF; } + uint32_t major() const { return (value >> 28) & 0xF; } }; struct xex2_opt_lan_key { @@ -462,8 +451,8 @@ struct xex2_opt_delta_patch_descriptor { struct xex2_opt_execution_info { xe::be media_id; // 0x0 - xe::be version; // 0x4 - xe::be base_version; // 0x8 + xex2_version version; // 0x4 + xex2_version base_version; // 0x8 xe::be title_id; // 0xC uint8_t platform; // 0x10 uint8_t executable_table; // 0x11