(arch, mode, code, offset, count=0)
| 553 | # This function return CsInsn objects |
| 554 | # NOTE: you might want to use more efficient Cs class & its methods. |
| 555 | def 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. |
searching dependent graphs…