Calculate xex size based on the total size of all of the sections
This commit is contained in:
parent
380fabebe7
commit
e6b4c6056f
|
@ -585,9 +585,17 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header,
|
|||
uncompressed_size += data_size + zero_size;
|
||||
}
|
||||
|
||||
// Calculate the total size of the XEX image from its headers.
|
||||
uint32_t total_size = 0;
|
||||
for (uint32_t i = 0; i < header->section_count; i++) {
|
||||
xe_xex2_section_t& section = header->sections[i];
|
||||
|
||||
total_size += section.info.page_count * section.page_size;
|
||||
}
|
||||
|
||||
// Allocate in-place the XEX memory.
|
||||
uint32_t alloc_result = memory->HeapAlloc(
|
||||
header->exe_address, uncompressed_size, xe::MEMORY_FLAG_ZERO);
|
||||
header->exe_address, total_size, xe::MEMORY_FLAG_ZERO);
|
||||
if (!alloc_result) {
|
||||
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", header->exe_address,
|
||||
uncompressed_size);
|
||||
|
|
Loading…
Reference in New Issue