aaaaaaaaaaaa
代码改变世界

节区相关操作函数

2018-03-04 18:05  二进制乐谱  阅读(392)  评论(0编辑  收藏  举报

idc 

http://www.cnblogs.com/fply/p/8505416.html

 

 

AskSelector(sel)

FindSelector(val)

SetSelector(sel, value)

 

获取第一个节区地址

FirstSeg()

 

下个节区地址

NextSeg(ea)

 

获取节区起始位置

SegStart(ea)

 

SegEnd(ea)

SegName(ea)

 

#创建一个节区
AddSegEx(startea, endea, base, use32, align, comb, flags):
""" Create a new segment @param startea: linear address of the start of the segment @param endea: linear address of the end of the segment this address will not belong to the segment 'endea' should be higher than 'startea' @param base: base paragraph or selector of the segment. a paragraph is 16byte memory chunk. If a selector value is specified, the selector should be already defined. @param use32: 0: 16bit segment, 1: 32bit segment, 2: 64bit segment @param align: segment alignment. see below for alignment values @param comb: segment combination. see below for combination values. @param flags: combination of ADDSEG_... bits @return: 0-failed, 1-ok """

 

 AddSeg(startea, endea, base, use32, align, comb)

 DelSeg(ea, flags)

SetSegBounds(ea, startea, endea, flags)

 RenameSeg(ea, name)

 

SetSegClass(ea, segclass)

SegAlign(ea, alignment):
    """
    Change alignment of the segment

    @param ea: any address in the segment
    @param alignment: new alignment of the segment (one of the sa... constants)

    @return: success (boolean)
    """
    return SetSegmentAttr(ea, SEGATTR_ALIGN, alignment)


saAbs        = idaapi.saAbs        # Absolute segment.
saRelByte    = idaapi.saRelByte    # Relocatable, byte aligned.
saRelWord    = idaapi.saRelWord    # Relocatable, word (2-byte, 16-bit) aligned.
saRelPara    = idaapi.saRelPara    # Relocatable, paragraph (16-byte) aligned.
saRelPage    = idaapi.saRelPage    # Relocatable, aligned on 256-byte boundary
                                    # (a "page" in the original Intel specification).
saRelDble    = idaapi.saRelDble    # Relocatable, aligned on a double word
                                    # (4-byte) boundary. This value is used by
                                    # the PharLap OMF for the same alignment.
saRel4K      = idaapi.saRel4K      # This value is used by the PharLap OMF for
                                    # page (4K) alignment. It is not supported
                                    # by LINK.
saGroup      = idaapi.saGroup      # Segment group
saRel32Bytes = idaapi.saRel32Bytes # 32 bytes
saRel64Bytes = idaapi.saRel64Bytes # 64 bytes
saRelQword   = idaapi.saRelQword   # 8 bytes

 

#通过名称获取selector,返回一个数据,段中DS

SegByName(segname)

 

SetSegDefReg(ea, reg, value)

 

SetSegmentType(segea, segtype)
    """
    Set segment type

    @param segea: any address within segment
    @param segtype: new segment type:

    @return: !=0 - ok
    """
    seg = idaapi.getseg(segea)

    if not seg:
        return False

    seg.type = segtype
    return seg.update()


SEG_NORM   = idaapi.SEG_NORM
SEG_XTRN   = idaapi.SEG_XTRN   # * segment with 'extern' definitions
                                #   no instructions are allowed
SEG_CODE   = idaapi.SEG_CODE   # pure code segment
SEG_DATA   = idaapi.SEG_DATA   # pure data segment
SEG_IMP    = idaapi.SEG_IMP    # implementation segment
SEG_GRP    = idaapi.SEG_GRP    # * group of segments
                                #   no instructions are allowed
SEG_NULL   = idaapi.SEG_NULL   # zero-length segment
SEG_UNDF   = idaapi.SEG_UNDF   # undefined segment type
SEG_BSS    = idaapi.SEG_BSS    # uninitialized segment
SEG_ABSSYM = idaapi.SEG_ABSSYM # * segment with definitions of absolute symbols
                                #   no instructions are allowed
SEG_COMM   = idaapi.SEG_COMM   # * segment with communal definitions
                                #   no instructions are allowed
SEG_IMEM   = idaapi.SEG_IMEM   # internal processor memory & sfr (8051)

 

GetSegmentAttr(segea, attr)

 

SetSegmentAttr(segea, attr, value)

 

 MoveSegm(ea, to, flags)

rebase_program(delta, flags)

 

aaaaaaaaaaaaa