def by_value(cls, enum, value): '''Return the member identifier for the member of the enumeration `enum` with the specified `value`.''' eid = by(enum) bmask = idaapi.BADADDR & mask(eid) res, _ = idaapi.get_first_serial_enum_member(eid, value, bmask) if res == idaapi.BADADDR: raise E.MemberNotFoundError(u"{:s}.by_value({:#x}, {:d}) : Unable to locate member by value.".format('.'.join((__name__, cls.__name__)), eid, value)) return res
def by_value(cls, enum, value): '''Return the member identifier for the member of the enumeration `enum` with the specified `value`.''' eid = by(enum) bmask = idaapi.BADADDR & mask(eid) res, _ = idaapi.get_first_serial_enum_member(eid, value, bmask) if res == idaapi.BADADDR: raise E.MemberNotFoundError(u"{:s}.by_value({:#x}, {:d}) : Unable to locate member by value.".format('.'.join((__name__, cls.__name__)), eid, value)) return res
def each(cls, enum): '''Given an enum id, yield each id of it's members''' bmask = -1&mask(enum) for v in cls._each(enum): res,_ = idaapi.get_first_serial_enum_member(enum, v, bmask) # XXX: what does get_next_serial_enum_member and the rest do? yield res return
def iterate(cls, enum): '''Iterate through all ids of each member associated with the enumeration `enum`.''' eid = by(enum) bmask = idaapi.BADADDR & mask(eid) for value in cls.__iterate__(eid): res, _ = idaapi.get_first_serial_enum_member(eid, value, bmask) # XXX: what does get_next_serial_enum_member and the rest do? yield res return
def iterate(cls, enum): '''Iterate through all ids of each member associated with the enumeration `enum`.''' eid = by(enum) bmask = idaapi.BADADDR & mask(eid) for value in cls.__iterate__(eid): res, _ = idaapi.get_first_serial_enum_member(eid, value, bmask) # XXX: what does get_next_serial_enum_member and the rest do? yield res return
def iterate(cls, enum): '''Iterate through all the member ids associated with the enumeration ``enum``.''' eid = by(enum) bmask = -1 & mask(eid) for v in cls.__iterate__(eid): res, _ = idaapi.get_first_serial_enum_member(eid, v, bmask) # XXX: what does get_next_serial_enum_member and the rest do? yield res return
def _iter_serial_enum_member(eid, value, bitmask): """Iterate serial and CID of enum members with given value and bitmask. Here only valid values are returned, as `idaapi.BADNODE` always indicates an invalid member. """ cid, serial = idaapi.get_first_serial_enum_member(eid, value, bitmask) while cid != idaapi.BADNODE: yield cid, serial cid, serial = idaapi.get_next_serial_enum_member(cid, serial)
def by_value(cls, enum, value): '''Return the member id for the member of the enumeration ``enum`` with the specified ``value``.''' eid = by(enum) bmask = -1 & mask(eid) res, _ = idaapi.get_first_serial_enum_member(eid, value, bmask) if res == idaapi.BADADDR: raise LookupError( "{:s}.by_value({:x}, {:d}) : Unable to locate member by value." .format('.'.join((__name__, cls.__name__)), eid, value)) return res
def byValue(enum, value): '''Given an enum id, return the member id with the specified /value/''' bmask = -1&mask(enum) res,_ = idaapi.get_first_serial_enum_member(enum, value, bmask) return res