Module ida_segment

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.

Global Variables

ADDSEG_FILLGAP

ADDSEG_FILLGAP = 16

ADDSEG_IDBENC

ADDSEG_IDBENC = 128

ADDSEG_NOAA

ADDSEG_NOAA = 64

ADDSEG_NOSREG

ADDSEG_NOSREG = 1

ADDSEG_NOTRUNC

ADDSEG_NOTRUNC = 4

ADDSEG_OR_DIE

ADDSEG_OR_DIE = 2

ADDSEG_QUIET

ADDSEG_QUIET = 8

ADDSEG_SPARSE

ADDSEG_SPARSE = 32

CSS_BREAK

CSS_BREAK = -4

CSS_NODBG

CSS_NODBG = -1

CSS_NOMEM

CSS_NOMEM = -3

CSS_NORANGE

CSS_NORANGE = -2

CSS_OK

CSS_OK = 0

MAX_GROUPS

MAX_GROUPS = 8

MAX_SEGM_TRANSLATIONS

MAX_SEGM_TRANSLATIONS = 64

MOVE_SEGM_CHUNK

MOVE_SEGM_CHUNK = -4

MOVE_SEGM_DEBUG

MOVE_SEGM_DEBUG = -8

MOVE_SEGM_IDP

MOVE_SEGM_IDP = -3

MOVE_SEGM_INVAL

MOVE_SEGM_INVAL = -11

MOVE_SEGM_LOADER

MOVE_SEGM_LOADER = -5

MOVE_SEGM_MAPPING

MOVE_SEGM_MAPPING = -10

MOVE_SEGM_ODD

MOVE_SEGM_ODD = -6

MOVE_SEGM_OK

MOVE_SEGM_OK = 0

MOVE_SEGM_ORPHAN

MOVE_SEGM_ORPHAN = -7

MOVE_SEGM_PARAM

MOVE_SEGM_PARAM = -1

MOVE_SEGM_ROOM

MOVE_SEGM_ROOM = -2

MOVE_SEGM_SOURCEFILES

MOVE_SEGM_SOURCEFILES = -9

MSF_FIXONCE

MSF_FIXONCE = 8

MSF_LDKEEP

MSF_LDKEEP = 4

MSF_NETNODES

MSF_NETNODES = 128

MSF_NOFIX

MSF_NOFIX = 2

MSF_PRIORITY

MSF_PRIORITY = 32

MSF_SILENT

MSF_SILENT = 1

SEGMOD_KEEP

SEGMOD_KEEP = 2

SEGMOD_KEEP0

SEGMOD_KEEP0 = 8

SEGMOD_KEEPSEL

SEGMOD_KEEPSEL = 16

SEGMOD_KILL

SEGMOD_KILL = 1

SEGMOD_NOMOVE

SEGMOD_NOMOVE = 32

SEGMOD_SILENT

SEGMOD_SILENT = 4

SEGMOD_SPARSE

SEGMOD_SPARSE = 64

SEGPERM_EXEC

SEGPERM_EXEC = 1

SEGPERM_MAXVAL

SEGPERM_MAXVAL = 7

SEGPERM_READ

SEGPERM_READ = 4

SEGPERM_WRITE

SEGPERM_WRITE = 2

SEG_ABSSYM

SEG_ABSSYM = 10

SEG_BSS

SEG_BSS = 9

SEG_CODE

SEG_CODE = 2

SEG_COMM

SEG_COMM = 11

SEG_DATA

SEG_DATA = 3

SEG_GRP

SEG_GRP = 6

SEG_IMEM

SEG_IMEM = 12

SEG_IMP

SEG_IMP = 4

SEG_MAX_BITNESS_CODE

SEG_MAX_BITNESS_CODE = 2

SEG_MAX_SEGTYPE_CODE

SEG_MAX_SEGTYPE_CODE = 12

SEG_NORM

SEG_NORM = 0

SEG_NULL

SEG_NULL = 7

SEG_UNDF

SEG_UNDF = 8

SEG_XTRN

SEG_XTRN = 1

SFL_COMORG

SFL_COMORG = 1

SFL_DEBUG

SFL_DEBUG = 8

SFL_HEADER

SFL_HEADER = 64

SFL_HIDDEN

SFL_HIDDEN = 4

SFL_HIDETYPE

SFL_HIDETYPE = 32

SFL_LOADER

SFL_LOADER = 16

SFL_OBOK

SFL_OBOK = 2

SNAP_ALL_SEG

SNAP_ALL_SEG = 0

SNAP_CUR_SEG

SNAP_CUR_SEG = 2

SNAP_LOAD_SEG

SNAP_LOAD_SEG = 1

SREG_NUM

SREG_NUM = 16

saAbs

saAbs = 0

saGroup

saGroup = 7

saRel1024Bytes

saRel1024Bytes = 13

saRel128Bytes

saRel128Bytes = 11

saRel2048Bytes

saRel2048Bytes = 14

saRel32Bytes

saRel32Bytes = 8

saRel4K

saRel4K = 6

saRel512Bytes

saRel512Bytes = 12

saRel64Bytes

saRel64Bytes = 9

saRelByte

saRelByte = 1

saRelDble

saRelDble = 5

saRelPage

saRelPage = 4

saRelPara

saRelPara = 3

saRelQword

saRelQword = 10

saRelWord

saRelWord = 2

saRel_MAX_ALIGN_CODE

saRel_MAX_ALIGN_CODE = 14

scCommon

scCommon = 6

scGroup

scGroup = 1

scPriv

scPriv = 0

scPub

scPub = 2

scPub2

scPub2 = 4

scPub3

scPub3 = 7

scStack

scStack = 5

sc_MAX_COMB_CODE

sc_MAX_COMB_CODE = 7

Functions

add_segm(para: ea_t, start: ea_t, end: ea_t, name: char const *, sclass: char const *, flags: int = 0) ‑> bool

add_segm(para, start, end, name, sclass, flags=0) -> bool 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.

para: (C++: ea_t) segment base paragraph. if paragraph can't fit in 16bit, then a new
            selector is allocated and mapped to the paragraph.
start: (C++: ea_t) start address of the segment. if start==BADADDR then start <-
             to_ea(para,0).
end: (C++: ea_t) 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.
name: (C++: const char *) name of new segment. may be nullptr
sclass: (C++: const char *) 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 flags: (C++: int) Add segment flags retval 1: ok retval 0: failed, a warning message is displayed

add_segm_ex(NONNULL_s: segment_t, name: char const *, sclass: char const *, flags: int) ‑> bool

add_segm_ex(NONNULL_s, name, sclass, flags) -> bool 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.

NONNULL_s: (C++: segment_t *)
name: (C++: const char *) name of new segment. may be nullptr. if specified, the segment is
            immediately renamed
sclass: (C++: const char *) class of the segment. may be nullptr. if specified, the segment
              class is immediately changed
flags: (C++: int) Add segment flags
retval 1: ok
retval 0: failed, a warning message is displayed

add_segment_translation(segstart: ea_t, mappedseg: ea_t) ‑> bool

add_segment_translation(segstart, mappedseg) -> bool Add segment translation.

segstart: (C++: ea_t) start address of the segment to add translation to
mappedseg: (C++: ea_t) start address of the overlayed segment
retval 1: ok
retval 0: too many translations or bad segstart

allocate_selector(segbase: ea_t) ‑> sel_t

allocate_selector(segbase) -> sel_t 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.

segbase: (C++: ea_t) a new segment base paragraph
return: the allocated selector number

change_segment_status(s: segment_t, is_deb_segm: bool) ‑> int

change_segment_status(s, is_deb_segm) -> int Convert a debugger segment to a regular segment and vice versa. When converting debug->regular, the memory contents will be copied to the database.

s: (C++: segment_t *) segment to modify
is_deb_segm: (C++: bool) new status of the segment
return: Change segment status result codes

del_segm(ea: ea_t, flags: int) ‑> bool

del_segm(ea, flags) -> bool Delete a segment.

ea: (C++: ea_t) any address belonging to the segment
flags: (C++: int) Segment modification flags
retval 1: ok
retval 0: failed, no segment at 'ea'.

del_segment_translations(segstart: ea_t) ‑> void

del_segment_translations(segstart) Delete the translation list

segstart: (C++: ea_t) start address of the segment to delete translation list

del_selector(selector: sel_t) ‑> void

del_selector(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.

selector: (C++: sel_t) number of selector to remove from the translation table

find_free_selector() ‑> sel_t

find_free_selector() -> sel_t Find first unused selector.

return: a number >= 1

find_selector(base: ea_t) ‑> sel_t

find_selector(base) -> sel_t Find a selector that has mapping to the specified paragraph.

base: (C++: ea_t) paragraph to search in the translation table
return: selector value or base

get_defsr(s: segment_t, reg: int) ‑> sel_t

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

s: segment_t *
reg: int

get_first_seg() ‑> segment_t *

get_first_seg() -> segment_t Get pointer to the first segment.

get_group_selector(grpsel: sel_t) ‑> sel_t

get_group_selector(grpsel) -> sel_t Get common selector for a group of segments.

grpsel: (C++: sel_t) selector of group segment
return: common selector of the group or 'grpsel' if no such group is found

get_last_seg() ‑> segment_t *

get_last_seg() -> segment_t Get pointer to the last segment.

get_next_seg(ea: ea_t) ‑> segment_t *

get_next_seg(ea) -> segment_t Get pointer to the next segment.

ea: (C++: ea_t)

get_prev_seg(ea: ea_t) ‑> segment_t *

get_prev_seg(ea) -> segment_t Get pointer to the previous segment.

ea: (C++: ea_t)

get_segm_base(s: segment_t) ‑> ea_t

get_segm_base(s) -> ea_t 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)

s: (C++: const segment_t *) pointer to segment
return: 0 if s == nullptr, otherwise segment base linear address

get_segm_by_name(name: char const *) ‑> segment_t *

get_segm_by_name(name) -> segment_t Get pointer to segment by its name. If there are several segments with the same name, returns the first of them.

name: (C++: const char *) segment name. may be nullptr.
return: nullptr or pointer to segment structure

get_segm_by_sel(selector: sel_t) ‑> segment_t *

get_segm_by_sel(selector) -> segment_t 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.

selector: (C++: sel_t) a segment with the specified selector will be returned
return: pointer to segment or nullptr

get_segm_class(s: segment_t) ‑> qstring *

get_segm_class(s) -> str Get segment class. Segment class is arbitrary text (max 8 characters).

s: (C++: const segment_t *) pointer to segment
return: size of segment class (-1 if s==nullptr or bufsize<=0)

get_segm_name(s: segment_t, flags: int = 0) ‑> qstring *

get_segm_name(s, flags=0) -> ssize_t Get true segment name by pointer to segment.

s: (C++: const segment_t *) pointer to segment
flags: (C++: int) 0-return name as is; 1-substitute bad symbols with _ 1 corresponds
             to GN_VISIBLE
return: size of segment name (-1 if s==nullptr)

get_segm_num(ea: ea_t) ‑> int

get_segm_num(ea) -> int Get number of segment by address.

ea: (C++: ea_t) linear address belonging to the segment
return: -1 if no segment occupies the specified address. otherwise returns
        number of the specified segment (0..get_segm_qty()-1)

get_segm_para(s: segment_t) ‑> ea_t

get_segm_para(s) -> ea_t 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).

s: (C++: const segment_t *) pointer to segment
return: 0 if s == nullptr, the segment base paragraph

get_segm_qty() ‑> int

get_segm_qty() -> int Get number of segments.

get_segment_alignment(align: uchar) ‑> char const *

get_segment_alignment(align) -> char const * Get text representation of segment alignment code.

align: (C++: uchar)
return: text digestable by IBM PC assembler.

get_segment_cmt(s: segment_t, repeatable: bool) ‑> qstring *

get_segment_cmt(s, repeatable) -> str Get segment comment.

s: (C++: const segment_t *) pointer to segment structure
repeatable: (C++: bool) 0: get regular comment. 1: get repeatable comment.
return: size of comment or -1

get_segment_combination(comb: uchar) ‑> char const *

get_segment_combination(comb) -> char const * Get text representation of segment combination code.

comb: (C++: uchar)
return: text digestable by IBM PC assembler.

get_segment_translations(transmap: eavec_t *, segstart: ea_t) ‑> ssize_t

get_segment_translations(transmap, segstart) -> ssize_t Get segment translation list.

transmap: (C++: eavec_t *) vector of segment start addresses for the translation list
segstart: (C++: ea_t) start address of the segment to get information about
return: -1 if no translation list or bad segstart. otherwise returns size of
        translation list.

get_selector_qty() ‑> size_t

get_selector_qty() -> size_t Get number of defined selectors.

get_visible_segm_name(s: segment_t) ‑> qstring *

get_visible_segm_name(s) -> str Get segment name by pointer to segment.

s: (C++: const segment_t *) pointer to segment
return: size of segment name (-1 if s==nullptr)

getn_selector(n: int) ‑> sel_t *, ea_t *

getn_selector(n) -> bool Get description of selector (0..get_selector_qty()-1)

n: (C++: int)

getnseg(n: int) ‑> segment_t *

getnseg(n) -> segment_t Get pointer to segment by its number. @warning: Obsoleted because it can slow down the debugger (it has to refresh the whole memory segmentation to calculate the correct answer)

n: (C++: int) segment number in the range (0..get_segm_qty()-1)
return: nullptr or pointer to segment structure

getseg(ea: ea_t) ‑> segment_t *

getseg(ea) -> segment_t Get pointer to segment by linear address.

ea: (C++: ea_t) linear address belonging to the segment
return: nullptr or pointer to segment structure

is_finally_visible_segm(s: segment_t) ‑> bool

is_finally_visible_segm(s) -> bool See SFL_HIDDEN, SCF_SHHID_SEGM.

s: (C++: segment_t *)

is_miniidb() ‑> bool

is_miniidb() -> bool Is the database a miniidb created by the debugger?.

return: true if the database contains no segments or only debugger segments

is_segm_locked(segm: segment_t) ‑> bool

is_segm_locked(segm) -> bool Is a segment pointer locked?

segm: (C++: const segment_t *) segment_t const *

is_spec_ea(ea: ea_t) ‑> bool

is_spec_ea(ea) -> bool Does the address belong to a segment with a special type?. (SEG_XTRN, SEG_GRP, SEG_ABSSYM, SEG_COMM)

ea: (C++: ea_t) linear address

is_spec_segm(seg_type: uchar) ‑> bool

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

seg_type: (C++: uchar)

is_visible_segm(s: segment_t) ‑> bool

is_visible_segm(s) -> bool See SFL_HIDDEN.

s: (C++: segment_t *)

lock_segm(segm: segment_t, lock: bool) ‑> void

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

segm: (C++: const segment_t *) segment_t const *
lock: (C++: bool)

move_segm(s: segment_t, to: ea_t, flags: int = 0) ‑> move_segm_code_t

move_segm(s, to, flags=0) -> move_segm_code_t 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.

s: (C++: segment_t *) segment to move
to: (C++: ea_t) new segment start address
flags: (C++: int) Move segment flags
return: Move segment result codes

move_segm_start(ea: ea_t, newstart: ea_t, mode: int) ‑> bool

move_segm_start(ea, newstart, mode) -> bool 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. note: this function never disables addresses.

ea: (C++: ea_t) any address belonging to the segment
newstart: (C++: ea_t) new start address of the segment note that segment start
                address should be higher than segment base linear address.
mode: (C++: int) 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(code: move_segm_code_t) ‑> char const *

move_segm_strerror(code) -> char const * Return string describing error MOVE_SEGM_... code.

code: (C++: move_segm_code_t) enum move_segm_code_t

rebase_program(delta: PyObject *, flags: int) ‑> int

rebase_program(delta, flags) -> int Rebase the whole program by 'delta' bytes.

delta: (C++: adiff_t) number of bytes to move the program
flags: (C++: int) Move segment flags it is recommended to use MSF_FIXONCE so that
             the loader takes care of global variables it stored in the
             database
return: Move segment result codes

segm_adjust_diff(s: segment_t, delta: adiff_t) ‑> adiff_t

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

s: (C++: const segment_t *) segment_t const *
delta: (C++: adiff_t)

segm_adjust_ea(s: segment_t, ea: ea_t) ‑> ea_t

segm_adjust_ea(s, ea) -> ea_t Truncate an address depending on the segment.

s: (C++: const segment_t *) segment_t const *
ea: (C++: ea_t)

segtype(ea: ea_t) ‑> uchar

segtype(ea) -> uchar Get segment type.

ea: (C++: ea_t) any linear address within the segment
return: Segment types, SEG_UNDF if no segment found at 'ea'

sel2ea(selector: sel_t) ‑> ea_t

sel2ea(selector) -> ea_t Get mapping of a selector as a linear address.

selector: (C++: sel_t) number of selector to translate to linear address
return: linear address the specified selector is mapped to. if there is no
        mapping, returns to_ea(selector,0);

sel2para(selector: sel_t) ‑> ea_t

sel2para(selector) -> ea_t Get mapping of a selector.

selector: (C++: sel_t) number of selector to translate
return: paragraph the specified selector is mapped to. if there is no mapping,
        returns 'selector'.

set_defsr(s: segment_t, reg: int, value: sel_t) ‑> void

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

s: segment_t *
reg: int
value: sel_t

set_group_selector(grp: sel_t, sel: sel_t) ‑> int

set_group_selector(grp, sel) -> int Create a new group of segments (used OMF files).

grp: (C++: sel_t) 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.
sel: (C++: sel_t) common selector of all segments belonging to the segment You should
           create all segments within the group with the same selector value.
return: 1 ok

0 too many groups (see MAX_GROUPS)

set_segm_addressing(s: segment_t, bitness: size_t) ‑> bool

set_segm_addressing(s, bitness) -> bool 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

s: (C++: segment_t *) pointer to segment
bitness: (C++: size_t) new addressing mode of segment
  • 2: 64bit segment

  • 1: 32bit segment

  • 0: 16bit segment return: success

set_segm_base(s: segment_t, newbase: ea_t) ‑> bool

set_segm_base(s, newbase) -> bool Internal function.

s: (C++: segment_t *)
newbase: (C++: ea_t)

set_segm_class(s: segment_t, sclass: char const *, flags: int = 0) ‑> int

set_segm_class(s, sclass, flags=0) -> int Set segment class.

s: (C++: segment_t *) pointer to segment (may be nullptr)
sclass: (C++: const char *) 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. flags: (C++: int) 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(ea: ea_t, newend: ea_t, flags: int) ‑> bool

set_segm_end(ea, newend, flags) -> bool 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.

ea: (C++: ea_t) any address belonging to the segment
newend: (C++: ea_t) new end address of the segment
flags: (C++: int) Segment modification flags
retval 1: ok
retval 0: failed, a warning message is displayed

set_segm_name(s: segment_t, name: char const *, flags: int = 0) ‑> int

set_segm_name(s, name, flags=0) -> int 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.

s: (C++: segment_t *) pointer to segment (may be nullptr)
name: (C++: const char *) new segment name
flags: (C++: int) 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(ea: ea_t, newstart: ea_t, flags: int) ‑> bool

set_segm_start(ea, newstart, flags) -> bool 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.

ea: (C++: ea_t) any address belonging to the segment
newstart: (C++: ea_t) new start address of the segment note that segment start
                address should be higher than segment base linear address.
flags: (C++: int) Segment modification flags
retval 1: ok
retval 0: failed, a warning message is displayed

set_segment_cmt(s: segment_t, cmt: char const *, repeatable: bool) ‑> void

set_segment_cmt(s, cmt, repeatable) Set segment comment.

s: (C++: const segment_t *) pointer to segment structure
cmt: (C++: const char *) comment string, may be multiline (with '

'). maximal size is 4096 bytes. Use empty str ("") to delete comment repeatable: (C++: bool) 0: set regular comment. 1: set repeatable comment.

set_segment_translations(segstart: ea_t, transmap: eavec_t const &) ‑> bool

set_segment_translations(segstart, transmap) -> bool Set new translation list.

segstart: (C++: ea_t) start address of the segment to add translation to
transmap: (C++: const eavec_t &) 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(selector: sel_t, paragraph: ea_t) ‑> int

set_selector(selector, paragraph) -> int 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.

selector: (C++: sel_t) 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. paragraph: (C++: ea_t) paragraph to map selector retval 1: ok retval 0: failure (bad selector or too many mappings)

set_visible_segm(s: segment_t, visible: bool) ‑> void

set_visible_segm(s, visible) See SFL_HIDDEN.

s: (C++: segment_t *)
visible: (C++: bool)

setup_selector(segbase: ea_t) ‑> sel_t

setup_selector(segbase) -> sel_t 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.

segbase: (C++: ea_t) a new segment base paragraph
return: the allocated selector number

std_out_segm_footer(ctx, 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.

ctx: (C++: struct outctx_t &) outctx_t &
seg: (C++: segment_t *)

take_memory_snapshot(type: int) ‑> bool

take_memory_snapshot(type) -> bool Take a memory snapshot of the running process.

type: (C++: int) specifies which snapshot we want (see SNAP_ Snapshot types)
return: success

update_segm(s: segment_t) ‑> bool

update_segm(s) -> bool

s: segment_t *

Classes

lock_segment(_segm: segment_t)

: Proxy of C++ lock_segment class.

__init__(self, _segm) -> lock_segment

 _segm: segment_t const *

segment_defsr_array(data: unsigned long long (&)[SREG_NUM])

: Proxy of C++ wrapped_array_t< sel_t,SREG_NUM > class.

__init__(self, data) -> segment_defsr_array

 data: unsigned long long (&)[SREG_NUM]

Instance variables

  • bytes: bytevec_t _get_bytes(self) -> bytevec_t


  • data: unsigned long long (&)[SREG_NUM] data


segment_t()

: Proxy of C++ segment_t class.

__init__(self) -> segment_t

Ancestors (in MRO)

* ida_range.range_t

Instance variables

  • align: uchar align


  • bitness: uchar bitness


  • color: bgcolor_t color


  • comb: uchar comb


  • defsr: wrapped_array_t< sel_t,SREG_NUM > __getDefsr(self) -> segment_defsr_array


  • flags: ushort flags


  • name: uval_t name


  • orgbase: uval_t orgbase


  • perm: uchar perm


  • sclass: uval_t sclass


  • sel: sel_t sel


  • type: uchar type


Methods

  • abits(self) ‑> int abits(self) -> int Get number of address bits.


  • abytes(self) ‑> int abytes(self) -> int Get number of address bytes.


  • clr_comorg(self) ‑> void clr_comorg(self)


  • clr_ob_ok(self) ‑> void clr_ob_ok(self)


  • comorg(self) ‑> bool comorg(self) -> bool


  • is_16bit(self) ‑> bool is_16bit(self) -> bool Is a 16-bit segment?


  • is_32bit(self) ‑> bool is_32bit(self) -> bool Is a 32-bit segment?


  • is_64bit(self) ‑> bool is_64bit(self) -> bool Is a 64-bit segment?


  • is_header_segm(self) ‑> bool is_header_segm(self) -> bool


  • is_hidden_segtype(self) ‑> bool is_hidden_segtype(self) -> bool


  • is_loader_segm(self) ‑> bool is_loader_segm(self) -> bool


  • is_visible_segm(self) ‑> bool is_visible_segm(self) -> bool


  • ob_ok(self) ‑> bool ob_ok(self) -> bool


  • set_comorg(self) ‑> void set_comorg(self)


  • set_debugger_segm(self, debseg: bool) ‑> void set_debugger_segm(self, debseg)

    debseg: bool


  • set_header_segm(self, on: bool) ‑> void set_header_segm(self, on)

    on: bool


  • set_hidden_segtype(self, hide: bool) ‑> void set_hidden_segtype(self, hide)

    hide: bool


  • set_loader_segm(self, ldrseg: bool) ‑> void set_loader_segm(self, ldrseg)

    ldrseg: bool


  • set_ob_ok(self) ‑> void set_ob_ok(self)


  • set_visible_segm(self, visible: bool) ‑> void set_visible_segm(self, visible)

    visible: bool


  • update(self) ‑> bool update(self) -> bool Update segment information. You must call this function after modification of segment characteristics. Note that not all fields of segment structure may be modified directly, there are special functions to modify some fields.

    return: success


  • use64(self) ‑> bool is_64bit(self) -> bool Is a 64-bit segment?


Last updated