C++ SDK Porting Guide from IDA 8.x to 9.0

IDA 9.0 API Changes and porting guide

Introduction

The largest change is the removal of two headers:

  • struct.hpp

  • enum.hpp

The functionalities for working with user-defined types are now available in typeinf.hpp (tinfo_t class).

struct.hpp

Removed classes

  • class member_t;

  • class struc_t;

struc_t is replaced by the notion of "user-defined type" (udt_type_data_t class) and member_t by dt member (udm_t class).

Removed APIs

  • get_struc_qty() Rough equivalent is get_ordinal_limit() or get_ordinal_count() but note that it also includes enums and typedefs.

  • get_first_struc_idx()

  • get_last_struc_idx()

  • get_prev_struc_idx()

  • get_next_struc_idx()

Local type ordinals always start at 1 (0 is invalid ordinal) and go up to get_ordinal_limit().

  • get_struc_idx(tid_t id)

  • get_struc_by_idx(uval_t idx)

enum.hpp

Enumerations are now manipulated via:

  • tinfo_t class

  • enum_type_data_t class

  • edm_t class. in typeinf.hpp

Removed APIs

  • get_enum_qty(void)

  • getn_enum(size_t idx)

  • get_enum_idx(enum_t id)

  • get_enum(const char *name)

  • is_bf(enum_t id)

  • is_enum_hidden(enum_t id)

  • set_enum_hidden(enum_t id, bool hidden)

  • is_enum_fromtil(enum_t id)

  • set_enum_fromtil(enum_t id, bool fromtil)

  • is_ghost_enum(enum_t id)

  • set_enum_ghost(enum_t id, bool ghost)

  • get_enum_name(qstring *out, enum_t id)

  • get_enum_name2(qstring *out, enum_t id, int flags=0)

  • get_enum_name(tid_t id, int flags=0)

  • get_enum_width(enum_t id)

  • set_enum_width(enum_t id, int width)

  • get_enum_cmt(qstring *buf, enum_t id, bool repeatable)

  • get_enum_size(enum_t id)

  • get_enum_flag(enum_t id)

  • get_enum_member_by_name(const char *name)

  • get_enum_member_value(const_t id)

  • get_enum_member_enum(const_t id)

  • get_enum_member_bmask(const_t id)

  • get_enum_member(enum_t id, uval_t value, int serial, bmask_t mask)

  • get_first_bmask(enum_t enum_id)

  • get_last_bmask(enum_t enum_id)

  • get_next_bmask(enum_t enum_id, bmask_t bmask\)

  • get_prev_bmask(enum_t enum_id, bmask_t bmask)

  • get_first_enum_member(enum_t id, bmask_t bmask=DEFMASK)

  • get_last_enum_member(enum_t id, bmask_t bmask=DEFMASK)

  • get_next_enum_member(enum_t id, uval_t value, bmask_t bmask=DEFMASK)

  • get_prev_enum_member(enum_t id, uval_t value, bmask_t bmask=DEFMASK)

  • get_enum_member_name(qstring *out, const_t id)

  • get_enum_member_cmt(qstring *buf, const_t id, bool repeatable)

  • get_first_serial_enum_member(uchar *out_serial, enum_t id, uval_t value, bmask_t bmask)

  • get_last_serial_enum_member(uchar *out_serial, enum_t id, uval_t value, bmask_t bmask)

  • get_next_serial_enum_member(uchar *in_out_serial, const_t first_cid)

  • get_prev_serial_enum_member(uchar *in_out_serial, const_t first_cid)

  • for_all_enum_members(enum_t id, enum_member_visitor_t &cv)

  • ida_export get_enum_member_serial(const_t cid)

  • get_enum_type_ordinal(enum_t id)

  • set_enum_type_ordinal(enum_t id, int32 ord)

  • add_enum(size_t idx, const char *name, flags64_t flag)

  • del_enum(enum_t id)

  • set_enum_idx(enum_t id, size_t idx)

  • set_enum_bf(enum_t id, bool bf)

  • set_enum_name(enum_t id, const char *name)

  • set_enum_cmt(enum_t id, const char *cmt, bool repeatable)

  • set_enum_flag(enum_t id, flags64_t flag)

  • add_enum_member(enum_t id, const char *name, uval_t value, bmask_t bmask=DEFMASK)

  • del_enum_member(enum_t id, uval_t value, uchar serial, bmask_t bmask)

  • set_enum_member_name(const_t id, const char *name)

  • set_enum_member_cmt(const_t id, const char *cmt, bool repeatable)

  • is_one_bit_mask(bmask_t mask)

  • set_bmask_name(enum_t id, bmask_t bmask, const char *name)

  • get_bmask_name(qstring *out, enum_t id, bmask_t bmask)

  • set_bmask_cmt(enum_t id, bmask_t bmask, const char *cmt, bool repeatable)

  • get_bmask_cmt(qstring *buf, enum_t id, bmask_t bmask, bool repeatable)

bytes.hpp

Added APIs

  • idaman ea_t ida_export find_binary(ea_t startea, ea_t endea, const char *ubinstr, int radix, int sflag, int strlits_encoding=0)

Modified APIs

Removed APIs

  • bin_search2(ea_t start_ea, ea_t end_ea, const compiled_binpat_vec_t &data, int flags)

  • bin_search(ea_t, ea_t, const uchar *, const uchar *, size_t, int, int)

  • get_8bit(ea_t *ea, uint32 *v, int *nbit)

  • get_octet(ea_t *ea, uint64 *v, int *nbit)

  • free_chunk(ea_t bottom, asize_t size, int32 step)

dirtree.hpp

Modified APIs

diskio.hpp

Modified APIs

Removed APIs

  • ecreate(const char *file)

  • eclose(FILE *fp)

  • eread(FILE *fp, void *buf, size_t size)

  • ewrite(FILE *fp, const void *buf, size_t size)

  • eseek(FILE *fp, qoff64_t pos)

  • enumerate_files(char *answer, size_t answer_size, const char *path, const char *fname, int (idaapi*func)(const char *file,void *ud), void *ud=nullptr)

err.h

Removed APIs

  • qerrcode(int new_code=-1)

expr.hpp

Modified APIs

frame.hpp

Added APIs

  • idaman bool ida_export add_frame_member(const func_t *pfn, const char *name, uval_t offset, const tinfo_t &tif, const struct value_repr_t *repr=nullptr, uint etf_flags=0)

  • THREAD_SAFE bool is_anonymous_member_name(const char *name)

  • THREAD_SAFE bool is_dummy_member_name(const char *name)

  • idaman bool ida_export is_special_frame_member(tid_t tid)

  • idaman bool ida_export set_frame_member_type(const func_t *pfn, uval_t offset, const tinfo_t &tif, const struct value_repr_t *repr=nullptr, uint etf_flags=0)

  • idaman bool ida_export delete_frame_members(const func_t *pfn, uval_t start_offset, uval_t end_offset)

  • idaman sval_t ida_export calc_frame_offset(func_t *pfn, sval_t off, const insn_t *insn = nullptr, const op_t *op = nullptr)

Modified PIs

Removed APIs

  • get_frame_member_by_id(qstring *out_mname, struc_t **out_fptr, tid_t mid)

  • get_stkvar(sval_t *actval, const insn_t &insn, const op_t &x, sval_t v) See get_stkvar in ida_typeinf.tinfo_t

  • get_min_spd_ea(func_t *pfn)

  • delete_unreferenced_stkvars(func_t *pfn)

  • delete_wrong_stkvar_ops(func_t *pfn)

funcs.hpp

Added APIs

  • bool func_item_iterator_t::set_ea(ea_t _ea)

Removed APIs

  • save_signatures(void)

  • invalidate_sp_analysis(func_t *pfn)

  • invalidate_sp_analysis(ea_t ea)

gdl.hpp

Added classes/structures

  • struct edge_t

  • class node_ordering_t

hexrays.hpp

Added classes/structures

  • class control_graph_t

  • class edge_mapper_t

  • class node_bitset_t

  • class array_of_node_bitset_t

  • struct ctry_t

  • struct cthrow_t

  • struct catchexpr_t

  • struct ccatch_t

  • struct cblock_pos_t

Added APIs

  • uvlr_t max_vlr_value(int size)

  • uvlr_t min_vlr_svalue(int size)

  • uvlr_t max_vlr_svalue(int size)

  • bool is_unsigned_cmpop(cmpop_t cmpop)

  • bool is_signed_cmpop(cmpop_t cmpop)

  • bool is_cmpop_with_eq(cmpop_t cmpop)

  • bool is_cmpop_without_eq(cmpop_t cmpop)

lvar_t

  • bool was_scattered_arg() const

  • void set_scattered_arg()

  • void clr_scattered_arg()

lvars_t

  • int find_input_reg(int reg, int _size=1)

simple_graph_t

  • virtual bool ignore_edge(int /*src*/, int /*dst*/ ) const

  • void hexapi compute_dominators(array_of_node_bitset_t &domin, bool post=false) const

  • void hexapi compute_immediate_dominators(const array_of_node_bitset_t &domin, intvec_t &idomin, bool post=false) const

  • int hexapi depth_first_preorder(node_ordering_t *pre) const

  • int hexapi depth_first_postorder(node_ordering_t *post) const

  • void depth_first_postorder(node_ordering_t *post, edge_mapper_t *et) const

  • void depth_first_postorder_for_all_entries(node_ordering_t *post) const

  • intvec_t find_dead_nodes() const

  • void find_reaching_nodes(int n, node_bitset_t &reaching) const

  • bool path_exists(int m, int n) const

  • bool path_back(const array_of_node_bitset_t &domin, int m, int n) const

  • bool path_back(const edge_mapper_t &et, int m, int n) const

  • iterator begin() const

  • iterator end()

  • int front()

  • void inc(iterator &p, int n=1) const

  • virtual int hexapi goup(int node) const

fnumber_t

  • int calc_max_exp() const

  • bool is_nan() const

minsn_t

  • bool was_unpaired() const

mba_t

  • mblock_t *hexapi split_block(mblock_t *blk, minsn_t *start_insn)

  • merror_t hexapi inline_func(codegen_t &cdg, int blknum, mba_ranges_t &ranges, int decomp_flags=0, int inline_flags=0)

  • const stkpnt_t *hexapi locate_stkpnt(ea_t ea) const

codegen_t

  • void hexapi clear()

vd_failure_t

  • virtual const char *what() const noexcept override

Modified APIs

stkvar_ref_t

mop_t

mba_t

valrng_t

Removed APIs:

  • bool hexapi get_member_type(const member_t *mptr, tinfo_t *type)

  • bool hexapi checkout_hexrays_license(bool silent)

  • bool get_member_type(const member_t *mptr, tinfo_t *type)

valrng_t

  • static uvlr_t max_value(int size_)

  • static uvlr_t min_svalue(int size_)

  • static uvlr_t max_svalue(int size_)

ctree_item_t

  • member_t *hexapi get_memptr(struc_t **p_sptr=nullptr) const

ctree_parentee_t

  • cblock_t *get_block()

vdui_t

  • bool hexapi set_strmem_type(struc_t *sptr, member_t *mptr)

  • bool hexapi rename_strmem(struc_t *sptr, member_t *mptr)

graph.hpp

Removed classes/structures

  • class node_ordering_t See code

  • struct edge_t See code

Modified classes/structures

Modified APIs

idalib.hpp

The new header for the IDA library

Added APIs

  • idaman int ida_export init_library(int argc = 0, char *argv[] = nullptr)

  • idaman int ida_export open_database(const char *file_path, bool run_auto)

  • idaman void ida_export close_database(bool save)

idd.hpp

Added APIs

  • idaman int ida_export cpu2ieee(fpvalue_t *ieee_out, const void *cpu_fpval, int size)

  • idaman int ida_export ieee2cpu(void *cpu_fpval, const fpvalue_t &ieee_out, int size)

idp.hpp

Removed APIs:

  • processor_t::has_realcvt(void) const

Modified APIs:

Added APIs

procmod_t

  • const op_t *procmod_t::make_op_reg(op_t *op, int reg, int8 dtype = -1) const

  • const op_t *procmod_t::make_op_imm(op_t *op, uval_t val, int8 dtype = -1) const

  • const op_t *procmod_t::make_op_displ(op_t *op, int base_reg, uval_t displ, int8 dtype = -1) const

  • const op_t *procmod_t::make_op_phrase(op_t *op, int base_reg, int index_reg, int8 dtype = -1) const

See also IDB events for a table providing a list a event replacement and removal.

kernwin.hpp

Removed APIs

  • open_enums_window(tid_t const_id=BADADDR)

  • open_structs_window(tid_t id=BADADDR, uval_t offset=0)

  • choose_struc(const char *title)

  • choose_enum_by_value(const char *title, enum_t default_id, uint64 value, int nbytes, uchar *serial)

Removed classes/structures

  • class enumplace_t

  • class structplace_t

Added APIs

  • bool is_ida_library(char *path, size_t pathsize, void** handle)

tagged_line_section_t

  • const tagged_line_section_t::tagged_line_section_t *nearest_before(const tagged_line_section_t &range, cpidx_t start, color_t tag=0) const

  • const tagged_line_section_t::tagged_line_section_t *nearest_after(const tagged_line_section_t &range, cpidx_t start, color_t tag=0) const

chooser_base_t

  • bool chooser_base_t::has_widget_lifecycle() const

Modified APIs

lex.hpp

Modified APIs

lines.hpp

Removed APIs

  • set_user_defined_prefix(size_t width, void (idaapi *get_user_defined_prefix)(qstring *buf, ea_t ea, int lnnum, int indent, const char *line))

Modified APIs

nalt.hpp

Modified APIs

parsejson.hpp

Added APIs

jvalue_t

  • void jvalue_t::set_str(const char *s)

jobj_t

  • void jobj_t::put(const char *key, const jobj_t &value)

pro.h

Removed APIs

  • unpack_memory(void *buf, size_t size, const uchar **pptr, const uchar *end)

Added APIs

  • idaman THREAD_SAFE bool ida_export get_login_name(qstring *out)

  • idaman void *ida_export pipe_process(qhandle_t *read_handle, qhandle_t *write_handle, launch_process_params_t *lpp, qstring *errbuf=nullptr)

bytevec_t

  • qstring bytevec_t::tohex(bool upper_case=true) const

qlist

  • void qlist::splice(iterator pos, qlist &other, iterator first, iterator last)

Added classes/structures

  • struct memory_serializer_t

regex.hpp

Removed APIs

  • regcomp(struct regex_t *preg, const char *pattern, int cflags)

  • regerror(int errcode, const struct regex_t *preg, char *errbuf, size_t errbuf_size)

  • regexec(const struct regex_t *preg, const char *str, size_t nmatch, struct regmatch_t pmatch[], int eflags)

  • regfree(struct regex_t *preg)

regfinder.hpp

Modified APIs

Removed APIs

  • reg_finder_op_make_rfop(func_t *pfn, const insn_t &insn, const op_t &op)

Added APIs

  • void reg_value_info_t::movt(const reg_value_info_t &r, const insn_t &insn)

  • static int reg_finder_op_t::get_op_width(const op_t &op)

  • static reg_finder_op_t reg_finder_op_t::make_stkoff(sval_t stkoff, int width)

registry.hpp

Removed APIs

  • reg_load(void)

  • reg_flush(void)

search.hpp

Removed APIs

  • user2bin(uchar *, uchar *, ea_t, const char *, int, bool)

  • find_binary(ea_t, ea_t, const char *, int, int)

typeinf.hpp

Removed APIs

  • set_numbered_type(til_t *ti, uint32 ordinal, int ntf_flags, const char *name, const type_t *type, const p_list *fields=nullptr, const char *cmt=nullptr, const p_list *fldcmts=nullptr, const sclass_t *sclass=nullptr)

  • get_ordinal_from_idb_type(const char *name, const type_t *type)

  • is_autosync(const char *name, const type_t *type)

  • is_autosync(const char *name, const tinfo_t &tif)

  • import_type(const til_t *til, int idx, const char *name, int flags=0)

  • get_udm_tid(const udm_t *udm, const char *udt_name)

Modified APIs

Added classes/structures

  • struct udm_visitor_t

Added APIs

  • bool ida_export detach_tinfo_t(tinfo_t *_this)

  • bool stroff_as_size(int plen, const tinfo_t &tif, asize_t value)

  • int ida_export visit_stroff_udms(udm_visitor_t &sfv, const tid_t *path, int plen, adiff_t *disp, bool appzero)

  • bool is_one_bit_mask(uval_t mask)

til_t

  • til_t *til_t::find_base(const char *n)

callregs_t

  • void callregs_t::set_registers(reg_kind_t kind, int first_reg, int last_reg)

tinfo_t

  • bool tinfo_t::get_named_type(const char *name, type_t decl_type=BTF_TYPEDEF, bool resolve=true, bool try_ordinal=true)

  • bool tinfo_t::get_numbered_type(uint32 ordinal, type_t decl_type=BTF_TYPEDEF, bool resolve=true)

  • bool tinfo_t::detach()

  • bool tinfo_t::is_punknown()

  • int tinfo_t::find_udm(uint64 offset, int strmem_flags=0) const

  • int tinfo_t::find_udm(const char *name, int strmem_flags=0) const

  • size_t tinfo_t::get_enum_nmembers() const

  • bool tinfo_t::is_empty_enum() const

  • tinfo_code_t tinfo_t::get_enum_repr(value_repr_t *repr) const

  • int tinfo_t::get_enum_width() const

  • uint64 tinfo_t::calc_enum_mask() const

  • tid_t tnfo_t::get_edm_tid(size_t idx) const

  • tinfo_t tinfo_t::get_innermost_member_type(uint64 bitoffset, uint64 *out_bitoffset=nullptr) const

  • bool tinfo_t::is_udm_by_til(size_t idx) const

  • tinfo_code_t tinfo_t::set_udm_by_til(size_t idx, bool on=true, uint etf_flags=0)

  • tinfo_code_t tinfo_t::set_fixed_struct(bool on=true)

  • tinfo_code_t tinfo_t::set_struct_size(size_t new_size)

  • bool tinfo_t::is_fixed_struct() const

  • bool tinfo_t::get_func_frame(const func_t *pfn)

  • bool tinfo_t::is_frame() const

  • ea_t tinfo_t::get_frame_func() const

  • ssize_t tinfo_t::get_stkvar(sval_t *actval, const insn_t &insn, const op_t *x, sval_t v)

  • tinfo_code_t tinfo_t::set_enum_radix(int radix, bool sign, uint etf_flags=0)

  • tinfo_code_t tinfo_t::set_funcarg_type(size_t index, const tinfo_t &tif, uint etf_flags=0)

  • tinfo_code_t tinfo_t::set_func_rettype(const tinfo_t &tif, uint etf_flags=0)

  • tinfo_code_t tinfo_t::del_funcargs(size_t idx1, size_t idx2, uint etf_flags=0)

  • tinfo_code_t tinfo_t::del_funcarg(size_t idx, uint etf_flags=0)

  • tinfo_code_t tinfo_t::add_funcarg(const funcarg_t &farg, uint etf_flags=0, ssize_t idx=-1)

  • tinfo_code_t tinfo_t::set_func_cc(cm_t cc, uint etf_flags=0)

  • tinfo_code_t tinfo_t::set_funcarg_loc(size_t index, const argloc_t &argloc, uint etf_flags=0)

  • tinfo_code_t tinfo_t::et_func_retloc(const argloc_t &argloc, uint etf_flags=0)

func_type_data_t

  • ssize_t func_type_data_t::find_argument(const char *name, size_t from=0, size_t to=size_t(-1)) const

enum_type_data_t

  • tinfo_code_t enum_type_data_t::get_value_repr(value_repr_t *repr) const

  • uchar enum_type_data_t::get_serial(size_t index) const

  • uchar enum_type_data_t::get_max_serial(uint64 value) const

udm_t

  • bool udm_t::is_retaddr() const

  • bool udm_t::is_savregs() const

  • bool udm_t::is_special_member() const

  • bool udm_t::is_by_til() const

  • void udm_t::set_retaddr(bool on=true)

  • void udm_t::set_savregs(bool on=true)

  • void udm_t::set_by_til(bool on=true)

udt_type_data_t

  • bool udt_type_data_t::is_fixed() const

  • void udt_type_data_t::set_fixed(bool on=true)

IDB events

The following table provide a list of IDB events that have been replaced or, in some cases, removed.

Last updated