mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
Fix module mapping
This commit is contained in:
@@ -285,18 +285,25 @@ bool memory_manager::release_memory(const uint64_t address, size_t size)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t memory_manager::find_free_allocation_base(const size_t size) const
|
||||
uint64_t memory_manager::find_free_allocation_base(const size_t size, const uint64_t start) const
|
||||
{
|
||||
uint64_t start_address = std::max(MIN_ALLOCATION_ADDRESS, 0x1000000000ULL);
|
||||
uint64_t start_address =
|
||||
std::max(MIN_ALLOCATION_ADDRESS, start ? start : 0x100000000ULL);
|
||||
|
||||
for (const auto& region : this->reserved_regions_)
|
||||
{
|
||||
const auto region_end = region.first + region.second.length;
|
||||
if(region_end < start_address)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!regions_with_length_intersect(start_address, size, region.first, region.second.length))
|
||||
{
|
||||
return start_address;
|
||||
}
|
||||
|
||||
start_address = page_align_up(region.first + region.second.length);
|
||||
start_address = page_align_up(region_end);
|
||||
}
|
||||
|
||||
if (start_address + size <= MAX_ALLOCATION_ADDRESS)
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
bool release_memory(uint64_t address, size_t size);
|
||||
|
||||
uint64_t find_free_allocation_base(size_t size) const;
|
||||
uint64_t find_free_allocation_base(size_t size, uint64_t start = 0) const;
|
||||
|
||||
region_info get_region_info(uint64_t address);
|
||||
|
||||
|
||||
@@ -200,8 +200,8 @@ namespace
|
||||
if (!emu.allocate_memory(binary.image_base, binary.size_of_image, memory_permission::read))
|
||||
{
|
||||
binary.image_base = emu.find_free_allocation_base(binary.size_of_image);
|
||||
if ((optional_header.DllCharacteristics &
|
||||
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) == 0 || //
|
||||
if (/*(optional_header.DllCharacteristics &
|
||||
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) == 0 ||*/ //
|
||||
!emu.allocate_memory(
|
||||
binary.image_base, binary.size_of_image, memory_permission::read))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user