[][src]Struct xgadget::gadget::Gadget

pub struct Gadget<'a> {
    pub instrs: Vec<DecodedInstruction>,
    pub full_matches: BTreeSet<u64>,
    pub partial_matches: BTreeMap<u64, Vec<&'a Binary>>,
}

Gadget instructions (data) coupled with occurrence addresses for full and partial matches (metadata). Gadgets sortable by lowest occurrence address. Hash and equality consider only gadget instructions, not occurrence addresses (fast de-duplication via sets).

Fields

instrs: Vec<DecodedInstruction>full_matches: BTreeSet<u64>partial_matches: BTreeMap<u64, Vec<&'a Binary>>

Implementations

impl<'a> Gadget<'a>[src]

pub fn new(
    instrs: Vec<DecodedInstruction>,
    full_matches: BTreeSet<u64>
) -> Gadget<'a>
[src]

Assumes instructions are correctly sorted, address guaranteed to be sorted

pub fn last_instr(&self) -> Option<&DecodedInstruction>[src]

Get tail

Trait Implementations

impl<'a> Clone for Gadget<'a>[src]

impl<'_> Eq for Gadget<'_>[src]

impl<'_> Hash for Gadget<'_>[src]

SET DE-DUPLICATION PERFORMANCE (see http://cglab.ca/~abeinges/blah/hash-rs/):

  • SipHash 2-4 (default): Resistant to an advanced form of DDoS attack, but slow.

    • Important for parsing untrusted inputs (e.g. network data), but not for our tool (it parses local binaries)
    • We default to FxHash to run about 30% faster
    • TODO (tnballo): HOWEVER an optional build config macro enables SipHash 2-4 (for parsing untrusted binaries, e.g. malware)
    • That's paranoid, malware doesn't control hashing logic for our lib's decoding structs
  • Fowler-Noll-Vo, aka FNV: fastest option, but only for small key sizes. Our key, Veczydis::DecodedInstruction, is large and scales proportionally with the flag --max-len (gadget instr count).

    • Not a good choice.
  • FxHash: fast, non-cryptographic hash used in Firefox and maintained by the Rust Core team. Our default for approximately 30% speed gains via "drop-in" replacement.

impl<'_> Ord for Gadget<'_>[src]

impl<'_> PartialEq<Gadget<'_>> for Gadget<'_>[src]

impl<'_> PartialOrd<Gadget<'_>> for Gadget<'_>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Gadget<'a>

impl<'a> Send for Gadget<'a>

impl<'a> Sync for Gadget<'a>

impl<'a> Unpin for Gadget<'a>

impl<'a> UnwindSafe for Gadget<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.