Skip to content

Commit

Permalink
Sigscan cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyuuhachi committed Jul 17, 2023
1 parent 315559a commit e18027b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/sigscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ macro unit {

#[track_caller]
pub fn scan(sig: &[Option<u8>]) -> *const u8 {
let start = 0x00400000;
let data: &'static [u8] = unsafe {
std::slice::from_raw_parts(start as *const u8, 0x00200000)
std::slice::from_raw_parts(0x00400000 as *const u8, 0x00200000)
};

let Some(a) = sig[0] else { panic!() };
let offset = memchr::memchr_iter(a, data)
.find(|&a| data[a..].iter().zip(sig).all(|(a,b)| b.map_or(true, |b| *a==b)))
.unwrap();

(start + offset) as *const u8
&data[offset]
}

pub macro sigscan($($a:tt)*) {
Expand Down

0 comments on commit e18027b

Please sign in to comment.