def bottom():
    '''Return the bottom address of the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.bottom() : Unable to locate the current segment.".format(
                __name__))
    return interface.range.end(seg)
def iterate():
    '''Iterate through all of the addresses within the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.iterate() : Unable to locate the current segment.".format(
                __name__))
    return iterate(seg)
def repr():
    '''Return the current segment in a printable form.'''
    segment = ui.current.segment()
    if segment is None:
        raise E.SegmentNotFoundError(
            u"{:s}.repr() : Unable to locate the current segment.".format(
                __name__))
    return repr(segment)
def size():
    '''Return the size of the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.size() : Unable to locate the current segment.".format(
                __name__))
    return interface.range.size(seg)
def by_selector(selector):
    '''Return the segment associated with `selector`.'''
    seg = idaapi.get_segm_by_sel(selector)
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.by_selector({:#x}) : Unable to locate the segment with the specified selector."
            .format(__name__, selector))
    return seg
def by_address(ea):
    '''Return the segment that contains the specified `ea`.'''
    seg = idaapi.getseg(interface.address.within(ea))
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.by_address({:#x}) : Unable to locate segment containing the specified address."
            .format(__name__, ea))
    return seg
Beispiel #7
0
def name():
    '''Return the name of the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            "{:s}.name() : Unable to locate the current segment.".format(
                __name__))
    return idaapi.get_true_segm_name(seg)
Beispiel #8
0
def top():
    '''Return the top address of the current segment.'''
    segment = ui.current.segment()
    if segment is None:
        raise E.SegmentNotFoundError(
            "{:s}.top() : Unable to locate the current segment.".format(
                __name__))
    return segment.startEA
Beispiel #9
0
def size():
    '''Return the size of the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            "{:s}.size() : Unable to locate the current segment.".format(
                __name__))
    return seg.endEA - seg.startEA
Beispiel #10
0
def by_name(name):
    '''Return the segment with the given `name`.'''
    s = idaapi.get_segm_by_name(name)
    if s is None:
        raise E.SegmentNotFoundError(
            "{:s}.by_name({!r}) : Unable to locate the segment with the specified name."
            .format(__name__, name))
    return s
Beispiel #11
0
def bounds():
    '''Return the bounds of the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.bounds() : Unable to locate the current segment.".format(
                __name__))
    return seg.startEA, seg.endEA
def by_name(name):
    '''Return the segment with the given `name`.'''
    res = utils.string.to(name)
    seg = idaapi.get_segm_by_name(res)
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.by_name({!r}) : Unable to locate the segment with the specified name."
            .format(__name__, name))
    return seg
Beispiel #13
0
def read():
    '''Return the contents of the current segment.'''
    segment = ui.current.segment()
    if segment is None:
        raise E.SegmentNotFoundError(
            "{:s}.read() : Unable to locate the current segment.".format(
                __name__))
    return idaapi.get_many_bytes(segment.startEA,
                                 segment.endEA - segment.startEA)
def color():
    '''Return the color of the current segment.'''
    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.color() : Unable to locate the current segment.".format(
                __name__))
    b, r = (seg.color & 0xff0000) >> 16, seg.color & 0x0000ff
    return None if seg.color == 0xffffffff else (r << 16) | (seg.color
                                                             & 0x00ff00) | b
def read():
    '''Return the contents of the current segment.'''
    get_bytes = idaapi.get_many_bytes if idaapi.__version__ < 7.0 else idaapi.get_bytes

    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.read() : Unable to locate the current segment.".format(
                __name__))
    return get_bytes(interface.range.start(seg), interface.range.size(seg))
def name():
    '''Return the name of the current segment.'''
    get_segment_name = idaapi.get_segm_name if hasattr(
        idaapi, 'get_segm_name') else idaapi.get_true_segm_name

    seg = ui.current.segment()
    if seg is None:
        raise E.SegmentNotFoundError(
            u"{:s}.name() : Unable to locate the current segment.".format(
                __name__))
    res = get_segment_name(seg)
    return utils.string.of(res)