pub(super) fn write_bytes_helper<T: Task>(
    task: &mut T,
    addr: RemotePtr<Void>,
    buf: &[u8],
    ok: Option<&mut bool>,
    flags: WriteFlags,
) {
    let buf_size = buf.len();
    if 0 == buf_size {
        return;
    }

    if let Some(local) = task.vm().local_mapping_mut(addr, buf_size) {
        local[0..buf.len()].copy_from_slice(buf);
        return;
    }

    if !task.vm().mem_fd().is_open() {
        let nwritten = task.write_bytes_ptrace(addr, buf);
        if nwritten > 0 {
            task.vm().notify_written(addr, nwritten, flags);
        }

        if ok.is_some() && nwritten < buf_size {
            *ok.unwrap() = false;
        }
        return;
    }

    Errno::clear();
    let nwritten_result = safe_pwrite64(task, buf, addr);
    // See comment in read_bytes_helper().
    if let Ok(0) = nwritten_result {
        task.open_mem_fd();
        // Try again
        return task.write_bytes_helper(addr, buf, ok, flags);
    }
    if errno() == EPERM {
        fatal!(
            "Can't write to /proc/{}/mem\n\
                        Maybe you need to disable grsecurity MPROTECT with:\n\
                           setfattr -n user.pax.flags -v 'emr' <executable>",
            task.tid
        );
    }

    let nwritten = nwritten_result.unwrap_or(0);
    if ok.is_some() {
        if nwritten < buf_size {
            *ok.unwrap() = false;
        }
    } else {
        ed_assert!(
            task,
            nwritten == buf_size,
            "Should have written {} bytes to {}, but only wrote {}",
            addr,
            buf_size,
            nwritten,
        );
    }
    if nwritten > 0 {
        task.vm().notify_written(addr, nwritten, flags);
    }
}
/// Forwarded method definition
///
/// `flags` is bits from WriteFlags.
Forwarded method definition
`flags` is bits from WriteFlags.
Forwarded method definition ` flags ` is bits from WriteFlags .
pub(super) fn write_bytes_helper<T: Task>(
    task: &mut T,
    addr: RemotePtr<Void>,
    buf: &[u8],
    ok: Option<&mut bool>,
    flags: WriteFlags,
) {
    let buf_size = buf.len();
    if 0 == buf_size {
        return;
    }
    if let Some(local) = task.vm().local_mapping_mut(addr, buf_size) {
        local[0..buf.len()].copy_from_slice(buf);
        return;
    }
    if !task.vm().mem_fd().is_open() {
        let nwritten = task.write_bytes_ptrace(addr, buf);
        if nwritten > 0 {
            task.vm().notify_written(addr, nwritten, flags);
        }
        if ok.is_some() && nwritten < buf_size {
            *ok.unwrap() = false;
        }
        return;
    }
    Errno::clear();
    let nwritten_result = safe_pwrite64(task, buf, addr);
    // See comment in read_bytes_helper().
    if let Ok(0) = nwritten_result {
        task.open_mem_fd();
        // Try again
        return task.write_bytes_helper(addr, buf, ok, flags);
    }
    if errno() == EPERM {
        fatal!(
            "Can't write to /proc/{}/mem\n\
                        Maybe you need to disable grsecurity MPROTECT with:\n\
                           setfattr -n user.pax.flags -v 'emr' <executable>",
            task.tid
        );
    }
    let nwritten = nwritten_result.unwrap_or(0);
    if ok.is_some() {
        if nwritten < buf_size {
            *ok.unwrap() = false;
        }
    } else {
        ed_assert!(
            task,
            nwritten == buf_size,
            "Should have written {} bytes to {}, but only wrote {}",
            addr,
            buf_size,
            nwritten,
        );
    }
    if nwritten > 0 {
        task.vm().notify_written(addr, nwritten, flags);
    }
}
pub ( super ) fn write_bytes_helper < T : Task > ( task : & mut T , addr : RemotePtr < Void > , buf : & [ u8 ] , ok : Option < & mut bool > , flags : WriteFlags , ) { let buf_size = buf . len ( ) ; if 0 == buf_size { return ; } if let Some ( local ) = task . vm ( ) . local_mapping_mut ( addr , buf_size ) { local [ 0 .. buf . len ( ) ] . copy_from_slice ( buf ) ; return ; } if ! task . vm ( ) . mem_fd ( ) . is_open ( ) { let nwritten = task . write_bytes_ptrace ( addr , buf ) ; if nwritten > 0 { task . vm ( ) . notify_written ( addr , nwritten , flags ) ; } if ok . is_some ( ) && nwritten < buf_size { * ok . unwrap ( ) = false ; } return ; } Errno :: clear ( ) ; let nwritten_result = safe_pwrite64 ( task , buf , addr ) ; // See comment in read_bytes_helper(). if let Ok ( 0 ) = nwritten_result { task . open_mem_fd ( ) ; // Try again return task . write_bytes_helper ( addr , buf , ok , flags ) ; } if errno ( ) == EPERM { fatal ! ( " \n \
 \n \
 " task tid ) ; } let nwritten = nwritten_result . unwrap_or ( 0 ) ; if ok . is_some ( ) { if nwritten < buf_size { * ok . unwrap ( ) = false ; } } else { ed_assert ! ( task nwritten buf_size " " addr buf_size nwritten ) ; } if nwritten > 0 { task . vm ( ) . notify_written ( addr , nwritten , flags ) ; } }
Forwarded method definition
`flags` is bits from WriteFlags.
Forwarded method definition ` flags ` is bits from WriteFlags .
task
&mut T
addr
RemotePtr<Void>
buf
&[u8]
ok
Option<&mut bool>
flags
WriteFlags