#include <kvm.h>
int kvm_read(kvm_t *kd, unsigned long addr, char *buf, unsigned nbytes);
int kvm_write(kvm_t *kd, unsigned long addr, char *buf, unsigned nbytes);
int kvm_uread(kvm_t *kd, unsigned long addr, char *buf, unsigned nbytes);
int kvm_uwrite(kvm_t *kd, unsigned long addr, char *buf, unsigned nbytes);
int kvm_kread(kvm_t *kd, unsigned long addr, char *buf, unsigned nbytes);
int kvm_kwrite(kvm_t *kd, unsigned long addr, char *buf, unsigned nbytes);
Unsafe
kvm_read() transfers data from the kernel image specified by kd (see kvm_open(3K) ) to the address space of the process. nbytes bytes of data are copied from the kernel virtual address given by addr to the buffer pointed to by buf.
kvm_write() is like kvm_read(), except that the direction of data transfer is reversed. In order to use this function, the kvm_open(3K) call that returned kd must have specified write access. If a user virtual address is given, it is resolved in the address space of the process specified in the most recent kvm_getu(3K) call.
kvm_uread() transfers data from the address space of the processes specified in the most recent kvm_getu(3K) call. nbytes bytes of data are copied from the user virtual address given by addr to the buffer pointed to by buf.
kvm_uwrite() is like kvm_uread(), except that the direction of the transfer is reversed. In order to use this function, the kvm_open(3K) call that returned kd must have specified write access. The address is resolved in the address space of the process specified in the most recent kvm_getu(3K) call.
kvm_kread() transfers data from the kernel address space to the address space of the process. nbytes bytes of data are copied from the kernel virtual address given by addr to the buffer pointed to by buf.
kvm_kwrite() is like kvm_kread(), except that the direction of the transfer is reversed. In order to use this function, the kvm_open(3K) call that returned kd must have specified write access.
Note: The use of kvm_uread(), kvm_uwrite(), kvm_kread() and kvm_kwrite() is encouraged over the use of kvm_read() and kvm_write() since these are more clearly defined interfaces.
All the above functions return the following values: