當前位置: 首頁>>代碼示例>>Python>>正文


Python ida_segment.getseg方法代碼示例

本文整理匯總了Python中ida_segment.getseg方法的典型用法代碼示例。如果您正苦於以下問題:Python ida_segment.getseg方法的具體用法?Python ida_segment.getseg怎麽用?Python ida_segment.getseg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ida_segment的用法示例。


在下文中一共展示了ida_segment.getseg方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: is_overlay

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def is_overlay(self, addr):
        """
        Checks if memory block (segment) is an overlay.

        Args:
            addr: Integer representing a program address.

        Returns:
            True if memory block (segment) is an overlay.
        """
        if ida_idp.ph_get_id() == ida_idp.PLFM_C166:
            return False
        s = ida_segment.getseg(addr)
        if s.start_ea in self.overlay:
            return self.overlay[s.start_ea]
        return False 
開發者ID:Cisco-Talos,項目名稱:GhIDA,代碼行數:18,代碼來源:idaxml.py

示例2: translate_address

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def translate_address(self, addr):
        """
        Returns the translated logical address.

        The logical address is adjusted for the segment base address.
        For 16-bit segmented memory, return the 20-bit address.

        Args:
            addr: Integer representing a program address.

        Returns:
            Integer representing the logical address.
        """
        if self.seg_addr == False:
            return addr - ida_segment.get_segm_base(ida_segment.getseg(addr))
        base = ida_segment.get_segm_para(ida_segment.getseg(addr))
        return (base << 16) + (addr - (base << 4)) 
開發者ID:Cisco-Talos,項目名稱:GhIDA,代碼行數:19,代碼來源:idaxml.py

示例3: get_line_comments

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def get_line_comments():
    """
    Iterate through every address in a segment and check for comments

    :return: Dict containing line comments
    """

    last_comment = ''
    comments = {}
    for ea in idautils.Segments():
        segm = ida_segment.getseg(ea)
        name = ida_segment.get_segm_name(segm)
        if name == 'LOAD':
            continue

        for i in range(segm.start_ea, segm.end_ea):
            comment = get_single_line_comment(i)
            if comment and comment != last_comment:
                comments[i] = comment
                last_comment = comment

    return comments 
開發者ID:zznop,項目名稱:bnida,代碼行數:24,代碼來源:ida_export.py

示例4: get_sections

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def get_sections():
    """
    Get section names and start/end addrs from IDA database

    :return: Dict containing section info
    """

    sections = {}
    for ea in idautils.Segments():
        segm = ida_segment.getseg(ea)
        name = ida_segment.get_segm_name(segm)
        if name == 'LOAD':
            continue

        curr = {}
        curr['start']  = segm.start_ea
        curr['end']    = segm.end_ea
        sections[name] = curr

    return sections 
開發者ID:zznop,項目名稱:bnida,代碼行數:22,代碼來源:ida_export.py

示例5: on_get_annotations

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def on_get_annotations(self, address, size, mouse_offs):
        caption = "Return instructions:"
        spaces = 40*'-'
        ann = [(None, None, caption, self.colormap[-1])]
        if len(self.ret_locs):
            i = 0
            offs = self._get_selection_offs()
            nret = len(self.ret_locs)
            for x in range(offs,nret):
                _, __, ret = self.ret_locs[x]
                seg = getseg(ret)
                textcol = self.txtcol
                if seg is not None:
                    if not seg.perm & SEGPERM_EXEC:
                        # red text color if ret not within executable segment
                        textcol = 0xEE0000
                ann.append((ret, self.ptrcol, "   %X  [%s]" % (ret, generate_disasm_line(ret, GENDSM_FORCE_CODE | GENDSM_REMOVE_TAGS)), textcol))
                i += 1
                if i > self.threshold and len(self.ret_locs) - i > 0:
                    ann.append((None, None, "<%d more not shown>" % (len(self.ret_locs) - i), self.colormap[-1]))
                    break
        return ann 
開發者ID:patois,項目名稱:IDACyber,代碼行數:24,代碼來源:vrop.py

示例6: enum_segment_ptrs

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def enum_segment_ptrs(ea):
	seg = ida_segment.getseg(ea)
	for (ea, ptr) in enum_ptrs(seg.start_ea, seg.end_ea):
		yield (ea, ptr) 
開發者ID:williballenthin,項目名稱:idawilli,代碼行數:6,代碼來源:resolve_ptrs.py

示例7: enum_segments

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def enum_segments():
    for ea in idautils.Segments():
        seg = ida_segment.getseg(ea)
        yield Segment(seg.start_ea, seg.end_ea, seg.name) 
開發者ID:williballenthin,項目名稱:idawilli,代碼行數:6,代碼來源:color.py

示例8: get_address_string

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def get_address_string(self, addr):
        """
        Returns a string representing the address.

        The representation is typically a hex string of the address,
        but may include a segment or space name prefixe based on the
        processor or architecture.

        Args:
            addr: Integer representing a program address.
        """
        temp = "0x%X" % (
            addr - ida_segment.get_segm_base(ida_segment.getseg(addr)))
        space = self.get_space_name(addr)
        if space != None:
            temp = "%s:%04X" % (space,
                                addr - ida_segment.get_segm_base(ida_segment.getseg(addr)))
        else:
            if (ida_idp.ph_get_id() == ida_idp.PLFM_386 and
                    ida_segment.getseg(addr).bitness == 0):
                base = ida_segment.get_segm_para(ida_segment.getseg(addr))
                temp = "%04X:%04X" % (base, addr - (base << 4))
        if ida_idp.ph_get_id() == ida_idp.PLFM_C166:
            temp = "0x%X" % addr
        if self.has_overlays == True and self.is_overlay(addr) == True:
            oname = ida_segment.get_segm_name(ida_segment.getseg(addr))
            if len(oname) > 0:
                temp = oname + "::" + temp
        return temp 
開發者ID:Cisco-Talos,項目名稱:GhIDA,代碼行數:31,代碼來源:idaxml.py

示例9: get_space_name

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def get_space_name(self, addr):
        """
        Returns the memory space name associated with an address.

        Args:
            addr: Integer representing a program address.

        Returns:
            String containg the memory space name.
            None if single address space architecture.

        Used for Harvard architectures (Intel 8051 and TMS, add others
        as needed). 
        """
        pid = ida_idp.ph_get_id()
        stype = ida_segment.segtype(addr)
        if pid == ida_idp.PLFM_8051:
            if stype == idc.SEG_CODE:
                return "CODE"
            else:
                if stype == idc.SEG_IMEM:
                    iaddr = addr - \
                        ida_segment.get_segm_base(ida_segment.getseg(addr))
                    if iaddr < 0x80:
                        return "INTMEM"
                    else:
                        return "SFR"
                else:
                    return "EXTMEM"
        if pid == ida_idp.PLFM_TMS:
            if stype == idc.SEG_CODE:
                return "CODE"
            else:
                return "DATA"
        return None 
開發者ID:Cisco-Talos,項目名稱:GhIDA,代碼行數:37,代碼來源:idaxml.py

示例10: __call__

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def __call__(self):
        cmt = Event.encode(self.cmt)
        if self.kind == ida_range.RANGE_KIND_FUNC:
            func = ida_funcs.get_func(self.start_ea)
            ida_funcs.set_func_cmt(func, cmt, self.rptble)
        elif self.kind == ida_range.RANGE_KIND_SEGMENT:
            segment = ida_segment.getseg(self.start_ea)
            ida_segment.set_segment_cmt(segment, cmt, self.rptble)
        else:
            raise Exception("Unsupported range kind: %d" % self.kind) 
開發者ID:IDArlingTeam,項目名稱:IDArling,代碼行數:12,代碼來源:events.py

示例11: adjust_addr

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def adjust_addr(sections, addr):
    """
    Adjust the address if there are differences in section base addresses

    :param sections: Dictionary containing section info
    :param addr: Address that might need adjusted
    :return: Adjusted address
    """

    bn_section_start = None
    section_name = None
    for name, section in sections.items():
        if addr >= int(section['start']) and addr <= int(section['end']):
            bn_section_start = int(section['start'])
            section_name = name
            break

    # Make sure the section was found (this check should always pass)
    if section_name is None:
        print('Section not found in bnida analysis data for addr: {:08x}'.format(addr))
        return None

    # Retrieve section start in IDA and adjust the addr
    ida_sections = idautils.Segments()
    for ea in ida_sections:
        segm = ida_segment.getseg(ea)
        if ida_segment.get_segm_name(segm) == section_name:
            return addr - bn_section_start + segm.start_ea

    print('Section not found - name:{} addr:{:08x}'.format(section_name, addr))
    return None 
開發者ID:zznop,項目名稱:bnida,代碼行數:33,代碼來源:ida_import.py

示例12: isExternalFunction

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def isExternalFunction(self, function_offset):
        function_segment = ida_segment.getseg(function_offset)
        function_segment_name = ida_segment.get_segm_name(function_segment)
        is_extern = function_segment_name in ["extern", "UNDEF"]
        return is_extern 
開發者ID:danielplohmann,項目名稱:smda,代碼行數:7,代碼來源:IdaInterface.py

示例13: export_code

# 需要導入模塊: import ida_segment [as 別名]
# 或者: from ida_segment import getseg [as 別名]
def export_code(self):
        """
        Exports the address ranges of code sequences as CODE_BLOCK(s)
        with START and END address attributes.
        """
        addr = self.min_ea
        if idc.is_code(idc.get_full_flags(addr)) == False:
            addr = ida_bytes.next_that(addr, self.max_ea, idc.is_code)
        if (addr == BADADDR):
            return
        self.update_status(CODE)
        timer = time.clock()
        data = ida_bytes.next_that(addr, self.max_ea, idc.is_data)
        unknown = ida_bytes.next_unknown(addr, self.max_ea)
        self.start_element(CODE, True)
        while (addr != BADADDR):
            start = addr
            end = min(data, unknown)
            if (end == BADADDR):
                if (ida_segment.getseg(start).end_ea < self.max_ea):
                    codeend = ida_segment.getseg(start).end_ea - 1
                    addr = ida_segment.getseg(idc.next_addr(codeend)).start_ea
                    if idc.is_code(idc.get_full_flags(addr)) == False:
                        addr = ida_bytes.next_that(addr, self.max_ea,
                                                   idc.is_code)
                else:
                    codeend = self.max_ea - 1
                    addr = BADADDR
            else:
                if (ida_segment.getseg(start).end_ea < end):
                    codeend = ida_segment.getseg(start).end_ea - 1
                    addr = ida_segment.getseg(idc.next_addr(codeend)).start_ea
                    if idc.is_code(ida_bytes.get_full_flags(addr)) == False:
                        addr = ida_bytes.next_that(addr, self.max_ea,
                                                   idc.is_code)
                else:
                    codeend = idc.get_item_end(ida_bytes.prev_that(end,
                                                                   start, idc.is_code)) - 1
                    addr = ida_bytes.next_that(end, self.max_ea, idc.is_code)
                if (data < addr):
                    data = ida_bytes.next_that(addr, self.max_ea,
                                               idc.is_data)
                if (unknown < addr):
                    unknown = ida_bytes.next_unknown(addr, self.max_ea)
            self.start_element(CODE_BLOCK)
            self.write_address_attribute(START, start)
            self.write_address_attribute(END, codeend)
            self.close_tag()
        self.end_element(CODE)
        self.display_cpu_time(timer) 
開發者ID:Cisco-Talos,項目名稱:GhIDA,代碼行數:52,代碼來源:idaxml.py


注:本文中的ida_segment.getseg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。