| IDA SDK

Functions
Numbered types

## Detailed Description

Functions to work with numbered (ordinal) types.

Numbered types may be named or anonymous. They are referenced by their ordinal number. Access to them is faster because there is no need to resolve their names. Also, they can stay anonymous and be aliased. They can be used only in the local type library created by IDA (in idati).

## Functions
idaman bool ida_export | enable_numbered_types (til_t *ti, bool enable)
| Enable the use of numbered types in til. More...
idaman bool ida_export | get_numbered_type (const til_t *ti, uint32 ordinal, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr)
| Retrieve a type by its ordinal number.
idaman uint32 ida_export | alloc_type_ordinals (til_t *ti, int qty)
| Allocate a range of ordinal numbers for new types. More...
uint32 | alloc_type_ordinal (til_t *ti)
| alloc_type_ordinals(ti, 1)
idaman uint32 ida_export | get_ordinal_limit (const til_t *ti=nullptr)
| Get number of allocated ordinals + 1. More...
uint32 | get_ordinal_count (const til_t *ti=nullptr)
| Get number of allocated ordinals. More...
idaman bool ida_export | del_numbered_type (til_t *ti, uint32 ordinal)
| Delete a numbered type.
idaman bool ida_export | set_type_alias (til_t *ti, uint32 src_ordinal, uint32 dst_ordinal)
| Create a type alias. More...
idaman uint32 ida_export | get_alias_target (const til_t *ti, uint32 ordinal)
| Find the final alias destination. More...
idaman int32 ida_export | get_type_ordinal (const til_t *ti, const char *name)
| Get type ordinal by its name.
idaman const char *ida_export | get_numbered_type_name (const til_t *ti, uint32 ordinal)
| Get type name (if exists) by its ordinal. More...
idaman ssize_t ida_export | create_numbered_type_name (qstring *buf, int32 ord)
| Create anonymous name for numbered type. More...
idaman bool ida_export | is_ordinal_name (const char *name, uint32 *ord=nullptr)
| Check if the name is an ordinal name. More...
idaman void ida_export | build_anon_type_name (qstring *buf, const type_t *type, const p_list *fields)
| Generate a name like $hex_numbers based on the field types and names.
idaman int ida_export | compact_numbered_types (til_t *ti, uint32 min_ord=0, intvec_t *p_ordmap=nullptr, int flags=0)
| Compact numbered types to get rid of empty slots. More...
idaman bool ida_export | is_type_choosable (const til_t *ti, uint32 ordinal)
| Check if a struct/union type is choosable. More...
idaman void ida_export | set_type_choosable (til_t *ti, uint32 ordinal, bool value)
| Enable/disable 'choosability' flag for a struct/union type. More...

## Function Documentation

## ◆ enable_numbered_types()

idaman bool ida_export enable_numbered_types | ( | til_t * | ti,
|  | bool | enable
| ) |  |

Enable the use of numbered types in til.

Currently it is impossible to disable numbered types once they are enabled

## ◆ alloc_type_ordinals()

idaman uint32 ida_export alloc_type_ordinals | ( | til_t * | ti,
|  | int | qty
| ) |  |

Allocate a range of ordinal numbers for new types.

Parameters

  ti | type library
  qty | number of ordinals to allocate

Returns
  the first ordinal. 0 means failure.

## ◆ get_ordinal_limit()

idaman uint32 ida_export get_ordinal_limit | ( | const til_t * | ti = `nullptr` | ) |

Get number of allocated ordinals + 1.

If there are no allocated ordinals, return 0. To enumerate all ordinals, use: for ( uint32 i = 1; i < limit; ++i )

Parameters

  ti | type library; nullptr means the local types for the current database.

Returns
  uint32(-1) if ordinals have not been enabled for the til. For local types (idati), ordinals are always enabled.

## ◆ get_ordinal_count()

uint32 get_ordinal_count | ( | const til_t * | ti = `nullptr` | ) |
| inline

Get number of allocated ordinals.

Parameters

  ti | type library; nullptr means the local types for the current database.

Returns
  0 if ordinals have not been enabled for the til.

## ◆ set_type_alias()

idaman bool ida_export set_type_alias | ( | til_t * | ti,
|  | uint32 | src_ordinal,
|  | uint32 | dst_ordinal
| ) |  |

Create a type alias.

Redirects all references to source type to the destination type. This is equivalent to instantaneous replacement all references to srctype by dsttype.

## ◆ get_alias_target()

idaman uint32 ida_export get_alias_target | ( | const til_t * | ti,
|  | uint32 | ordinal
| ) |  |

Find the final alias destination.

If the ordinal has not been aliased, return the specified ordinal itself If failed, returns 0.

## ◆ get_numbered_type_name()

idaman const char *ida_export get_numbered_type_name | ( | const til_t * | ti,
|  | uint32 | ordinal
| ) |  |

Get type name (if exists) by its ordinal.

If the type is anonymous, returns "". If failed, returns nullptr

## ◆ create_numbered_type_name()

idaman ssize_t ida_export create_numbered_type_name | ( | qstring * | buf,
|  | int32 | ord
| ) |  |

Create anonymous name for numbered type.

This name can be used to reference a numbered type by its ordinal Ordinal names have the following format: '#' + set_de(ord) Returns: -1 if error, otherwise the name length

## ◆ is_ordinal_name()

idaman bool ida_export is_ordinal_name | ( | const char * | name,
|  | uint32 * | ord = `nullptr`
| ) |  |

Check if the name is an ordinal name.

Ordinal names have the following format: '#' + set_de(ord)

## ◆ compact_numbered_types()

idaman int ida_export compact_numbered_types | ( | til_t * | ti,
|  | uint32 | min_ord = `0`,
|  | intvec_t * | p_ordmap = `nullptr`,
|  | int | flags = `0`
| ) |  |

Compact numbered types to get rid of empty slots.

Parameters

  ti | type library to compact
  min_ord | minimal ordinal number to start to compact. lower ordinals are not modified
  p_ordmap | the resulting mapping (for example, the new ordinal of min_ord will be in ordmap[0])
  flags | reserved

Returns
  number of freed type slots

## ◆ is_type_choosable()

idaman bool ida_export is_type_choosable | ( | const til_t * | ti,
|  | uint32 | ordinal
| ) |  |

Check if a struct/union type is choosable.

Parameters

  ti | type library
  ordinal | ordinal number of a UDT type

## ◆ set_type_choosable()

idaman void ida_export set_type_choosable | ( | til_t * | ti,
|  | uint32 | ordinal,
|  | bool | value
| ) |  |

Enable/disable 'choosability' flag for a struct/union type.

Parameters

  ti | type library
  ordinal | ordinal number of a UDT type
  value | flag value