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:
Update zydis-bingenin this PR to #derive[Hash] for the the generated enums.
Update ffi.rs on this repo as needed to #derive(Hash) for DecodedInstruction and DecodedOperand
Ran cargo clean && cargo test to make sure this doesn’t somehow break things
What:
I'd like to use
DecodedInstruction
as a key in aHashMap<DecodedInstruction, Vec<u64>>
(map instruction to addresses at which it occurs).Why:
I could use the
Formatter.format_instruction
withip
beingNone
to create a string representation of the instruction and then use the string as aHashMap
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:
zydis-bingen
in this PR to#derive[Hash]
for the the generated enums.ffi.rs
on this repo as needed to#derive(Hash)
forDecodedInstruction
andDecodedOperand
cargo clean && cargo test
to make sure this doesn’t somehow break thingsDoes this seem reasonable? Thanks in advance!