This commit is contained in:
Intege-rs
2024-11-14 14:39:09 -05:00
parent 427eb56a50
commit 020bd3a5db
11 changed files with 1131 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ macros = ["sub_macros"]
libm = ["sub_libm"]
pe = ["sub_pe"]
xpat = ["core", "sub_xpat", "macros"]
winuser = ["sub_winu", "pe", "sub_pe/windows"]
[dependencies]
@@ -18,4 +18,5 @@ sub_core = { workspace = true, optional = true }
sub_libm = { workspace = true, optional = true}
sub_pe = { workspace = true, optional = true }
sub_winu = { workspace = true, optional = true }
sub_macros = { workspace = true, optional = true }
sub_macros = { workspace = true, optional = true }
sub_xpat = { workspace = true, optional = true }

View File

@@ -18,6 +18,7 @@ import!(sub_core, core, "core");
import!(sub_libm, libm, "libm");
import!(sub_pe, pe, "pe");
import!(sub_winu, win, "winuser");
import!(sub_xpat, xpat, "xpat");
/// the macro crate is a proc macro, so it is a bit different.
#[cfg(feature = "macros")]

17
x/tests/test_xpat.rs Normal file
View File

@@ -0,0 +1,17 @@
#[test]
pub fn test_pattern() {
let pattern = x::pattern!("E8 [0-4] BB ");
let buffer: &[u8] = &[ 0xAA, 0xE8, 0xBB, 0xE8, 0x00, 0xBB, ];
let mut scanner = x::Scanner::new(buffer, pattern, ..);
let mut saves = [0usize;8];
assert!(scanner.next(&mut saves));
assert_eq!(saves[0], 1);
assert!(scanner.next(&mut saves));
assert_eq!(saves[0], 3);
}