[Kernel/CPU] Fix XEX version numbers not being output correctly

Couldn't find a way to get bitfields & byte-swapping to play well together, so this was the best I could come up with... at least the proper version numbers will show in the log file now :)
This commit is contained in:
emoose 2020-01-07 19:57:21 +00:00 committed by illusion
parent 4cf31a840a
commit 02839ab562
4 changed files with 29 additions and 45 deletions

View File

@ -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<uint32_t>(patch_header->source_version.value);
target_ver.value =
xe::byte_swap<uint32_t>(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);
}

View File

@ -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<ImportLibraryFn> imports;
};
struct SecurityInfoContext {

View File

@ -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<uint32_t>(library->version.value);
version_min.value =
xe::byte_swap<uint32_t>(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.

View File

@ -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<uint32_t> 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<uint32_t> media_id; // 0x0
xe::be<xex2_version> version; // 0x4
xe::be<xex2_version> base_version; // 0x8
xex2_version version; // 0x4
xex2_version base_version; // 0x8
xe::be<uint32_t> title_id; // 0xC
uint8_t platform; // 0x10
uint8_t executable_table; // 0x11