From d21a114f84965fee605dcd228928f2a04874571a Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Wed, 19 Mar 2025 10:45:49 +0100 Subject: [PATCH] Support path mappings for analysis --- src/analyzer/main.cpp | 15 +++++++++++++++ src/windows-emulator/file_system.hpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index fca08166..e4e4e070 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -16,6 +16,7 @@ namespace std::string registry_path{"./registry"}; std::string emulation_root{}; std::set> modules{}; + std::unordered_map path_mappings{}; }; void watch_system_objects(windows_emulator& win_emu, const std::set>& modules, @@ -124,6 +125,7 @@ namespace .verbose_calls = options.verbose_logging, .disable_logging = options.silent, .silent_until_main = options.concise_logging, + .path_mappings = options.path_mappings, .modules = options.modules, }; @@ -258,6 +260,19 @@ namespace arg_it = args.erase(arg_it); options.emulation_root = args[0]; } + else if (arg == "-p") + { + if (args.size() < 3) + { + throw std::runtime_error("No path mapping provided after -p"); + } + arg_it = args.erase(arg_it); + windows_path source = args[0]; + arg_it = args.erase(arg_it); + std::filesystem::path target = std::filesystem::absolute(args[0]); + + options.path_mappings[std::move(source)] = std::move(target); + } else if (arg == "-r") { if (args.size() < 2) diff --git a/src/windows-emulator/file_system.hpp b/src/windows-emulator/file_system.hpp index e39fd320..de5a618b 100644 --- a/src/windows-emulator/file_system.hpp +++ b/src/windows-emulator/file_system.hpp @@ -27,7 +27,7 @@ class file_system { if (!win_path.is_absolute()) { - throw std::runtime_error("Only absolute paths can be translated!"); + throw std::runtime_error("Only absolute paths can be translated: " + win_path.string()); } const auto mapping = this->mappings_.find(win_path);