After installing the Capstone python module, I ran this example on a Win7x86 PC with a minor edit (added arch and mode).

However, when attempting to use insn.regs_access(), it throws a NoneType object which is not iterable:

enter preformatted text here

  1 from capstone import *
  3 CODE = b"\x8d\x4c\x32\x08\x01\xd8"
  5 md = Cs(CS_ARCH_X86, CS_MODE_32)
  6 md.detail = True
  8 for insn in md.disasm(code, 0x1000):
  9     print("%s\t%s" % (insn.mnemonic, insn.op_str))
 11     (regs_read, regs_write) = insn.regs_access()
 13     if len(regs_read) > 0:
 14         print("\n\tRegisters read:", end="")
 15         for r in regs_read:
 16             print(" %s" %(insn.reg_name(r)))
 19     if len(regs_write) > 0:
 20         print("\n\tRegisters modified:")
 21         for r in regs_write:
 22             print(" %s" %(insn.reg_name(r)))

However, I get the following:

X:\blah>python capTest.py
lea    ecx, dword ptr [edx + esi + 8]
Traceback (most recent call last):
  File "capTest.py", line 11, in <module>
   (regs_read, regs_write) = insn.regs_access()
TypeError: 'NoneType' object is not iterable

How can this be resolved?

1 Answer 1


Emailed Quynh, a member of the Capstone team. He was more than helpful!

Compiled from next branch in msvc...msvc2012 is a prereq. works now!

if you try to build with cygwin you'll receive an error in cs_open (exported by cs.c)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.