IDA C++ SDK 9.2
Loading...
Searching...
No Matches
Segment modification

Topics

 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 set_segm_end (ea_t ea, ea_t newend, int flags)
 Set segment end address.
idaman bool ida_export set_segm_start (ea_t ea, ea_t newstart, int flags)
 Set segment start address.
idaman bool ida_export move_segm_start (ea_t ea, ea_t newstart, int mode)
 Move segment start.
idaman const char *ida_export move_segm_strerror (move_segm_code_t code)
 Return string describing error MOVE_SEGM_... code.
idaman DEPRECATED 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.
idaman move_segm_code_t ida_export move_segment (ea_t seg_ea, ea_t to, int flags=0)
 Move segment to a new address.
idaman move_segm_code_t ida_export rebase_program (adiff_t delta, int flags)
 Rebase the whole program by 'delta' bytes.
idaman DEPRECATED int ida_export change_segment_status (segment_t *s, bool is_deb_segm)
 Convert a debugger segment to a regular segment and vice versa.
idaman int ida_export change_segment_status_by_ea (ea_t ea, bool is_deb_segm)
 Convert a debugger segment to a regular segment and vice versa by address.
idaman bool ida_export take_memory_snapshot (int type)
 Take a memory snapshot of the running process.
idaman bool ida_export is_miniidb ()
 Is the database a miniidb created by the debugger?
idaman DEPRECATED bool ida_export set_segm_base (segment_t *s, ea_t newbase)
 Internal function.
idaman bool ida_export set_segment_base_ea (ea_t seg_ea, ea_t newbase)
 Set segment base.

Detailed Description

Function Documentation

◆ 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
eaany address belonging to the segment
newendnew end address of the segment
flagsSegment modification flags
Return values
1ok
0failed, 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
eaany address belonging to the segment
newstartnew start address of the segment note that segment start address should be higher than segment base linear address.
flagsSegment modification flags
Return values
1ok
0failed, 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
eaany address belonging to the segment
newstartnew start address of the segment note that segment start address should be higher than segment base linear address.
modepolicy 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
1ok
0failed, a warning message is displayed

◆ move_segm_strerror()

idaman const char *ida_export move_segm_strerror ( move_segm_code_t code)

Return string describing error MOVE_SEGM_... code.

◆ move_segm()

idaman DEPRECATED 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.

Deprecated
Use move_segment() for safer access. 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
ssegment to move
tonew segment start address
flagsMove segment flags
Returns
Move segment result codes

◆ move_segment()

idaman move_segm_code_t ida_export move_segment ( ea_t seg_ea,
ea_t to,
int flags = 0 )

Move segment to a 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
seg_eaany address within the segment to move
tonew segment start address
flagsMove 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
deltanumber of bytes to move the program
flagsMove 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 DEPRECATED int ida_export change_segment_status ( segment_t * s,
bool is_deb_segm )

Convert a debugger segment to a regular segment and vice versa.

Deprecated
Use change_segment_status_by_ea() for safer access. When converting debug->regular, the memory contents will be copied to the database.
Parameters
ssegment to modify
is_deb_segmnew status of the segment
Returns
Change segment status result codes

◆ change_segment_status_by_ea()

idaman int ida_export change_segment_status_by_ea ( ea_t ea,
bool is_deb_segm )

Convert a debugger segment to a regular segment and vice versa by address.

When converting debug->regular, the memory contents will be copied to the database.

Parameters
eaany address within the segment
is_deb_segmnew status of the segment
Returns
Change segment status result codes

◆ take_memory_snapshot()

idaman bool ida_export take_memory_snapshot ( int type)

Take a memory snapshot of the running process.

Parameters
typespecifies which snapshot we want (see SNAP_ Snapshot types)
Returns
success

◆ is_miniidb()

idaman bool ida_export is_miniidb ( )

Is the database a miniidb created by the debugger?

Returns
true if the database contains no segments or only debugger segments

◆ set_segm_base()

idaman DEPRECATED bool ida_export set_segm_base ( segment_t * s,
ea_t newbase )

Internal function.

Deprecated
Use set_segment_base() for safer access.

◆ set_segment_base_ea()

idaman bool ida_export set_segment_base_ea ( ea_t seg_ea,
ea_t newbase )

Set segment base.

Internal function.

Parameters
seg_eaany address within the segment
newbasenew base linear address
Returns
success