capstone-rust / capstone-rs

high-level Capstone system bindings for Rust
217 stars 75 forks source link

public the Insn.detail() method #99

Closed lj94093 closed 3 years ago

lj94093 commented 3 years ago

For some reason I need to get the operand type of a instruction. But I find that Insn.detail() is a private method.

pub(crate) unsafe fn detail(&self, arch: Arch) -> InsnDetail {
    InsnDetail(&*self.insn.detail, arch)
}

Is there some reason necessarily to set the detail() to pub(crate)?Or maybe I have to use the capstone-sys directly?

tmfink commented 3 years ago

You can get an instance of InsnDetail by calling Capstone::insn_detail(). Then, you can get the architecture-specific detail (like operands) by calling the .arch_detail() method. For details, see the demo example:

https://github.com/capstone-rust/capstone-rs/blob/e294314c42e0572e09d987744f77e60a0780073a/capstone-rs/examples/demo.rs#L38-L40

tmfink commented 3 years ago

I should probably add "back references" to the types that explain how to get an instance of that type.