Functions that deal with segments. More...
Classes | |
class | segment_t |
Describes a program segment. More... | |
class | lock_segment |
Helper class to lock a segment pointer so it stays valid. More... | |
Macros | |
#define | SREG_NUM 16 |
Maximum number of segment registers is 16 (see segregs.hpp) | |
#define | saAbs 0 |
Absolute segment. | |
#define | saRelByte 1 |
Relocatable, byte aligned. | |
#define | saRelWord 2 |
Relocatable, word (2-byte) aligned. | |
#define | saRelPara 3 |
Relocatable, paragraph (16-byte) aligned. | |
#define | saRelPage 4 |
Relocatable, aligned on 256-byte boundary. | |
#define | saRelDble 5 |
Relocatable, aligned on a double word (4-byte) boundary. More... | |
#define | saRel4K 6 |
This value is used by the PharLap OMF for page (4K) alignment. More... | |
#define | saGroup 7 |
Segment group. | |
#define | saRel32Bytes 8 |
32 bytes | |
#define | saRel64Bytes 9 |
64 bytes | |
#define | saRelQword 10 |
8 bytes | |
#define | saRel128Bytes 11 |
128 bytes | |
#define | saRel512Bytes 12 |
512 bytes | |
#define | saRel1024Bytes 13 |
1024 bytes | |
#define | saRel2048Bytes 14 |
2048 bytes | |
#define | saRel_MAX_ALIGN_CODE saRel2048Bytes |
#define | scPriv 0 |
Private. More... | |
#define | scGroup 1 |
Segment group. | |
#define | scPub 2 |
Public. More... | |
#define | scPub2 4 |
As defined by Microsoft, same as C=2 (public). | |
#define | scStack 5 |
Stack. More... | |
#define | scCommon 6 |
Common. Combine by overlay using maximum size. | |
#define | scPub3 7 |
As defined by Microsoft, same as C=2 (public). | |
#define | sc_MAX_COMB_CODE scPub3 |
#define | SEGPERM_EXEC 1 |
Execute. | |
#define | SEGPERM_WRITE 2 |
Write. | |
#define | SEGPERM_READ 4 |
Read. | |
#define | SEGPERM_MAXVAL (SEGPERM_EXEC + SEGPERM_WRITE + SEGPERM_READ) |
#define | SEG_MAX_BITNESS_CODE 2 |
#define | SFL_COMORG 0x01 |
IDP dependent field (IBM PC: if set, ORG directive is not commented out) | |
#define | SFL_OBOK 0x02 |
Orgbase is present? (IDP dependent field) | |
#define | SFL_HIDDEN 0x04 |
Is the segment hidden? | |
#define | SFL_DEBUG 0x08 |
Is the segment created for the debugger?. More... | |
#define | SFL_LOADER 0x10 |
Is the segment created by the loader? | |
#define | SFL_HIDETYPE 0x20 |
Hide segment type (do not print it in the listing) | |
#define | SFL_HEADER 0x40 |
Header segment (do not create offsets to it in the disassembly) | |
#define | SEG_NORM 0 |
unknown type, no assumptions | |
#define | SEG_XTRN 1 |
* segment with 'extern' definitions. More... | |
#define | SEG_CODE 2 |
code segment | |
#define | SEG_DATA 3 |
data segment | |
#define | SEG_IMP 4 |
java: implementation segment | |
#define | SEG_GRP 6 |
* group of segments | |
#define | SEG_NULL 7 |
zero-length segment | |
#define | SEG_UNDF 8 |
undefined segment type (not used) | |
#define | SEG_BSS 9 |
uninitialized segment | |
#define | SEG_ABSSYM 10 |
* segment with definitions of absolute symbols | |
#define | SEG_COMM 11 |
* segment with communal definitions | |
#define | SEG_IMEM 12 |
internal processor memory & sfr (8051) | |
#define | SEG_MAX_SEGTYPE_CODE SEG_IMEM |
#define | ADDSEG_NOSREG 0x0001 |
set all default segment register values to BADSEL (undefine all default segment registers) | |
#define | ADDSEG_OR_DIE 0x0002 |
qexit() if can't add a segment | |
#define | ADDSEG_NOTRUNC 0x0004 |
don't truncate the new segment at the beginning of the next segment if they overlap. More... | |
#define | ADDSEG_QUIET 0x0008 |
silent mode, no "Adding segment..." in the messages window | |
#define | ADDSEG_FILLGAP 0x0010 |
fill gap between new segment and previous one. More... | |
#define | ADDSEG_SPARSE 0x0020 |
use sparse storage method for the new ranges of the created segment. More... | |
#define | ADDSEG_NOAA 0x0040 |
do not mark new segment for auto-analysis | |
#define | ADDSEG_IDBENC 0x0080 |
'name' and 'sclass' are given in the IDB encoding; non-ASCII bytes will be decoded accordingly | |
#define | SEGMOD_KILL 0x0001 |
disable addresses if segment gets shrinked or deleted | |
#define | SEGMOD_KEEP 0x0002 |
keep information (code & data, etc) | |
#define | SEGMOD_SILENT 0x0004 |
be silent | |
#define | SEGMOD_KEEP0 0x0008 |
flag for internal use, don't set | |
#define | SEGMOD_KEEPSEL 0x0010 |
do not try to delete unused selector | |
#define | SEGMOD_NOMOVE 0x0020 |
don't move info from the start of segment to the new start address (for set_segm_start()) | |
#define | SEGMOD_SPARSE 0x0040 |
use sparse storage if extending the segment (for set_segm_start(), set_segm_end()) | |
#define | MSF_SILENT 0x0001 |
don't display a "please wait" box on the screen | |
#define | MSF_NOFIX 0x0002 |
don't call the loader to fix relocations | |
#define | MSF_LDKEEP 0x0004 |
keep the loader in the memory (optimization) | |
#define | MSF_FIXONCE 0x0008 |
call loader only once with the special calling method. More... | |
#define | MSF_PRIORITY 0x0020 |
loader segments will overwrite any existing debugger segments when moved. More... | |
#define | MSF_NETNODES 0x0080 |
move netnodes instead of changing inf.netdelta (this is slower); valid for rebase_program() | |
#define | CSS_OK 0 |
ok | |
#define | CSS_NODBG -1 |
debugger is not running | |
#define | CSS_NORANGE -2 |
could not find corresponding memory range | |
#define | CSS_NOMEM -3 |
not enough memory (might be because the segment is too big) | |
#define | CSS_BREAK -4 |
memory reading process stopped by user | |
#define | SNAP_ALL_SEG 0 |
Take a snapshot of all segments. | |
#define | SNAP_LOAD_SEG 1 |
Take a snapshot of loader segments. | |
#define | SNAP_CUR_SEG 2 |
Take a snapshot of current segment. | |
#define | MAX_GROUPS 8 |
max number of segment groups | |
#define | MAX_SEGM_TRANSLATIONS 64 |
max number of segment translations | |
Enumerations | |
enum | move_segm_code_t { MOVE_SEGM_OK = 0 , MOVE_SEGM_PARAM = -1 , MOVE_SEGM_ROOM = -2 , MOVE_SEGM_IDP = -3 , MOVE_SEGM_CHUNK = -4 , MOVE_SEGM_LOADER = -5 , MOVE_SEGM_ODD = -6 , MOVE_SEGM_ORPHAN = -7 , MOVE_SEGM_DEBUG = -8 , MOVE_SEGM_SOURCEFILES = -9 , MOVE_SEGM_MAPPING = -10 , MOVE_SEGM_INVAL = -11 } |
Functions | |
CASSERT (sizeof(segment_t)==104) | |
bool | is_visible_segm (segment_t *s) |
See SFL_HIDDEN. | |
bool | is_finally_visible_segm (segment_t *s) |
See SFL_HIDDEN, SCF_SHHID_SEGM. | |
idaman void ida_export | set_visible_segm (segment_t *s, bool visible) |
See SFL_HIDDEN. | |
idaman bool ida_export | is_spec_segm (uchar seg_type) |
Has segment a special type?. More... | |
idaman bool ida_export | is_spec_ea (ea_t ea) |
Does the address belong to a segment with a special type?. More... | |
idaman void ida_export | lock_segm (const segment_t *segm, bool lock) |
Lock segment pointer Locked pointers are guaranteed to remain valid until they are unlocked. More... | |
idaman bool ida_export | is_segm_locked (const segment_t *segm) |
Is a segment pointer locked? | |
idaman bool ida_export | getn_selector (sel_t *sel, ea_t *base, int n) |
Get description of selector (0..get_selector_qty()-1) | |
idaman size_t ida_export | get_selector_qty (void) |
Get number of defined selectors. | |
idaman sel_t ida_export | setup_selector (ea_t segbase) |
Allocate a selector for a segment if necessary. More... | |
idaman sel_t ida_export | allocate_selector (ea_t segbase) |
Allocate a selector for a segment unconditionally. More... | |
idaman sel_t ida_export | find_free_selector (void) |
Find first unused selector. More... | |
idaman int ida_export | set_selector (sel_t selector, ea_t paragraph) |
Set mapping of selector to a paragraph. More... | |
idaman void ida_export | del_selector (sel_t selector) |
Delete mapping of a selector. More... | |
idaman ea_t ida_export | sel2para (sel_t selector) |
Get mapping of a selector. More... | |
ea_t idaapi | sel2ea (sel_t selector) |
Get mapping of a selector as a linear address. More... | |
idaman sel_t ida_export | find_selector (ea_t base) |
Find a selector that has mapping to the specified paragraph. More... | |
idaman int ida_export | enumerate_selectors (int(idaapi *func)(sel_t sel, ea_t para)) |
Enumerate all selectors from the translation table. More... | |
idaman ea_t ida_export | enumerate_segments_with_selector (sel_t selector, ea_t(idaapi *func)(segment_t *s, void *ud), void *ud=nullptr) |
Enumerate all segments with the specified selector. More... | |
idaman segment_t *ida_export | get_segm_by_sel (sel_t selector) |
Get pointer to segment structure. More... | |
idaman bool ida_export | add_segm_ex (segment_t *NONNULL s, const char *name, const char *sclass, int flags) |
Add a new segment. More... | |
idaman bool ida_export | add_segm (ea_t para, ea_t start, ea_t end, const char *name, const char *sclass, int flags=0) |
Add a new segment, second form. More... | |
idaman bool ida_export | del_segm (ea_t ea, int flags) |
Delete a segment. More... | |
idaman int ida_export | get_segm_qty (void) |
Get number of segments. | |
idaman segment_t *ida_export | getseg (ea_t ea) |
Get pointer to segment by linear address. More... | |
idaman segment_t *ida_export | getnseg (int n) |
Get pointer to segment by its number. More... | |
idaman int ida_export | get_segm_num (ea_t ea) |
Get number of segment by address. More... | |
idaman segment_t *ida_export | get_next_seg (ea_t ea) |
Get pointer to the next segment. | |
idaman segment_t *ida_export | get_prev_seg (ea_t ea) |
Get pointer to the previous segment. | |
idaman segment_t *ida_export | get_first_seg (void) |
Get pointer to the first segment. | |
idaman segment_t *ida_export | get_last_seg (void) |
Get pointer to the last segment. | |
idaman segment_t *ida_export | get_segm_by_name (const char *name) |
Get pointer to segment by its name. More... | |
idaman bool ida_export | set_segm_end (ea_t ea, ea_t newend, int flags) |
Set segment end address. More... | |
idaman bool ida_export | set_segm_start (ea_t ea, ea_t newstart, int flags) |
Set segment start address. More... | |
idaman bool ida_export | move_segm_start (ea_t ea, ea_t newstart, int mode) |
Move segment start. More... | |
idaman const char *ida_export | move_segm_strerror (move_segm_code_t code) |
Return string describing error MOVE_SEGM_... code. | |
idaman move_segm_code_t ida_export | move_segm (segment_t *s, ea_t to, int flags=0) |
This function moves all information to the new address. More... | |
idaman move_segm_code_t ida_export | rebase_program (adiff_t delta, int flags) |
Rebase the whole program by 'delta' bytes. More... | |
idaman int ida_export | change_segment_status (segment_t *s, bool is_deb_segm) |
Convert a debugger segment to a regular segment and vice versa. More... | |
idaman bool ida_export | take_memory_snapshot (int type) |
Take a memory snapshot of the running process. More... | |
idaman bool ida_export | is_miniidb (void) |
Is the database a miniidb created by the debugger?. More... | |
idaman bool ida_export | set_segm_base (segment_t *s, ea_t newbase) |
Internal function. | |
idaman int ida_export | set_group_selector (sel_t grp, sel_t sel) |
Create a new group of segments (used OMF files). More... | |
idaman sel_t ida_export | get_group_selector (sel_t grpsel) |
Get common selector for a group of segments. More... | |
idaman bool ida_export | add_segment_translation (ea_t segstart, ea_t mappedseg) |
Add segment translation. More... | |
idaman bool ida_export | set_segment_translations (ea_t segstart, const eavec_t &transmap) |
Set new translation list. More... | |
idaman void ida_export | del_segment_translations (ea_t segstart) |
Delete the translation list. More... | |
idaman ssize_t ida_export | get_segment_translations (eavec_t *transmap, ea_t segstart) |
Get segment translation list. More... | |
idaman ssize_t ida_export | get_segment_cmt (qstring *buf, const segment_t *s, bool repeatable) |
Get segment comment. More... | |
idaman void ida_export | set_segment_cmt (const segment_t *s, const char *cmt, bool repeatable) |
Set segment comment. More... | |
idaman void ida_export | std_out_segm_footer (struct outctx_t &ctx, segment_t *seg) |
Generate segment footer line as a comment line. More... | |
idaman int ida_export | set_segm_name (segment_t *s, const char *name, int flags=0) |
Rename segment. More... | |
idaman ssize_t ida_export | get_segm_name (qstring *buf, const segment_t *s, int flags=0) |
Get true segment name by pointer to segment. More... | |
ssize_t idaapi | get_visible_segm_name (qstring *buf, const segment_t *s) |
Get segment name by pointer to segment. More... | |
ssize_t | get_segm_expr (qstring *buf, ea_t from, sel_t sel) |
Get colored segment name expression in the form (segname + displacement). More... | |
idaman ssize_t ida_export | get_segm_class (qstring *buf, const segment_t *s) |
Get segment class. More... | |
idaman int ida_export | set_segm_class (segment_t *s, const char *sclass, int flags=0) |
Set segment class. More... | |
idaman uchar ida_export | segtype (ea_t ea) |
Get segment type. More... | |
idaman const char *ida_export | get_segment_alignment (uchar align) |
Get text representation of segment alignment code. More... | |
idaman const char *ida_export | get_segment_combination (uchar comb) |
Get text representation of segment combination code. More... | |
idaman ea_t ida_export | get_segm_para (const segment_t *s) |
Get segment base paragraph. More... | |
idaman ea_t ida_export | get_segm_base (const segment_t *s) |
Get segment base linear address. More... | |
idaman bool ida_export | set_segm_addressing (segment_t *s, size_t bitness) |
Change segment addressing mode (16, 32, 64 bits). More... | |
bool | is_debugger_segm (ea_t ea) |
Does the address belong to a debug segment? | |
bool | is_ephemeral_segm (ea_t ea) |
Does the address belong to an ephemeral segment? | |
idaman ea_t ida_export | correct_address (ea_t ea, ea_t from, ea_t to, ea_t size, bool skip_check=false) |
idaman bool ida_export | update_segm (segment_t *s) |
idaman adiff_t ida_export | segm_adjust_diff (const segment_t *s, adiff_t delta) |
Truncate and sign extend a delta depending on the segment. | |
idaman ea_t ida_export | segm_adjust_ea (const segment_t *s, ea_t ea) |
Truncate an address depending on the segment. | |
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.
Generated by 1.9.3