Workaround unicorn handing back bytearrays

This commit is contained in:
Richo Healey 2016-10-05 22:47:40 -07:00
parent d872649234
commit 9413509982
1 changed files with 4 additions and 0 deletions

View File

@ -843,6 +843,10 @@ class Cs(object):
print(code)
code = code.encode()
print(code)'''
# Hack, unicorn's memory accessors give you back bytearrays, but they
# cause TypeErrors when you hand them into Capstone.
if isinstance(code, bytearray):
code = bytes(code)
res = _cs.cs_disasm(self.csh, code, len(code), offset, count, ctypes.byref(all_insn))
if res > 0:
try: