| 1 | #include "VirtualMemory.h" |
| 2 | |
| 3 | void VirtualMemory::MapRegion(WeakFileAccessor fileAccessor, AddressRange mappedRange, uint64_t fileOffset) |
| 4 | { |
| 5 | // Create a new VirtualMemoryRegion object |
| 6 | VirtualMemoryRegion region {fileOffset, std::move(fileAccessor)}; |
| 7 | |
| 8 | // TODO: How to handle overlapping regions? |
| 9 | for (const auto& [existingRange, existingRegion] : m_regions) |
| 10 | { |
| 11 | if (existingRange.Overlaps(mappedRange)) |
| 12 | { |
| 13 | // Handle overlapping regions, e.g., throw an exception or skip the mapping |
| 14 | BinaryNinja::LogError("Overlapping memory region %llx", existingRange.start); |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | // Insert the region into the map |
| 19 | m_regions.insert_or_assign(mappedRange, region); |
| 20 | } |
| 21 | |
| 22 | std::optional<VirtualMemoryRegion> VirtualMemory::GetRegionAtAddress(uint64_t address, uint64_t& addressOffset) |
| 23 | { |