add get_aux_string function
This commit is contained in:
parent
2e45754e27
commit
85d2f9b0f9
@ -203,3 +203,17 @@ pub extern "C" fn nyx_print_aux_buffer(nyx_process: * mut NyxProcess) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn nyx_get_aux_string(nyx_process: * mut NyxProcess, buffer: *mut u8, size: u32) -> u32 {
|
||||||
|
|
||||||
|
unsafe{
|
||||||
|
assert!(!nyx_process.is_null());
|
||||||
|
assert!((nyx_process as usize) % std::mem::align_of::<NyxProcess>() == 0);
|
||||||
|
assert!((buffer as usize) % std::mem::align_of::<u8>() == 0);
|
||||||
|
|
||||||
|
let len = std::cmp::min( (*nyx_process).process.aux.misc.len as usize, size as usize);
|
||||||
|
std::ptr::copy((*nyx_process).process.aux.misc.data.as_mut_ptr(), buffer, len);
|
||||||
|
len as u32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -255,6 +255,11 @@ impl NyxProcess {
|
|||||||
self.process.aux.result.tmp_snapshot_created != 0
|
self.process.aux.result.tmp_snapshot_created != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn aux_string(&self) -> String {
|
||||||
|
let len = self.process.aux.misc.len;
|
||||||
|
String::from_utf8_lossy(&self.process.aux.misc.data[0..len as usize]).to_string()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn exec(&mut self) -> NyxReturnValue {
|
pub fn exec(&mut self) -> NyxReturnValue {
|
||||||
match self.process.send_payload(){
|
match self.process.send_payload(){
|
||||||
Err(_) => NyxReturnValue::IoError,
|
Err(_) => NyxReturnValue::IoError,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user