| IDA SDK

Functions
Segment names
Segments

## Detailed Description

Various ways to retrieve the name of a segment.

## Functions
idaman int ida_export | set_segm_name (segment_t *s, const char *name, int flags=0)
| Rename segment. More...
idaman ssize_t ida_export | get_segm_name (qstring *buf, const segment_t *s, int flags=0)
| Get true segment name by pointer to segment. More...
ssize_t idaapi | get_visible_segm_name (qstring *buf, const segment_t *s)
| Get segment name by pointer to segment. More...
ssize_t | get_segm_expr (qstring *buf, ea_t from, sel_t sel)
| Get colored segment name expression in the form (segname + displacement). More...

## Function Documentation

## ◆ set_segm_name()

idaman int ida_export set_segm_name | ( | segment_t * | s,
|  | const char * | name,
|  | int | flags = `0`
| ) |  |

Rename segment.

The new name is validated (see validate_name). A segment always has a name. If you hadn't specified a name, the kernel will assign it "seg###" name where ### is segment number.

Parameters

  s | pointer to segment (may be nullptr)
  name | new segment name
  flags | ADDSEG_IDBENC or 0

Return values

  1 | ok, name is good and segment is renamed
  0 | failure, name is bad or segment is nullptr

## ◆ get_segm_name()

idaman ssize_t ida_export get_segm_name | ( | qstring * | buf,
|  | const segment_t * | s,
|  | int | flags = `0`
| ) |  |

Get true segment name by pointer to segment.

Parameters

  buf | output buffer. cannot be nullptr
  s | pointer to segment
  flags | 0-return name as is; 1-substitute bad symbols with _ 1 corresponds to GN_VISIBLE

Returns
  size of segment name (-1 if s==nullptr)

## ◆ get_visible_segm_name()

ssize_t idaapi get_visible_segm_name | ( | qstring * | buf,
|  | const segment_t * | s
| ) |  |
| inline

Get segment name by pointer to segment.

Parameters

  buf | output buffer. cannot be nullptr
  s | pointer to segment

Returns
  size of segment name (-1 if s==nullptr)

## ◆ get_segm_expr()

ssize_t get_segm_expr | ( | qstring * | buf,
|  | ea_t | from,
|  | sel_t | sel
| ) |  |

Get colored segment name expression in the form (segname + displacement).

Parameters

  buf | output buffer to hold segment expression
  from | linear address of instruction operand or data referring to the name. This address will be used to get fixup information, so it should point to exact position of operand in the instruction.
  sel | value to convert to segment expression

Returns
  size of segment expression or -1