Ejemplo n.º 1
0
def remove(segment, contents=False):
    """Remove the specified `segment`.

    If the bool `contents` is specified, then remove the contents of the segment from the database.
    """
    if not isinstance(segment, idaapi.segment_t):
        cls = idaapi.segment_t
        raise E.InvalidParameterError(
            "{:s}.remove({!r}) : Expected a {!s}, but received a {!s}.".format(
                __name__, segment, cls, type(segment)))

    res = idaapi.del_selector(segment.sel)
    if res == 0:
        logging.warn(
            "{:s}.remove({!r}) : Unable to delete the selector {:#x}.".format(
                __name__, segment, segment.sel))

    res = idaapi.del_segm(
        segment.startEA,
        idaapi.SEGMOD_KILL if contents else idaapi.SEGMOD_KEEP)
    if res == 0:
        logging.warn(
            "{:s}.remove({!r}) : Unable to delete the segment {:s} with the selector {:s}."
            .format(__name__, segment, segment.name, segment.sel))
    return res
def remove(segment, contents=False):
    """Remove the specified `segment`.

    If the bool `contents` is specified, then remove the contents of the segment from the database.
    """
    if not isinstance(segment, idaapi.segment_t):
        cls = idaapi.segment_t
        raise E.InvalidParameterError(
            u"{:s}.remove({!r}) : Expected an `idaapi.segment_t`, but received a {!s}."
            .format(__name__, segment, type(segment)))

    # delete the selector defined by the segment_t
    res = idaapi.del_selector(segment.sel)
    if res == 0:
        logging.warning(
            u"{:s}.remove({!r}) : Unable to delete the selector {:#x}.".format(
                __name__, segment, segment.sel))

    # remove the actual segment using the address in the segment_t
    res = idaapi.del_segm(
        interface.range.start(segment),
        idaapi.SEGMOD_KILL if contents else idaapi.SEGMOD_KEEP)
    if res == 0:
        logging.warning(
            u"{:s}.remove({!r}) : Unable to delete the segment {:s} with the selector {:s}."
            .format(__name__, segment, segment.name, segment.sel))
    return res
Ejemplo n.º 3
0
def delete(segment, remove=False):
    '''Given a segment_t, delete it along with any selectors that might point to it.'''
    assert type(segment) is idaapi.segment_t
    assert segment is not None
    res = idaapi.del_selector(segment.sel)
    if res == 0:
        logging.warn("segment.delete(%s):Unable to delete selector %x", repr(segment), segment.sel)
    res = idaapi.del_segm(segment.startEA, idaapi.SEGMOD_KILL if remove else idaapi.SEGMOD_KEEP)
    if res == 0:
        logging.warn("segment %s:Unable to delete segment %s", segment.name, segment.sel)
    return res
Ejemplo n.º 4
0
def remove(segment, remove=False):
    """Remove the segment identified by ``segment``.
    If the bool ``remove`` is specified, then remove the content of the segment from the database.
    """
    if not isinstance(segment, idaapi.segment_t):
        raise TypeError("{:s}.remove({!r}) : segment is not of an idaapi.segment_t. : {!r}".format(__name__, segment, type(segment)))
    res = idaapi.del_selector(segment.sel)
    if res == 0:
        logging.warn("{:s}.remove({!r}):Unable to delete selector {:x}".format(__name__, segment, segment.sel))
    res = idaapi.del_segm(segment.startEA, idaapi.SEGMOD_KILL if remove else idaapi.SEGMOD_KEEP)
    if res == 0:
        logging.warn("{:s}.remove({!r}):Unable to delete segment {:s} : {:s}".format(__name__, segment, segment.name, segment.sel))
    return res
Ejemplo n.º 5
0
def delete(segment, remove=False):
    '''Given a segment_t, delete it along with any selectors that might point to it.'''
    assert type(segment) is idaapi.segment_t
    assert segment is not None
    res = idaapi.del_selector(segment.sel)
    if res == 0:
        logging.warn("segment.delete(%s):Unable to delete selector %x",
                     repr(segment), segment.sel)
    res = idaapi.del_segm(segment.startEA,
                          idaapi.SEGMOD_KILL if remove else idaapi.SEGMOD_KEEP)
    if res == 0:
        logging.warn("segment %s:Unable to delete segment %s", segment.name,
                     segment.sel)
    return res
Ejemplo n.º 6
0
def remove(segment, contents=False):
    """Remove the specified `segment`.

    If the bool `contents` is specified, then remove the contents of the segment from the database.
    """
    if not isinstance(segment, idaapi.segment_t):
        cls = idaapi.segment_t
        raise E.InvalidParameterError(u"{:s}.remove({!r}) : Expected an `idaapi.segment_t`, but received a {!s}.".format(__name__, segment, type(segment)))

    # delete the selector defined by the segment_t
    res = idaapi.del_selector(segment.sel)
    if res == 0:
        logging.warn(u"{:s}.remove({!r}) : Unable to delete the selector {:#x}.".format(__name__, segment, segment.sel))

    # remove the actual segment using the address in the segment_t
    res = idaapi.del_segm(segment.startEA, idaapi.SEGMOD_KILL if contents else idaapi.SEGMOD_KEEP)
    if res == 0:
        logging.warn(u"{:s}.remove({!r}) : Unable to delete the segment {:s} with the selector {:s}.".format(__name__, segment, segment.name, segment.sel))
    return res
Ejemplo n.º 7
0
 def __call__(self):
     idaapi.del_segm(self.ea, idaapi.SEGMOD_KEEP | idaapi.SEGMOD_SILENT)