Skip to content

Commit e621c79

Browse files
committed
Fixed constant name and deprecated versions check for Capstone.
1 parent 098fd24 commit e621c79

1 file changed

Lines changed: 2 additions & 30 deletions

File tree

winappdbg/disasm.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -310,30 +310,9 @@ def __init__(self, arch=None):
310310
win32.ARCH_AMD64: (capstone.CS_ARCH_X86, capstone.CS_MODE_64),
311311
win32.ARCH_THUMB: (capstone.CS_ARCH_ARM, capstone.CS_MODE_THUMB),
312312
win32.ARCH_ARM: (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
313-
win32.ARCH_ARM64: (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM),
313+
win32.ARCH_ARM64: (capstone.CS_ARCH_AARCH64, capstone.CS_MODE_ARM),
314314
}
315315

316-
# Test for the bug in early versions of Capstone.
317-
# If found, warn the user about it.
318-
try:
319-
self.__bug = not isinstance(
320-
list(
321-
capstone.cs_disasm_quick(
322-
capstone.CS_ARCH_X86, capstone.CS_MODE_32, b"\x90", 1
323-
)
324-
)[0],
325-
capstone.capstone.CsInsn,
326-
)
327-
except AttributeError:
328-
self.__bug = False
329-
if self.__bug:
330-
warnings.warn(
331-
"This version of the Capstone bindings is unstable,"
332-
" please upgrade to a newer one!",
333-
RuntimeWarning,
334-
stacklevel=4,
335-
)
336-
337316
def decode(self, address, code):
338317
# Get the constants for the requested architecture.
339318
arch, mode = self.__constants[self.arch]
@@ -342,13 +321,6 @@ def decode(self, address, code):
342321
md = capstone.Cs(arch, mode)
343322
decoder = md.disasm_lite
344323

345-
# If the buggy version of the bindings are being used, we need to catch
346-
# all exceptions broadly. If not, we only need to catch CsError.
347-
if self.__bug:
348-
CsError = Exception
349-
else:
350-
CsError = capstone.CsError
351-
352324
# Create the variables for the instruction length, mnemonic and
353325
# operands. That way they won't be created within the loop,
354326
# minimizing the chances data might be overwritten.
@@ -370,7 +342,7 @@ def decode(self, address, code):
370342
]
371343
except IndexError:
372344
pass # No instructions decoded.
373-
except CsError:
345+
except capstone.CsError:
374346
pass # Any other error.
375347

376348
# On success add the decoded instruction.

0 commit comments

Comments
 (0)