1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use std::ops::Range;
use crate::*;
use super::Wrap;
impl<'a, Pe32: pe32::Pe<'a>, Pe64: pe64::Pe<'a>> Wrap<pe32::scanner::Scanner<Pe32>, pe64::scanner::Scanner<Pe64>> {
#[inline]
pub fn finds(&self, pat: &[pattern::Atom], range: Range<u32>, save: &mut [u32]) -> bool {
match self {
Wrap::T32(scanner) => scanner.finds(pat, range, save),
Wrap::T64(scanner) => scanner.finds(pat, range, save),
}
}
#[inline]
pub fn finds_code(&self, pat: &[pattern::Atom], save: &mut [u32]) -> bool {
match self {
Wrap::T32(scanner) => scanner.finds_code(pat, save),
Wrap::T64(scanner) => scanner.finds_code(pat, save),
}
}
#[inline]
pub fn matches<'pat>(&self, pat: &'pat [pattern::Atom], range: Range<u32>) -> Wrap<pe32::scanner::Matches<'pat, Pe32>, pe64::scanner::Matches<'pat, Pe64>> {
match self {
Wrap::T32(scanner) => Wrap::T32(scanner.matches(pat, range)),
Wrap::T64(scanner) => Wrap::T64(scanner.matches(pat, range)),
}
}
#[inline]
pub fn matches_code<'pat>(&self, pat: &'pat [pattern::Atom]) -> Wrap<pe32::scanner::Matches<'pat, Pe32>, pe64::scanner::Matches<'pat, Pe64>> {
match self {
Wrap::T32(scanner) => Wrap::T32(scanner.matches_code(pat)),
Wrap::T64(scanner) => Wrap::T64(scanner.matches_code(pat)),
}
}
#[inline]
pub fn exec(&self, cursor: u32, pat: &[pattern::Atom], save: &mut [u32]) -> bool {
match self {
Wrap::T32(scanner) => scanner.exec(cursor, pat, save),
Wrap::T64(scanner) => scanner.exec(cursor, pat, save),
}
}
}
impl<'a, 'pat, Pe32: pe32::Pe<'a>, Pe64: pe64::Pe<'a>> Wrap<pe32::scanner::Matches<'pat, Pe32>, pe64::scanner::Matches<'pat, Pe64>> {
#[inline]
pub fn scanner(&self) -> Wrap<pe32::scanner::Scanner<Pe32>, pe64::scanner::Scanner<Pe64>> {
match self {
Wrap::T32(matches) => Wrap::T32(matches.scanner()),
Wrap::T64(matches) => Wrap::T64(matches.scanner()),
}
}
#[inline]
pub fn pattern(&self) -> &'pat [pattern::Atom] {
match self {
Wrap::T32(matches) => matches.pattern(),
Wrap::T64(matches) => matches.pattern(),
}
}
#[inline]
pub fn range(&self) -> Range<u32> {
match self {
Wrap::T32(matches) => matches.range(),
Wrap::T64(matches) => matches.range(),
}
}
#[inline]
pub fn hits(&self) -> u32 {
match self {
Wrap::T32(matches) => matches.hits(),
Wrap::T64(matches) => matches.hits(),
}
}
#[inline]
pub fn next(&mut self, save: &mut [u32]) -> bool {
match self {
Wrap::T32(matches) => matches.next(save),
Wrap::T64(matches) => matches.next(save),
}
}
}