From 57a823ae39b22687591dc023bd34cf227dd914c4 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 1 Dec 2015 19:53:17 -0600 Subject: [PATCH] Add (commented out) code to setup page protections for xex modules. --- src/xenia/cpu/xex_module.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 07730e211..ba2a24184 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -281,6 +281,34 @@ bool XexModule::Load(const std::string& name, const std::string& path, } } + // Setup memory protection. + // TODO: This introduces a load of constants into the JIT, and Xenia isn't + // quite set-up to handle constants yet... + /* + auto sec_header = xex_security_info(); + auto heap = memory()->LookupHeap(sec_header->load_address); + auto page_size = heap->page_size(); + 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); + + auto address = sec_header->load_address + (page * page_size); + auto size = desc.size * page_size; + switch (desc.info) { + case XEX_SECTION_CODE: + case XEX_SECTION_READONLY_DATA: + heap->Protect(address, size, kMemoryProtectRead); + break; + case XEX_SECTION_DATA: + heap->Protect(address, size, kMemoryProtectRead | kMemoryProtectWrite); + break; + } + + page += desc.size; + } + */ + return true; }