Crates.io | linux-memutils |
lib.rs | linux-memutils |
version | 2.0.1 |
created_at | 2025-02-15 19:32:51.770871+00 |
updated_at | 2025-09-06 18:04:17.71567+00 |
description | Basic utilities for reading from physical memory on Linux. |
homepage | |
repository | https://gitlab.com/BVollmerhaus/agesafetch |
max_upload_size | |
id | 1557041 |
size | 55,535 |
Basic utilities for reading from physical memory on Linux.
This crate provides modules for:
/proc/iomem
file./dev/mem
character device file without
erroring out on inaccessible bytes.Add the dependency to your Cargo.toml
:
[dependencies]
linux-memutils = "2.0.1"
/proc/iomem
use linux_memutils::iomem;
fn main() {
let memory_map = iomem::parse_proc_iomem().unwrap();
let third_memory_region = &memory_map[2];
println!("{third_memory_region}");
// => [0x000000000009f000-0x000000000009ffff] (Reserved)
}
use linux_memutils::reader;
use std::fs::File;
fn main() {
// [...]
let file = File::open("/dev/mem").unwrap();
let reader = reader::SkippingBufReader::new(
file,
third_memory_region.start_address,
Some(third_memory_region.end_address),
);
// Our `reader` can now be used similarly to an io:BufReader,
// the key difference being that it skips inaccessible bytes
}
use linux_memutils::agesa;
fn main() {
match agesa::find_agesa_version().unwrap() {
Some(found_version) => {
println!("{}", found_version.version_string)
}
None => eprintln!("Did not find AGESA version.")
}
}
⚠️ Note that these examples need to be run with elevated privileges.
As usual, the documentation for this library can be found on docs.rs.
This project is licensed under the MIT license. See the LICENSE file for more information.