From 36c4338853d9f468c16839cb8a5ef7b6df65a88a Mon Sep 17 00:00:00 2001 From: KiraCoding <38864051+KiraCoding@users.noreply.github.com> Date: Fri, 13 Sep 2024 08:30:39 +0200 Subject: [PATCH] wip --- src/header.rs | 0 src/program.rs | 2 -- src/section.rs | 6 ++++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/header.rs 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)