From f41e7bf881504477994d1fd2b9f7e70734fedcfd Mon Sep 17 00:00:00 2001 From: ahm3dgg Date: Fri, 9 Jan 2026 06:45:32 +0200 Subject: [PATCH] Exclude win32u.dll from module_load_count --- src/windows-emulator/module/module_manager.cpp | 6 +++--- src/windows-emulator/module/module_manager.hpp | 2 +- src/windows-emulator/syscalls/section.cpp | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/windows-emulator/module/module_manager.cpp b/src/windows-emulator/module/module_manager.cpp index 4a2a491b..b715ab28 100644 --- a/src/windows-emulator/module/module_manager.cpp +++ b/src/windows-emulator/module/module_manager.cpp @@ -221,7 +221,7 @@ mapped_module* module_manager::map_module_core(const pe_detection_result& detect mapped_module mod = mapper(); mod.is_static = is_static; - if (!mod.path.empty()) + if (!mod.path.empty() && mod.path.filename() != "win32u.dll") { this->module_load_count[mod.path]++; } @@ -451,9 +451,9 @@ void module_manager::map_main_modules(const windows_path& executable_path, const } } -std::optional module_manager::get_module_load_count_by_path(const std::filesystem::path& path) +std::optional module_manager::get_module_load_count_by_path(const windows_path& path) { - auto local_file = weakly_canonical(absolute(path)); + auto local_file = std::filesystem::weakly_canonical(std::filesystem::absolute(this->file_sys_->translate(path))); if (!module_load_count.contains(local_file)) { diff --git a/src/windows-emulator/module/module_manager.hpp b/src/windows-emulator/module/module_manager.hpp index 717dc3cf..38a28ee4 100644 --- a/src/windows-emulator/module/module_manager.hpp +++ b/src/windows-emulator/module/module_manager.hpp @@ -94,7 +94,7 @@ class module_manager void map_main_modules(const windows_path& executable_path, const windows_path& system32_path, const windows_path& syswow64_path, const logger& logger); - std::optional get_module_load_count_by_path(const std::filesystem::path& path); + std::optional get_module_load_count_by_path(const windows_path& path); mapped_module* map_module(const windows_path& file, const logger& logger, bool is_static = false, bool allow_duplicate = false); mapped_module* map_local_module(const std::filesystem::path& file, const logger& logger, bool is_static = false, bool allow_duplicate = false); diff --git a/src/windows-emulator/syscalls/section.cpp b/src/windows-emulator/syscalls/section.cpp index 93b92745..d2a39d3d 100644 --- a/src/windows-emulator/syscalls/section.cpp +++ b/src/windows-emulator/syscalls/section.cpp @@ -285,8 +285,7 @@ namespace syscalls return STATUS_IMAGE_MACHINE_TYPE_MISMATCH; } - auto local_file = c.win_emu.file_sys.translate(section_entry->file_name); - if (c.win_emu.mod_manager.get_module_load_count_by_path(local_file) > 1) + if (c.win_emu.mod_manager.get_module_load_count_by_path(section_entry->file_name) > 1) { return STATUS_IMAGE_NOT_AT_BASE; }