Skip to content

Commit

Permalink
address issue added in 0.1.2 on hosts with more than 256Mb memory
Browse files Browse the repository at this point in the history
  • Loading branch information
demoray committed Oct 18, 2019
1 parent 3b35a47 commit 31cb05d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
11 changes: 7 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avml"
version = "0.1.2"
version = "0.1.3"
license = "MIT"
description = "A portable volatile memory acquisition tool"
authors = ["[email protected]"]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/avml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn kcore(
for range in ranges {
for phdr in &file.phdrs {
if range.start == phdr.vaddr - start {
image.write_block(phdr.offset, Range{start: range.start, end: phdr.memsz})?;
image.write_block(phdr.offset, Range{start: range.start, end: range.start + phdr.memsz})?;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ impl Header {
where
W: Write,
{
println!("WUT {} {}", self.range.start, self.range.end);
let bytes = self.encode()?;
println!("header: {:?}", bytes);
dst.write_all(&bytes)?;
Ok(())
}
Expand Down Expand Up @@ -121,8 +123,9 @@ impl Image {
pub fn write_block(
&mut self,
offset: u64,
range: Range<u64>,
mut range: Range<u64>,
) -> Result<(), Box<dyn Error>> {
range.end -= 1;
let header = Header {
range,
version: self.version,
Expand Down
11 changes: 10 additions & 1 deletion src/iomem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,21 @@ mod tests {
#[test]
fn parse_iomem() {
let ranges = super::parse("test/iomem.txt").unwrap();

let expected = [
4096..654_335,
1_048_576..1_073_676_287,
4_294_967_296..6_979_321_855,
];
assert_eq!(ranges, expected);

let ranges = super::parse("test/iomem-2.txt").unwrap();
let expected = [
4096..655_359,
1_048_576..1_055_838_207,
1_056_026_624..1_073_328_127,
1_073_737_728..1_073_741_823,
4_294_967_296..6_979_321_855,
];
assert_eq!(ranges, expected);
}
}
24 changes: 24 additions & 0 deletions test/iomem-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
00000000-00000fff : Reserved
00001000-0009ffff : System RAM
000c0000-000fffff : Reserved
000f0000-000fffff : System ROM
00100000-3eeecfff : System RAM
0be00000-0ca01160 : Kernel code
0ca01161-0d4396bf : Kernel data
0d6ba000-0dbfffff : Kernel bss
3eeed000-3eef1fff : ACPI Tables
3ef1b000-3ff9afff : System RAM
3ffb7000-3ffb8fff : Unknown E820 type
3ffbb000-3ffbbfff : Unknown E820 type
3ffbe000-3ffbefff : Unknown E820 type
3ffc1000-3ffc1fff : Unknown E820 type
3ffc4000-3ffc5fff : Unknown E820 type
3ffc8000-3ffc8fff : Unknown E820 type
3fff3000-3fffafff : ACPI Tables
3fffb000-3fffefff : ACPI Non-volatile Storage
3ffff000-3fffffff : System RAM
40000000-407fffff : 5620e0c7-8062-4dce-aeb7-520c7ef76171
fec00000-fec00fff : PNP0003:00
fee00000-fee00fff : Local APIC
fee00000-fee00fff : PNP0003:00
100000000-19fffffff : System RAM

0 comments on commit 31cb05d

Please sign in to comment.