當前位置: 首頁>>代碼示例>>Python>>正文


Python capstone.CsError方法代碼示例

本文整理匯總了Python中capstone.CsError方法的典型用法代碼示例。如果您正苦於以下問題:Python capstone.CsError方法的具體用法?Python capstone.CsError怎麽用?Python capstone.CsError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在capstone的用法示例。


在下文中一共展示了capstone.CsError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _set_arch

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import CsError [as 別名]
def _set_arch(self, arch, *modes):
        """
        Try and set the current architecture
        """
        try:
            a = self.valid_archs[''.join(['CS_ARCH_', arch.upper()])]
            if a is None:
                l.error("Invalid architecture selected - run lsarch for valid options")
                return False
            ms = [self.modes[''.join(['CS_MODE_', m.upper()])] for m in modes]
        except KeyError:
            l.error("ERROR: Invalid architecture or mode string specified")
            return False
        try:
            _cs = cs.Cs(a, sum(ms))
            self._arch = (arch, modes)
            l.debug("Architecture set to %s, mode(s): %s", arch, ', '.join(modes))
            self._cs = _cs
        except cs.CsError as e:
            l.error("ERROR: %s", e)
            return False
        return True 
開發者ID:0xbc,項目名稱:chiasm-shell,代碼行數:24,代碼來源:disassembler.py

示例2: default

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import CsError [as 別名]
def default(self, line):
        """
        Default behaviour - if no other commands are detected,
        try and disassemble the current input according to the
        currently set architecture and modes..

        :param line: Current line's text to try and disassemble.
        """
        # quick, brittle hack to enforce backslash encoding for now
        regex = re.compile('^(\\\\x[a-fA-F0-9]{2})+$')
        if not regex.match(line.strip()):
            l.error("\\xXX\\xXX... is the only valid input format (XX = hex digits)")
            return

        try:
            self._last_decoding = []
            stripped_line = re.sub(r'\\x([0-9a-fA-F]+)', r'\1', line)
            for (addr, size, mn, op_str) in \
                    self._cs.disasm_lite(binascii.a2b_hex(stripped_line), self._firstaddr):
                self._last_decoding.append((addr, size, mn, op_str))
                disas_str = "0x{:x}:\t{}\t{}".format(addr, mn, op_str)
                l.info(disas_str)
        except cs.CsError as e:
            l.error("ERROR: %s", e)
        except ValueError:
            l.error("\\xXX\\xXX... is the only valid input format (XX = hex digits)") 
開發者ID:0xbc,項目名稱:chiasm-shell,代碼行數:28,代碼來源:disassembler.py

示例3: unprocess

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import CsError [as 別名]
def unprocess(self, data):
        super(AsmBase, self).unprocess(data)
        output = ''
        try:
            for (address, size, mnemonic, op_str) in \
                    self.cs.disasm_lite(bytes(data), 0x1000):
                if len(output) > 0:
                    output += '\n'
                output += '%s\t%s' % (mnemonic, op_str)
        except capstone.CsError as e:
            self.error = e
            self.log.error(self.error)
            self.log.debug(self.error, exc_info=True)
            return b''
        return output.encode() 
開發者ID:takeshixx,項目名稱:deen,代碼行數:17,代碼來源:__base__.py


注:本文中的capstone.CsError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。