capstone-rust / capstone-rs

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

`X86Operand` uses `Option<RegAccessType>` for specifying the access types of memory operands #135

Open jrmuizel opened 1 year ago

jrmuizel commented 1 year ago

I found it confusing that RegAccessType is used. It sort of implies that it describes how the register is accessed and not the memory.

e.g.:

0x1000: addl $1, (%rdi)
    insn id:     8
    bytes:       [131, 7, 1]
    read regs:
    write regs:  rflags
    insn groups:
    operands: 2
        X86Operand(X86Operand { size: 4, access: None, avx_bcast: X86_AVX_BCAST_INVALID, avx_zero_opmask: false, op_type: Imm(1) })
        X86Operand(X86Operand { size: 4, access: Some(ReadWrite), avx_bcast: X86_AVX_BCAST_INVALID, avx_zero_opmask: false, op_type: Mem(X86OpMem(x86_op_mem { segment: 0, base: 39, index: 0, scale: 1, disp: 0 })) })

The second operand has access: Some(ReadWrite) but that's not describing how rdi is accessed.

jrmuizel commented 1 year ago

Maybe just renaming the type to AccessType is a good solution?

tmfink commented 9 months ago

Maybe just renaming the type to AccessType is a good solution?

I agree--that makes sense to me. The C type is name cs_ac_type, which does not imply anything about access to registers.