def refresh_views():
"""
Refresh the IDA views.
"""
# refresh IDA views
idaapi.refresh_idaview_anyway()
# NOTE/COMPAT: refresh hexrays view, if active
if using_ida7api:
current_widget = idaapi.get_current_widget()
vu = idaapi.get_widget_vdui(current_widget)
else:
current_tform = idaapi.get_current_tform()
vu = idaapi.get_tform_vdui(current_tform)
if vu:
vu.refresh_ctext()
python类refresh_idaview_anyway()的实例源码
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, rgb, **frame):
"""Sets the color of the basic-block ``bb`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, n = cls.get_color(bb), by_address(bb.startEA), idaapi.node_info_t()
# specify the bg color
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb.id, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the colors of each item too.
for ea in block.iterate(bb):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def finish(self, bap):
idaapi.IDAPython_ExecScript(bap.script.name, globals())
idaapi.refresh_idaview_anyway()
BapTaint._do_callbacks(self.kind)
idc.Refresh()
def load_script(self, bap, ea):
idc.SetStatus(idc.IDA_STATUS_WORK)
idaapi.IDAPython_ExecScript(bap.script.name, globals())
self._do_callbacks(ea)
idc.Refresh()
# do we really need to call this?
idaapi.refresh_idaview_anyway()
idc.SetStatus(idc.IDA_STATUS_READY)
def add_starts(self, bap):
syms = []
for line in bap.syms:
heappush(syms, int(line, 16))
for i in range(len(syms)):
idaapi.add_func(heappop(syms), idaapi.BADADDR)
idc.Refresh()
idaapi.refresh_idaview_anyway()
def refresh(cls):
idaapi.refresh_lists()
return idaapi.refresh_idaview_anyway()
def refresh(cls):
idaapi.refresh_lists()
return idaapi.refresh_idaview_anyway()
def color_block(ea=None, color=0x55ff7f):
"""http://reverseengineering.stackexchange.com/questions/10662/change-block-node-color-with-idapython
and WanderingGlitch for the tip of refresh_idaview_anyway()"""
func_top = fn.top()
f = idaapi.get_func(ea)
g = idaapi.FlowChart(f, flags=idaapi.FC_PREDS)
bb_id = get_bb_id(g, ea)
p = idaapi.node_info_t()
p.bg_color = color
idaapi.set_node_info2(func_top, bb_id, p, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
idaapi.refresh_idaview_anyway()
def set_color(cls, ea, none):
'''Removes the color of the basic-block at address ``ea``.'''
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
try: idaapi.clr_node_info2(fn.startEA, bb, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(ea):
database.set_color(ea, None)
# internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, ea, none):
'''Removes the color of the basic-block at address ``ea``.'''
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
try: idaapi.clr_node_info2(fn.startEA, bb, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(ea):
database.set_color(ea, None)
# internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, none):
'''Removes the color of the basic-block ``bb``.'''
res, fn = cls.get_color(bb), by_address(bb.startEA)
try: idaapi.clr_node_info2(fn.startEA, bb.id, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(bb):
database.set_color(ea, None)
#internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, none):
'''Removes the color of the basic-block ``bb``.'''
res, fn = cls.get_color(bb), by_address(bb.startEA)
try: idaapi.clr_node_info2(fn.startEA, bb.id, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(bb):
database.set_color(ea, None)
#internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, none):
'''Removes the color of the basic-block at address ``ea``.'''
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
try: idaapi.clr_node_info2(fn.startEA, bb, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(ea):
database.set_color(ea, None)
# internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, ea, none):
'''Removes the color of the basic-block at address ``ea``.'''
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
try: idaapi.clr_node_info2(fn.startEA, bb, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(ea):
database.set_color(ea, None)
# internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, none):
'''Removes the color of the basic-block ``bb``.'''
res, fn = cls.get_color(bb), by_address(bb.startEA)
try: idaapi.clr_node_info2(fn.startEA, bb.id, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(bb):
database.set_color(ea, None)
#internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res
def set_color(cls, bb, none):
'''Removes the color of the basic-block ``bb``.'''
res, fn = cls.get_color(bb), by_address(bb.startEA)
try: idaapi.clr_node_info2(fn.startEA, bb.id, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(bb):
database.set_color(ea, None)
#internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, none):
'''Removes the color of the basic-block at address ``ea``.'''
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
try: idaapi.clr_node_info2(fn.startEA, bb, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
finally: idaapi.refresh_idaview_anyway()
# clear the color of each item too.
for ea in block.iterate(ea):
database.set_color(ea, None)
# internal.netnode.alt.remove(ea, 0x14)
return res
def set_color(cls, ea, rgb, **frame):
"""Sets the color of the basic-block at address ``ea`` to ``rgb``.
If the color ``frame`` is specified, set the frame to the specified color.
"""
res, fn, bb = cls.get_color(ea), by_address(ea), cls.id(ea)
n = idaapi.node_info_t()
# specify the bgcolor
r,b = (rgb&0xff0000) >> 16, rgb&0x0000ff
n.bg_color = n.frame_color = (b<<16)|(rgb&0x00ff00)|r
# now the frame color
frgb = frame.get('frame', 0x000000)
fr, fb = (frgb & 0xff0000) >> 16, frgb&0x0000ff
n.frame_color = (fb<<16)|(frgb&0x00ff00)|fr
# set the node
f = (idaapi.NIF_BG_COLOR|idaapi.NIF_FRAME_COLOR) if frame else idaapi.NIF_BG_COLOR
try: idaapi.set_node_info2(fn.startEA, bb, n, f)
finally: idaapi.refresh_idaview_anyway()
# update the color of each item too
for ea in block.iterate(ea):
database.set_color(ea, rgb)
#internal.netnode.alt.set(ea, 0x14, n.bg_color)
return res