mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-21 12:43:57 +00:00
Merge remote-tracking branch 'origin/main' into wow64
This commit is contained in:
@@ -54,7 +54,7 @@ struct mapped_module
|
||||
|
||||
bool contains(const uint64_t address) const
|
||||
{
|
||||
return address >= this->image_base && address < (this->image_base + this->size_of_image);
|
||||
return (address - this->image_base) < this->size_of_image;
|
||||
}
|
||||
|
||||
uint64_t find_export(const std::string_view export_name) const
|
||||
|
||||
@@ -211,6 +211,7 @@ mapped_module* module_manager::map_module_core(const pe_detection_result& detect
|
||||
|
||||
const auto image_base = mod.image_base;
|
||||
const auto entry = this->modules_.try_emplace(image_base, std::move(mod));
|
||||
this->last_module_cache_ = this->modules_.end();
|
||||
|
||||
// TODO: Patch shell32.dll entry point to prevent TLS storage issues
|
||||
// The shell32.dll module in SysWOW64 has TLS storage that fails, causing crashes
|
||||
@@ -409,6 +410,7 @@ void module_manager::install_wow64_heaven_gate(const logger& logger)
|
||||
module.sections.emplace_back(std::move(section));
|
||||
|
||||
this->modules_.emplace(module.image_base, std::move(module));
|
||||
this->last_module_cache_ = this->modules_.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,6 +523,7 @@ void module_manager::serialize(utils::buffer_serializer& buffer) const
|
||||
void module_manager::deserialize(utils::buffer_deserializer& buffer)
|
||||
{
|
||||
buffer.read_map(this->modules_);
|
||||
this->last_module_cache_ = this->modules_.end();
|
||||
|
||||
const auto executable_base = buffer.read<uint64_t>();
|
||||
const auto ntdll_base = buffer.read<uint64_t>();
|
||||
@@ -559,6 +562,7 @@ bool module_manager::unmap(const uint64_t address)
|
||||
this->callbacks_->on_module_unload(mod->second);
|
||||
unmap_module(*this->memory_, mod->second);
|
||||
this->modules_.erase(mod);
|
||||
this->last_module_cache_ = this->modules_.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ class module_manager
|
||||
callbacks* callbacks_{};
|
||||
|
||||
module_map modules_{};
|
||||
mutable module_map::iterator last_module_cache_{modules_.end()};
|
||||
|
||||
// Strategy pattern components
|
||||
mapping_strategy_factory strategy_factory_;
|
||||
@@ -198,6 +199,11 @@ class module_manager
|
||||
|
||||
module_map::iterator get_module(const uint64_t address)
|
||||
{
|
||||
if (last_module_cache_ != this->modules_.end() && last_module_cache_->second.contains(address))
|
||||
{
|
||||
return last_module_cache_;
|
||||
}
|
||||
|
||||
if (this->modules_.empty())
|
||||
{
|
||||
return this->modules_.end();
|
||||
@@ -213,6 +219,7 @@ class module_manager
|
||||
|
||||
if (upper_bound->second.contains(address))
|
||||
{
|
||||
last_module_cache_ = upper_bound;
|
||||
return upper_bound;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user