Module ida_segregs

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).

Global Variables

R_cs

R_cs = 30

R_ds

R_ds = 32

R_es

R_es = 29

R_fs

R_fs = 33

R_gs

R_gs = 34

R_ss

R_ss = 31

SR_auto

SR_auto = 3

SR_autostart

SR_autostart = 4

SR_inherit

SR_inherit = 1

SR_user

SR_user = 2

Functions

copy_sreg_ranges(dst_rg: int, src_rg: int, map_selector: bool = False) ‑> void

copy_sreg_ranges(dst_rg, src_rg, map_selector=False) Duplicate segment register ranges.

dst_rg: (C++: int) number of destination segment register
src_rg: (C++: int) copy ranges from
map_selector: (C++: bool) map selectors to linear addresses using sel2ea()

del_sreg_range(ea: ea_t, rg: int) ‑> bool

del_sreg_range(ea, rg) -> bool 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.

ea: (C++: ea_t) start_ea of the deleted range
rg: (C++: int) the segment register number
return: success

get_prev_sreg_range(out: sreg_range_t, ea: ea_t, rg: int) ‑> bool

get_prev_sreg_range(out, ea, rg) -> bool Get segment register range previous to one with address. note: more efficient then get_sreg_range(reg, ea-1)

out: (C++: sreg_range_t *) segment register range
ea: (C++: ea_t) any linear address in the program
rg: (C++: int) the segment register number
return: success

get_sreg(ea: ea_t, rg: int) ‑> sel_t

get_sreg(ea, rg) -> sel_t Get value of a segment register. This function uses segment register range and default segment register values stored in the segment structure.

ea: (C++: ea_t) linear address in the program
rg: (C++: int) number of the segment register
return: value of the segment register, BADSEL if value is unknown.

get_sreg_range(out: sreg_range_t, ea: ea_t, rg: int) ‑> bool

get_sreg_range(out, ea, rg) -> bool Get segment register range by linear address.

out: (C++: sreg_range_t *) segment register range
ea: (C++: ea_t) any linear address in the program
rg: (C++: int) the segment register number
return: success

get_sreg_range_num(ea: ea_t, rg: int) ‑> int

get_sreg_range_num(ea, rg) -> int Get number of segment register range by address.

ea: (C++: ea_t) any address in the range
rg: (C++: int) the segment register number
return: -1 if no range occupies the specified address. otherwise returns number
        of the specified range (0..get_srranges_qty()-1)

get_sreg_ranges_qty(rg: int) ‑> size_t

get_sreg_ranges_qty(rg) -> size_t Get number of segment register ranges.

rg: (C++: int) the segment register number

getn_sreg_range(out: sreg_range_t, rg: int, n: int) ‑> bool

getn_sreg_range(out, rg, n) -> bool Get segment register range by its number.

out: (C++: sreg_range_t *) segment register range
rg: (C++: int) the segment register number
n: (C++: int) number of range (0..qty()-1)
return: success

set_default_dataseg(ds_sel: sel_t) ‑> void

set_default_dataseg(ds_sel) Set default value of DS register for all segments.

ds_sel: (C++: sel_t)

set_default_sreg_value(sg: segment_t *, rg: int, value: sel_t) ‑> bool

set_default_sreg_value(sg, rg, value) -> bool Set default value of a segment register for a segment.

sg: (C++: segment_t *) pointer to segment structure if nullptr, then set the register for
          all segments
rg: (C++: int) number of segment register
value: (C++: sel_t) its default value. this value will be used by get_sreg() if value
             of the register is unknown at the specified address.
return: success

set_sreg_at_next_code(ea1: ea_t, ea2: ea_t, rg: int, value: sel_t) ‑> void

set_sreg_at_next_code(ea1, ea2, rg, 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.

ea1: (C++: ea_t) address to start to search for an instruction
ea2: (C++: ea_t) the maximal address
rg: (C++: int) the segment register number
value: (C++: sel_t) the segment register value

split_sreg_range(ea: ea_t, rg: int, v: sel_t, tag: uchar, silent: bool = False) ‑> bool

split_sreg_range(ea, rg, v, tag, silent=False) -> bool Create a new segment register range. This function is used when the IDP emulator detects that a segment register changes its value.

ea: (C++: ea_t) linear address where the segment register will have a new value. if
          ea==BADADDR, nothing to do.
rg: (C++: int) the number of the segment register
v: (C++: sel_t) the new value of the segment register. If the value is unknown, you
         should specify BADSEL.
tag: (C++: uchar) the register info tag. see Segment register range tags
silent: (C++: bool) if false, display a warning() in the case of failure
return: success

Classes

sreg_range_t()

: Proxy of C++ sreg_range_t class.

__init__(self) -> sreg_range_t

Ancestors (in MRO)

* ida_range.range_t

Instance variables

  • tag: uchar tag


  • val: sel_t val


Last updated