diff --git a/ableos/src/rhai_shell/mod.rs b/ableos/src/rhai_shell/mod.rs index 31346520..31ddc85d 100644 --- a/ableos/src/rhai_shell/mod.rs +++ b/ableos/src/rhai_shell/mod.rs @@ -89,15 +89,16 @@ pub fn set_hostname(name: String) { } /// Examine a memory pointer -pub fn peek_memory(ptr: i64) -> u8 { - let ptr: usize = ptr.unsigned_abs() as _; +pub fn peek_memory(ptr: i64) -> i64 { println!(">:("); - unsafe { *(ptr as *const u8) } + unsafe { *(ptr as *const u8) as _ } } -pub fn poke_memory(ptr: i64, val: u8) { - let ptr: usize = ptr.unsigned_abs() as _; - unsafe { *(ptr as *mut u8) = val } +pub fn poke_memory(ptr: i64, val: i64) { + match val.try_into() { + Ok(val) => unsafe { *(ptr as *mut u8) = val }, + Err(_) => println!("Error: {val} cannot be converted into u8"), + } } pub fn ls() {