mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 11:43:56 +00:00
More cleanup and fixes
This commit is contained in:
@@ -34,6 +34,7 @@ public:
|
||||
virtual void read_raw_register(int reg, void* value, size_t size) = 0;
|
||||
virtual void write_raw_register(int reg, const void* value, size_t size) = 0;
|
||||
|
||||
virtual bool try_map_memory(uint64_t address, size_t size, memory_permission permissions) = 0;
|
||||
virtual void map_memory(uint64_t address, size_t size, memory_permission permissions) = 0;
|
||||
virtual void unmap_memory(uint64_t address, size_t size) = 0;
|
||||
|
||||
|
||||
@@ -53,10 +53,11 @@ namespace unicorn
|
||||
|
||||
this->uc_ = obj.uc_;
|
||||
this->hook_ = obj.hook_;
|
||||
|
||||
obj.hook_ = {};
|
||||
obj.uc_ = {};
|
||||
}
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ namespace unicorn
|
||||
|
||||
~unicorn_x64_emulator() override
|
||||
{
|
||||
this->hooks_.clear();
|
||||
uc_close(this->uc_);
|
||||
}
|
||||
|
||||
@@ -196,6 +197,11 @@ namespace unicorn
|
||||
uce(uc_mem_map(*this, address, size, static_cast<uint32_t>(permissions)));
|
||||
}
|
||||
|
||||
bool try_map_memory(const uint64_t address, const size_t size, memory_permission permissions) override
|
||||
{
|
||||
return uc_mem_map(*this, address, size, static_cast<uint32_t>(permissions)) == UC_ERR_OK;
|
||||
}
|
||||
|
||||
void unmap_memory(const uint64_t address, const size_t size) override
|
||||
{
|
||||
uce(uc_mem_unmap(*this, address, size));
|
||||
|
||||
@@ -400,21 +400,13 @@ namespace
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
succeeded = emu.try_map_memory(allocation_base, allocation_bytes, protection);
|
||||
if (succeeded || !allocate_anywhere)
|
||||
{
|
||||
emu.map_memory(allocation_base, allocation_bytes, protection);
|
||||
succeeded = true;
|
||||
break;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!allocate_anywhere)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
allocation_base += allocation_granularity;
|
||||
}
|
||||
allocation_base += allocation_granularity;
|
||||
}
|
||||
|
||||
base_address.write(allocation_base);
|
||||
@@ -463,22 +455,13 @@ namespace
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
succeeded = emu.try_map_memory(allocation_base, allocation_bytes, protection);
|
||||
if (succeeded || !allocate_anywhere)
|
||||
{
|
||||
emu.map_memory(allocation_base, allocation_bytes, protection);
|
||||
succeeded = true;
|
||||
break;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
succeeded = false;
|
||||
if (!allocate_anywhere)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
allocation_base += allocation_granularity;
|
||||
}
|
||||
allocation_base += allocation_granularity;
|
||||
}
|
||||
|
||||
base_address.write(allocation_base);
|
||||
|
||||
Reference in New Issue
Block a user