diff --git a/Cargo.lock b/Cargo.lock index 80cac08..cfbc20b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,9 +121,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bindgen" -version = "0.56.0" +version = "0.59.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" dependencies = [ "bitflags", "cexpr", @@ -168,9 +168,9 @@ checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cexpr" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ "nom", ] @@ -440,9 +440,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "env_logger" -version = "0.8.4" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" dependencies = [ "atty", "humantime", @@ -786,6 +786,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -804,12 +810,12 @@ checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" [[package]] name = "nom" -version = "5.1.2" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" dependencies = [ "memchr", - "version_check", + "minimal-lexical", ] [[package]] @@ -1169,9 +1175,9 @@ dependencies = [ [[package]] name = "shlex" -version = "0.1.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "simplelog" @@ -1511,10 +1517,12 @@ dependencies = [ [[package]] name = "which" -version = "3.1.1" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2" dependencies = [ + "either", + "lazy_static", "libc", ] diff --git a/leechcore-sys/Cargo.toml b/leechcore-sys/Cargo.toml index 1bee9cf..3a94c61 100644 --- a/leechcore-sys/Cargo.toml +++ b/leechcore-sys/Cargo.toml @@ -13,5 +13,5 @@ ctor = "0.1" [build-dependencies] cc = "1.0" -bindgen = "0.56" +bindgen = "0.59" pkg-config = "0.3" diff --git a/memflow-pcileech/src/lib.rs b/memflow-pcileech/src/lib.rs index 71ef006..b5c64d9 100644 --- a/memflow-pcileech/src/lib.rs +++ b/memflow-pcileech/src/lib.rs @@ -116,19 +116,19 @@ struct WriteGap { } impl PhysicalMemory for PciLeech { - fn phys_read_raw_iter<'a>(&mut self, data: PhysicalReadMemOps) -> Result<()> { + fn phys_read_raw_iter<'a>(&mut self, mut data: PhysicalReadMemOps) -> Result<()> { let vec = if let Some(mem_map) = &self.mem_map { mem_map .map_iter(data.inp, data.out_fail) - .map(|d| (d.0 .0.into(), d.2)) + .map(|d| (d.0 .0.into(), d.1, d.2)) .collect::>() } else { - data.inp.map(|d| (d.0, d.2)).collect::>() + data.inp.map(|d| (d.0, d.1, d.2)).collect::>() }; // get total number of pages let num_pages = vec.iter().fold(0u64, |acc, read| { - acc + calc_num_pages(read.0.to_umem(), read.1.len() as u64) + acc + calc_num_pages(read.0.to_umem(), read.2.len() as u64) }); // allocate scatter buffer @@ -149,8 +149,8 @@ impl PhysicalMemory for PciLeech { // prepare mems let mut gaps = Vec::new(); let mut i = 0usize; - for read in vec.into_iter() { - for (page_addr, out) in read.1.page_chunks(read.0.into(), PAGE_SIZE) { + for read in vec.iter() { + for (page_addr, out) in read.2.page_chunks(read.0.into(), PAGE_SIZE) { let mem = unsafe { *mems.add(i) }; let addr_align = page_addr.to_umem() & (BUF_ALIGN - 1); @@ -234,6 +234,15 @@ impl PhysicalMemory for PciLeech { LcMemFree(mems as *mut c_void); }; + // call out sucess for everything + /* + for read in vec.into_iter() { + for (page_addr, out) in read.2.page_chunks(read.0.into(), PAGE_SIZE) { + opt_call(data.out.as_deref_mut(), CTup2(page_addr, out)); + } + } + */ + Ok(()) } @@ -241,15 +250,15 @@ impl PhysicalMemory for PciLeech { let vec = if let Some(mem_map) = &self.mem_map { mem_map .map_iter(data.inp, data.out_fail) - .map(|d| (d.0 .0.into(), d.2)) + .map(|d| (d.0 .0.into(), d.1, d.2)) .collect::>() } else { - data.inp.map(|d| (d.0, d.2)).collect::>() + data.inp.map(|d| (d.0, d.1, d.2)).collect::>() }; // get total number of pages let num_pages = vec.iter().fold(0u64, |acc, read| { - acc + calc_num_pages(read.0.to_umem(), read.1.len() as u64) + acc + calc_num_pages(read.0.to_umem(), read.2.len() as u64) }); // allocate scatter buffer @@ -271,7 +280,7 @@ impl PhysicalMemory for PciLeech { let mut gaps = Vec::new(); let mut i = 0usize; for write in vec.iter() { - for (page_addr, out) in write.1.page_chunks(write.0.into(), PAGE_SIZE) { + for (page_addr, out) in write.2.page_chunks(write.0.into(), PAGE_SIZE) { let mem = unsafe { *mems.add(i) }; let addr_align = page_addr.to_umem() & (BUF_ALIGN - 1); @@ -351,6 +360,9 @@ impl PhysicalMemory for PciLeech { } } + // TODO: + // opt_call(out.as_deref_mut(), CTup2(meta_addr, data)); + // dispatch write { let handle = self.handle.lock().unwrap();