42 auto ___ = gsl::on_failure([&]
45 for (
auto arg = args.begin(); arg != args.end(); ++arg)
47 if (arg->empty() || arg->find_first_not_of(
" \t") == std::string::npos)
50 if (*arg ==
"--cpuid")
52 if (++arg == args.end())
55 m_cpuid = std::stoull(*arg,
nullptr, 16);
59 if (*arg ==
"--vcpuid")
61 if (++arg == args.end())
64 m_vcpuid = std::stoull(*arg,
nullptr, 16);
68 if (*arg ==
"-h" || *arg ==
"--help")
71 if (arg->front() ==
'-')
80 filtered_args.push_back(*arg);
86 if (cmd ==
"load")
return parse_load(filtered_args);
87 if (cmd ==
"unload")
return parse_unload(filtered_args);
88 if (cmd ==
"start")
return parse_start(filtered_args);
89 if (cmd ==
"stop")
return parse_stop(filtered_args);
90 if (cmd ==
"dump")
return parse_dump(filtered_args);
91 if (cmd ==
"status")
return parse_status(filtered_args);
92 if (cmd ==
"vmcall")
return parse_vmcall(filtered_args);
103 {
return m_modules; }
115 {
return m_registers; }
126 command_line_parser::reset()
noexcept 135 m_string_data.clear();
139 command_line_parser::parse_load(arg_list_type &args)
149 command_line_parser::parse_unload(arg_list_type &args)
156 command_line_parser::parse_start(arg_list_type &args)
163 command_line_parser::parse_stop(arg_list_type &args)
170 command_line_parser::parse_dump(arg_list_type &args)
177 command_line_parser::parse_status(arg_list_type &args)
184 command_line_parser::parse_vmcall(arg_list_type &args)
189 auto opcode = bfn::take(args, 0);
191 if (opcode ==
"versions")
return parse_vmcall_version(args);
192 if (opcode ==
"registers")
return parse_vmcall_registers(args);
193 if (opcode ==
"string")
return parse_vmcall_string(args);
194 if (opcode ==
"data")
return parse_vmcall_data(args);
195 if (opcode ==
"event")
return parse_vmcall_event(args);
196 if (opcode ==
"unittest")
return parse_vmcall_unittest(args);
202 command_line_parser::parse_vmcall_version(arg_list_type &args)
209 m_registers.
r02 = std::stoull(args[0]);
215 command_line_parser::parse_vmcall_registers(arg_list_type &args)
217 auto index = args.size() - 1;
225 m_registers.
r15 = std::stoull(args[
index--],
nullptr, 16);
227 m_registers.
r14 = std::stoull(args[
index--],
nullptr, 16);
229 m_registers.
r13 = std::stoull(args[
index--],
nullptr, 16);
231 m_registers.
r12 = std::stoull(args[
index--],
nullptr, 16);
233 m_registers.
r11 = std::stoull(args[
index--],
nullptr, 16);
235 m_registers.
r10 = std::stoull(args[
index--],
nullptr, 16);
237 m_registers.
r09 = std::stoull(args[
index--],
nullptr, 16);
239 m_registers.
r08 = std::stoull(args[
index--],
nullptr, 16);
241 m_registers.
r07 = std::stoull(args[
index--],
nullptr, 16);
243 m_registers.
r06 = std::stoull(args[
index--],
nullptr, 16);
245 m_registers.
r05 = std::stoull(args[
index--],
nullptr, 16);
247 m_registers.
r04 = std::stoull(args[
index--],
nullptr, 16);
249 m_registers.
r03 = std::stoull(args[
index--],
nullptr, 16);
251 m_registers.
r02 = std::stoull(args[
index--],
nullptr, 16);
262 command_line_parser::parse_vmcall_string(arg_list_type &args)
267 auto type = bfn::take(args, 0);
269 if (
type ==
"unformatted")
return parse_vmcall_string_unformatted(args);
270 if (
type ==
"json")
return parse_vmcall_string_json(args);
276 command_line_parser::parse_vmcall_data(arg_list_type &args)
281 auto type = bfn::take(args, 0);
282 if (
type ==
"unformatted")
return parse_vmcall_data_unformatted(args);
288 command_line_parser::parse_vmcall_event(arg_list_type &args)
295 m_registers.
r02 = std::stoull(args[0],
nullptr, 16);
301 command_line_parser::parse_vmcall_unittest(arg_list_type &args)
308 m_registers.
r02 = std::stoull(args[0],
nullptr, 16);
314 command_line_parser::parse_vmcall_string_unformatted(arg_list_type &args)
319 m_string_data = args[0];
326 m_registers.
r05 =
reinterpret_cast<decltype(m_registers.r05)
>(m_string_data.data());
327 m_registers.
r06 = m_string_data.length();
333 command_line_parser::parse_vmcall_string_json(arg_list_type &args)
338 m_string_data = json::parse(args[0]).dump();
345 m_registers.
r05 =
reinterpret_cast<decltype(m_registers.r05)
>(m_string_data.data());
346 m_registers.
r06 = m_string_data.length();
352 command_line_parser::parse_vmcall_data_unformatted(arg_list_type &args)
ioctl::registers_type registers_type
#define missing_argument()
#define unknown_vmcall_type(a)
virtual const filename_type & ifile() const noexcept
file::filename_type filename_type
virtual void parse(const arg_list_type &args)
virtual cpuid_type cpuid() const noexcept
ioctl::cpuid_type cpuid_type
void uint64_t uint64_t uint64_t *rdx noexcept
auto index(const T virt, const F from)
#define unknown_vmcall_string_type(a)
virtual command_type cmd() const noexcept
std::vector< arg_type > arg_list_type
#define unknown_vmcall_data_type(a)
virtual const filename_type & ofile() const noexcept
virtual const registers_type & registers() const noexcept
ioctl::vcpuid_type vcpuid_type
virtual vcpuid_type vcpuid() const noexcept
virtual const filename_type & modules() const noexcept
#define unknown_command(a)
#define VMCALL_MAGIC_NUMBER