thegooglecodearchive / idapython

Automatically exported from code.google.com/p/idapython
Other
0 stars 0 forks source link

SetColor(ea, CIC_FUNC, color) doesn't work #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following code should color all functions green, but does nothing:

code_seg = FirstSeg()
for addr in Functions(SegStart(code_seg), SegEnd(code_seg)):
    SetColor(addr, CIC_FUNC, 0x00FF00)

This seems to be fixed by adding a call to idaapi.update_func. The 
CIC_SEGM case should probably be modified as well?

-----

def SetColor(ea, what, color):
    """
    Set item color

    @param ea: address of the item
    @param what: type of the item (one of CIC_* constants)
    @param color: new color code in RGB (hex 0xBBGGRR)

    @return: success (True or False)
    """
    if what not in [ CIC_ITEM, CIC_FUNC, CIC_SEGM ]:
        raise ValueError, "'what' must be one of CIC_ITEM, CIC_FUNC and 
CIC_SEGM"

    if what == CIC_ITEM:
        return idaapi.set_item_color(ea, color)

    if what == CIC_FUNC:
        func = idaapi.get_func(ea)
        if func:
            func.color = color
            return bool(idaapi.update_func(func))
        else:
            return False

    if what == CIC_SEGM:
        seg = idaapi.getseg(ea)
        if seg:
            seg.color = color
            return True
        else:
            return False

Original issue reported on code.google.com by goo...@simon.user.lysator.liu.se on 14 Nov 2008 at 7:47

GoogleCodeExporter commented 9 years ago
The segment colour changes also need to be updated manually with seg.update().
Both cases are now fixed in the trunk. Thank for the report!

Original comment by gergely.erdelyi on 16 Nov 2008 at 4:11