support disassembling bytes from memoryview

This commit is contained in:
jesko 2021-05-28 09:51:40 +02:00
parent af57fb3a01
commit 3f75a02950

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: