Support path mappings for analysis

This commit is contained in:
Maurice Heumann
2025-03-19 10:45:49 +01:00
parent 44dfc2edaa
commit d21a114f84
2 changed files with 16 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ namespace
std::string registry_path{"./registry"};
std::string emulation_root{};
std::set<std::string, std::less<>> modules{};
std::unordered_map<windows_path, std::filesystem::path> path_mappings{};
};
void watch_system_objects(windows_emulator& win_emu, const std::set<std::string, std::less<>>& 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)

View File

@@ -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);