capstone icon indicating copy to clipboard operation
capstone copied to clipboard

Switching mode to thumb and reverse(to ARM) on the go.

Open levdikovd opened this issue 3 years ago • 2 comments

I want to place this code to my project:

if(p_ib->flags&INSTR_BLOCK_ARCH_THUMB)
{
  cs_struct * cs_struct = handle;
  cs_struct->mode |= CS_MODE_THUMB;
}
else
{
  cs_struct * cs_struct = handle;
  cs_struct->mode &= ~CS_MODE_THUMB;
}
cs_disasm_iter(handle,
                   (const uint8_t **)&abs_addr,
                   &size,
                   (uint64_t *)&rel_addr,
                   p_instr);

How to use the private structure(cs_struct) in my own project?

levdikovd avatar Dec 29 '21 08:12 levdikovd

no, you should not refer to private struct, but just rely on whatever you have in capstone.h.

a simple solution is to have another cs_struct handle for ARM mode.

aquynh avatar Dec 30 '21 04:12 aquynh

no, you should not refer to private struct, but just rely on whatever you have in capstone.h.

To elaborate, if you rely on a private parts of any library, your code can break silently/unexpectedly. Library authors hide implementation details so that the details can be changed without breaking the interface.

If you think the library does not have a feature you want, feel free to open a feature request issue. :wink:

tmfink avatar Dec 31 '21 00:12 tmfink