fxos/shell/m.cpp

42 lines
1013 B
C++

#include "parser.h"
#include "shell.h"
//---
// ms
//---
static FxOS::Symbol parse_ms(Session &, Parser &parser)
{
Token t = parser.expect({T::NUM, T::SYSCALL});
FxOS::Symbol s;
if(t.type == T::SYSCALL)
s.type = FxOS::Symbol::Syscall;
else
s.type = FxOS::Symbol::Address;
s.value = t.value.NUM;
s.name = parser.symbol();
parser.end();
return s;
}
void _ms(Session &session, Symbol s)
{
if(!session.current_space)
return;
session.current_space->symbols.add(s);
}
static ShellCommand _ms_cmd(
"ms", [](Session &s, Parser &p) { _ms(s, parse_ms(s, p)); },
[](Session &s, Parser &p) { parse_ms(s, p); }, "Metadata Symbol", R"(
ms <address|syscall> <symbol>
Defines a new symbol at the specified address or syscall number in the current
virtual space. If a syscall number is provided, the address is not resolved;
the same syscall symbol can be used across multiple OS versions regardless of
where the functions are actually located.
)");