Monitors Windows system calls in the guest. Filters selected syscalls and prints arguments/return values (optionally JSON). Demonstrates system-call filtering, WindowsEvent, and SystemCallMonitor usage.
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <csignal>
#include <iostream>
#include <mutex>
#include <string>
namespace po = boost::program_options;
po::variables_map& vm);
std::unique_ptr<Domain>
domain;
}
int main(
int argc,
char** argv) {
po::options_description desc("Options");
std::string domain_name;
std::string process_name;
desc.add_options()
("domain,D", po::value<std::string>(&domain_name)->required(), "The domain name or ID attach to")
("procname", po::value<std::string>(&process_name), "A process name to filter for")
("no-flush", "Don't flush the output buffer after each event")
("json", "Output JSON format")
("help", "Display program help")
("unsupported", "Display system calls that we don't have handlers for");
desc.add_options()(category.c_str(),
std::string("Enable " + category + " related system calls").c_str());
}
std::cout.sync_with_stdio(false);
po::variables_map vm;
auto hypervisor = Hypervisor::instance();
domain = hypervisor->attach_domain(domain_name);
if (!
domain->detect_guest()) {
std::cerr << "Failed to detect guest OS\n";
return 1;
}
if (!process_name.empty()) {
domain->task_filter().add_name(process_name);
}
if (vm.count("unsupported") == 0) {
bool category_used = false;
domain->system_call_filter().enabled(
true);
if (
domain->guest()->os() == OS::Windows) {
if (vm.count(category)) {
category_used = true;
}
}
}
if (!category_used) {
if (
domain->guest()->os() == OS::Windows) {
}
}
}
domain->intercept_system_calls(
true);
SystemCallMonitor monitor(!vm.count(
"no-flush"), vm.count(
"json"), vm.count(
"unsupported"));
return 0;
}
po::variables_map& vm) {
try {
po::store(po::parse_command_line(argc, argv, desc), vm);
if (vm.count("help")) {
std::cout << "ivsyscallmon - Watch guest system calls" << '\n';
std::cout << desc << '\n';
exit(0);
}
po::notify(vm);
} catch (po::error& e) {
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
std::cerr << desc << std::endl;
exit(1);
}
}
Definition SystemCallMonitor.hh:21
A representation of a Windows Guest OS.
Definition WindowsGuest.hh:33
virtual void enable_category(const std::string &category, SystemCallFilter &filter) const =0
Enable a specific category for a filter.
virtual void default_syscall_filter(SystemCallFilter &filter) const =0
Configure a system call filter for all supported calls.
bool interrupted
Definition ivcallmon.cc:43
int main(int argc, char **argv)
Definition main.c:35
Classes related to Microsoft Windows guests.
Definition LanguageId.hh:21
Core IntroVirt classes.
Definition Cr0.hh:20
void sig_handler(int signum)
Definition vmcall_interface.cc:571
void parse_program_options(int argc, char **argv, po::options_description &desc, po::variables_map &vm)
Definition vmcall_interface.cc:581
unique_ptr< Domain > domain
Definition vmcall_interface.cc:48