Rewriting memory manager.

This commit is contained in:
Ben Vanik
2015-05-16 00:23:13 -07:00
parent 3a7d1f21e8
commit 147a70b9c1
23 changed files with 1348 additions and 657 deletions

View File

@@ -30,8 +30,11 @@ bool RawModule::LoadFile(uint32_t base_address, const std::wstring& path) {
// Allocate memory.
// Since we have no real heap just load it wherever.
base_address_ = base_address;
memory_->LookupHeap(base_address_)
->AllocFixed(base_address_, file_length, 0,
kMemoryAllocationReserve | kMemoryAllocationCommit,
kMemoryProtectRead | kMemoryProtectWrite);
uint8_t* p = memory_->TranslateVirtual(base_address_);
std::memset(p, 0, file_length);
// Read into memory.
fread(p, file_length, 1, file);