Skip to main content

pattern

Macro pattern 

Source
macro_rules! pattern {
    [ $( $tok:tt ),* $(,)? ] => { ... };
}
Expand description

Build a &'static [Option<u8>; N] at compile time from a list of byte literals and _ wildcards.

ยงExamples

use pe_sigscan::pattern;

// `_` is the wildcard token. Use byte literals (0xNN) for fixed bytes.
const SIG: &[Option<u8>] = pattern![0x48, 0x8B, _, _, 0x48, 0x89];
assert_eq!(SIG, &[Some(0x48), Some(0x8B), None, None, Some(0x48), Some(0x89)]);

This is the zero-cost / no-allocation alternative to Pattern::from_ida. Use it when the pattern is known at compile time (the common case for hard-coded signatures); use Pattern::from_ida when the pattern is loaded from config, a dump file, or user input at runtime.