本文整理汇总了Python中idc.here方法的典型用法代码示例。如果您正苦于以下问题:Python idc.here方法的具体用法?Python idc.here怎么用?Python idc.here使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idc
的用法示例。
在下文中一共展示了idc.here方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def __init__(self, ea=UseCurrentAddress, name=None):
if name is not None and ea != self.UseCurrentAddress:
raise ValueError(("Either supply a name or an address (ea). "
"Not both. (ea={!r}, name={!r})").format(ea, name))
elif name is not None:
ea = idc.get_name_ea_simple(name)
if ea == idc.BADADDR:
raise exceptions.SarkNoFunction(
"The supplied name does not belong to an existing function. "
"(name = {!r})".format(name))
elif ea == self.UseCurrentAddress:
ea = idc.here()
elif ea is None:
raise ValueError("`None` is not a valid address. To use the current screen ea, "
"use `Function(ea=Function.UseCurrentAddress)` or supply no `ea`.")
elif isinstance(ea, Line):
ea = ea.ea
self._func = get_func(ea)
self._comments = Comments(self)
示例2: __init__
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def __init__(self, ea=UseCurrentAddress, name=None):
if name is not None and ea != self.UseCurrentAddress:
raise ValueError(("Either supply a name or an address (ea). "
"Not both. (ea={!r}, name={!r})").format(ea, name))
elif name is not None:
ea = idc.get_name_ea_simple(name)
elif ea == self.UseCurrentAddress:
ea = idc.here()
elif ea is None:
raise ValueError("`None` is not a valid address. To use the current screen ea, "
"use `Line(ea=Line.UseCurrentAddress)` or supply no `ea`.")
self._ea = idaapi.get_item_head(ea)
self._comments = Comments(self._ea)
示例3: show_highlighted_function_meaningful
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def show_highlighted_function_meaningful():
line = sark.Line()
meaningful_displayed = False
for xref in line.xrefs_from:
try:
if xref.type.is_flow:
continue
function = sark.Function(xref.to)
show_meaningful_in_function(function)
meaningful_displayed = True
except sark.exceptions.SarkNoFunction:
pass
if not meaningful_displayed:
idaapi.msg("[FunctionStrings] No function referenced by current line: 0x{:08X}.\n".format(idc.here()))
示例4: getFuncRanges
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def getFuncRanges(ea, doAllFuncs):
if using_ida7api:
return getFuncRanges_ida7(ea, doAllFuncs)
if doAllFuncs:
funcs = []
funcGen = idautils.Functions(idc.SegStart(ea), idc.SegEnd(ea))
for i in funcGen:
funcs.append(i)
funcRanges = []
for i in range(len(funcs) - 1):
funcRanges.append( (funcs[i], funcs[i+1]) )
funcRanges.append( (funcs[-1], idc.SegEnd(ea)) )
return funcRanges
else:
#just get the range of the current function
fakeRanges = [( idc.GetFunctionAttr(idc.here(), idc.FUNCATTR_START), idc.GetFunctionAttr(idc.here(), idc.FUNCATTR_END)), ]
return fakeRanges
示例5: stripNumberedName
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def stripNumberedName(name):
'''Remove trailing unique ID like IDA does for same names'''
idx = len(name) -1
while idx >= 0:
if (name[idx] == '_'):
if (len(name)-1) == idx:
#last char is '_', not allowed so return name
return name
else:
#encountered a '_', strip here
return name[:idx]
if name[idx] in g_NUMBERS:
#still processing tail
pass
else:
#encountered unexpected sequence, just return name
return name
idx -= 1
return name
示例6: emit_fnbytes_python
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def emit_fnbytes_python(fva=None, warn=True):
"""Emit function bytes as Python code with disassembly in comments.
Args:
fva (numbers.Integral): function virtual address.
Defaults to here() if that is the start of a function, else
defaults to the start of the function that here() is a part of.
warn (bool): enable interactive warnings
Returns:
str: Python code you can spruce up and paste into a script.
"""
header = 'instrs_{name} = (\n'
footer = ')'
indent = ' '
def _emit_instr_python(va, the_bytes, size):
disas = idc.GetDisasm(va)
return "'%s' # %s\n" % (binascii.hexlify(the_bytes), disas)
return _emit_fnbytes(_emit_instr_python, header, footer, indent, fva, warn)
示例7: emit_fnbytes_c
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def emit_fnbytes_c(fva=None, warn=True):
"""Emit function bytes as C code with disassembly in comments.
Args:
fva (numbers.Integral): function virtual address.
Defaults to here() if that is the start of a function, else
defaults to the start of the function that here() is a part of.
warn (bool): enable interactive warnings
Returns:
str: C code you can spruce up and paste into a script.
"""
header = 'unsigned char *instrs_{name} = {{\n'
footer = '};'
indent = '\t'
def _emit_instr_for_c(va, the_bytes, size):
disas = idc.GetDisasm(va)
buf = ''.join(['\\x%s' % (binascii.hexlify(c)) for c in the_bytes])
return '"%s" /* %s */\n' % (buf, disas)
return _emit_fnbytes(_emit_instr_for_c, header, footer, indent, fva, warn)
示例8: target_button_clicked
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def target_button_clicked(self):
self.target_field.setText(hex(idc.here()))
示例9: decode_here_clicked
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def decode_here_clicked(self):
inst = idc.here()
if not idc.isCode(idc.GetFlags(inst)):
print "Not code instruction"
else:
raw = idc.GetManyBytes(inst, idc.NextHead(inst)-inst)
s = to_hex(raw)
self.decode_ir(s)
示例10: target_button_clicked
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def target_button_clicked(self):
if self.radio_addr.isChecked():
self.target_field.setText(hex(idc.here()))
else:
self.target_field.setText(idc.GetFunctionName(idc.here()))
# ================================================================================
# ================================================================================
# ==================== Data structures ==================
示例11: highlight_dead_code
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def highlight_dead_code(self, enabled):
curr_fun = idaapi.get_func(idc.here()).startEA
cfg = self.functions_cfg[curr_fun]
# for cfg in self.functions_cfg.values():
for bb in cfg.values():
color = {Status.DEAD: 0x5754ff, Status.ALIVE: 0x98FF98, Status.UNKNOWN: 0xaa0071}[bb.status]
color = 0xFFFFFF if enabled else color
for i in bb:
idc.SetColor(i, idc.CIC_ITEM, color)
self.actions[HIGHLIGHT_DEAD_CODE] = (self.highlight_dead_code, not enabled)
self.result_widget.action_selector_changed(HIGHLIGHT_DEAD_CODE)
示例12: highlight_spurious
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def highlight_spurious(self, enabled):
print "Highlight spurious clicked !"
curr_fun = idaapi.get_func(idc.here()).startEA
cfg = self.functions_cfg[curr_fun]
color = 0xFFFFFF if enabled else 0x507cff
for bb in [x for x in cfg.values() if x.is_alive()]: # Iterate only alive basic blocks
for i, st in bb.instrs_status.items():
if st == Status.DEAD: # Instructions dead in alive basic blocks are spurious
idc.SetColor(i, idc.CIC_ITEM, color)
self.actions[HIGHLIGHT_SPURIOUS_CALCULUS] = (self.highlight_spurious, not enabled)
self.result_widget.action_selector_changed(HIGHLIGHT_SPURIOUS_CALCULUS)
示例13: from_button_clicked
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def from_button_clicked(self):
self.from_field.setText(hex(idc.here()))
示例14: to_button_clicked
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def to_button_clicked(self):
self.to_field.setText(hex(idc.here()))
示例15: restrict_from_button_clicked
# 需要导入模块: import idc [as 别名]
# 或者: from idc import here [as 别名]
def restrict_from_button_clicked(self):
self.restrict_from_field.setText(hex(idc.here()))