| 631 | |
| 632 | # Python-style class to disasm code |
| 633 | class CsInsn(object): |
| 634 | def __init__(self, cs, all_info): |
| 635 | self._raw = copy_ctypes(all_info) |
| 636 | self._cs = cs |
| 637 | if self._cs._detail and self._raw.id != 0: |
| 638 | # save detail |
| 639 | self._raw.detail = ctypes.pointer(all_info.detail._type_()) |
| 640 | ctypes.memmove(ctypes.byref(self._raw.detail[0]), ctypes.byref(all_info.detail[0]), ctypes.sizeof(type(all_info.detail[0]))) |
| 641 | |
| 642 | def __repr__(self): |
| 643 | return '<CsInsn 0x%x [%s]: %s %s>' % (self.address, self.bytes.hex(), self.mnemonic, self.op_str) |
| 644 | |
| 645 | # return instruction's ID. |
| 646 | @property |
| 647 | def id(self): |
| 648 | return self._raw.id |
| 649 | |
| 650 | # return instruction's address. |
| 651 | @property |
| 652 | def address(self): |
| 653 | return self._raw.address |
| 654 | |
| 655 | # return instruction's size. |
| 656 | @property |
| 657 | def size(self): |
| 658 | return self._raw.size |
| 659 | |
| 660 | # return instruction's machine bytes (which should have @size bytes). |
| 661 | @property |
| 662 | def bytes(self): |
| 663 | return bytearray(self._raw.bytes)[:self._raw.size] |
| 664 | |
| 665 | # return instruction's mnemonic. |
| 666 | @property |
| 667 | def mnemonic(self): |
| 668 | if self._cs._diet: |
| 669 | # Diet engine cannot provide @mnemonic. |
| 670 | raise CsError(CS_ERR_DIET) |
| 671 | |
| 672 | return self._raw.mnemonic.decode('ascii') |
| 673 | |
| 674 | # return instruction's operands (in string). |
| 675 | @property |
| 676 | def op_str(self): |
| 677 | if self._cs._diet: |
| 678 | # Diet engine cannot provide @op_str. |
| 679 | raise CsError(CS_ERR_DIET) |
| 680 | |
| 681 | return self._raw.op_str.decode('ascii') |
| 682 | |
| 683 | # return list of all implicit registers being read. |
| 684 | @property |
| 685 | def regs_read(self): |
| 686 | if self._raw.id == 0: |
| 687 | raise CsError(CS_ERR_SKIPDATA) |
| 688 | |
| 689 | if self._cs._diet: |
| 690 | # Diet engine cannot provide @regs_read. |
no outgoing calls
no test coverage detected
searching dependent graphs…