Esempio n. 1
0
def Structs():
    """
    Get a list of structures

    @return: List of tuples (idx, sid, name)
    """
    idx = idc.GetFirstStrucIdx()
    while idx != ida_idaapi.BADADDR:
        sid = idc.GetStrucId(idx)
        yield (idx, sid, idc.GetStrucName(sid))
        idx = idc.GetNextStrucIdx(idx)
Esempio n. 2
0
def get_struc_id_from_member_if(member_id):
    try:
        return member_struc_ids[member_id]
    except KeyError:

        idx = idc.GetFirstStrucIdx()
        while idx != idc.BADADDR:
            struc_id = idc.GetStrucId(idx)
            if idc.IsUnion(struc_id):
                offset = idc.GetFirstMember(struc_id)

                while offset != idc.BADADDR:
                    smember_id = idc.GetMemberId(struc_id, offset)
                    if smember_id == member_id:
                        member_struc_ids[member_id] = struc_id
                        return struc_id
                    offset = idc.GetStrucNextOff(struc_id, offset)
            idx = idc.GetNextStrucIdx(idx)
        logger.error("Could not find struc id from member id 0x%08X (name=%s)" %
                     (member_id, idaapi.get_struc_name(member_id)))
        return None
Esempio n. 3
0
 def all_ids():
     return [idc.GetStrucId(i) for i in range(idc.GetStrucQty())]
Esempio n. 4
0
def dispatch(args):

    ## dispatch args....
    class A():
        pass

    a = A()
    for name in args:
        setattr(a, name, args[name])
    del args

    ### dispatch idp events
    if a.action == 'rename':
        debug('[*] renaming %s to %s @ %x', a.old_name, a.new_name, a.ea)
        idc.MakeNameEx(a.ea, str(a.new_name), idaapi.SN_NOWARN)
        return

    ## dispatch idb events
    if a.action == 'cmt_changed':
        if not a.cmt: a.cmt = ''
        _pcmt = a.cmt if len(a.cmt) < 10 else a.cmt[:10] + '...'
        debug('[*] cmt changed @ %X (rep:%s) - %s', a.ea, a.rep, _pcmt)
        if a.rep: idc.MakeRptCmt(a.ea, str(a.cmt))
        else: idc.MakeComm(a.ea, str(a.cmt))

    if a.action == 'struct_created':
        debug('[*] Struct %s created with id %x', a.sname, a.struct)
        print idc.AddStrucEx(-1, str(a.sname), a.union)

    if a.action == 'struct_deleted':
        sid = idc.GetStrucId(a.struct)
        sname = idc.GetStrucName(sid)
        debug('[*] Struct(%x) %s deleted', a.struct, sname)
        idc.DelStruc(sid)

    if a.action == 'struct_renamed':
        sid = idc.GetStrucId(a.struct)
        sname = idc.GetStrucName(sid)
        debug('[*] Struct(%d - %x) renamed from %s to %s', a.struct, sid,
              sname, a.sname)
        idc.SetStrucName(sid, str(a.sname))

    if a.action == 'struct_cmt_changed':
        sid = idc.GetStrucId(a.struct)
        debug('[*] Struct(%d - %x) %s - cmt changed', a.struct, sid, a.sname)
        idc.SetStrucComment(sid, a.cmt, 0)

    if a.action == 'struct_expanded':
        pass

    if a.action == 'struct_member_created':
        pass

    if a.action == 'struct_member_deleted':
        pass
    if a.action == 'struct_member_renamed':
        pass
    if a.action == 'struct_member_changed':
        pass
    if a.action == 'struct_member_':
        pass
    if a.action == 'struct_member_created':
        pass
    if a.action == 'struct_member_created':
        pass

    # if a.action == 'struct_expanded':
    #     debug('

    return 0