I'm trying to write a simple script to disassemble ARM/THUMB bytecode. It's very common in ARM to switch from one mode to another, and therefore it's quite crucial that the disassembler be able to follow that. I'm having trouble with it, even though the docs say it's very simple ( see https://www.capstone-engine.org/lang_python.html#62-dynamically-change-disassemble-mode-at-run-time ). This does not seem to work at runtime for me.
Here is what my test looks like:
for i in md.disasm(CODE, 0x1000):
print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
if i.mnemonic == "bx":
md.mode = cs.CS_MODE_THUMB
Note that it actually does go into thumb mode, just not during the loop. Therefore, what happens is that the code is completely disassembled in ARM, but if I run it again it will be completely disassembled in THUMB.
Thank you in advance for your help