MCPcopy Create free account
hub / github.com/capstone-engine/capstone / cs_disasm_quick

Function cs_disasm_quick

bindings/python/capstone/__init__.py:555–584  ·  view source on GitHub ↗
(arch, mode, code, offset, count=0)

Source from the content-addressed store, hash-verified

553# This function return CsInsn objects
554# NOTE: you might want to use more efficient Cs class & its methods.
555def cs_disasm_quick(arch, mode, code, offset, count=0):
556 # verify version compatibility with the core before doing anything
557 (major, minor, _combined) = cs_version()
558 if major != CS_API_MAJOR or minor != CS_API_MINOR:
559 # our binding version is different from the core's API version
560 raise CsError(CS_ERR_VERSION)
561
562 csh = ctypes.c_size_t()
563 status = _cs.cs_open(arch, mode, ctypes.byref(csh))
564 if status != CS_ERR_OK:
565 raise CsError(status)
566
567 all_insn = ctypes.POINTER(_cs_insn)()
568 res = _cs.cs_disasm(csh, code, len(code), offset, count, ctypes.byref(all_insn))
569 if res > 0:
570 try:
571 for i in range(res):
572 yield CsInsn(_dummy_cs(csh, arch), all_insn[i])
573 finally:
574 _cs.cs_free(all_insn, res)
575 else:
576 status = _cs.cs_errno(csh)
577 if status != CS_ERR_OK:
578 raise CsError(status)
579 return
580 yield
581
582 status = _cs.cs_close(ctypes.byref(csh))
583 if status != CS_ERR_OK:
584 raise CsError(status)
585
586
587# Another quick, but lighter function to disasm raw binary code.

Callers 1

test_cs_disasm_quickFunction · 0.85

Calls 9

CsErrorClass · 0.85
_dummy_csClass · 0.85
cs_openMethod · 0.80
cs_disasmMethod · 0.80
cs_freeMethod · 0.80
cs_errnoMethod · 0.80
cs_closeMethod · 0.80
cs_versionFunction · 0.70
CsInsnClass · 0.70

Tested by 1

test_cs_disasm_quickFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…