Add/Delete/Modify segments. More...
Modules | |
Add segment flags | |
Passed as 'flags' parameter to add_segm_ex() | |
Segment modification flags | |
Used by functions in Segment manipulation functions. | |
Move segment result codes | |
Return values for move_segm() add rebase_program() | |
Move segment flags | |
Passed as 'flags' parameter to move_segm() and rebase_program() | |
Change segment status result codes | |
Return values for change_segment_status() | |
Snapshot types | |
Specifies which segments should be included in the snapshot. | |
Functions | |
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. | |
Detailed Description
Add/Delete/Modify segments.
Function Documentation
◆ add_segm_ex()
idaman bool ida_export add_segm_ex | ( | segment_t *NONNULL | s, |
const char * | name, | ||
const char * | 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.
- Parameters
-
s pointer to filled segment structure. segment selector should have proper mapping (see set_selector()). - if s.start_ea==BADADDR then s.start_ea <- get_segm_base(&s)
- if s.end_ea==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 the s.end_ea < s.start_ea, then fail.
- if s.end_ea is too high and the new segment would overlap the next segment, s.end_ea is adjusted properly.
name name of new segment. may be nullptr. if specified, the segment is immediately renamed sclass class of the segment. may be nullptr. if specified, the segment class is immediately changed flags Add segment flags
- Return values
-
1 ok 0 failed, a warning message is displayed
◆ add_segm()
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.
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.
- Parameters
-
para segment base paragraph. if paragraph can't fit in 16bit, then a new selector is allocated and mapped to the paragraph. start start address of the segment. if start==BADADDR then start <- to_ea(para,0). 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. name name of new segment. may be nullptr sclass class of the segment. may be nullptr. type of the new segment is modified if class is one of predefined names: flags Add segment flags
- Return values
-
1 ok 0 failed, a warning message is displayed
◆ del_segm()
idaman bool ida_export del_segm | ( | ea_t | ea, |
int | flags | ||
) |
Delete a segment.
- Parameters
-
ea any address belonging to the segment flags Segment modification flags
- Return values
-
1 ok 0 failed, no segment at 'ea'.
◆ getseg()
idaman segment_t *ida_export getseg | ( | ea_t | ea | ) |
Get pointer to segment by linear address.
- Parameters
-
ea linear address belonging to the segment
- Returns
- nullptr or pointer to segment structure
◆ getnseg()
idaman segment_t *ida_export getnseg | ( | int | n | ) |
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)
- Parameters
-
n segment number in the range (0..get_segm_qty()-1)
- Returns
- nullptr or pointer to segment structure
◆ get_segm_num()
idaman int ida_export get_segm_num | ( | ea_t | ea | ) |
Get number of segment by address.
- Parameters
-
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_by_name()
idaman segment_t *ida_export get_segm_by_name | ( | const char * | name | ) |
Get pointer to segment by its name.
If there are several segments with the same name, returns the first of them.
- Parameters
-
name segment name. may be nullptr.
- Returns
- nullptr or pointer to segment structure
◆ set_segm_end()
idaman bool ida_export set_segm_end | ( | ea_t | ea, |
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.
- Parameters
-
ea any address belonging to the segment newend new end address of the segment flags Segment modification flags
- Return values
-
1 ok 0 failed, a warning message is displayed
◆ set_segm_start()
idaman bool ida_export set_segm_start | ( | ea_t | ea, |
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.
- Parameters
-
ea any address belonging to the segment newstart new start address of the segment note that segment start address should be higher than segment base linear address. flags Segment modification flags
- Return values
-
1 ok 0 failed, a warning message is displayed
◆ move_segm_start()
idaman bool ida_export move_segm_start | ( | ea_t | ea, |
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.
- Note
- this function never disables addresses.
- Parameters
-
ea any address belonging to the segment newstart new start address of the segment note that segment start address should be higher than segment base linear address. 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)
- Return values
-
1 ok 0 failed, a warning message is displayed
◆ move_segm()
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.
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.
- Parameters
-
s segment to move to new segment start address flags Move segment flags
- Returns
- Move segment result codes
◆ rebase_program()
idaman move_segm_code_t ida_export rebase_program | ( | adiff_t | delta, |
int | flags | ||
) |
Rebase the whole program by 'delta' bytes.
- Parameters
-
delta number of bytes to move the program 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
◆ change_segment_status()
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.
When converting debug->regular, the memory contents will be copied to the database.
- Parameters
-
s segment to modify is_deb_segm new status of the segment
◆ take_memory_snapshot()
idaman bool ida_export take_memory_snapshot | ( | int | type | ) |
Take a memory snapshot of the running process.
- Parameters
-
type specifies which snapshot we want (see SNAP_ Snapshot types)
- Returns
- success
◆ is_miniidb()
idaman bool ida_export is_miniidb | ( | void | ) |
Is the database a miniidb created by the debugger?.
- Returns
- true if the database contains no segments or only debugger segments
Generated by 1.9.3