Merge pull request #205 from DrChat/dll_size_fix
Correct DLL allocation size based on section headers
This commit is contained in:
commit
76e8929d6e
|
@ -585,9 +585,17 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header,
|
||||||
uncompressed_size += data_size + zero_size;
|
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.
|
// Allocate in-place the XEX memory.
|
||||||
uint32_t alloc_result = memory->HeapAlloc(
|
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) {
|
if (!alloc_result) {
|
||||||
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", header->exe_address,
|
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", header->exe_address,
|
||||||
uncompressed_size);
|
uncompressed_size);
|
||||||
|
|
Loading…
Reference in New Issue