IDAPython 9.0
Loading...
Searching...
No Matches
ida_segment Namespace Reference

Detailed Description

Functions that deal with segments.

IDA requires that all program addresses belong to segments (each address must belong to exactly one segment). The situation when an address doesn't belong to any segment is allowed as a temporary situation only when the user changes program segmentation. Bytes outside a segment can't be converted to instructions, have names, comments, etc. Each segment has its start address, ending address and represents a contiguous range of addresses. There might be unused holes between segments.
Each segment has its unique segment selector. This selector is used to distinguish the segment from other segments. For 16-bit programs the selector is equal to the segment base paragraph. For 32-bit programs there is special array to translate the selectors to the segment base paragraphs. A selector is a 32/64 bit value.
The segment base paragraph determines the offsets in the segment. If the start address of the segment == (base << 4) then the first offset in the segment will be 0. The start address should be higher or equal to (base << 4). We will call the offsets in the segment 'virtual addresses'. So, the virtual address of the first byte of the segment is
(start address of segment - segment base linear address)
For IBM PC, the virtual address corresponds to the offset part of the address. For other processors (Z80, for example), virtual addresses correspond to Z80 addresses and linear addresses are used only internally. For MS Windows programs the segment base paragraph is 0 and therefore the segment virtual addresses are equal to linear addresses. 

Classes

class  lock_segment
 
class  segment_defsr_array
 
class  segment_t
 

Functions

bool set_segment_translations (ida_idaapi.ea_t segstart, 'eavec_t const &' transmap)
 
bool is_visible_segm ('segment_t' s)
 
bool is_finally_visible_segm ('segment_t' s)
 
None set_visible_segm ('segment_t' s, bool visible)
 
bool is_spec_segm ('uchar' seg_type)
 
bool is_spec_ea (ida_idaapi.ea_t ea)
 
None lock_segm ('segment_t' segm, bool lock)
 
bool is_segm_locked ('segment_t' segm)
 
'sel_t *, ea_t *' getn_selector (int n)
 
'size_t' get_selector_qty ()
 
'sel_t' setup_selector (ida_idaapi.ea_t segbase)
 
'sel_t' allocate_selector (ida_idaapi.ea_t segbase)
 
'sel_t' find_free_selector ()
 
int set_selector ('sel_t' selector, ida_idaapi.ea_t paragraph)
 
None del_selector ('sel_t' selector)
 
ida_idaapi.ea_t sel2para ('sel_t' selector)
 
ida_idaapi.ea_t sel2ea ('sel_t' selector)
 
'sel_t' find_selector (ida_idaapi.ea_t base)
 
'segment_t *' get_segm_by_sel ('sel_t' selector)
 
bool add_segm_ex ('segment_t' NONNULL_s, str name, str sclass, int flags)
 
bool add_segm (ida_idaapi.ea_t para, ida_idaapi.ea_t start, ida_idaapi.ea_t end, str name, str sclass, int flags=0)
 
bool del_segm (ida_idaapi.ea_t ea, int flags)
 
int get_segm_qty ()
 
'segment_t *' getseg (ida_idaapi.ea_t ea)
 
'segment_t *' getnseg (int n)
 
int get_segm_num (ida_idaapi.ea_t ea)
 
'segment_t *' get_next_seg (ida_idaapi.ea_t ea)
 
'segment_t *' get_prev_seg (ida_idaapi.ea_t ea)
 
'segment_t *' get_first_seg ()
 
'segment_t *' get_last_seg ()
 
'segment_t *' get_segm_by_name (str name)
 
bool set_segm_end (ida_idaapi.ea_t ea, ida_idaapi.ea_t newend, int flags)
 
bool set_segm_start (ida_idaapi.ea_t ea, ida_idaapi.ea_t newstart, int flags)
 
bool move_segm_start (ida_idaapi.ea_t ea, ida_idaapi.ea_t newstart, int mode)
 
str move_segm_strerror ('move_segm_code_t' code)
 
'move_segm_code_t' move_segm ('segment_t' s, ida_idaapi.ea_t to, int flags=0)
 
int change_segment_status ('segment_t' s, bool is_deb_segm)
 
bool take_memory_snapshot (int type)
 
bool is_miniidb ()
 
bool set_segm_base ('segment_t' s, ida_idaapi.ea_t newbase)
 
int set_group_selector ('sel_t' grp, 'sel_t' sel)
 
'sel_t' get_group_selector ('sel_t' grpsel)
 
bool add_segment_translation (ida_idaapi.ea_t segstart, ida_idaapi.ea_t mappedseg)
 
None del_segment_translations (ida_idaapi.ea_t segstart)
 
'ssize_t' get_segment_translations ('eavec_t *' transmap, ida_idaapi.ea_t segstart)
 
str get_segment_cmt ('segment_t' s, bool repeatable)
 
None set_segment_cmt ('segment_t' s, str cmt, bool repeatable)
 
None std_out_segm_footer ('outctx_t &' ctx, 'segment_t' seg)
 
int set_segm_name ('segment_t' s, str name, int flags=0)
 
str get_segm_name ('segment_t' s, int flags=0)
 
str get_visible_segm_name ('segment_t' s)
 
str get_segm_class ('segment_t' s)
 
int set_segm_class ('segment_t' s, str sclass, int flags=0)
 
'uchar' segtype (ida_idaapi.ea_t ea)
 
str get_segment_alignment ('uchar' align)
 
str get_segment_combination ('uchar' comb)
 
ida_idaapi.ea_t get_segm_para ('segment_t' s)
 
ida_idaapi.ea_t get_segm_base ('segment_t' s)
 
bool set_segm_addressing ('segment_t' s, 'size_t' bitness)
 
bool update_segm ('segment_t' s)
 
'adiff_t' segm_adjust_diff ('segment_t' s, 'adiff_t' delta)
 
ida_idaapi.ea_t segm_adjust_ea ('segment_t' s, ida_idaapi.ea_t ea)
 
 get_defsr (s, reg)
 
 set_defsr (s, reg, value)
 
int rebase_program ('PyObject *' delta, int flags)
 

Variables

 SREG_NUM = _ida_segment.SREG_NUM
 
 saAbs = _ida_segment.saAbs
 
 saRelByte = _ida_segment.saRelByte
 
 saRelWord = _ida_segment.saRelWord
 
 saRelPara = _ida_segment.saRelPara
 
 saRelPage = _ida_segment.saRelPage
 
 saRelDble = _ida_segment.saRelDble
 
 saRel4K = _ida_segment.saRel4K
 
 saGroup = _ida_segment.saGroup
 
 saRel32Bytes = _ida_segment.saRel32Bytes
 
 saRel64Bytes = _ida_segment.saRel64Bytes
 
 saRelQword = _ida_segment.saRelQword
 
 saRel128Bytes = _ida_segment.saRel128Bytes
 
 saRel512Bytes = _ida_segment.saRel512Bytes
 
 saRel1024Bytes = _ida_segment.saRel1024Bytes
 
 saRel2048Bytes = _ida_segment.saRel2048Bytes
 
 saRel_MAX_ALIGN_CODE = _ida_segment.saRel_MAX_ALIGN_CODE
 
 scPriv = _ida_segment.scPriv
 
 scGroup = _ida_segment.scGroup
 
 scPub = _ida_segment.scPub
 
 scPub2 = _ida_segment.scPub2
 
 scStack = _ida_segment.scStack
 
 scCommon = _ida_segment.scCommon
 
 scPub3 = _ida_segment.scPub3
 
 sc_MAX_COMB_CODE = _ida_segment.sc_MAX_COMB_CODE
 
 SEGPERM_EXEC = _ida_segment.SEGPERM_EXEC
 
 SEGPERM_WRITE = _ida_segment.SEGPERM_WRITE
 
 SEGPERM_READ = _ida_segment.SEGPERM_READ
 
 SEGPERM_MAXVAL = _ida_segment.SEGPERM_MAXVAL
 
 SEG_MAX_BITNESS_CODE = _ida_segment.SEG_MAX_BITNESS_CODE
 
 SFL_COMORG = _ida_segment.SFL_COMORG
 
 SFL_OBOK = _ida_segment.SFL_OBOK
 
 SFL_HIDDEN = _ida_segment.SFL_HIDDEN
 
 SFL_DEBUG = _ida_segment.SFL_DEBUG
 
 SFL_LOADER = _ida_segment.SFL_LOADER
 
 SFL_HIDETYPE = _ida_segment.SFL_HIDETYPE
 
 SFL_HEADER = _ida_segment.SFL_HEADER
 
 SEG_NORM = _ida_segment.SEG_NORM
 
 SEG_XTRN = _ida_segment.SEG_XTRN
 
 SEG_CODE = _ida_segment.SEG_CODE
 
 SEG_DATA = _ida_segment.SEG_DATA
 
 SEG_IMP = _ida_segment.SEG_IMP
 
 SEG_GRP = _ida_segment.SEG_GRP
 
 SEG_NULL = _ida_segment.SEG_NULL
 
 SEG_UNDF = _ida_segment.SEG_UNDF
 
 SEG_BSS = _ida_segment.SEG_BSS
 
 SEG_ABSSYM = _ida_segment.SEG_ABSSYM
 
 SEG_COMM = _ida_segment.SEG_COMM
 
 SEG_IMEM = _ida_segment.SEG_IMEM
 
 SEG_MAX_SEGTYPE_CODE = _ida_segment.SEG_MAX_SEGTYPE_CODE
 
 ADDSEG_NOSREG = _ida_segment.ADDSEG_NOSREG
 
 ADDSEG_OR_DIE = _ida_segment.ADDSEG_OR_DIE
 
 ADDSEG_NOTRUNC = _ida_segment.ADDSEG_NOTRUNC
 
 ADDSEG_QUIET = _ida_segment.ADDSEG_QUIET
 
 ADDSEG_FILLGAP = _ida_segment.ADDSEG_FILLGAP
 
 ADDSEG_SPARSE = _ida_segment.ADDSEG_SPARSE
 
 ADDSEG_NOAA = _ida_segment.ADDSEG_NOAA
 
 ADDSEG_IDBENC = _ida_segment.ADDSEG_IDBENC
 
 SEGMOD_KILL = _ida_segment.SEGMOD_KILL
 
 SEGMOD_KEEP = _ida_segment.SEGMOD_KEEP
 
 SEGMOD_SILENT = _ida_segment.SEGMOD_SILENT
 
 SEGMOD_KEEP0 = _ida_segment.SEGMOD_KEEP0
 
 SEGMOD_KEEPSEL = _ida_segment.SEGMOD_KEEPSEL
 
 SEGMOD_NOMOVE = _ida_segment.SEGMOD_NOMOVE
 
 SEGMOD_SPARSE = _ida_segment.SEGMOD_SPARSE
 
 MOVE_SEGM_OK = _ida_segment.MOVE_SEGM_OK
 
 MOVE_SEGM_PARAM = _ida_segment.MOVE_SEGM_PARAM
 
 MOVE_SEGM_ROOM = _ida_segment.MOVE_SEGM_ROOM
 
 MOVE_SEGM_IDP = _ida_segment.MOVE_SEGM_IDP
 
 MOVE_SEGM_CHUNK = _ida_segment.MOVE_SEGM_CHUNK
 
 MOVE_SEGM_LOADER = _ida_segment.MOVE_SEGM_LOADER
 
 MOVE_SEGM_ODD = _ida_segment.MOVE_SEGM_ODD
 
 MOVE_SEGM_ORPHAN = _ida_segment.MOVE_SEGM_ORPHAN
 
 MOVE_SEGM_DEBUG = _ida_segment.MOVE_SEGM_DEBUG
 
 MOVE_SEGM_SOURCEFILES = _ida_segment.MOVE_SEGM_SOURCEFILES
 
 MOVE_SEGM_MAPPING = _ida_segment.MOVE_SEGM_MAPPING
 
 MOVE_SEGM_INVAL = _ida_segment.MOVE_SEGM_INVAL
 
 MSF_SILENT = _ida_segment.MSF_SILENT
 
 MSF_NOFIX = _ida_segment.MSF_NOFIX
 
 MSF_LDKEEP = _ida_segment.MSF_LDKEEP
 
 MSF_FIXONCE = _ida_segment.MSF_FIXONCE
 
 MSF_PRIORITY = _ida_segment.MSF_PRIORITY
 
 MSF_NETNODES = _ida_segment.MSF_NETNODES
 
 CSS_OK = _ida_segment.CSS_OK
 
 CSS_NODBG = _ida_segment.CSS_NODBG
 
 CSS_NORANGE = _ida_segment.CSS_NORANGE
 
 CSS_NOMEM = _ida_segment.CSS_NOMEM
 
 CSS_BREAK = _ida_segment.CSS_BREAK
 
 SNAP_ALL_SEG = _ida_segment.SNAP_ALL_SEG
 
 SNAP_LOAD_SEG = _ida_segment.SNAP_LOAD_SEG
 
 SNAP_CUR_SEG = _ida_segment.SNAP_CUR_SEG
 
 MAX_GROUPS = _ida_segment.MAX_GROUPS
 
 MAX_SEGM_TRANSLATIONS = _ida_segment.MAX_SEGM_TRANSLATIONS
 

Function Documentation

◆ add_segm()

bool add_segm ( ida_idaapi.ea_t para,
ida_idaapi.ea_t start,
ida_idaapi.ea_t end,
str name,
str sclass,
int flags = 0 )
Add a new segment, second form. Segment alignment is set to saRelByte. Segment combination is "public" or "stack" (if segment class is "STACK"). Addressing mode of segment is taken as default (16bit or 32bit). Default segment registers are set to BADSEL. If a segment already exists at the specified range of addresses, this segment will be truncated. Instructions and data in the old segment will be deleted if the new segment has another addressing mode or another segment base address. 
    
@param para: segment base paragraph. if paragraph can't fit in 16bit, then a new selector is allocated and mapped to the paragraph.
@param start: start address of the segment. if start==BADADDR then start <- to_ea(para,0).
@param end: end address of the segment. end address should be higher than start address. For emulate empty segments, use SEG_NULL segment type. If the end address is lower than start address, then fail. If end==BADADDR, then a segment up to the next segment will be created (if the next segment doesn't exist, then 1 byte segment will be created). If 'end' is too high and the new segment would overlap the next segment, 'end' is adjusted properly.
@param name: name of new segment. may be nullptr
@param sclass: class of the segment. may be nullptr. type of the new segment is modified if class is one of predefined names:
* "CODE" -> SEG_CODE
* "DATA" -> SEG_DATA
* "CONST" -> SEG_DATA
* "STACK" -> SEG_BSS
* "BSS" -> SEG_BSS
* "XTRN" -> SEG_XTRN
* "COMM" -> SEG_COMM
* "ABS" -> SEG_ABSSYM
@param flags: Add segment flags
@retval 1: ok
@retval 0: failed, a warning message is displayed

◆ add_segm_ex()

bool add_segm_ex ( 'segment_t' NONNULL_s,
str name,
str sclass,
int flags )
Add a new segment. If a segment already exists at the specified range of addresses, this segment will be truncated. Instructions and data in the old segment will be deleted if the new segment has another addressing mode or another segment base address. 
    
@param name: name of new segment. may be nullptr. if specified, the segment is immediately renamed
@param sclass: class of the segment. may be nullptr. if specified, the segment class is immediately changed
@param flags: Add segment flags
@retval 1: ok
@retval 0: failed, a warning message is displayed

◆ add_segment_translation()

bool add_segment_translation ( ida_idaapi.ea_t segstart,
ida_idaapi.ea_t mappedseg )
Add segment translation. 
    
@param segstart: start address of the segment to add translation to
@param mappedseg: start address of the overlayed segment
@retval 1: ok
@retval 0: too many translations or bad segstart

◆ allocate_selector()

'sel_t' allocate_selector ( ida_idaapi.ea_t segbase)
Allocate a selector for a segment unconditionally. You must call this function before calling add_segm_ex(). add_segm() calls this function itself, so you don't need to allocate a selector. This function will allocate a new free selector and setup its mapping using find_free_selector() and set_selector() functions. 
    
@param segbase: a new segment base paragraph
@returns the allocated selector number

◆ change_segment_status()

int change_segment_status ( 'segment_t' s,
bool is_deb_segm )
Convert a debugger segment to a regular segment and vice versa. When converting debug->regular, the memory contents will be copied to the database. 
    
@param s: segment to modify
@param is_deb_segm: new status of the segment
@returns Change segment status result codes

◆ del_segm()

bool del_segm ( ida_idaapi.ea_t ea,
int flags )
Delete a segment. 
    
@param ea: any address belonging to the segment
@param flags: Segment modification flags
@retval 1: ok
@retval 0: failed, no segment at 'ea'.

◆ del_segment_translations()

None del_segment_translations ( ida_idaapi.ea_t segstart)
Delete the translation list 
    
@param segstart: start address of the segment to delete translation list

◆ del_selector()

None del_selector ( 'sel_t' selector)
Delete mapping of a selector. Be wary of deleting selectors that are being used in the program, this can make a mess in the segments. 
    
@param selector: number of selector to remove from the translation table

◆ find_free_selector()

'sel_t' find_free_selector ( )
Find first unused selector. 
    
@returns a number >= 1

◆ find_selector()

'sel_t' find_selector ( ida_idaapi.ea_t base)
Find a selector that has mapping to the specified paragraph. 
    
@param base: paragraph to search in the translation table
@returns selector value or base

◆ get_defsr()

get_defsr ( s,
reg )
Deprecated, use instead:
value = s.defsr[reg]

◆ get_first_seg()

'segment_t *' get_first_seg ( )
Get pointer to the first segment.

◆ get_group_selector()

'sel_t' get_group_selector ( 'sel_t' grpsel)
Get common selector for a group of segments. 
    
@param grpsel: selector of group segment
@returns common selector of the group or 'grpsel' if no such group is found

◆ get_last_seg()

'segment_t *' get_last_seg ( )
Get pointer to the last segment.

◆ get_next_seg()

'segment_t *' get_next_seg ( ida_idaapi.ea_t ea)
Get pointer to the next segment.

◆ get_prev_seg()

'segment_t *' get_prev_seg ( ida_idaapi.ea_t ea)
Get pointer to the previous segment.

◆ get_segm_base()

ida_idaapi.ea_t get_segm_base ( 'segment_t' s)
Get segment base linear address. Segment base linear address is used to calculate virtual addresses. The virtual address of the first byte of the segment will be (start address of segment - segment base linear address) 
    
@param s: pointer to segment
@returns 0 if s == nullptr, otherwise segment base linear address

◆ get_segm_by_name()

'segment_t *' get_segm_by_name ( str name)
Get pointer to segment by its name. If there are several segments with the same name, returns the first of them. 
    
@param name: segment name. may be nullptr.
@returns nullptr or pointer to segment structure

◆ get_segm_by_sel()

'segment_t *' get_segm_by_sel ( 'sel_t' selector)
Get pointer to segment structure. This function finds a segment by its selector. If there are several segments with the same selectors, the last one will be returned. 
    
@param selector: a segment with the specified selector will be returned
@returns pointer to segment or nullptr

◆ get_segm_class()

str get_segm_class ( 'segment_t' s)
Get segment class. Segment class is arbitrary text (max 8 characters). 
    
@param s: pointer to segment
@returns size of segment class (-1 if s==nullptr or bufsize<=0)

◆ get_segm_name()

str get_segm_name ( 'segment_t' s,
int flags = 0 )
Get true segment name by pointer to segment. 
    
@param s: pointer to segment
@param flags: 0-return name as is; 1-substitute bad symbols with _ 1 corresponds to GN_VISIBLE
@returns size of segment name (-1 if s==nullptr)

◆ get_segm_num()

int get_segm_num ( ida_idaapi.ea_t ea)
Get number of segment by address. 
    
@param ea: linear address belonging to the segment
@returns -1 if no segment occupies the specified address. otherwise returns number of the specified segment (0..get_segm_qty()-1)

◆ get_segm_para()

ida_idaapi.ea_t get_segm_para ( 'segment_t' s)
Get segment base paragraph. Segment base paragraph may be converted to segment base linear address using to_ea() function. In fact, to_ea(get_segm_para(s), 0) == get_segm_base(s). 
    
@param s: pointer to segment
@returns 0 if s == nullptr, the segment base paragraph

◆ get_segm_qty()

int get_segm_qty ( )
Get number of segments.

◆ get_segment_alignment()

str get_segment_alignment ( 'uchar' align)
Get text representation of segment alignment code. 
    
@returns text digestable by IBM PC assembler.

◆ get_segment_cmt()

str get_segment_cmt ( 'segment_t' s,
bool repeatable )
Get segment comment. 
    
@param s: pointer to segment structure
@param repeatable: 0: get regular comment. 1: get repeatable comment.
@returns size of comment or -1

◆ get_segment_combination()

str get_segment_combination ( 'uchar' comb)
Get text representation of segment combination code. 
    
@returns text digestable by IBM PC assembler.

◆ get_segment_translations()

'ssize_t' get_segment_translations ( 'eavec_t *' transmap,
ida_idaapi.ea_t segstart )
Get segment translation list. 
    
@param transmap: vector of segment start addresses for the translation list
@param segstart: start address of the segment to get information about
@returns -1 if no translation list or bad segstart. otherwise returns size of translation list.

◆ get_selector_qty()

'size_t' get_selector_qty ( )
Get number of defined selectors.

◆ get_visible_segm_name()

str get_visible_segm_name ( 'segment_t' s)
Get segment name by pointer to segment. 
    
@param s: pointer to segment
@returns size of segment name (-1 if s==nullptr)

◆ getn_selector()

'sel_t *, ea_t *' getn_selector ( int n)
Get description of selector (0..get_selector_qty()-1)

◆ getnseg()

'segment_t *' getnseg ( int n)
Get pointer to segment by its number. 
    
@param n: segment number in the range (0..get_segm_qty()-1)
@returns nullptr or pointer to segment structure

◆ getseg()

'segment_t *' getseg ( ida_idaapi.ea_t ea)
Get pointer to segment by linear address. 
    
@param ea: linear address belonging to the segment
@returns nullptr or pointer to segment structure

◆ is_finally_visible_segm()

bool is_finally_visible_segm ( 'segment_t' s)
See SFL_HIDDEN, SCF_SHHID_SEGM.

◆ is_miniidb()

bool is_miniidb ( )
Is the database a miniidb created by the debugger?. 
    
@returns true if the database contains no segments or only debugger segments

◆ is_segm_locked()

bool is_segm_locked ( 'segment_t' segm)
Is a segment pointer locked?

◆ is_spec_ea()

bool is_spec_ea ( ida_idaapi.ea_t ea)
Does the address belong to a segment with a special type?. (SEG_XTRN, SEG_GRP, SEG_ABSSYM, SEG_COMM) 
    
@param ea: linear address

◆ is_spec_segm()

bool is_spec_segm ( 'uchar' seg_type)
Has segment a special type?. (SEG_XTRN, SEG_GRP, SEG_ABSSYM, SEG_COMM) 

◆ is_visible_segm()

bool is_visible_segm ( 'segment_t' s)
See SFL_HIDDEN.

◆ lock_segm()

None lock_segm ( 'segment_t' segm,
bool lock )
Lock segment pointer Locked pointers are guaranteed to remain valid until they are unlocked. Ranges with locked pointers cannot be deleted or moved. 

◆ move_segm()

'move_segm_code_t' move_segm ( 'segment_t' s,
ida_idaapi.ea_t to,
int flags = 0 )
This function moves all information to the new address. It fixes up address sensitive information in the kernel. The total effect is equal to reloading the segment to the target address. For the file format dependent address sensitive information, loader_t::move_segm is called. Also IDB notification event idb_event::segm_moved is called. 
    
@param s: segment to move
@param to: new segment start address
@param flags: Move segment flags
@returns Move segment result codes

◆ move_segm_start()

bool move_segm_start ( ida_idaapi.ea_t ea,
ida_idaapi.ea_t newstart,
int mode )
Move segment start. The main difference between this function and set_segm_start() is that this function may expand the previous segment while set_segm_start() never does it. So, this function allows to change bounds of two segments simultaneously. If the previous segment and the specified segment have the same addressing mode and segment base, then instructions and data are not destroyed - they simply move from one segment to another. Otherwise all instructions/data which migrate from one segment to another are destroyed. 
    
@param ea: any address belonging to the segment
@param newstart: new start address of the segment note that segment start address should be higher than segment base linear address.
@param mode: policy for destroying defined items
* 0: if it is necessary to destroy defined items, display a dialog box and ask confirmation
* 1: if it is necessary to destroy defined items, just destroy them without asking the user
* -1: if it is necessary to destroy defined items, don't destroy them (i.e. function will fail)
* -2: don't destroy defined items (function will succeed)
@retval 1: ok
@retval 0: failed, a warning message is displayed

◆ move_segm_strerror()

str move_segm_strerror ( 'move_segm_code_t' code)
Return string describing error MOVE_SEGM_... code.

◆ rebase_program()

int rebase_program ( 'PyObject *' delta,
int flags )
Rebase the whole program by 'delta' bytes. 
    
@param delta: number of bytes to move the program
@param flags: Move segment flags it is recommended to use MSF_FIXONCE so that the loader takes care of global variables it stored in the database
@returns Move segment result codes

◆ segm_adjust_diff()

'adiff_t' segm_adjust_diff ( 'segment_t' s,
'adiff_t' delta )
Truncate and sign extend a delta depending on the segment.

◆ segm_adjust_ea()

ida_idaapi.ea_t segm_adjust_ea ( 'segment_t' s,
ida_idaapi.ea_t ea )
Truncate an address depending on the segment.

◆ segtype()

'uchar' segtype ( ida_idaapi.ea_t ea)
Get segment type. 
    
@param ea: any linear address within the segment
@returns Segment types, SEG_UNDF if no segment found at 'ea'

◆ sel2ea()

ida_idaapi.ea_t sel2ea ( 'sel_t' selector)
Get mapping of a selector as a linear address. 
    
@param selector: number of selector to translate to linear address
@returns linear address the specified selector is mapped to. if there is no mapping, returns to_ea(selector,0);

◆ sel2para()

ida_idaapi.ea_t sel2para ( 'sel_t' selector)
Get mapping of a selector. 
    
@param selector: number of selector to translate
@returns paragraph the specified selector is mapped to. if there is no mapping, returns 'selector'.

◆ set_defsr()

set_defsr ( s,
reg,
value )
Deprecated, use instead:
s.defsr[reg] = value

◆ set_group_selector()

int set_group_selector ( 'sel_t' grp,
'sel_t' sel )
Create a new group of segments (used OMF files). 
    
@param grp: selector of group segment (segment type is SEG_GRP) You should create an 'empty' (1 byte) group segment It won't contain anything and will be used to redirect references to the group of segments to the common selector.
@param sel: common selector of all segments belonging to the segment You should create all segments within the group with the same selector value.
@retval 1: ok
@retval 0: too many groups (see MAX_GROUPS)

◆ set_segm_addressing()

bool set_segm_addressing ( 'segment_t' s,
'size_t' bitness )
Change segment addressing mode (16, 32, 64 bits). You must use this function to change segment addressing, never change the 'bitness' field directly. This function will delete all instructions, comments and names in the segment 
    
@param s: pointer to segment
@param bitness: new addressing mode of segment
* 2: 64bit segment
* 1: 32bit segment
* 0: 16bit segment
@returns success

◆ set_segm_base()

bool set_segm_base ( 'segment_t' s,
ida_idaapi.ea_t newbase )
Internal function.

◆ set_segm_class()

int set_segm_class ( 'segment_t' s,
str sclass,
int flags = 0 )
Set segment class. 
    
@param s: pointer to segment (may be nullptr)
@param sclass: segment class (may be nullptr). If segment type is SEG_NORM and segment class is one of predefined names, then segment type is changed to:
* "CODE" -> SEG_CODE
* "DATA" -> SEG_DATA
* "STACK" -> SEG_BSS
* "BSS" -> SEG_BSS
* if "UNK" then segment type is reset to SEG_NORM.
@param flags: Add segment flags
@retval 1: ok, name is good and segment is renamed
@retval 0: failure, name is nullptr or bad or segment is nullptr

◆ set_segm_end()

bool set_segm_end ( ida_idaapi.ea_t ea,
ida_idaapi.ea_t newend,
int flags )
Set segment end address. The next segment is shrinked to allow expansion of the specified segment. The kernel might even delete the next segment if necessary. The kernel will ask the user for a permission to destroy instructions or data going out of segment scope if such instructions exist. 
    
@param ea: any address belonging to the segment
@param newend: new end address of the segment
@param flags: Segment modification flags
@retval 1: ok
@retval 0: failed, a warning message is displayed

◆ set_segm_name()

int set_segm_name ( 'segment_t' s,
str name,
int flags = 0 )
Rename segment. The new name is validated (see validate_name). A segment always has a name. If you hadn't specified a name, the kernel will assign it "seg###" name where ### is segment number. 
    
@param s: pointer to segment (may be nullptr)
@param name: new segment name
@param flags: ADDSEG_IDBENC or 0
@retval 1: ok, name is good and segment is renamed
@retval 0: failure, name is bad or segment is nullptr

◆ set_segm_start()

bool set_segm_start ( ida_idaapi.ea_t ea,
ida_idaapi.ea_t newstart,
int flags )
Set segment start address. The previous segment is trimmed to allow expansion of the specified segment. The kernel might even delete the previous segment if necessary. The kernel will ask the user for a permission to destroy instructions or data going out of segment scope if such instructions exist. 
    
@param ea: any address belonging to the segment
@param newstart: new start address of the segment note that segment start address should be higher than segment base linear address.
@param flags: Segment modification flags
@retval 1: ok
@retval 0: failed, a warning message is displayed

◆ set_segment_cmt()

None set_segment_cmt ( 'segment_t' s,
str cmt,
bool repeatable )
Set segment comment. 
    
@param s: pointer to segment structure
@param cmt: comment string, may be multiline (with '
'). maximal size is 4096 bytes. Use empty str ("") to delete comment
@param repeatable: 0: set regular comment. 1: set repeatable comment.

◆ set_segment_translations()

bool set_segment_translations ( ida_idaapi.ea_t segstart,
'eavec_t const &' transmap )
Set new translation list. 
    
@param segstart: start address of the segment to add translation to
@param transmap: vector of segment start addresses for the translation list. If transmap is empty, the translation list is deleted.
@retval 1: ok
@retval 0: too many translations or bad segstart

◆ set_selector()

int set_selector ( 'sel_t' selector,
ida_idaapi.ea_t paragraph )
Set mapping of selector to a paragraph. You should call this function _before_ creating a segment which uses the selector, otherwise the creation of the segment will fail. 
    
@param selector: number of selector to map
* if selector == BADSEL, then return 0 (fail)
* if the selector has had a mapping, old mapping is destroyed
* if the selector number is equal to paragraph value, then the mapping is destroyed because we don't need to keep trivial mappings.
@param paragraph: paragraph to map selector
@retval 1: ok
@retval 0: failure (bad selector or too many mappings)

◆ set_visible_segm()

None set_visible_segm ( 'segment_t' s,
bool visible )
See SFL_HIDDEN.

◆ setup_selector()

'sel_t' setup_selector ( ida_idaapi.ea_t segbase)
Allocate a selector for a segment if necessary. You must call this function before calling add_segm_ex(). add_segm() calls this function itself, so you don't need to allocate a selector. This function will allocate a selector if 'segbase' requires more than 16 bits and the current processor is IBM PC. Otherwise it will return the segbase value. 
    
@param segbase: a new segment base paragraph
@returns the allocated selector number

◆ std_out_segm_footer()

None std_out_segm_footer ( 'outctx_t &' ctx,
'segment_t' seg )
Generate segment footer line as a comment line. This function may be used in IDP modules to generate segment footer if the target assembler doesn't have 'ends' directive. 

◆ take_memory_snapshot()

bool take_memory_snapshot ( int type)
Take a memory snapshot of the running process. 
    
@param type: specifies which snapshot we want (see SNAP_ Snapshot types)
@returns success

◆ update_segm()

bool update_segm ( 'segment_t' s)

Variable Documentation

◆ ADDSEG_FILLGAP

ADDSEG_FILLGAP = _ida_segment.ADDSEG_FILLGAP

◆ ADDSEG_IDBENC

ADDSEG_IDBENC = _ida_segment.ADDSEG_IDBENC

◆ ADDSEG_NOAA

ADDSEG_NOAA = _ida_segment.ADDSEG_NOAA

◆ ADDSEG_NOSREG

ADDSEG_NOSREG = _ida_segment.ADDSEG_NOSREG

◆ ADDSEG_NOTRUNC

ADDSEG_NOTRUNC = _ida_segment.ADDSEG_NOTRUNC

◆ ADDSEG_OR_DIE

ADDSEG_OR_DIE = _ida_segment.ADDSEG_OR_DIE

◆ ADDSEG_QUIET

ADDSEG_QUIET = _ida_segment.ADDSEG_QUIET

◆ ADDSEG_SPARSE

ADDSEG_SPARSE = _ida_segment.ADDSEG_SPARSE

◆ CSS_BREAK

CSS_BREAK = _ida_segment.CSS_BREAK

◆ CSS_NODBG

CSS_NODBG = _ida_segment.CSS_NODBG

◆ CSS_NOMEM

CSS_NOMEM = _ida_segment.CSS_NOMEM

◆ CSS_NORANGE

CSS_NORANGE = _ida_segment.CSS_NORANGE

◆ CSS_OK

CSS_OK = _ida_segment.CSS_OK

◆ MAX_GROUPS

MAX_GROUPS = _ida_segment.MAX_GROUPS

◆ MAX_SEGM_TRANSLATIONS

MAX_SEGM_TRANSLATIONS = _ida_segment.MAX_SEGM_TRANSLATIONS

◆ MOVE_SEGM_CHUNK

MOVE_SEGM_CHUNK = _ida_segment.MOVE_SEGM_CHUNK

◆ MOVE_SEGM_DEBUG

MOVE_SEGM_DEBUG = _ida_segment.MOVE_SEGM_DEBUG

◆ MOVE_SEGM_IDP

MOVE_SEGM_IDP = _ida_segment.MOVE_SEGM_IDP

◆ MOVE_SEGM_INVAL

MOVE_SEGM_INVAL = _ida_segment.MOVE_SEGM_INVAL

◆ MOVE_SEGM_LOADER

MOVE_SEGM_LOADER = _ida_segment.MOVE_SEGM_LOADER

◆ MOVE_SEGM_MAPPING

MOVE_SEGM_MAPPING = _ida_segment.MOVE_SEGM_MAPPING

◆ MOVE_SEGM_ODD

MOVE_SEGM_ODD = _ida_segment.MOVE_SEGM_ODD

◆ MOVE_SEGM_OK

MOVE_SEGM_OK = _ida_segment.MOVE_SEGM_OK

◆ MOVE_SEGM_ORPHAN

MOVE_SEGM_ORPHAN = _ida_segment.MOVE_SEGM_ORPHAN

◆ MOVE_SEGM_PARAM

MOVE_SEGM_PARAM = _ida_segment.MOVE_SEGM_PARAM

◆ MOVE_SEGM_ROOM

MOVE_SEGM_ROOM = _ida_segment.MOVE_SEGM_ROOM

◆ MOVE_SEGM_SOURCEFILES

MOVE_SEGM_SOURCEFILES = _ida_segment.MOVE_SEGM_SOURCEFILES

◆ MSF_FIXONCE

MSF_FIXONCE = _ida_segment.MSF_FIXONCE

◆ MSF_LDKEEP

MSF_LDKEEP = _ida_segment.MSF_LDKEEP

◆ MSF_NETNODES

MSF_NETNODES = _ida_segment.MSF_NETNODES

◆ MSF_NOFIX

MSF_NOFIX = _ida_segment.MSF_NOFIX

◆ MSF_PRIORITY

MSF_PRIORITY = _ida_segment.MSF_PRIORITY

◆ MSF_SILENT

MSF_SILENT = _ida_segment.MSF_SILENT

◆ saAbs

saAbs = _ida_segment.saAbs

◆ saGroup

saGroup = _ida_segment.saGroup

◆ saRel1024Bytes

saRel1024Bytes = _ida_segment.saRel1024Bytes

◆ saRel128Bytes

saRel128Bytes = _ida_segment.saRel128Bytes

◆ saRel2048Bytes

saRel2048Bytes = _ida_segment.saRel2048Bytes

◆ saRel32Bytes

saRel32Bytes = _ida_segment.saRel32Bytes

◆ saRel4K

saRel4K = _ida_segment.saRel4K

◆ saRel512Bytes

saRel512Bytes = _ida_segment.saRel512Bytes

◆ saRel64Bytes

saRel64Bytes = _ida_segment.saRel64Bytes

◆ saRel_MAX_ALIGN_CODE

saRel_MAX_ALIGN_CODE = _ida_segment.saRel_MAX_ALIGN_CODE

◆ saRelByte

saRelByte = _ida_segment.saRelByte

◆ saRelDble

saRelDble = _ida_segment.saRelDble

◆ saRelPage

saRelPage = _ida_segment.saRelPage

◆ saRelPara

saRelPara = _ida_segment.saRelPara

◆ saRelQword

saRelQword = _ida_segment.saRelQword

◆ saRelWord

saRelWord = _ida_segment.saRelWord

◆ sc_MAX_COMB_CODE

sc_MAX_COMB_CODE = _ida_segment.sc_MAX_COMB_CODE

◆ scCommon

scCommon = _ida_segment.scCommon

◆ scGroup

scGroup = _ida_segment.scGroup

◆ scPriv

scPriv = _ida_segment.scPriv

◆ scPub

scPub = _ida_segment.scPub

◆ scPub2

scPub2 = _ida_segment.scPub2

◆ scPub3

scPub3 = _ida_segment.scPub3

◆ scStack

scStack = _ida_segment.scStack

◆ SEG_ABSSYM

SEG_ABSSYM = _ida_segment.SEG_ABSSYM

◆ SEG_BSS

SEG_BSS = _ida_segment.SEG_BSS

◆ SEG_CODE

SEG_CODE = _ida_segment.SEG_CODE

◆ SEG_COMM

SEG_COMM = _ida_segment.SEG_COMM

◆ SEG_DATA

SEG_DATA = _ida_segment.SEG_DATA

◆ SEG_GRP

SEG_GRP = _ida_segment.SEG_GRP

◆ SEG_IMEM

SEG_IMEM = _ida_segment.SEG_IMEM

◆ SEG_IMP

SEG_IMP = _ida_segment.SEG_IMP

◆ SEG_MAX_BITNESS_CODE

SEG_MAX_BITNESS_CODE = _ida_segment.SEG_MAX_BITNESS_CODE

◆ SEG_MAX_SEGTYPE_CODE

SEG_MAX_SEGTYPE_CODE = _ida_segment.SEG_MAX_SEGTYPE_CODE

◆ SEG_NORM

SEG_NORM = _ida_segment.SEG_NORM

◆ SEG_NULL

SEG_NULL = _ida_segment.SEG_NULL

◆ SEG_UNDF

SEG_UNDF = _ida_segment.SEG_UNDF

◆ SEG_XTRN

SEG_XTRN = _ida_segment.SEG_XTRN

◆ SEGMOD_KEEP

SEGMOD_KEEP = _ida_segment.SEGMOD_KEEP

◆ SEGMOD_KEEP0

SEGMOD_KEEP0 = _ida_segment.SEGMOD_KEEP0

◆ SEGMOD_KEEPSEL

SEGMOD_KEEPSEL = _ida_segment.SEGMOD_KEEPSEL

◆ SEGMOD_KILL

SEGMOD_KILL = _ida_segment.SEGMOD_KILL

◆ SEGMOD_NOMOVE

SEGMOD_NOMOVE = _ida_segment.SEGMOD_NOMOVE

◆ SEGMOD_SILENT

SEGMOD_SILENT = _ida_segment.SEGMOD_SILENT

◆ SEGMOD_SPARSE

SEGMOD_SPARSE = _ida_segment.SEGMOD_SPARSE

◆ SEGPERM_EXEC

SEGPERM_EXEC = _ida_segment.SEGPERM_EXEC

◆ SEGPERM_MAXVAL

SEGPERM_MAXVAL = _ida_segment.SEGPERM_MAXVAL

◆ SEGPERM_READ

SEGPERM_READ = _ida_segment.SEGPERM_READ

◆ SEGPERM_WRITE

SEGPERM_WRITE = _ida_segment.SEGPERM_WRITE

◆ SFL_COMORG

SFL_COMORG = _ida_segment.SFL_COMORG

◆ SFL_DEBUG

SFL_DEBUG = _ida_segment.SFL_DEBUG

◆ SFL_HEADER

SFL_HEADER = _ida_segment.SFL_HEADER

◆ SFL_HIDDEN

SFL_HIDDEN = _ida_segment.SFL_HIDDEN

◆ SFL_HIDETYPE

SFL_HIDETYPE = _ida_segment.SFL_HIDETYPE

◆ SFL_LOADER

SFL_LOADER = _ida_segment.SFL_LOADER

◆ SFL_OBOK

SFL_OBOK = _ida_segment.SFL_OBOK

◆ SNAP_ALL_SEG

SNAP_ALL_SEG = _ida_segment.SNAP_ALL_SEG

◆ SNAP_CUR_SEG

SNAP_CUR_SEG = _ida_segment.SNAP_CUR_SEG

◆ SNAP_LOAD_SEG

SNAP_LOAD_SEG = _ida_segment.SNAP_LOAD_SEG

◆ SREG_NUM

SREG_NUM = _ida_segment.SREG_NUM