Functions that deal with the segment registers. More...
Classes | |
struct | sreg_range_t |
The values of the segment registers are kept as address ranges. More... | |
Macros | |
#define | SR_inherit 1 |
the value is inherited from the previous range | |
#define | SR_user 2 |
the value is specified by the user | |
#define | SR_auto 3 |
the value is determined by IDA | |
#define | SR_autostart 4 |
used as SR_auto for segment starting address | |
Functions | |
idaman sel_t ida_export | get_sreg (ea_t ea, int rg) |
Get value of a segment register. More... | |
idaman bool ida_export | split_sreg_range (ea_t ea, int rg, sel_t v, uchar tag, bool silent=false) |
Create a new segment register range. More... | |
idaman bool ida_export | set_default_sreg_value (segment_t *sg, int rg, sel_t value) |
Set default value of a segment register for a segment. More... | |
idaman void ida_export | set_sreg_at_next_code (ea_t ea1, ea_t ea2, int rg, sel_t value) |
Set the segment register value at the next instruction. More... | |
idaman bool ida_export | get_sreg_range (sreg_range_t *out, ea_t ea, int rg) |
Get segment register range by linear address. More... | |
idaman bool ida_export | get_prev_sreg_range (sreg_range_t *out, ea_t ea, int rg) |
Get segment register range previous to one with address. More... | |
idaman void ida_export | set_default_dataseg (sel_t ds_sel) |
Set default value of DS register for all segments. | |
idaman size_t ida_export | get_sreg_ranges_qty (int rg) |
Get number of segment register ranges. More... | |
idaman bool ida_export | getn_sreg_range (sreg_range_t *out, int rg, int n) |
Get segment register range by its number. More... | |
idaman int ida_export | get_sreg_range_num (ea_t ea, int rg) |
Get number of segment register range by address. More... | |
idaman bool ida_export | del_sreg_range (ea_t ea, int rg) |
Delete segment register range started at ea. More... | |
idaman void ida_export | copy_sreg_ranges (int dst_rg, int src_rg, bool map_selector=false) |
Duplicate segment register ranges. More... | |
Detailed Description
Functions that deal with the segment registers.
If your processor doesn't use segment registers, then these functions are of no use for you. However, you should define two virtual segment registers - CS and DS (for code segment and data segment) and specify their internal numbers in the LPH structure (processor_t::reg_code_sreg and processor_t::reg_data_sreg).
Function Documentation
◆ get_sreg()
idaman sel_t ida_export get_sreg | ( | ea_t | ea, |
int | rg | ||
) |
Get value of a segment register.
This function uses segment register range and default segment register values stored in the segment structure.
- Parameters
-
ea linear address in the program rg number of the segment register
- Returns
- value of the segment register, BADSEL if value is unknown.
◆ split_sreg_range()
idaman bool ida_export split_sreg_range | ( | ea_t | ea, |
int | rg, | ||
sel_t | v, | ||
uchar | tag, | ||
bool | silent = false |
||
) |
Create a new segment register range.
This function is used when the IDP emulator detects that a segment register changes its value.
- Parameters
-
ea linear address where the segment register will have a new value. if ea==BADADDR, nothing to do. rg the number of the segment register v the new value of the segment register. If the value is unknown, you should specify BADSEL. tag the register info tag. see Segment register range tags silent if false, display a warning() in the case of failure
- Returns
- success
◆ set_default_sreg_value()
idaman bool ida_export set_default_sreg_value | ( | segment_t * | sg, |
int | rg, | ||
sel_t | value | ||
) |
Set default value of a segment register for a segment.
- Parameters
-
sg pointer to segment structure if nullptr, then set the register for all segments rg number of segment register value its default value. this value will be used by get_sreg() if value of the register is unknown at the specified address.
- Returns
- success
◆ set_sreg_at_next_code()
idaman void ida_export set_sreg_at_next_code | ( | ea_t | ea1, |
ea_t | ea2, | ||
int | rg, | ||
sel_t | value | ||
) |
Set the segment register value at the next instruction.
This function is designed to be called from idb_event::sgr_changed handler in order to contain the effect of changing a segment register value only until the next instruction.
It is useful, for example, in the ARM module: the modification of the T register does not affect existing instructions later in the code.
- Parameters
-
ea1 address to start to search for an instruction ea2 the maximal address rg the segment register number value the segment register value
◆ get_sreg_range()
idaman bool ida_export get_sreg_range | ( | sreg_range_t * | out, |
ea_t | ea, | ||
int | rg | ||
) |
Get segment register range by linear address.
- Parameters
-
out segment register range ea any linear address in the program rg the segment register number
- Returns
- success
◆ get_prev_sreg_range()
idaman bool ida_export get_prev_sreg_range | ( | sreg_range_t * | out, |
ea_t | ea, | ||
int | rg | ||
) |
Get segment register range previous to one with address.
- Note
- more efficient then get_sreg_range(reg, ea-1)
- Parameters
-
out segment register range ea any linear address in the program rg the segment register number
- Returns
- success
◆ get_sreg_ranges_qty()
idaman size_t ida_export get_sreg_ranges_qty | ( | int | rg | ) |
Get number of segment register ranges.
- Parameters
-
rg the segment register number
◆ getn_sreg_range()
idaman bool ida_export getn_sreg_range | ( | sreg_range_t * | out, |
int | rg, | ||
int | n | ||
) |
Get segment register range by its number.
- Parameters
-
out segment register range rg the segment register number n number of range (0..qty()-1)
- Returns
- success
◆ get_sreg_range_num()
idaman int ida_export get_sreg_range_num | ( | ea_t | ea, |
int | rg | ||
) |
Get number of segment register range by address.
- Parameters
-
ea any address in the range rg the segment register number
- Returns
- -1 if no range occupies the specified address. otherwise returns number of the specified range (0..get_srranges_qty()-1)
◆ del_sreg_range()
idaman bool ida_export del_sreg_range | ( | ea_t | ea, |
int | rg | ||
) |
Delete segment register range started at ea.
When a segment register range is deleted, the previous range is extended to cover the empty space. The segment register range at the beginning of a segment cannot be deleted.
- Parameters
-
ea start_ea of the deleted range rg the segment register number
- Returns
- success
◆ copy_sreg_ranges()
idaman void ida_export copy_sreg_ranges | ( | int | dst_rg, |
int | src_rg, | ||
bool | map_selector = false |
||
) |
Duplicate segment register ranges.
- Parameters
-
dst_rg number of destination segment register src_rg copy ranges from map_selector map selectors to linear addresses using sel2ea()
Generated by 1.9.3