KVM_READ(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… KVM_READ(3) πŸ’…

okay bestie, this one’s from the Library Functions Manual, and it’s all about peeking into β€” and writing to β€” kernel virtual memory. iconic behavior, honestly. 🫢


🌸 NAME 🌸

  • kvm_read, kvm_read2, kvm_write β€” read or write kernel virtual memory

πŸŽ€ LIBRARY πŸŽ€

Kernel Data Access Library (libkvm, -lkvm)


✨ SYNOPSIS ✨

#include <kvm.h>

ssize_t
kvm_read(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes);

ssize_t
kvm_read2(kvm_t *kd, kvaddr_t addr, void *buf, size_t nbytes);

ssize_t
kvm_write(kvm_t *kd, unsigned long addr, const void *buf,
    size_t nbytes);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, kvm_read(), kvm_read2(), and kvm_write() are the functions you use to read and write kernel virtual memory (or a crash dump file). for the whole β€œhow do I even open kernel virtual memory and crash dumps” situation, go check kvm_open(3). iykyk πŸ’–

kvm_read() and kvm_read2() transfer nbytes bytes of data from the kernel space address addr to buf. meanwhile, kvm_write() goes the other way and transfers data from buf to addr. ✨

and bestie, listen: unlike their SunOS counterparts, these functions cannot be used to read or write process address spaces. periodt. πŸ’…

kvm_read2() uses a different type (kvaddr_t) for the addr argument, which lets you use addresses larger than ULONG_MAX when you’re examining non-native kernel images. slay. 🌈


πŸ’– RETURN VALUES πŸ’–

on success, the number of bytes actually transferred is returned. otherwise, -1 is returned. simple as that. πŸŽ€


🌟 SEE ALSO 🌟


πŸ‘‘ HISTORY πŸ‘‘

kvm_read2() first appeared in FreeBSD 11.0. noted. ⭐


peace out, bestie 🫢 β€” this page is from Debian, dated November 27, 2015, and its title is KVM_READ(3). πŸ’œ

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms