mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
Support loading comctl32.dll (#129)
This commit is contained in:
@@ -96,6 +96,7 @@ bool test_tls()
|
||||
|
||||
LoadLibraryA("d3dcompiler_47.dll");
|
||||
LoadLibraryA("dsound.dll");
|
||||
LoadLibraryA("comctl32.dll");
|
||||
/*LoadLibraryA("d3d9.dll");
|
||||
LoadLibraryA("dxgi.dll");
|
||||
LoadLibraryA("wlanapi.dll");*/
|
||||
|
||||
@@ -32,6 +32,8 @@ struct mapped_module
|
||||
|
||||
std::vector<mapped_section> sections{};
|
||||
|
||||
bool is_static{false};
|
||||
|
||||
bool is_within(const uint64_t address) const
|
||||
{
|
||||
return address >= this->image_base && address < (this->image_base + this->size_of_image);
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace utils
|
||||
|
||||
buffer.write_vector(mod.exports);
|
||||
buffer.write_map(mod.address_names);
|
||||
|
||||
buffer.write(mod.is_static);
|
||||
}
|
||||
|
||||
static void deserialize(buffer_deserializer& buffer, mapped_module& mod)
|
||||
@@ -47,6 +49,8 @@ namespace utils
|
||||
|
||||
buffer.read_vector(mod.exports);
|
||||
buffer.read_map(mod.address_names);
|
||||
|
||||
buffer.read(mod.is_static);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +60,13 @@ module_manager::module_manager(emulator& emu, file_system& file_sys)
|
||||
{
|
||||
}
|
||||
|
||||
mapped_module* module_manager::map_module(const windows_path& file, const logger& logger)
|
||||
mapped_module* module_manager::map_module(const windows_path& file, const logger& logger, const bool is_static)
|
||||
{
|
||||
return this->map_local_module(this->file_sys_->translate(file), logger);
|
||||
return this->map_local_module(this->file_sys_->translate(file), logger, is_static);
|
||||
}
|
||||
|
||||
mapped_module* module_manager::map_local_module(const std::filesystem::path& file, const logger& logger)
|
||||
mapped_module* module_manager::map_local_module(const std::filesystem::path& file, const logger& logger,
|
||||
const bool is_static)
|
||||
{
|
||||
auto local_file = canonical(absolute(file));
|
||||
|
||||
@@ -76,6 +81,7 @@ mapped_module* module_manager::map_local_module(const std::filesystem::path& fil
|
||||
try
|
||||
{
|
||||
auto mod = map_module_from_file(*this->emu_, std::move(local_file));
|
||||
mod.is_static = is_static;
|
||||
|
||||
logger.log("Mapped %s at 0x%" PRIx64 "\n", mod.path.generic_string().c_str(), mod.image_base);
|
||||
|
||||
@@ -105,7 +111,7 @@ void module_manager::deserialize(utils::buffer_deserializer& buffer)
|
||||
buffer.read_map(this->modules_);
|
||||
}
|
||||
|
||||
bool module_manager::unmap(const uint64_t address)
|
||||
bool module_manager::unmap(const uint64_t address, const logger& logger)
|
||||
{
|
||||
const auto mod = this->modules_.find(address);
|
||||
if (mod == this->modules_.end())
|
||||
@@ -113,6 +119,13 @@ bool module_manager::unmap(const uint64_t address)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mod->second.is_static)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.log("Unmapping %s (0x%" PRIx64 ")\n", mod->second.path.generic_string().c_str(), mod->second.image_base);
|
||||
|
||||
unmap_module(*this->emu_, mod->second);
|
||||
this->modules_.erase(mod);
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ class module_manager
|
||||
using module_map = std::map<uint64_t, mapped_module>;
|
||||
module_manager(emulator& emu, file_system& file_sys);
|
||||
|
||||
mapped_module* map_module(const windows_path& file, const logger& logger);
|
||||
mapped_module* map_local_module(const std::filesystem::path& file, const logger& logger);
|
||||
mapped_module* map_module(const windows_path& file, const logger& logger, bool is_static = false);
|
||||
mapped_module* map_local_module(const std::filesystem::path& file, const logger& logger, bool is_static = false);
|
||||
|
||||
mapped_module* find_by_address(const uint64_t address)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ class module_manager
|
||||
void serialize(utils::buffer_serializer& buffer) const;
|
||||
void deserialize(utils::buffer_deserializer& buffer);
|
||||
|
||||
bool unmap(const uint64_t address);
|
||||
bool unmap(const uint64_t address, const logger& logger);
|
||||
const module_map& modules() const
|
||||
{
|
||||
return modules_;
|
||||
|
||||
@@ -2633,7 +2633,7 @@ namespace
|
||||
|
||||
NTSTATUS handle_NtUserGetThreadState()
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtIsUILanguageComitted()
|
||||
@@ -3267,7 +3267,7 @@ namespace
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (c.proc.mod_manager.unmap(base_address))
|
||||
if (c.proc.mod_manager.unmap(base_address, c.win_emu.log))
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
@@ -3576,6 +3576,11 @@ namespace
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtRequestWaitReplyPort()
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserFindWindowEx()
|
||||
{
|
||||
return 0;
|
||||
@@ -3822,6 +3827,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& ha
|
||||
add_handler(NtUserFindWindowEx);
|
||||
add_handler(NtUserMoveWindow);
|
||||
add_handler(NtSystemDebugControl);
|
||||
add_handler(NtRequestWaitReplyPort);
|
||||
|
||||
#undef add_handler
|
||||
}
|
||||
|
||||
@@ -887,14 +887,14 @@ void windows_emulator::setup_process(const emulator_settings& settings)
|
||||
|
||||
setup_context(*this, settings);
|
||||
|
||||
context.executable = context.mod_manager.map_module(settings.application, this->log);
|
||||
context.executable = context.mod_manager.map_module(settings.application, this->log, true);
|
||||
|
||||
context.peb.access([&](PEB64& peb) {
|
||||
peb.ImageBaseAddress = reinterpret_cast<std::uint64_t*>(context.executable->image_base); //
|
||||
});
|
||||
|
||||
context.ntdll = context.mod_manager.map_module(R"(C:\Windows\System32\ntdll.dll)", this->log);
|
||||
context.win32u = context.mod_manager.map_module(R"(C:\Windows\System32\win32u.dll)", this->log);
|
||||
context.ntdll = context.mod_manager.map_module(R"(C:\Windows\System32\ntdll.dll)", this->log, true);
|
||||
context.win32u = context.mod_manager.map_module(R"(C:\Windows\System32\win32u.dll)", this->log, true);
|
||||
|
||||
const auto ntdll_data = emu.read_memory(context.ntdll->image_base, context.ntdll->size_of_image);
|
||||
const auto win32u_data = emu.read_memory(context.win32u->image_base, context.win32u->size_of_image);
|
||||
|
||||
Reference in New Issue
Block a user