chore: allow making remoteWrite with remote ptr

This commit is contained in:
əlemi 2023-03-28 19:10:06 +02:00
parent 45d3f8d734
commit 4a20ddbbda
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -72,19 +72,24 @@ impl RemoteSyscall for RemoteOpen {
} }
pub struct RemoteWrite { pub struct RemoteWrite {
fd: u64, fd: i64,
buf: RemoteString, ptr: u64,
len: u64,
} }
impl RemoteWrite { impl RemoteWrite {
pub fn args(fd: u64, buf: RemoteString) -> Self { pub fn args(fd: i64, ptr: u64, len: u64) -> Self {
RemoteWrite { fd, buf } RemoteWrite { fd, ptr, len }
}
pub fn string(fd: i64, txt: RemoteString) -> Self {
RemoteWrite { fd, ptr: txt.ptr.expect("remote write with uninjected remote str") as u64, len: txt.txt.len() as u64 }
} }
} }
impl RemoteSyscall for RemoteWrite { impl RemoteSyscall for RemoteWrite {
fn registers(&self, regs: &mut user_regs_struct) { fn registers(&self, regs: &mut user_regs_struct) {
Self::prepare_registers(regs, 1, self.fd, self.buf.ptr.unwrap() as u64, self.buf.txt.len() as u64, 0, 0, 0); Self::prepare_registers(regs, 1, self.fd as u64, self.ptr, self.len, 0, 0, 0);
} }
} }