MCPcopy Create free account
hub / github.com/MagnetForensics/dumpit-linux / get_memory_ranges

Method get_memory_ranges

src/main.rs:227–265  ·  view source on GitHub ↗

Get the physical memory ranges (System RAM) from /proc/iomem

()

Source from the content-addressed store, hash-verified

225
226 // Get the physical memory ranges (System RAM) from /proc/iomem
227 fn get_memory_ranges() -> Result<Vec<MemoryRange>> {
228 let mut iomem_ranges = Vec::new();
229
230 let file = fs::File::open(format!("{}iomem", PROC_DIR))?;
231 let reader = BufReader::new(file);
232
233 for line in reader.lines() {
234 let line = line?;
235 if line.contains("System RAM") {
236 let part1: Vec<&str> = line.split(" ").collect();
237 if part1.len() > 0 {
238 let part2: Vec<&str> = part1[0].split("-").collect();
239 if part2.len() > 1 {
240 let start_phys_addr = u64::from_str_radix(part2[0], 16)?;
241 let end_phys_addr = u64::from_str_radix(part2[1], 16)? + 1;
242 let memsz = end_phys_addr - start_phys_addr;
243
244 iomem_ranges.push(MemoryRange {
245 start_phys_addr,
246 end_phys_addr,
247 memsz,
248 is_virtual: false,
249 p_flags: 0,
250 virt_addr: 0,
251 kcore_file_off: 0,
252 out_file_off: 0
253 // program_header: None
254 })
255 }
256 }
257 }
258 }
259
260 if iomem_ranges.len() == 0 {
261 return Err(Error::IoError("/proc/iomem has no entries.".to_string()));
262 }
263
264 Ok(iomem_ranges)
265 }
266
267 // Retrieve the values of vmcoreinfo_data & vmcoreinfo_size inside /proc/kallsyms
268 fn get_vmcoreinfo_syms(&mut self) -> Result<()> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected