IDA SDK

- Main Page
- Header Files
- Classes
- Modules

- File List
- File Members

Classes | Functions | Macros | Variables
srarea.hpp File Reference

## 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::regCodeSreg and processor_t::regDataSreg).

## Classes
struct | segreg_area_t
| The values of the segment registers are kept as address ranges. More...

## Functions
idaman sel_t ida_export | get_segreg (ea_t ea, int rg)
| Get value of a segment register. More...
idaman bool ida_export | split_srarea (ea_t ea, int rg, sel_t v, uchar tag, bool silent=false)
| Create a new segment register area. More...
idaman bool ida_export | set_default_segreg_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_srarea2 (segreg_area_t *out, ea_t ea, int rg)
| Get segment register area by linear address. More...
idaman bool ida_export | get_prev_srarea (segreg_area_t *out, ea_t ea, int rg)
| Get segment register area 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_srareas_qty2 (int rg)
| Get number of segment register areas. More...
idaman bool ida_export | getn_srarea2 (segreg_area_t *out, int rg, int n)
| Get segment register area by its number. More...
idaman int ida_export | get_srarea_num (int rg, ea_t ea)
| Get number of segment register area by address. More...
idaman bool ida_export | del_srarea (int rg, ea_t ea)
| Delete segment register area started at ea. More...
idaman void ida_export | copy_srareas (int dst_rg, int src_rg, bool map_selector=false)
| Duplicate segment register areas. More...

## Macros
#define | SR_inherit 1
| the value is inherited from the previous area
#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
#define | SUPPORT_OBSOLETE_SRAREA

## Variables
idaman areacb_t ida_export_data | SRareas
| Segment register area control block. More...

## Function Documentation

idaman sel_t ida_export get_segreg | ( | ea_t | ea,
|  | int | rg
| ) |  |

Get value of a segment register.

This function uses segment register area 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.

idaman bool ida_export split_srarea | ( | ea_t | ea,
|  | int | rg,
|  | sel_t | v,
|  | uchar | tag,
|  | bool | silent = `false`
| ) |  |

Create a new segment register area.

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 area tags
  silent | if false, display a warning() in the case of failure

Returns
  success

idaman bool ida_export set_default_segreg_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 NULL, then set the register for all segments
  rg | number of segment register
  value | its default value. this value will be used by get_segreg() if value of the register is unknown at the specified address.

Returns
  success

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 processor_t::setsgr 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

idaman bool ida_export get_srarea2 | ( | segreg_area_t * | out,
|  | ea_t | ea,
|  | int | rg
| ) |  |

Get segment register area by linear address.

Parameters

  rg | the segment register number
  ea | any linear address in the program
  out | segment register area

Returns
  success

idaman bool ida_export get_prev_srarea | ( | segreg_area_t * | out,
|  | ea_t | ea,
|  | int | rg
| ) |  |

Get segment register area previous to one with address.

Note
  more efficient then get_srarea2(reg, ea-1)

Parameters

  rg | the segment register number
  ea | any linear address in the program
  out | segment register area

Returns
  success

idaman size_t ida_export get_srareas_qty2 | ( | int | rg | ) |

Get number of segment register areas.

Parameters

  rg | the segment register number

idaman bool ida_export getn_srarea2 | ( | segreg_area_t * | out,
|  | int | rg,
|  | int | n
| ) |  |

Get segment register area by its number.

Parameters

  rg | the segment register number
  n | number of area (0..qty()-1)
  out | segment register area

Returns
  success

idaman int ida_export get_srarea_num | ( | int | rg,
|  | ea_t | ea
| ) |  |

Get number of segment register area by address.

Parameters

  rg | the segment register number
  ea | any address in the area

Returns
  -1 if no area occupies the specified address. otherwise returns number of the specified area (0..get_srareas_qty2()-1)

idaman bool ida_export del_srarea | ( | int | rg,
|  | ea_t | ea
| ) |  |

Delete segment register area started at ea.

When a segment register area is deleted, the previous area is extended to cover the empty space. The segment register area at the beginning of a segment can not be deleted.

Parameters

  rg | the segment register number
  ea | startEA of the deleted area

Returns
  success

idaman void ida_export copy_srareas | ( | int | dst_rg,
|  | int | src_rg,
|  | bool | map_selector = `false`
| ) |  |

Duplicate segment register areas.

Parameters

  dst_rg | number of destination segment register
  src_rg | copy areas from
  map_selector | map selectors to linear addresses using sel2ea()

## Variable Documentation

idaman areacb_t ida_export_data SRareas

Segment register area control block.

See area.hpp for explanations. OBSOLETE