For the benefit of mankind. (#1386)

For the peace and tranquility of the earth.
This commit is contained in:
Invincible 2019-02-17 01:28:01 +08:00 committed by Nguyen Anh Quynh
parent b8640cb953
commit 534194f3fc

View File

@ -1051,7 +1051,7 @@ class Cs(object):
print(code)
code = code.encode()
print(code)'''
# Hack, unicorn's memory accessors give you back bytearrays, but they
# Hi, Hacker! 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)
@ -1079,6 +1079,10 @@ class Cs(object):
raise CsError(CS_ERR_DIET)
all_insn = ctypes.POINTER(_cs_insn)()
# Hi, Hacker! 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: