diff --git a/src/header.rs b/src/header.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/program.rs b/src/program.rs index fea72ca..1fe6374 100644 --- a/src/program.rs +++ b/src/program.rs @@ -144,9 +144,7 @@ impl Program { fn init() -> Self { let base = Base::program(); - let pe = unsafe { PeView::module(base.as_nonnull().as_ptr()) }; - let len = pe.nt_headers().OptionalHeader.SizeOfImage as usize; let sections = pe diff --git a/src/section.rs b/src/section.rs index 8d20da5..5b77c4c 100644 --- a/src/section.rs +++ b/src/section.rs @@ -38,10 +38,14 @@ impl Section { } pub fn contains(&self, pattern: &[u8]) -> bool { + assert!(pattern.len() >= 1); + self.find(pattern).is_some() } pub fn find(&self, pattern: &[u8]) -> Option> { + assert!(pattern.len() >= 1); + self.as_slice() .par_windows(pattern.len()) .position_first(|window| window == pattern) @@ -49,6 +53,8 @@ impl Section { } pub fn rfind(&self, pattern: &[u8]) -> Option> { + assert!(pattern.len() >= 1); + self.as_slice() .par_windows(pattern.len()) .position_last(|window| window == pattern)