From 3b5ef52621c9d7596451c59fb5d60ffb5628365a Mon Sep 17 00:00:00 2001 From: Cancerous Date: Fri, 6 Dec 2019 11:57:48 -0500 Subject: [PATCH] title update fixup - breaks xex1 temporarily --- src/xenia/cpu/xex_module.cc | 21 +++++++++++---------- src/xenia/cpu/xex_module.h | 8 ++++---- src/xenia/kernel/user_module.cc | 12 ++++++------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 2d1e6de28..e45aa57ad 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -103,9 +103,10 @@ bool XexModule::GetOptHeader(xex2_header_keys key, void** out_ptr) const { return XexModule::GetOptHeader(xex_header(), key, out_ptr); } -const void* XexModule::GetSecurityInfo(const xex2_header* header) { - return reinterpret_cast(uintptr_t(header) + - header->security_offset); +const xex2_security_info* XexModule::GetSecurityInfo( + const xex2_header* header) { + return reinterpret_cast(uintptr_t(header) + + header->security_offset); } const PESection* XexModule::GetPESection(const char* name) { @@ -120,9 +121,9 @@ const PESection* XexModule::GetPESection(const char* name) { uint32_t XexModule::GetProcAddress(uint16_t ordinal) const { // First: Check the xex2 export table. - if (*xex_security_info()->export_table) { + if (xex_security_info()->export_table) { auto export_table = memory()->TranslateVirtual( - *xex_security_info()->export_table); + xex_security_info()->export_table); ordinal -= export_table->base; if (ordinal >= export_table->count) { @@ -587,7 +588,7 @@ int XexModule::ReadImageBasicCompressed(const void* xex_addr, // Calculate the total size of the XEX image from its headers. uint32_t total_size = 0; - for (uint32_t i = 0; i < *xex_security_info()->page_descriptor_count; i++) { + for (uint32_t i = 0; i < xex_security_info()->page_descriptor_count; i++) { // Byteswap the bitfield manually. xex2_page_descriptor desc; desc.value = xe::byte_swap(xex_security_info()->page_descriptors[i].value); @@ -916,7 +917,7 @@ bool XexModule::Load(const std::string& name, const std::string& path, // Try setting our base_address based on XEX_HEADER_IMAGE_BASE_ADDRESS, fall // back to xex_security_info otherwise - base_address_ = *xex_security_info()->load_address; + base_address_ = xex_security_info()->load_address; xe::be* base_addr_opt = nullptr; if (GetOptHeader(XEX_HEADER_IMAGE_BASE_ADDRESS, &base_addr_opt)) base_address_ = *base_addr_opt; @@ -971,7 +972,7 @@ bool XexModule::LoadContinue() { high_address_ = 0; auto sec_header = xex_security_info(); - for (uint32_t i = 0, page = 0; i < *sec_header->page_descriptor_count; i++) { + for (uint32_t i = 0, page = 0; i < sec_header->page_descriptor_count; i++) { // Byteswap the bitfield manually. xex2_page_descriptor desc; desc.value = xe::byte_swap(sec_header->page_descriptors[i].value); @@ -1046,7 +1047,7 @@ bool XexModule::LoadContinue() { } // Setup memory protection. - for (uint32_t i = 0, page = 0; i < *sec_header->page_descriptor_count; i++) { + for (uint32_t i = 0, page = 0; i < sec_header->page_descriptor_count; i++) { // Byteswap the bitfield manually. xex2_page_descriptor desc; desc.value = xe::byte_swap(sec_header->page_descriptors[i].value); @@ -1449,7 +1450,7 @@ 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++) { + for (uint32_t i = 0, page = 0; i < sec_header->page_descriptor_count; i++) { // Byteswap the bitfield manually. xex2_page_descriptor desc; desc.value = xe::byte_swap(sec_header->page_descriptors[i].value); diff --git a/src/xenia/cpu/xex_module.h b/src/xenia/cpu/xex_module.h index 2f669d555..9cf57cc6b 100644 --- a/src/xenia/cpu/xex_module.h +++ b/src/xenia/cpu/xex_module.h @@ -66,8 +66,8 @@ class XexModule : public xe::cpu::Module { const xex2_header* xex_header() const { return reinterpret_cast(xex_header_mem_.data()); } - const SecurityInfoContext* xex_security_info() const { - return &security_info_; + const xex2_security_info* xex_security_info() const { + return GetSecurityInfo(xex_header()); } uint32_t image_size() const { @@ -76,7 +76,7 @@ class XexModule : public xe::cpu::Module { // Calculate the new total size of the XEX image from its headers. auto heap = memory()->LookupHeap(base_address_); uint32_t total_size = 0; - for (uint32_t i = 0; i < *xex_security_info()->page_descriptor_count; i++) { + for (uint32_t i = 0; i < xex_security_info()->page_descriptor_count; i++) { // Byteswap the bitfield manually. xex2_page_descriptor desc; desc.value = @@ -127,7 +127,7 @@ class XexModule : public xe::cpu::Module { return GetOptHeader(key, reinterpret_cast(out_ptr)); } - static const void* GetSecurityInfo(const xex2_header* header); + static const xex2_security_info* GetSecurityInfo(const xex2_header* header); const PESection* GetPESection(const char* name); diff --git a/src/xenia/kernel/user_module.cc b/src/xenia/kernel/user_module.cc index 692e8f5d5..1851250ad 100644 --- a/src/xenia/kernel/user_module.cc +++ b/src/xenia/kernel/user_module.cc @@ -272,7 +272,7 @@ X_STATUS UserModule::LoadXexContinue() { ldr_data->dll_base = 0; // GetProcAddress will read this. ldr_data->xex_header_base = guest_xex_header_; - ldr_data->full_image_size = *security_header->image_size; + ldr_data->full_image_size = security_header->image_size; ldr_data->image_base = this->xex_module()->base_address(); ldr_data->entry_point = entry_point_; @@ -453,13 +453,13 @@ void UserModule::Dump() { auto security_info = xex_module()->xex_security_info(); sb.AppendFormat("Security Header:\n"); sb.AppendFormat(" Image Flags: %.8X\n", - (uint32_t)*security_info->image_flags); + (uint32_t)security_info->image_flags); sb.AppendFormat(" Load Address: %.8X\n", - (uint32_t)*security_info->load_address); + (uint32_t)security_info->load_address); sb.AppendFormat(" Image Size: %.8X\n", - (uint32_t)*security_info->image_size); + (uint32_t)security_info->image_size); sb.AppendFormat(" Export Table: %.8X\n", - (uint32_t)*security_info->export_table); + (uint32_t)security_info->export_table); // Optional headers sb.AppendFormat("Optional Header Count: %d\n", @@ -703,7 +703,7 @@ void UserModule::Dump() { } sb.AppendFormat("Sections:\n"); - for (uint32_t i = 0, page = 0; i < *security_info->page_descriptor_count; + for (uint32_t i = 0, page = 0; i < security_info->page_descriptor_count; i++) { // Manually byteswap the bitfield data. xex2_page_descriptor page_descriptor;