Module ida_segment
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.
Global variables
var ADDSEG_FILLGAP
-
fill gap between new segment and previous one. i.e. if such a gap exists, and this gap is less than 64K, then fill the gap by extending the previous segment and adding .align directive to it. This way we avoid gaps between segments. too many gaps lead to a virtual array failure. it cannot hold more than ~1000 gaps.
var ADDSEG_IDBENC
-
'name' and 'sclass' are given in the IDB encoding; non-ASCII bytes will be decoded accordingly
var ADDSEG_NOAA
-
do not mark new segment for auto-analysis
var ADDSEG_NOSREG
-
set all default segment register values to BADSEL (undefine all default segment registers)
var ADDSEG_NOTRUNC
-
don't truncate the new segment at the beginning of the next segment if they overlap. destroy/truncate old segments instead.
var ADDSEG_OR_DIE
-
qexit() if can't add a segment
var ADDSEG_QUIET
-
silent mode, no "Adding segment..." in the messages window
var ADDSEG_SPARSE
-
use sparse storage method for the new ranges of the created segment. please note that the ranges that were already enabled before creating the segment will not change their storage type.
var CSS_BREAK
-
memory reading process stopped by user
var CSS_NODBG
-
debugger is not running
var CSS_NOMEM
-
not enough memory (might be because the segment is too big)
var CSS_NORANGE
-
could not find corresponding memory range
var CSS_OK
-
ok
var MAX_GROUPS
-
max number of segment groups
var MAX_SEGM_TRANSLATIONS
-
max number of segment translations
var MOVE_SEGM_CHUNK
-
Too many chunks are defined, can't move.
var MOVE_SEGM_DEBUG
-
Debugger segments cannot be moved.
var MOVE_SEGM_IDP
-
IDP module forbids moving the segment.
var MOVE_SEGM_INVAL
-
Invalid argument (delta/target does not fit the address space)
var MOVE_SEGM_LOADER
-
The segment has been moved but the loader complained.
var MOVE_SEGM_MAPPING
-
Memory mapping ranges of addresses hinder segment movement.
var MOVE_SEGM_ODD
-
Cannot move segments by an odd number of bytes.
var MOVE_SEGM_OK
-
all ok
var MOVE_SEGM_ORPHAN
-
Orphan bytes hinder segment movement.
var MOVE_SEGM_PARAM
-
The specified segment does not exist.
var MOVE_SEGM_ROOM
-
Not enough free room at the target address.
var MOVE_SEGM_SOURCEFILES
-
Source files ranges of addresses hinder segment movement.
var MSF_FIXONCE
-
call loader only once with the special calling method. valid for rebase_program(). see loader_t::move_segm.
var MSF_LDKEEP
-
keep the loader in the memory (optimization)
var MSF_NETNODES
-
move netnodes instead of changing inf.netdelta (this is slower); valid forrebase_program()
var MSF_NOFIX
-
don't call the loader to fix relocations
var MSF_PRIORITY
-
loader segments will overwrite any existing debugger segments when moved. valid for move_segm()
var MSF_SILENT
-
don't display a "please wait" box on the screen
var SEGMOD_KEEP
-
keep information (code & data, etc)
var SEGMOD_KEEP0
-
flag for internal use, don't set
var SEGMOD_KEEPSEL
-
do not try to delete unused selector
var SEGMOD_KILL
-
disable addresses if segment gets shrinked or deleted
var SEGMOD_NOMOVE
-
don't move info from the start of segment to the new start address (for set_segm_start())
var SEGMOD_SILENT
-
be silent
var SEGMOD_SPARSE
-
use sparse storage if extending the segment (for set_segm_start(), set_segm_end())
var SEGPERM_EXEC
-
Execute.
var SEGPERM_MAXVAL
-
SEGPERM_MAXVAL = 7
var SEGPERM_READ
-
Read.
var SEGPERM_WRITE
-
Write.
var SEG_ABSSYM
-
- segment with definitions of absolute symbols
var SEG_BSS
-
uninitialized segment
var SEG_CODE
-
code segment
var SEG_COMM
-
- segment with communal definitions
var SEG_DATA
-
data segment
var SEG_GRP
-
- group of segments
var SEG_IMEM
-
internal processor memory & sfr (8051)
var SEG_IMP
-
SEG_IMP = 4
var SEG_MAX_BITNESS_CODE
-
SEG_MAX_BITNESS_CODE = 2
var SEG_MAX_SEGTYPE_CODE
-
SEG_MAX_SEGTYPE_CODE = 12
var SEG_NORM
-
unknown type, no assumptions
var SEG_NULL
-
zero-length segment
var SEG_UNDF
-
undefined segment type (not used)
var SEG_XTRN
-
- segment with 'extern' definitions. no instructions are allowed
var SFL_COMORG
-
IDP dependent field (IBM PC: if set, ORG directive is not commented out)
var SFL_DEBUG
-
Is the segment created for the debugger?. Such segments are temporary and do not have permanent flags.
var SFL_HEADER
-
Header segment (do not create offsets to it in the disassembly)
var SFL_HIDDEN
-
Is the segment hidden?
var SFL_HIDETYPE
-
Hide segment type (do not print it in the listing)
var SFL_LOADER
-
Is the segment created by the loader?
var SFL_OBOK
-
Orgbase is present? (IDP dependent field)
var SNAP_ALL_SEG
-
Take a snapshot of all segments.
var SNAP_CUR_SEG
-
Take a snapshot of current segment.
var SNAP_LOAD_SEG
-
Take a snapshot of loader segments.
var SREG_NUM
-
Maximum number of segment registers is 16 (see segregs.hpp)
var saAbs
-
Absolute segment.
var saGroup
-
Segment group.
var saRel1024Bytes
-
1024 bytes
var saRel128Bytes
-
128 bytes
var saRel2048Bytes
-
2048 bytes
var saRel32Bytes
-
32 bytes
var saRel4K
-
This value is used by the PharLap OMF for page (4K) alignment. It is not supported by LINK.
var saRel512Bytes
-
512 bytes
var saRel64Bytes
-
64 bytes
var saRelByte
-
Relocatable, byte aligned.
var saRelDble
-
Relocatable, aligned on a double word (4-byte) boundary.
var saRelPage
-
Relocatable, aligned on 256-byte boundary.
var saRelPara
-
Relocatable, paragraph (16-byte) aligned.
var saRelQword
-
8 bytes
var saRelWord
-
Relocatable, word (2-byte) aligned.
var saRel_MAX_ALIGN_CODE
-
saRel_MAX_ALIGN_CODE = 14
var scCommon
-
Common. Combine by overlay using maximum size.
var scGroup
-
Segment group.
var scPriv
-
Private. Do not combine with any other program segment.
var scPub
-
Public. Combine by appending at an offset that meets the alignment requirement.
var scPub2
-
As defined by Microsoft, same as C=2 (public).
var scPub3
-
As defined by Microsoft, same as C=2 (public).
var scStack
-
Stack. Combine as for C=2. This combine type forces byte alignment.
var sc_MAX_COMB_CODE
-
sc_MAX_COMB_CODE = 7
Functions
def add_segm(*args) ‑> bool
-
add_segm(para, start, end, name, sclass, flags=0) -> boolAdd 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 newselector 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 startaddress. 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 nullptrsclass: (C++: const char *) class of the segment. may be nullptr. type of the new segment ismodified 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 flagsretval 1: okretval 0: failed, a warning message is displayed def add_segm_ex(*args) ‑> bool
-
add_segm_ex(NONNULL_s, name, sclass, flags) -> boolAdd 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 isimmediately renamedsclass: (C++: const char *) class of the segment. may be nullptr. if specified, the segmentclass is immediately changedflags: (C++: int) Add segment flagsretval 1: okretval 0: failed, a warning message is displayed
def add_segment_translation(*args) ‑> bool
-
add_segment_translation(segstart, mappedseg) -> boolAdd segment translation.segstart: (C++: ea_t) start address of the segment to add translation tomappedseg: (C++: ea_t) start address of the overlayed segmentretval 1: okretval 0: too many translations or bad segstart
def allocate_selector(*args) ‑> sel_t
-
allocate_selector(segbase) -> sel_tAllocate 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 paragraphreturn: the allocated selector number
def change_segment_status(*args) ‑> int
-
change_segment_status(s, is_deb_segm) -> intConvert 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 modifyis_deb_segm: (C++: bool) new status of the segmentreturn: Change segment status result codes
def del_segm(*args) ‑> bool
-
del_segm(ea, flags) -> boolDelete a segment.ea: (C++: ea_t) any address belonging to the segmentflags: (C++: int) Segment modification flagsretval 1: okretval 0: failed, no segment at 'ea'.
def del_segment_translations(*args) ‑> void
-
del_segment_translations(segstart)Delete the translation listsegstart: (C++: ea_t) start address of the segment to delete translation list
def del_selector(*args) ‑> 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
def find_free_selector(*args) ‑> sel_t
-
find_free_selector() -> sel_tFind first unused selector.return: a number >= 1
def find_selector(*args) ‑> sel_t
-
find_selector(base) -> sel_tFind a selector that has mapping to the specified paragraph.base: (C++: ea_t) paragraph to search in the translation tablereturn: selector value or base
def get_defsr(*args) ‑> sel_t
-
get_defsr(s, reg) -> sel_tDeprecated, use instead:value = s.defsr[reg]s: segment_t *reg: int
def get_first_seg(*args) ‑> segment_t *
-
get_first_seg() -> segment_tGet pointer to the first segment.
def get_group_selector(*args) ‑> sel_t
-
get_group_selector(grpsel) -> sel_tGet common selector for a group of segments.grpsel: (C++: sel_t) selector of group segmentreturn: common selector of the group or 'grpsel' if no such group is found
def get_last_seg(*args) ‑> segment_t *
-
get_last_seg() -> segment_tGet pointer to the last segment.
def get_next_seg(*args) ‑> segment_t *
-
get_next_seg(ea) -> segment_tGet pointer to the next segment.ea: (C++: ea_t)
def get_prev_seg(*args) ‑> segment_t *
-
get_prev_seg(ea) -> segment_tGet pointer to the previous segment.ea: (C++: ea_t)
def get_segm_base(*args) ‑> ea_t
-
get_segm_base(s) -> ea_tGet 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 segmentreturn: 0 if s == nullptr, otherwise segment base linear address
def get_segm_by_name(*args) ‑> segment_t *
-
get_segm_by_name(name) -> segment_tGet 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
def get_segm_by_sel(*args) ‑> segment_t *
-
get_segm_by_sel(selector) -> segment_tGet 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 returnedreturn: pointer to segment or nullptr
def get_segm_class(*args) ‑> qstring *
-
get_segm_class(s) -> strGet segment class. Segment class is arbitrary text (max 8 characters).s: (C++: const segment_t *) pointer to segmentreturn: size of segment class (-1 if s==nullptr or bufsize<=0)
def get_segm_name(*args) ‑> qstring *
-
get_segm_name(s, flags=0) -> strGet true segment name by pointer to segment.s: (C++: const segment_t *) pointer to segmentflags: (C++: int) 0-return name as is; 1-substitute bad symbols with _ 1 correspondsto GN_VISIBLEreturn: size of segment name (-1 if s==nullptr)
def get_segm_num(*args) ‑> int
-
get_segm_num(ea) -> intGet number of segment by address.ea: (C++: ea_t) linear address belonging to the segmentreturn: -1 if no segment occupies the specified address. otherwise returnsnumber of the specified segment (0..get_segm_qty()-1)
def get_segm_para(*args) ‑> ea_t
-
get_segm_para(s) -> ea_tGet 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 segmentreturn: 0 if s == nullptr, the segment base paragraph
def get_segm_qty(*args) ‑> int
-
get_segm_qty() -> intGet number of segments.
def get_segment_alignment(*args) ‑> 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.
def get_segment_cmt(*args) ‑> qstring *
-
get_segment_cmt(s, repeatable) -> strGet segment comment.s: (C++: const segment_t *) pointer to segment structurerepeatable: (C++: bool) 0: get regular comment. 1: get repeatable comment.return: size of comment or -1
def get_segment_combination(*args) ‑> 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.
def get_segment_translations(*args) ‑> ssize_t
-
get_segment_translations(transmap, segstart) -> ssize_tGet segment translation list.transmap: (C++: eavec_t *) vector of segment start addresses for the translation listsegstart: (C++: ea_t) start address of the segment to get information aboutreturn: -1 if no translation list or bad segstart. otherwise returns size oftranslation list.
def get_selector_qty(*args) ‑> size_t
-
get_selector_qty() -> size_tGet number of defined selectors.
def get_visible_segm_name(*args) ‑> qstring *
-
get_visible_segm_name(s) -> strGet segment name by pointer to segment.s: (C++: const segment_t *) pointer to segmentreturn: size of segment name (-1 if s==nullptr)
def getn_selector(*args) ‑> sel_t *, ea_t *
-
getn_selector(n) -> boolGet description of selector (0..get_selector_qty()-1)n: (C++: int)
def getnseg(*args) ‑> segment_t *
-
getnseg(n) -> segment_tGet pointer to segment by its number.warning: Obsoleted because it can slow down the debugger (it has to refresh thewhole 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
def getseg(*args) ‑> segment_t *
-
getseg(ea) -> segment_tGet pointer to segment by linear address.ea: (C++: ea_t) linear address belonging to the segmentreturn: nullptr or pointer to segment structure
def is_finally_visible_segm(*args) ‑> bool
-
is_finally_visible_segm(s) -> boolSee SFL_HIDDEN, SCF_SHHID_SEGM.s: (C++: segment_t *)
def is_miniidb(*args) ‑> bool
-
is_miniidb() -> boolIs the database a miniidb created by the debugger?.return: true if the database contains no segments or only debugger segments
def is_segm_locked(*args) ‑> bool
-
is_segm_locked(segm) -> boolIs a segment pointer locked?segm: (C++: const segment_t *) segment_t const *
def is_spec_ea(*args) ‑> bool
-
is_spec_ea(ea) -> boolDoes the address belong to a segment with a special type?. (SEG_XTRN, SEG_GRP, SEG_ABSSYM, SEG_COMM)ea: (C++: ea_t) linear address
def is_spec_segm(*args) ‑> bool
-
is_spec_segm(seg_type) -> boolHas segment a special type?. (SEG_XTRN, SEG_GRP, SEG_ABSSYM, SEG_COMM)seg_type: (C++: uchar)
def is_visible_segm(*args) ‑> bool
-
is_visible_segm(s) -> boolSee SFL_HIDDEN.s: (C++: segment_t *)
def lock_segm(*args) ‑> 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)
def move_segm(*args) ‑> move_segm_code_t
-
move_segm(s, to, flags=0) -> move_segm_code_tThis 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 moveto: (C++: ea_t) new segment start addressflags: (C++: int) Move segment flagsreturn: Move segment result codes
def move_segm_start(*args) ‑> bool
-
move_segm_start(ea, newstart, mode) -> boolMove 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 segmentnewstart: (C++: ea_t) new start address of the segment note that segment startaddress 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: okretval 0: failed, a warning message is displayed def move_segm_strerror(*args) ‑> 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
def rebase_program(*args) ‑> int
-
rebase_program(delta, flags) -> intRebase the whole program by 'delta' bytes.delta: (C++: adiff_t) number of bytes to move the programflags: (C++: int) Move segment flags it is recommended to use MSF_FIXONCE so thatthe loader takes care of global variables it stored in the databasereturn: Move segment result codes
def segm_adjust_diff(*args) ‑> adiff_t
-
segm_adjust_diff(s, delta) -> adiff_tTruncate and sign extend a delta depending on the segment.s: (C++: const segment_t *) segment_t const *delta: (C++: adiff_t)
def segm_adjust_ea(*args) ‑> ea_t
-
segm_adjust_ea(s, ea) -> ea_tTruncate an address depending on the segment.s: (C++: const segment_t *) segment_t const *ea: (C++: ea_t)
def segtype(*args) ‑> uchar
-
segtype(ea) -> ucharGet segment type.ea: (C++: ea_t) any linear address within the segmentreturn: Segment types, SEG_UNDF if no segment found at 'ea'
def sel2ea(*args) ‑> ea_t
-
sel2ea(selector) -> ea_tGet mapping of a selector as a linear address.selector: (C++: sel_t) number of selector to translate to linear addressreturn: linear address the specified selector is mapped to. if there is nomapping, returns to_ea(selector,0);
def sel2para(*args) ‑> ea_t
-
sel2para(selector) -> ea_tGet mapping of a selector.selector: (C++: sel_t) number of selector to translatereturn: paragraph the specified selector is mapped to. if there is no mapping,returns 'selector'.
def set_defsr(*args) ‑> void
-
set_defsr(s, reg, value)Deprecated, use instead:s.defsr[reg] = values: segment_t *reg: intvalue: sel_t
def set_group_selector(*args) ‑> int
-
set_group_selector(grp, sel) -> intCreate a new group of segments (used OMF files).grp: (C++: sel_t) selector of group segment (segment type is SEG_GRP) You shouldcreate 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 shouldcreate all segments within the group with the same selector value.return: 1 ok 0 too many groups (see MAX_GROUPS)
def set_segm_addressing(*args) ‑> bool
-
set_segm_addressing(s, bitness) -> boolChange 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 segments: (C++: segment_t *) pointer to segmentbitness: (C++: size_t) new addressing mode of segment
- 2: 64bit segment
- 1: 32bit segment
- 0: 16bit segment
return: success def set_segm_base(*args) ‑> bool
-
set_segm_base(s, newbase) -> boolInternal function.s: (C++: segment_t *)newbase: (C++: ea_t)
def set_segm_class(*args) ‑> int
-
set_segm_class(s, sclass, flags=0) -> intSet 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 andsegment 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 flagsretval 1: ok, name is good and segment is renamedretval 0: failure, name is nullptr or bad or segment is nullptr def set_segm_end(*args) ‑> bool
-
set_segm_end(ea, newend, flags) -> boolSet 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 segmentnewend: (C++: ea_t) new end address of the segmentflags: (C++: int) Segment modification flagsretval 1: okretval 0: failed, a warning message is displayed
def set_segm_name(*args) ‑> int
-
set_segm_name(s, name, flags=0) -> intRename 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 nameflags: (C++: int) ADDSEG_IDBENC or 0retval 1: ok, name is good and segment is renamedretval 0: failure, name is bad or segment is nullptr
def set_segm_start(*args) ‑> bool
-
set_segm_start(ea, newstart, flags) -> boolSet 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 segmentnewstart: (C++: ea_t) new start address of the segment note that segment startaddress should be higher than segment base linear address.flags: (C++: int) Segment modification flagsretval 1: okretval 0: failed, a warning message is displayed
def set_segment_cmt(*args) ‑> void
-
set_segment_cmt(s, cmt, repeatable)Set segment comment.s: (C++: const segment_t *) pointer to segment structurecmt: (C++: const char *) comment string, may be multiline (with ' '). maximal size is 4096 bytes. Use empty str ("") to delete commentrepeatable: (C++: bool) 0: set regular comment. 1: set repeatable comment.
def set_segment_translations(*args) ‑> bool
-
set_segment_translations(segstart, transmap) -> boolSet new translation list.segstart: (C++: ea_t) start address of the segment to add translation totransmap: (C++: const eavec_t &) vector of segment start addresses for the translation list. Iftransmap is empty, the translation list is deleted.retval 1: okretval 0: too many translations or bad segstart
def set_selector(*args) ‑> int
-
set_selector(selector, paragraph) -> intSet 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 selectorretval 1: okretval 0: failure (bad selector or too many mappings) def set_visible_segm(*args) ‑> void
-
set_visible_segm(s, visible)See SFL_HIDDEN.s: (C++: segment_t *)visible: (C++: bool)
def setup_selector(*args) ‑> sel_t
-
setup_selector(segbase) -> sel_tAllocate 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 paragraphreturn: 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 *)
def take_memory_snapshot(*args) ‑> bool
-
take_memory_snapshot(type) -> boolTake a memory snapshot of the running process.type: (C++: int) specifies which snapshot we want (see SNAP_ Snapshot types)return: success
def update_segm(*args) ‑> bool
-
update_segm(s) -> bools: segment_t *
Classes
class lock_segment (*args)
-
Proxy of C++ lock_segment class.__init__(self, _segm) -> lock_segment_segm: segment_t const *
class segment_defsr_array (*args)
-
Proxy of C++ wrapped_array_t< sel_t,SREG_NUM > class.__init__(self, data) -> segment_defsr_arraydata: unsigned long long (&)[SREG_NUM]
Instance variables
var bytes : bytevec_t
-
_get_bytes(self) -> bytevec_t
var data
-
data
class segment_t (*args)
-
Proxy of C++ segment_t class.__init__(self) -> segment_t
Ancestors
Instance variables
var align
-
Segment alignment codes
var bitness
-
Number of bits in the segment addressing
- 0: 16 bits
- 1: 32 bits
- 2: 64 bits
var color
-
the segment color
var comb
-
Segment combination codes
var defsr : wrapped_array_t< sel_t,SREG_NUM >
-
default segment register values. first element of this array keeps information about value of processor_t::reg_first_sreg
var end_ea
-
end_ea
var flags
-
Segment flags
var name
-
use get/set_segm_name() functions
var orgbase
-
this field is IDP dependent. you may keep your information about the segment here
var perm
-
Segment permissions (0 means no information)
var sclass
-
use get/set_segm_class() functions
var sel
-
segment selector - should be unique. You can't change this field after creating the segment. Exception: 16bit OMF files may have several segments with the same selector, but this is not good (no way to denote a segment exactly) so it should be fixed in the future.
var start_ea
-
start_ea
var type
-
segment type (see Segment types). The kernel treats different segment types differently. Segments marked with '*' contain no instructions or data and are not declared as 'segments' in the disassembly.
Methods
def abits(self, *args) ‑> int
-
abits(self) -> intGet number of address bits.
def abytes(self, *args) ‑> int
-
abytes(self) -> intGet number of address bytes.
def clr_comorg(self, *args) ‑> void
-
clr_comorg(self)
def clr_ob_ok(self, *args) ‑> void
-
clr_ob_ok(self)
def comorg(self, *args) ‑> bool
-
comorg(self) -> bool
def is_16bit(self, *args) ‑> bool
-
is_16bit(self) -> boolIs a 16-bit segment?
def is_32bit(self, *args) ‑> bool
-
is_32bit(self) -> boolIs a 32-bit segment?
def is_64bit(self, *args) ‑> bool
-
is_64bit(self) -> boolIs a 64-bit segment?
def is_header_segm(self, *args) ‑> bool
-
is_header_segm(self) -> bool
-
is_hidden_segtype(self) -> bool
def is_loader_segm(self, *args) ‑> bool
-
is_loader_segm(self) -> bool
def is_visible_segm(self, *args) ‑> bool
-
is_visible_segm(self) -> bool
def ob_ok(self, *args) ‑> bool
-
ob_ok(self) -> bool
def set_comorg(self, *args) ‑> void
-
set_comorg(self)
def set_debugger_segm(self, *args) ‑> void
-
set_debugger_segm(self, debseg)debseg: bool
def set_header_segm(self, *args) ‑> void
-
set_header_segm(self, on)on: bool
-
set_hidden_segtype(self, hide)hide: bool
def set_loader_segm(self, *args) ‑> void
-
set_loader_segm(self, ldrseg)ldrseg: bool
def set_ob_ok(self, *args) ‑> void
-
set_ob_ok(self)
def set_visible_segm(self, *args) ‑> void
-
set_visible_segm(self, visible)visible: bool
def update(self, *args) ‑> bool
-
update(self) -> boolUpdate 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
def use64(self, *args) ‑> bool
-
is_64bit(self) -> boolIs a 64-bit segment?
Inherited members