zyantific / zydis-rs

Zydis Rust Bindings
MIT License
83 stars 14 forks source link

#[derive(Hash)] for DecodedInstruction and DecodedOperand #23

Closed tnballo closed 4 years ago

tnballo commented 4 years ago

What:

I'd like to use DecodedInstruction as a key in a HashMap<DecodedInstruction, Vec<u64>> (map instruction to addresses at which it occurs).

Why:

I could use the Formatter.format_instruction with ip being None to create a string representation of the instruction and then use the string as a HashMap key, but my goal for a specific analysis is to efficiently de-duplicate instructions that occur at multiple addresses to then print only unique instructions and 1+ corresponding program counters.

Doing "lazy" formatting to human readable text (after de-duplicating instructions with HashMap first) would allow me to do the majority of processing with decoding only, getting the most out of Zydis (as opposed to Capstone) in terms of performance.

What I did:

Does this seem reasonable? Thanks in advance!