本文整理汇总了Python中miasm2.ir.translators.Translator.available_languages方法的典型用法代码示例。如果您正苦于以下问题:Python Translator.available_languages方法的具体用法?Python Translator.available_languages怎么用?Python Translator.available_languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类miasm2.ir.translators.Translator
的用法示例。
在下文中一共展示了Translator.available_languages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from miasm2.ir.translators import Translator [as 别名]
# 或者: from miasm2.ir.translators.Translator import available_languages [as 别名]
def __init__(self, expr):
"@expr: Expr instance"
# Init
self.languages = list(Translator.available_languages())
self.expr = expr
# Initial translation
text = Translator.to_language(self.languages[0]).from_expr(self.expr)
# Create the Form
idaapi.Form.__init__(self, r"""STARTITEM 0
Python Expression
{FormChangeCb}
<Language:{cbLanguage}>
<Translation:{result}>
""", {
'result': idaapi.Form.MultiLineTextControl(text=text,
flags=translatorForm.flags),
'cbLanguage': idaapi.Form.DropdownListControl(
items=self.languages,
readonly=True,
selval=0),
'FormChangeCb': idaapi.Form.FormChangeCb(self.OnFormChange),
})
示例2: ExprRandom_OpSubRange
# 需要导入模块: from miasm2.ir.translators import Translator [as 别名]
# 或者: from miasm2.ir.translators.Translator import available_languages [as 别名]
random.seed(0)
class ExprRandom_OpSubRange(ExprRandom):
operations_by_args_number = {1: ["-"],
2: ["<<", ">>",],
"2+": ["+", "*", "&", "|", "^"],
}
print "[+] Compute a random expression:"
expr = ExprRandom_OpSubRange.get(depth=8)
print "-> %s" % expr
print
target_exprs = {lang:Translator.to_language(lang).from_expr(expr)
for lang in Translator.available_languages()}
for target_lang, target_expr in target_exprs.iteritems():
print "[+] Translate in %s:" % target_lang
print target_expr
print
print "[+] Eval in Python:"
def memory(addr, size):
ret = random.randint(0, (1 << size) - 1)
print "Memory access: @0x%x -> 0x%x" % (addr, ret)
return ret
for expr_id in expr.get_r(mem_read=True):
if isinstance(expr_id, ExprId):
value = random.randint(0, (1 << expr_id.size) - 1)
print "Declare var: %s = 0x%x" % (expr_id.name, value)