support disassembling bytes from memoryview

This commit is contained in:
jesko 2021-05-28 09:51:40 +02:00
parent f278de39c1
commit d59c50f623
1 changed files with 2 additions and 2 deletions

View File

@ -1099,7 +1099,7 @@ class Cs(object):
print(code)'''
# Pass a bytearray by reference
size = len(code)
if isinstance(code, bytearray):
if isinstance(code, (bytearray, memoryview)):
code = ctypes.byref(ctypes.c_char.from_buffer(code))
res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn))
if res > 0:
@ -1127,7 +1127,7 @@ class Cs(object):
all_insn = ctypes.POINTER(_cs_insn)()
size = len(code)
# Pass a bytearray by reference
if isinstance(code, bytearray):
if isinstance(code, (bytearray, memoryview) ):
code = ctypes.byref(ctypes.c_char.from_buffer(code))
res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn))
if res > 0: