This commit is contained in:
elfein 2021-11-11 00:49:21 -08:00
parent 9f1b708ccf
commit e83cdc6ed9
2 changed files with 135 additions and 105 deletions

View file

@ -13,7 +13,7 @@ struct HostFunctions;
impl HostFunctions {
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
let (params, ret_ty): (&[ValueType], Option<ValueType>) = match index {
*SysCall::KILL => (&[ValueType::I32, ValueType::I32], Some(ValueType::I32)),
SysCall::KILL => (&[ValueType::I32, ValueType::I32], Some(ValueType::I32)),
_ => return false,
};
signature.params() == params && signature.return_type() == ret_ty

View file

@ -34,3 +34,33 @@ pub enum SysCall {
// Security Syscalls
ENCRYPT = 50,
}
impl From<usize> for SysCall {
fn from(n: usize) -> Self {
match n {
0 => Self::KILL,
1 => Self::CONSOLE_RESET,
2 => Self::CONSOLE_IN,
3 => Self::CONSOLE_OUT,
4 => Self::CONSOLE_GET_TITLE,
5 => Self::CONSOLE_SET_TITLE,
10 => Self::GET_PRIORITY,
11 => Self::SET_PRIORITY,
12 => Self::GET_HOSTNAME,
13 => Self::SET_HOSTNAME,
20 => Self::GET_CONFIG,
21 => Self::SET_CONFIG,
22 => Self::MAKE_DIRECTORY,
23 => Self::DELETE_DIRECTORY,
24 => Self::RENAME_DIRECTORY,
25 => Self::SET_DIRECTORY_ACCESS,
26 => Self::MAKE_FILE,
27 => Self::DELETE_FILE,
28 => Self::RENAME_FILE,
29 => Self::SET_FILE_ACCESS,
30 => Self::FILE_READ,
31 => Self::FILE_WRITE,
50 => Self::ENCRYPT,
}
}
}