diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 88a61b964..a1a859d90 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -754,7 +754,7 @@ int XexModule::ReadImageBasicCompressed(const void* xex_addr, xex2_page_descriptor desc; desc.value = xe::byte_swap(xex_security_info()->page_descriptors[i].value); - total_size += desc.size * heap->page_size(); + total_size += desc.page_count * heap->page_size(); } // Allocate in-place the XEX memory. @@ -1108,13 +1108,13 @@ bool XexModule::LoadContinue() { desc.value = xe::byte_swap(sec_header->page_descriptors[i].value); const auto start_address = base_address_ + (page * page_size); - const auto end_address = start_address + (desc.size * page_size); + const auto end_address = start_address + (desc.page_count * page_size); if (desc.info == XEX_SECTION_CODE) { low_address_ = std::min(low_address_, start_address); high_address_ = std::max(high_address_, end_address); } - page += desc.size; + page += desc.page_count; } // Notify backend that we have an executable range. @@ -1180,7 +1180,7 @@ bool XexModule::LoadContinue() { desc.value = xe::byte_swap(sec_header->page_descriptors[i].value); auto address = base_address_ + (page * page_size); - auto size = desc.size * page_size; + auto size = desc.page_count * page_size; switch (desc.info) { case XEX_SECTION_CODE: case XEX_SECTION_READONLY_DATA: @@ -1191,7 +1191,7 @@ bool XexModule::LoadContinue() { break; } - page += desc.size; + page += desc.page_count; } return true; @@ -1576,12 +1576,14 @@ bool XexModule::FindSaveRest() { auto page_size = base_address_ <= 0x90000000 ? 64 * 1024 : 4 * 1024; auto sec_header = xex_security_info(); for (uint32_t i = 0, page = 0; i < sec_header->page_descriptor_count; i++) { - const xex2_page_descriptor* section = - &xex_security_info()->page_descriptors[i]; - const auto start_address = base_address_ + (page * page_size); - const auto end_address = start_address + (section->size * page_size); + // Byteswap the bitfield manually. + xex2_page_descriptor desc; + desc.value = xe::byte_swap(sec_header->page_descriptors[i].value); - if (section->info == XEX_SECTION_CODE) { + const auto start_address = base_address_ + (page * page_size); + const auto end_address = start_address + (desc.page_count * page_size); + + if (desc.info == XEX_SECTION_CODE) { if (!gplr_start) { gplr_start = memory_->SearchAligned(start_address, end_address, gprlr_code_values, @@ -1602,7 +1604,7 @@ bool XexModule::FindSaveRest() { } } - page += section->size; + page += desc.page_count; } // Add function stubs. diff --git a/src/xenia/cpu/xex_module.h b/src/xenia/cpu/xex_module.h index d9d1996de..5c8cb8d6b 100644 --- a/src/xenia/cpu/xex_module.h +++ b/src/xenia/cpu/xex_module.h @@ -67,7 +67,7 @@ class XexModule : public xe::cpu::Module { desc.value = xe::byte_swap(xex_security_info()->page_descriptors[i].value); - total_size += desc.size * heap->page_size(); + total_size += desc.page_count * heap->page_size(); } return total_size; } diff --git a/src/xenia/kernel/user_module.cc b/src/xenia/kernel/user_module.cc index 644b8c315..fb0e48179 100644 --- a/src/xenia/kernel/user_module.cc +++ b/src/xenia/kernel/user_module.cc @@ -679,12 +679,13 @@ void UserModule::Dump() { const uint32_t page_size = xex_module()->base_address() < 0x90000000 ? 64 * 1024 : 4 * 1024; uint32_t start_address = xex_module()->base_address() + (page * page_size); - uint32_t end_address = start_address + (page_descriptor.size * page_size); + uint32_t end_address = + start_address + (page_descriptor.page_count * page_size); sb.AppendFormat(" %3u %s %3u pages %.8X - %.8X (%d bytes)\n", page, - type, page_descriptor.size, start_address, end_address, - page_descriptor.size * page_size); - page += page_descriptor.size; + type, page_descriptor.page_count, start_address, + end_address, page_descriptor.page_count * page_size); + page += page_descriptor.page_count; } // Print out imports. diff --git a/src/xenia/kernel/util/xex2_info.h b/src/xenia/kernel/util/xex2_info.h index 4a7d85d2f..23aa62524 100644 --- a/src/xenia/kernel/util/xex2_info.h +++ b/src/xenia/kernel/util/xex2_info.h @@ -514,8 +514,8 @@ struct xex2_header { struct xex2_page_descriptor { union { struct { - uint32_t info : 4; - uint32_t size : 28; + xex2_section_type info : 4; + uint32_t page_count : 28; }; xe::be value; // 0x0 };