title update fixup - breaks xex1 temporarily
This commit is contained in:
parent
5627e3abb5
commit
cb246e7501
|
@ -103,9 +103,10 @@ bool XexModule::GetOptHeader(xex2_header_keys key, void** out_ptr) const {
|
||||||
return XexModule::GetOptHeader(xex_header(), key, out_ptr);
|
return XexModule::GetOptHeader(xex_header(), key, out_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* XexModule::GetSecurityInfo(const xex2_header* header) {
|
const xex2_security_info* XexModule::GetSecurityInfo(
|
||||||
return reinterpret_cast<const void*>(uintptr_t(header) +
|
const xex2_header* header) {
|
||||||
header->security_offset);
|
return reinterpret_cast<const xex2_security_info*>(uintptr_t(header) +
|
||||||
|
header->security_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PESection* XexModule::GetPESection(const char* name) {
|
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 {
|
uint32_t XexModule::GetProcAddress(uint16_t ordinal) const {
|
||||||
// First: Check the xex2 export table.
|
// First: Check the xex2 export table.
|
||||||
if (*xex_security_info()->export_table) {
|
if (xex_security_info()->export_table) {
|
||||||
auto export_table = memory()->TranslateVirtual<const xex2_export_table*>(
|
auto export_table = memory()->TranslateVirtual<const xex2_export_table*>(
|
||||||
*xex_security_info()->export_table);
|
xex_security_info()->export_table);
|
||||||
|
|
||||||
ordinal -= export_table->base;
|
ordinal -= export_table->base;
|
||||||
if (ordinal >= export_table->count) {
|
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.
|
// Calculate the total size of the XEX image from its headers.
|
||||||
uint32_t total_size = 0;
|
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.
|
// Byteswap the bitfield manually.
|
||||||
xex2_page_descriptor desc;
|
xex2_page_descriptor desc;
|
||||||
desc.value = xe::byte_swap(xex_security_info()->page_descriptors[i].value);
|
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
|
// Try setting our base_address based on XEX_HEADER_IMAGE_BASE_ADDRESS, fall
|
||||||
// back to xex_security_info otherwise
|
// back to xex_security_info otherwise
|
||||||
base_address_ = *xex_security_info()->load_address;
|
base_address_ = xex_security_info()->load_address;
|
||||||
xe::be<uint32_t>* base_addr_opt = nullptr;
|
xe::be<uint32_t>* base_addr_opt = nullptr;
|
||||||
if (GetOptHeader(XEX_HEADER_IMAGE_BASE_ADDRESS, &base_addr_opt))
|
if (GetOptHeader(XEX_HEADER_IMAGE_BASE_ADDRESS, &base_addr_opt))
|
||||||
base_address_ = *base_addr_opt;
|
base_address_ = *base_addr_opt;
|
||||||
|
@ -971,7 +972,7 @@ bool XexModule::LoadContinue() {
|
||||||
high_address_ = 0;
|
high_address_ = 0;
|
||||||
|
|
||||||
auto sec_header = xex_security_info();
|
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.
|
// Byteswap the bitfield manually.
|
||||||
xex2_page_descriptor desc;
|
xex2_page_descriptor desc;
|
||||||
desc.value = xe::byte_swap(sec_header->page_descriptors[i].value);
|
desc.value = xe::byte_swap(sec_header->page_descriptors[i].value);
|
||||||
|
@ -1046,7 +1047,7 @@ bool XexModule::LoadContinue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup memory protection.
|
// 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.
|
// Byteswap the bitfield manually.
|
||||||
xex2_page_descriptor desc;
|
xex2_page_descriptor desc;
|
||||||
desc.value = xe::byte_swap(sec_header->page_descriptors[i].value);
|
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 page_size = base_address_ <= 0x90000000 ? 64 * 1024 : 4 * 1024;
|
||||||
auto sec_header = xex_security_info();
|
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.
|
// Byteswap the bitfield manually.
|
||||||
xex2_page_descriptor desc;
|
xex2_page_descriptor desc;
|
||||||
desc.value = xe::byte_swap(sec_header->page_descriptors[i].value);
|
desc.value = xe::byte_swap(sec_header->page_descriptors[i].value);
|
||||||
|
|
|
@ -66,8 +66,8 @@ class XexModule : public xe::cpu::Module {
|
||||||
const xex2_header* xex_header() const {
|
const xex2_header* xex_header() const {
|
||||||
return reinterpret_cast<const xex2_header*>(xex_header_mem_.data());
|
return reinterpret_cast<const xex2_header*>(xex_header_mem_.data());
|
||||||
}
|
}
|
||||||
const SecurityInfoContext* xex_security_info() const {
|
const xex2_security_info* xex_security_info() const {
|
||||||
return &security_info_;
|
return GetSecurityInfo(xex_header());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t image_size() const {
|
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.
|
// Calculate the new total size of the XEX image from its headers.
|
||||||
auto heap = memory()->LookupHeap(base_address_);
|
auto heap = memory()->LookupHeap(base_address_);
|
||||||
uint32_t total_size = 0;
|
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.
|
// Byteswap the bitfield manually.
|
||||||
xex2_page_descriptor desc;
|
xex2_page_descriptor desc;
|
||||||
desc.value =
|
desc.value =
|
||||||
|
@ -127,7 +127,7 @@ class XexModule : public xe::cpu::Module {
|
||||||
return GetOptHeader(key, reinterpret_cast<void**>(out_ptr));
|
return GetOptHeader(key, reinterpret_cast<void**>(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);
|
const PESection* GetPESection(const char* name);
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ X_STATUS UserModule::LoadXexContinue() {
|
||||||
|
|
||||||
ldr_data->dll_base = 0; // GetProcAddress will read this.
|
ldr_data->dll_base = 0; // GetProcAddress will read this.
|
||||||
ldr_data->xex_header_base = guest_xex_header_;
|
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->image_base = this->xex_module()->base_address();
|
||||||
ldr_data->entry_point = entry_point_;
|
ldr_data->entry_point = entry_point_;
|
||||||
|
|
||||||
|
@ -453,13 +453,13 @@ void UserModule::Dump() {
|
||||||
auto security_info = xex_module()->xex_security_info();
|
auto security_info = xex_module()->xex_security_info();
|
||||||
sb.AppendFormat("Security Header:\n");
|
sb.AppendFormat("Security Header:\n");
|
||||||
sb.AppendFormat(" Image Flags: %.8X\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",
|
sb.AppendFormat(" Load Address: %.8X\n",
|
||||||
(uint32_t)*security_info->load_address);
|
(uint32_t)security_info->load_address);
|
||||||
sb.AppendFormat(" Image Size: %.8X\n",
|
sb.AppendFormat(" Image Size: %.8X\n",
|
||||||
(uint32_t)*security_info->image_size);
|
(uint32_t)security_info->image_size);
|
||||||
sb.AppendFormat(" Export Table: %.8X\n",
|
sb.AppendFormat(" Export Table: %.8X\n",
|
||||||
(uint32_t)*security_info->export_table);
|
(uint32_t)security_info->export_table);
|
||||||
|
|
||||||
// Optional headers
|
// Optional headers
|
||||||
sb.AppendFormat("Optional Header Count: %d\n",
|
sb.AppendFormat("Optional Header Count: %d\n",
|
||||||
|
@ -703,7 +703,7 @@ void UserModule::Dump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendFormat("Sections:\n");
|
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++) {
|
i++) {
|
||||||
// Manually byteswap the bitfield data.
|
// Manually byteswap the bitfield data.
|
||||||
xex2_page_descriptor page_descriptor;
|
xex2_page_descriptor page_descriptor;
|
||||||
|
|
Loading…
Reference in New Issue