IDA SDK
Public Attributes | Public Member Functions | Public Types | List of all members
processor_t Struct Reference

Detailed Description

Describes a processor module (IDP).

An IDP file may have only one such structure called LPH. The kernel will copy it to ph structure and use ph.

Public Attributes

int32 version
 Expected kernel version, should be IDP_INTERFACE_VERSION.
 
int32 id
 one of Processor IDs
 
uint32 flag
 Processor feature bits
 
uint32 flag2
 Processor additional feature bits
 
int32 cnbits
 Number of bits in a byte for code segments (usually 8). More...
 
int32 dnbits
 Number of bits in a byte for non-code segments (usually 8). More...
 
const asm_t *const * assemblers
 pointer to array of target assembler definitions. More...
 
hook_cb_t_notify
 Event notification handler.
 
const char *const * reg_names
 array of register names
 
int32 regs_num
 number of registers
 
size_t tbyte_size
 Size of long double (tbyte) for this processor (meaningful only if asm_t::a_tbyte != NULL)
 
char real_width [4]
 Number of digits in floating numbers after the decimal point. More...
 
int32 icode_return
 Icode of return instruction. It is ok to give any of possible return instructions.
 
void * unused_slot
 Reserved, currently equals to NULL.
 
Names

IDP module may support several compatible processors.

The following arrays define processor names:

const char *const * psnames
 short processor names (NULL terminated). More...
 
const char *const * plnames
 long processor names (NULL terminated). More...
 
Segment registers

Segment register information (use virtual CS and DS registers if your processor doesn't have segment registers):

int32 reg_first_sreg
 number of first segment register
 
int32 reg_last_sreg
 number of last segment register
 
int32 segreg_size
 size of a segment register in bytes
 
Virtual segment registers

If your processor doesn't have segment registers, you should define 2 virtual segment registers for CS and DS.

Let's call them rVcs and rVds.

int32 reg_code_sreg
 number of CS register
 
int32 reg_data_sreg
 number of DS register
 
Empirics
const bytes_tcodestart
 Array of typical code start sequences. More...
 
const bytes_tretcodes
 Array of 'return' instruction opcodes. More...
 

Public Member Functions

bool has_idp_opts (void) const
 #PR_IDP_OPTS
 
bool has_realcvt (void) const
 #PR_REALCVT
 
bool has_segregs (void) const
 PR_SEGS
 
bool use32 (void) const
 PR_USE64 or PR_USE32
 
bool use64 (void) const
 PR_USE64
 
bool ti (void) const
 PR_TYPEINFO
 
bool stkup (void) const
 PR_STACK_UP
 
bool use_tbyte (void) const
 PR_USE_TBYTE
 
bool use_mappings (void) const
 PR2_MAPPINGS
 
int get_segm_bitness (void) const
 Get segment bitness. More...
 
ssize_t notify (event_t event_code,...)
 
int init (const char *idp_modname)
 
int term ()
 
int newprc (int pnum, bool keep_cfg)
 
int newasm (int asmnum)
 
int newfile (const char *fname)
 
int oldfile (const char *fname)
 
int newbinary (const char *filename, qoff64_t fileoff, ea_t basepara, ea_t binoff, uint64 nbytes)
 
int endbinary (bool ok)
 
int creating_segm (segment_t *seg)
 
int assemble (uchar *_bin, ea_t ea, ea_t cs, ea_t ip, bool _use32, const char *line)
 
int ana_insn (insn_t *out)
 
int emu_insn (const insn_t &insn)
 
int out_header (outctx_t &ctx)
 
int out_footer (outctx_t &ctx)
 
int out_segstart (outctx_t &ctx, segment_t *seg)
 
int out_segend (outctx_t &ctx, segment_t *seg)
 
int out_assumes (outctx_t &ctx)
 
int out_insn (outctx_t &ctx)
 
int out_mnem (outctx_t &ctx)
 
int out_operand (outctx_t &ctx, const op_t &op)
 
int out_data (outctx_t &ctx, bool analyze_only)
 
int out_label (outctx_t &ctx, const char *colored_name)
 
int out_special_item (outctx_t &ctx, uchar segtype)
 
int gen_stkvar_def (outctx_t &ctx, const class member_t *mptr, sval_t v)
 
int gen_regvar_def (outctx_t &ctx, regvar_t *v)
 
int gen_src_file_lnnum (outctx_t &ctx, const char *file, size_t lnnum)
 
int rename (ea_t ea, const char *new_name, int flags)
 
int may_show_sreg (ea_t current_ea)
 
int coagulate (ea_t start_ea)
 
int auto_queue_empty (int type)
 
int func_bounds (int *possible_return_code, func_t *pfn, ea_t max_func_end_ea)
 
int may_be_func (const insn_t &insn, int state)
 
int is_sane_insn (const insn_t &insn, int no_crefs)
 
int cmp_operands (const op_t &op1, const op_t &op2)
 
int is_jump_func (func_t *pfn, ea_t *jump_target, ea_t *func_pointer)
 
int is_basic_block_end (const insn_t &insn, bool call_insn_stops_block)
 
int getreg (uval_t *rv, int regnum)
 
int undefine (ea_t ea)
 
int moving_segm (segment_t *seg, ea_t to, int flags)
 
int is_sp_based (const insn_t &insn, const op_t &x)
 
int is_far_jump (int icode)
 
int is_call_insn (const insn_t &insn)
 
int is_ret_insn (const insn_t &insn, bool strict)
 
int is_align_insn (ea_t ea)
 
int can_have_type (const op_t &op)
 
int get_stkvar_scale_factor ()
 
int create_flat_group (ea_t image_base, int bitness, sel_t dataseg_sel)
 
int is_alloca_probe (ea_t ea)
 
int get_reg_name (qstring *buf, int reg, size_t width, int reghi)
 
int gen_asm_or_lst (bool starting, FILE *fp, bool is_asm, int flags, void *outline)
 
int gen_map_file (int *nlines, FILE *fp)
 
int get_autocmt (qstring *buf, const insn_t &insn)
 
int is_insn_table_jump (const insn_t &insn)
 
int loader_elf_machine (linput_t *li, int machine_type, const char **p_procname, proc_def_t **p_pd)
 
int is_indirect_jump (const insn_t &insn)
 
int verify_noreturn (func_t *pfn)
 
int verify_sp (func_t *pfn)
 
int create_func_frame (func_t *pfn)
 
int get_frame_retsize (int *retsize, const func_t *pfn)
 
int treat_hindering_item (ea_t hindering_item_ea, flags_t new_item_flags, ea_t new_item_ea, asize_t new_item_length)
 
int extract_address (ea_t *out_ea, ea_t screen_ea, const char *string, size_t x)
 
int str2reg (const char *regname)
 
int is_switch (switch_info_t *si, const insn_t &insn)
 
int create_switch_xrefs (ea_t jumpea, const switch_info_t &si)
 
int calc_switch_cases (void *casevec, eavec_t *targets, ea_t insn_ea, const switch_info_t &si)
 
int get_bg_color (bgcolor_t *color, ea_t ea)
 
int validate_flirt_func (ea_t start_ea, const char *funcname)
 
int get_operand_string (qstring *buf, const insn_t &insn, int opnum)
 
int add_cref (ea_t from, ea_t to, cref_t type)
 
int add_dref (ea_t from, ea_t to, dref_t type)
 
int del_cref (ea_t from, ea_t to, bool expand)
 
int del_dref (ea_t from, ea_t to)
 
int coagulate_dref (ea_t from, ea_t to, bool may_define, ea_t *code_ea)
 
const char * set_idp_options (const char *keyword, int vtype, const void *value)
 
int set_proc_options (const char *options, int confidence)
 
int adjust_libfunc_ea (const idasgn_t &sig, const libfunc_t &libfun, ea_t *ea)
 
int realcvt (void *m, unsigned short *e, unsigned short swt)
 
int delay_slot_insn (ea_t *ea, bool *bexec, bool *fexec)
 
int adjust_refinfo (refinfo_t *ri, ea_t ea, int n, const fixup_data_t &fd)
 
int is_cond_insn (const insn_t &insn)
 
int next_exec_insn (ea_t *target, ea_t ea, int tid, regval_getter_t *_getreg, const regval_t &regvalues)
 
int calc_step_over (ea_t *target, ea_t ip)
 
int get_macro_insn_head (ea_t *head, ea_t ip)
 
int get_dbr_opnum (int *opnum, const insn_t &insn)
 
int insn_reads_tbit (const insn_t &insn, regval_getter_t *_getreg, const regval_t &regvalues)
 
int get_idd_opinfo (idd_opinfo_t *opinf, ea_t ea, int n, int thread_id, regval_getter_t *_getreg, const regval_t &regvalues)
 
int calc_next_eas (eavec_t *res, const insn_t &insn, bool over)
 
int clean_tbit (ea_t ea, regval_getter_t *_getreg, const regval_t &regvalues)
 
int get_reg_info (const char **main_regname, bitrange_t *bitrange, const char *regname)
 
int setup_til ()
 
int max_ptr_size ()
 
int get_default_enum_size (cm_t cm)
 
int calc_cdecl_purged_bytes (ea_t ea)
 
int get_stkarg_offset ()
 
int equal_reglocs (const argloc_t &a1, const argloc_t &a2)
 
int decorate_name (qstring *outbuf, const char *name, bool mangle, cm_t cc, const tinfo_t &type)
 
int calc_retloc (argloc_t *retloc, const tinfo_t &rettype, cm_t cc)
 
int calc_varglocs (func_type_data_t *ftd, regobjs_t *regs, relobj_t *stkargs, int nfixed)
 
int calc_arglocs (func_type_data_t *fti)
 
int use_stkarg_type (ea_t ea, const funcarg_t &arg)
 
int use_regarg_type (int *idx, ea_t ea, void *rargs)
 
int use_arg_types (ea_t ea, func_type_data_t *fti, void *rargs)
 
int calc_purged_bytes (int *p_purged_bytes, const func_type_data_t &fti)
 
int shadow_args_size (int *shadow_size, func_t *pfn)
 
int get_cc_regs (callregs_t *regs, cm_t cc)
 
int get_simd_types (void *out, const simd_info_t *simd_attrs, const argloc_t *argloc, bool create_tifs)
 
int arg_addrs_ready (ea_t caller, int n, const tinfo_t &tif, ea_t *addrs)
 
int adjust_argloc (argloc_t *argloc, const tinfo_t *type, int size)
 
int lower_func_type (intvec_t *argnums, func_type_data_t *fti)
 
int get_abi_info (qstrvec_t *abi_names, qstrvec_t *abi_opts, comp_t comp)
 
int get_stkvar_scale (void)
 Get the stack variable scaling factor. More...
 
Byte size

Number of 8bit bytes required to hold one byte of the target processor.

int cbsize (void)
 for code segments
 
int dbsize (void)
 for non-code segments
 

Public Types

enum  event_t {
  ev_init, ev_term, ev_newprc, ev_newasm,
  ev_newfile, ev_oldfile, ev_newbinary, ev_endbinary,
  ev_set_idp_options, ev_set_proc_options, ev_ana_insn, ev_emu_insn,
  ev_out_header, ev_out_footer, ev_out_segstart, ev_out_segend,
  ev_out_assumes, ev_out_insn, ev_out_mnem, ev_out_operand,
  ev_out_data, ev_out_label, ev_out_special_item, ev_gen_stkvar_def,
  ev_gen_regvar_def, ev_gen_src_file_lnnum, ev_creating_segm, ev_moving_segm,
  ev_coagulate, ev_undefine, ev_treat_hindering_item, ev_rename,
  ev_is_far_jump, ev_is_sane_insn, ev_is_cond_insn, ev_is_call_insn,
  ev_is_ret_insn, ev_may_be_func, ev_is_basic_block_end, ev_is_indirect_jump,
  ev_is_insn_table_jump, ev_is_switch, ev_calc_switch_cases, ev_create_switch_xrefs,
  ev_is_align_insn, ev_is_alloca_probe, ev_delay_slot_insn, ev_is_sp_based,
  ev_can_have_type, ev_cmp_operands, ev_adjust_refinfo, ev_get_operand_string,
  ev_get_reg_name, ev_str2reg, ev_get_autocmt, ev_get_bg_color,
  ev_is_jump_func, ev_func_bounds, ev_verify_sp, ev_verify_noreturn,
  ev_create_func_frame, ev_get_frame_retsize, ev_get_stkvar_scale_factor, ev_demangle_name,
  ev_add_cref, ev_add_dref, ev_del_cref, ev_del_dref,
  ev_coagulate_dref, ev_may_show_sreg, ev_loader_elf_machine, ev_auto_queue_empty,
  ev_validate_flirt_func, ev_adjust_libfunc_ea, ev_assemble, ev_extract_address,
  ev_realcvt, ev_gen_asm_or_lst, ev_gen_map_file, ev_create_flat_group,
  ev_getreg, ev_last_cb_before_debugger, ev_next_exec_insn = 1000, ev_calc_step_over,
  ev_calc_next_eas, ev_get_macro_insn_head, ev_get_dbr_opnum, ev_insn_reads_tbit,
  ev_clean_tbit, ev_get_idd_opinfo, ev_get_reg_info, ev_last_cb_before_type_callbacks,
  ev_setup_til = 2000, ev_get_abi_info, ev_max_ptr_size, ev_get_default_enum_size,
  ev_get_cc_regs, ev_get_stkarg_offset, ev_shadow_args_size, ev_get_simd_types,
  ev_calc_cdecl_purged_bytes, ev_calc_purged_bytes, ev_calc_retloc, ev_calc_arglocs,
  ev_calc_varglocs, ev_adjust_argloc, ev_lower_func_type, ev_equal_reglocs,
  ev_use_stkarg_type, ev_use_regarg_type, ev_use_arg_types, ev_arg_addrs_ready,
  ev_decorate_name, ev_loader =3000
}
 Callback notification codes. More...
 
typedef const regval_t &idaapi regval_getter_t(const char *name, const regval_t *regvalues)
 

Instruction set

int32 instruc_start
 icode of the first instruction
 
int32 instruc_end
 icode of the last instruction + 1
 
const instruc_tinstruc
 Array of instructions.
 
bool is_canon_insn (uint16 itype) const
 Does the given value specify a valid instruction for this instruction set?. More...
 

Member Enumeration Documentation

Callback notification codes.

These are passed to notify() when certain events occur in the kernel, allowing the processor module to take appropriate action.

If you are not developing a processor module, many of these codes already have a corresponding function to use instead ( is_call_insn vs is_call_insn(ea_t), for example).

If you are developing a processor module, your notify() function must implement the desired behavior when called with a given code.

Enumerator
ev_init 

The IDP module is just loaded.

Parameters
idp_modname(const char *) processor module name
Returns
<0 on failure
ev_term 

The IDP module is being unloaded.

ev_newprc 

Before changing processor type.

Parameters
pnum(int) processor number in the array of processor names
keep_cfg(bool) true: do not modify kernel configuration
Return values
1ok
<0prohibit
ev_newasm 

Before setting a new assembler.

Parameters
asmnum(int)
ev_newfile 

A new file has been loaded.

Parameters
fname(char *) input file name
ev_oldfile 

An old file has been loaded.

Parameters
fname(char *) input file name
ev_newbinary 

IDA is about to load a binary file.

Parameters
filename(char *) binary file name
fileoff(qoff64_t) offset in the file
basepara(ea_t) base loading paragraph
binoff(ea_t) loader offset
nbytes(uint64) number of bytes to load
ev_endbinary 

IDA has loaded a binary file.

Parameters
ok(bool) file loaded successfully?
ev_set_idp_options 

Set IDP-specific configuration option Also see set_options_t above.

Parameters
keyword(const char *)
value_type(int)
value(const void *)
errbuf(const char **) - a error message will be returned here (can be NULL)
Returns
1 ok
0 not implemented
-1 error (and message in errbuf)
ev_set_proc_options 

Called if the user specified an option string in the command line: -p<processor name>="">:<options>.

Can be used for setting a processor subtype. Also called if option string is passed to set_processor_type() and IDC's SetProcessorType().

Parameters
options(const char *)
confidence(int) 0: loader's suggestion 1: user's decision
Returns
< 0 if bad option string
ev_ana_insn 

Analyze one instruction and fill 'out' structure.

This function shouldn't change the database, flags or anything else. All these actions should be performed only by emu_insn() function. {ea} contains address of instruction to analyze.

Parameters
out(insn_t *)
Returns
length of the instruction in bytes, 0 if instruction can't be decoded.
0 if instruction can't be decoded.
ev_emu_insn 

Emulate instruction, create cross-references, plan to analyze subsequent instructions, modify flags etc.

Upon entrance to this function, all information about the instruction is in 'insn' structure.

Parameters
insn(const insn_t *)
Returns
1 ok
-1 the kernel will delete the instruction
ev_out_header 

Function to produce start of disassembled text.

Parameters
outctx(outctx_t *)
Returns
void
ev_out_footer 

Function to produce end of disassembled text.

Parameters
outctx(outctx_t *)
Returns
void
ev_out_segstart 

Function to produce start of segment.

Parameters
outctx(outctx_t *)
seg(segment_t *)
Returns
1 ok
0 not implemented
ev_out_segend 

Function to produce end of segment.

Parameters
outctx(outctx_t *)
seg(segment_t *)
Returns
1 ok
0 not implemented
ev_out_assumes 

Function to produce assume directives when segment register value changes.

Parameters
outctx(outctx_t *)
Returns
1 ok
0 not implemented
ev_out_insn 

Generate text representation of an instruction in 'ctx.insn' outctx_t provides functions to output the generated text.

This function shouldn't change the database, flags or anything else. All these actions should be performed only by emu_insn() function.

Parameters
outctx(outctx_t *)
Returns
void
ev_out_mnem 

Generate instruction mnemonics.

This callback should append the colored mnemonics to ctx.outbuf Optional notification, if absent, out_mnem will be called.

Parameters
outctx(outctx_t *)
Returns
1 if appended the mnemonics
0 not implemented
ev_out_operand 

Generate text representation of an instruction operand outctx_t provides functions to output the generated text.

All these actions should be performed only by emu_insn() function.

Parameters
outctx(outctx_t *)
op(const op_t *)
Returns
1 ok
-1 operand is hidden
ev_out_data 

Generate text representation of data items This function may change the database and create cross-references if analyze_only is set.

Parameters
outctx(outctx_t *)
analyze_only(bool)
Returns
1 ok
0 not implemented
ev_out_label 

The kernel is going to generate an instruction label line or a function header.

Parameters
outctx(outctx_t *)
colored_name(const char *)
Returns
<0 if the kernel should not generate the label
0 not implemented or continue
ev_out_special_item 

Generate text representation of an item in a special segment i.e.

absolute symbols, externs, communal definitions etc

Parameters
outctx(outctx_t *)
segtype(uchar)
Returns
1 ok
0 not implemented
-1 overflow
ev_gen_stkvar_def 

Generate stack variable definition line Default line is varname = type ptr value, where 'type' is one of byte,word,dword,qword,tbyte.

Parameters
outctx(outctx_t *)
mptr(const member_t *)
v(sval_t)
Returns
1 - ok
0 - not implemented
ev_gen_regvar_def 

Generate register variable definition line.

Parameters
outctx(outctx_t *)
v(regvar_t *)
Return values
>0ok, generated the definition text
Returns
0 - not implemented
ev_gen_src_file_lnnum 

Callback: generate analog of:

#line "file.c" 123

directive.

Parameters
outctx(outctx_t *) output context
file(const char *) source file (may be NULL)
lnnum(size_t) line number
Return values
1directive has been generated
Returns
0 - not implemented
ev_creating_segm 

A new segment is about to be created.

Parameters
seg(segment_t *)
Return values
1ok
<0segment should not be created
ev_moving_segm 

May the kernel move the segment?

Parameters
seg(segment_t *) segment to move
to(ea_t) new segment start address
flags(int) combination of Move segment flags
Return values
0yes
<0the kernel should stop
ev_coagulate 

Try to define some unexplored bytes.

This notification will be called if the kernel tried all possibilities and could not find anything more useful than to convert to array of bytes. The module can help the kernel and convert the bytes into something more useful.

Parameters
start_ea(ea_t)
Returns
number of converted bytes
ev_undefine 

An item in the database (insn or data) is being deleted.

Parameters
ea(ea_t)
Returns
1 do not delete srranges at the item end
0 srranges can be deleted
ev_treat_hindering_item 

An item hinders creation of another item.

Parameters
hindering_item_ea(ea_t)
new_item_flags(flags_t) (0 for code)
new_item_ea(ea_t)
new_item_length(asize_t)
Return values
0no reaction
!=0the kernel may delete the hindering item
ev_rename 

The kernel is going to rename a byte.

Parameters
ea(ea_t)
new_name(const char *)
flags(int) Set name flags
Returns
<0 if the kernel should not rename it.
2 to inhibit the notification. I.e., the kernel should not rename, but 'set_name()' should return 'true'. also see renamed the return value is ignored when kernel is going to delete name
ev_is_far_jump 

is indirect far jump or call instruction? meaningful only if the processor has 'near' and 'far' reference types

Parameters
icode(int)
Returns
0 not implemented
1 yes
-1 no
ev_is_sane_insn 

Is the instruction sane for the current file type?.

Parameters
insn(const insn_t*) the instruction
no_crefs(int) 1: the instruction has no code refs to it. ida just tries to convert unexplored bytes to an instruction (but there is no other reason to convert them into an instruction) 0: the instruction is created because of some coderef, user request or another weighty reason.
Return values
>=0ok
<0no, the instruction isn't likely to appear in the program
ev_is_cond_insn 

Is conditional instruction?

Parameters
insn(const insn_t *) instruction address
Return values
1yes
-1no
0not implemented or not instruction
ev_is_call_insn 

Is the instruction a "call"?

Parameters
insn(const insn_t *) instruction
Return values
0unknown
<0no
1yes
ev_is_ret_insn 

Is the instruction a "return"?

Parameters
insn(const insn_t *) instruction
strict(bool) 1: report only ret instructions 0: include instructions like "leave" which begins the function epilog
Return values
0unknown
<0no
1yes
ev_may_be_func 

Can a function start here?

Parameters
insn(const insn_t*) the instruction
state(int) autoanalysis phase 0: creating functions 1: creating chunks
Returns
probability 0..100
ev_is_basic_block_end 

Is the current instruction end of a basic block?.

This function should be defined for processors with delayed jump slots.

Parameters
insn(const insn_t*) the instruction
call_insn_stops_block(bool)
Return values
0unknown
<0no
1yes
ev_is_indirect_jump 

Determine if instruction is an indirect jump.

If CF_JUMP bit can not describe all jump types jumps, please define this callback.

Parameters
insn(const insn_t*) the instruction
Return values
0use CF_JUMP
1no
2yes
ev_is_insn_table_jump 

Determine if instruction is a table jump or call.

If CF_JUMP bit can not describe all kinds of table jumps, please define this callback. It will be called for insns with CF_JUMP bit set.

Parameters
insn(const insn_t*) the instruction
Return values
0yes
<0no
ev_is_switch 

Find 'switch' idiom.

It will be called for instructions marked with CF_JUMP.

Parameters
si(switch_info_t *), out
insn(const insn_t *) instruction possibly belonging to a switch
Return values
1switch is found, 'si' is filled
0no switch found or not implemented
ev_calc_switch_cases 

Calculate case values and targets for a custom jump table.

Parameters
casevec(::casevec_t *) vector of case values (may be NULL)
targets(eavec_t *) corresponding target addresses (my be NULL)
insn_ea(ea_t) address of the 'indirect jump' instruction
si(switch_info_t *) switch information
Return values
1ok
<=0failed
ev_create_switch_xrefs 

Create xrefs for a custom jump table.

Parameters
jumpea(ea_t) address of the jump insn
si(const switch_info_t *) switch information
Returns
must return 1 Must be implemented if module uses custom jump tables, SWI_CUSTOM
ev_is_align_insn 

Is the instruction created only for alignment purposes?.

Do not directly call this function, use is_align_insn()

Parameters
ea(ea_t) - instruction address
Return values
numberof bytes in the instruction
ev_is_alloca_probe 

Does the function at 'ea' behave as __alloca_probe?

Parameters
ea(ea_t)
Return values
1yes
0no
ev_delay_slot_insn 

Get delay slot instruction.

Parameters
ea(ea_t *) instruction address in question, if answer is positive then set 'ea' to the delay slot insn address
bexec(bool *) execute slot if jumping, initially set to 'true'
fexec(bool *) execute slot if not jumping, initally set to 'true'
Return values
1positive answer
<=0ordinary insn
Note
Input 'ea' may point to the instruction with a delay slot or to the delay slot instruction itself.
ev_is_sp_based 

Check whether the operand is relative to stack pointer or frame pointer This event is used to determine how to output a stack variable If not implemented, then all operands are sp based by default.

Implement this event only if some stack references use frame pointer instead of stack pointer.

Parameters
mode(int *) out, combination of SP/FP operand flags
insn(const insn_t *)
op(const op_t *)
Returns
0 not implemented
1 ok
ev_can_have_type 

Can the operand have a type as offset, segment, decimal, etc? (for example, a register AX can't have a type, meaning that the user can't change its representation.

see bytes.hpp for information about types and flags)

Parameters
op(const op_t *)
Return values
0unknown
<0no
1yes
ev_cmp_operands 

Compare instruction operands.

Parameters
op1(const op_t*)
op2(const op_t*)
Return values
1equal
-1not equal
0not implemented
ev_adjust_refinfo 

Called from apply_fixup before converting operand to reference.

Can be used for changing the reference info.

Parameters
ri(refinfo_t *)
ea(ea_t) instruction address
n(int) operand number
fd(const fixup_data_t *)
Returns
< 0 - do not create an offset
0 - not implemented or refinfo adjusted
ev_get_operand_string 

Request text string for operand (cli, java, ...).

Parameters
buf(qstring *)
insn(const insn_t*) the instruction
opnum(int) operand number, -1 means any string operand
Returns
0 no string (or empty string) >0 original string length without terminating zero
ev_get_reg_name 

Generate text representation of a register.

Most processor modules do not need to implement this callback. It is useful only if processor_t::reg_names[reg] does not provide the correct register name.

Parameters
buf(qstring *) output buffer
reg(int) internal register number as defined in the processor module
width(size_t) register width in bytes
reghi(int) if not -1 then this function will return the register pair
Returns
-1 if error, strlen(buf) otherwise
ev_str2reg 

Convert a register name to a register number.

The register number is the register index in the processor_t::reg_names array Most processor modules do not need to implement this callback It is useful only if processor_t::reg_names[reg] does not provide the correct register names

Parameters
regname(const char *)
Returns
register number + 1
0 not implemented or could not be decoded
ev_get_autocmt 

Callback: get dynamic auto comment.

Will be called if the autocomments are enabled and the comment retrieved from ida.int starts with '$!'. 'insn' contains valid info.

Parameters
buf(qstring *) output buffer
insn(const insn_t*) the instruction
Return values
1new comment has been generated
0callback has not been handled. the buffer must not be changed in this case
ev_get_bg_color 

Get item background color.

Plugins can hook this callback to color disassembly lines dynamically

Parameters
color(bgcolor_t *), out
ea(ea_t)
Return values
0not implemented
1color set
ev_is_jump_func 

Is the function a trivial "jump" function?.

Parameters
pfn(func_t *)
jump_target(ea_t *)
func_pointer(ea_t *)
Return values
<0no
0don't know
1yes, see 'jump_target' and 'func_pointer'
ev_func_bounds 

find_func_bounds() finished its work.

The module may fine tune the function bounds

Parameters
possible_return_code(int *), in/out
pfn(func_t *)
max_func_end_ea(ea_t) (from the kernel's point of view)
Returns
void
ev_verify_sp 

All function instructions have been analyzed.

Now the processor module can analyze the stack pointer for the whole function

Parameters
pfn(func_t *)
Return values
0ok
<0bad stack pointer
ev_verify_noreturn 

The kernel wants to set 'noreturn' flags for a function.

Parameters
pfn(func_t *)
Returns
0: ok. any other value: do not set 'noreturn' flag
ev_create_func_frame 

Create a function frame for a newly created function Set up frame size, its attributes etc.

Parameters
pfn(func_t *)
Returns
1 ok
0 not implemented
ev_get_frame_retsize 

Get size of function return address in bytes If this eveny is not implemented, the kernel will assume.

  • 8 bytes for 64-bit function
  • 4 bytes for 32-bit function
  • 2 bytes otherwise If this eveny is not implemented, the kernel will assume
    Parameters
    frsize(int *) frame size (out)
    pfn(const func_t *), can't be NULL
    Returns
    1 ok
    0 not implemented
ev_get_stkvar_scale_factor 

Should stack variable references be multiplied by a coefficient before being used in the stack frame?.

Currently used by TMS320C55 because the references into the stack should be multiplied by 2

Note
PR_SCALE_STKVARS should be set to use this callback
Returns
scaling factor, 0-not implemented
ev_demangle_name 

Demangle a C++ (or another language) name into a user-readable string.

This event is called by demangle_name()

Parameters
res(int32 *) value to return from demangle_name()
out(qstring *) output buffer. may be NULL
name(const char *) mangled name
disable_mask(uint32) flags to inhibit parts of output or compiler info/other (see MNG_)
demreq(demreq_type_t) operation to perform
Returns
: 1 if success, 0-not implemented
Note
if you call demangle_name() from the handler, protect against recursion!
ev_add_cref 

A code reference is being created.

Parameters
from(ea_t)
to(ea_t)
type(cref_t)
Returns
< 0 - cancel cref creation
0 - not implemented or continue
ev_add_dref 

A data reference is being created.

Parameters
from(ea_t)
to(ea_t)
type(dref_t)
Returns
< 0 - cancel dref creation
0 - not implemented or continue
ev_del_cref 

A code reference is being deleted.

Parameters
from(ea_t)
to(ea_t)
expand(bool)
Returns
< 0 - cancel cref deletion
0 - not implemented or continue
ev_del_dref 

A data reference is being deleted.

Parameters
from(ea_t)
to(ea_t)
Returns
< 0 - cancel dref deletion
0 - not implemented or continue
ev_coagulate_dref 

Data reference is being analyzed.

plugin may correct 'code_ea' (e.g. for thumb mode refs, we clear the last bit)

Parameters
from(ea_t)
to(ea_t)
may_define(bool)
code_ea(ea_t *)
Returns
< 0 - cancel dref analysis
0 - not implemented or continue
ev_may_show_sreg 

The kernel wants to display the segment registers in the messages window.

Parameters
current_ea(ea_t)
Returns
<0 if the kernel should not show the segment registers. (assuming that the module has done it)
0 - not implemented
ev_loader_elf_machine 

ELF loader machine type checkpoint.

A plugin check of the 'machine_type'. If it is the desired one, the the plugin fills 'p_procname' with the processor name (one of the names present in processor_t::psnames). 'p_pd' is used to handle relocations, otherwise can be left untouched. This event occurs for each newly loaded ELF file

Parameters
li(linput_t *)
machine_type(int)
p_procname(const char **)
p_pd(proc_def_t **) (see ldr\elf.h)
Returns
e_machine value (if it is different from the original e_machine value, procname and 'p_pd' will be ignored and the new value will be used)
ev_auto_queue_empty 

One analysis queue is empty.

Parameters
type(atype_t)
Return values
>=0yes, keep the queue empty (default)
<0no, the queue is not empty anymore see also idb_event::auto_empty_finally
ev_validate_flirt_func 

Flirt has recognized a library function.

This callback can be used by a plugin or proc module to intercept it and validate such a function.

Parameters
start_ea(ea_t)
funcname(const char *)
Return values
-1do not create a function,
0function is validated
ev_adjust_libfunc_ea 

Called when a signature module has been matched against bytes in the database.

This is used to compute the offset at which a particular module's libfunc should be applied.

Parameters
sig(const idasgn_t *)
libfun(const libfunc_t *)
ea(ea_t *)
Note
'ea' initially contains the ea_t of the start of the pattern match
Return values
1the ea_t pointed to by the third argument was modified.
<=0not modified. use default algorithm.
ev_assemble 

Assemble an instruction.

(display a warning if an error is found).

Parameters
bin(uchar *) pointer to output opcode buffer
ea(ea_t) linear address of instruction
cs(ea_t) cs of instruction
ip(ea_t) ip of instruction
use32(bool) is 32bit segment?
line(const char *) line to assemble
Returns
size of the instruction in bytes
ev_extract_address 

Extract address from a string.

Parameters
out_ea(ea_t *), out
screen_ea(ea_t)
string(const char *)
position(size_t)
Return values
1ok
0kernel should use the standard algorithm
-1error
ev_realcvt 

Floating point -> IEEE conversion.

Parameters
m(void *) pointer to data
e(uint16 *) internal IEEE format data
swt(uint16) operation (see realcvt() in ieee.h)
Returns
0 not implemented
1 ok
Floating point/IEEE Conversion codes on error
ev_gen_asm_or_lst 

Callback: generating asm or lst file.

The kernel calls this callback twice, at the beginning and at the end of listing generation. The processor module can intercept this event and adjust its output

Parameters
starting(bool) beginning listing generation
fp(FILE *) output file
is_asm(bool) true:assembler, false:listing
flags(int) flags passed to gen_file()
outline(gen_outline_t **) ptr to ptr to outline callback. if this callback is defined for this code, it will be used by the kernel to output the generated lines
Returns
void
ev_gen_map_file 

Generate map file.

If not implemented the kernel itself will create the map file.

Parameters
nlines(int *) number of lines in map file (-1 means write error)
fp(FILE *) output file
Returns
0 not implemented
1 ok
Return values
-1write error
ev_create_flat_group 

Create special segment representing the flat group.

Parameters
image_base(ea_t)
bitness(int)
dataseg_sel(sel_t) return value is ignored
ev_getreg 

IBM PC only internal request, should never be used for other purpose Get register value by internal index.

Parameters
regval(uval_t *), out
regnum(int)
Returns
1 ok
0 not implemented
-1 failed (undefined value or bad regnum)
ev_last_cb_before_debugger 

START OF DEBUGGER CALLBACKS.

ev_next_exec_insn 

Get next address to be executed This function must return the next address to be executed.

If the instruction following the current one is executed, then it must return BADADDR Usually the instructions to consider are: jumps, branches, calls, returns. This function is essential if the 'single step' is not supported in hardware.

Parameters
target(ea_t *), out: pointer to the answer
ea(ea_t) instruction address
tid(int) current therad id
getreg(::processor_t::regval_getter_t *) function to get register values
regvalues(const regval_t *) register values array
Return values
0unimplemented
1implemented
ev_calc_step_over 

Calculate the address of the instruction which will be executed after "step over".

The kernel will put a breakpoint there. If the step over is equal to step into or we can not calculate the address, return BADADDR.

Parameters
target(ea_t *) pointer to the answer
ip(ea_t) instruction address
Return values
0unimplemented
1implemented
ev_calc_next_eas 

Calculate list of addresses the instruction in 'insn' may pass control to.

This callback is required for source level debugging.

Parameters
res(eavec_t *), out: array for the results.
insn(const insn_t*) the instruction
over(bool) calculate for step over (ignore call targets)
Return values
<0incalculable (indirect jumps, for example)
>=0number of addresses of called functions in the array. They must be put at the beginning of the array (0 if over=true)
ev_get_macro_insn_head 

Calculate the start of a macro instruction.

This notification is called if IP points to the middle of an instruction

Parameters
head(ea_t *), out: answer, BADADDR means normal instruction
ip(ea_t) instruction address
Return values
0unimplemented
1implemented
ev_get_dbr_opnum 

Get the number of the operand to be displayed in the debugger reference view (text mode).

Parameters
opnum(int *) operand number (out, -1 means no such operand)
insn(const insn_t*) the instruction
Return values
0unimplemented
1implemented
ev_insn_reads_tbit 

Check if insn will read the TF bit.

Parameters
insn(const insn_t*) the instruction
getreg(::processor_t::regval_getter_t *) function to get register values
regvalues(const regval_t *) register values array
Return values
2yes, will generate 'step' exception
1yes, will store the TF bit in memory
0no
ev_clean_tbit 

Clear the TF bit after an insn like pushf stored it in memory.

Parameters
ea(ea_t) instruction address
getreg(::processor_t::regval_getter_t *) function to get register values
regvalues(const regval_t *) register values array
Return values
1ok
0failed
ev_get_idd_opinfo 

Get operand information.

This callback is used to calculate the operand value for double clicking on it, hints, etc.

Parameters
opinf(idd_opinfo_t *) the output buffer
ea(ea_t) instruction address
n(int) operand number
thread_id(int) current thread id
getreg(::processor_t::regval_getter_t *) function to get register values
regvalues(const regval_t *) register values array
Returns
1-ok, 0-failed
ev_get_reg_info 

Get register information by its name.

example: "ah" returns:

  • main_regname="eax"
  • bitrange_t = { offset==8, nbits==8 }

This callback may be unimplemented if the register names are all present in processor_t::reg_names and they all have the same size

Parameters
main_regname(const char **), out
bitrange(bitrange_t *), out: position and size of the value within 'main_regname' (empty bitrange == whole register)
regname(const char *)
Return values
1ok
-1failed (not found)
0unimplemented
ev_setup_til 

Setup default type libraries.

(called after loading a new file into the database). The processor module may load tils, setup memory model and perform other actions required to set up the type system. This is an optional callback.

Parameters
none
Returns
void
ev_get_abi_info 

Get all possible ABI names and optional extensions for given compiler abiname/option is a string entirely consisting of letters, digits and underscore.

Parameters
abi_names(qstrvec_t *) - all possible ABis each in form abiname-opt1-opt2-...
abi_opts(qstrvec_t *) - array of all possible options in form "opt:description" or opt:hint-line#description
comp(comp_t) - compiler ID
Return values
0not implemented
1ok
ev_max_ptr_size 

Get maximal size of a pointer in bytes.

Parameters
none
Returns
max possible size of a pointer
ev_get_default_enum_size 

Get default enum size.

Parameters
cm(cm_t)
Returns
sizeof(enum)
ev_get_cc_regs 

Get register allocation convention for given calling convention.

Parameters
regs(callregs_t *), out
cc(cm_t)
Returns
1
0 - not implemented
ev_get_stkarg_offset 

Get offset from SP to the first stack argument.

For example: pc: 0, hppa: -0x34, ppc: 0x38

Parameters
none
Returns
the offset
ev_shadow_args_size 

Get size of shadow args in bytes.

Parameters
[out]shadow_args_size(int *)
pfn(func_t *) (may be NULL)
Returns
1 if filled *shadow_args_size
0 - not implemented
ev_get_simd_types 

Get SIMD-related types according to given attributes ant/or argument location.

Parameters
out(::simd_info_vec_t *)
simd_attrs(const simd_info_t *), may be NULL
argloc(const argloc_t *), may be NULL
create_tifs(bool) return valid tinfo_t objects, create if neccessary
Returns
number of found types, -1-error If name==NULL, initialize all SIMD types
ev_calc_cdecl_purged_bytes 

Calculate number of purged bytes after call.

Parameters
ea(ea_t) address of the call instruction
Returns
number of purged bytes (usually add sp, N)
ev_calc_purged_bytes 

Calculate number of purged bytes by the given function type.

Parameters
[out]p_purged_bytes(int *) ptr to output
fti(const func_type_data_t *) func type details
Returns
1
0 - not implemented
ev_calc_retloc 

Calculate return value location.

Parameters
[out]retloc(argloc_t *)
rettype(const tinfo_t *)
cc(cm_t)
Returns
0 not implemented
1 ok,
-1 error
ev_calc_arglocs 

Calculate function argument locations.

This callback should fill retloc, all arglocs, and stkargs. This callback supersedes calc_argloc2. This callback is never called for CM_CC_SPECIAL functions.

Parameters
fti(func_type_data_t *) points to the func type info
Return values
0not implemented
1ok
-1error
ev_calc_varglocs 

Calculate locations of the arguments that correspond to '...'.

Parameters
ftd(func_type_data_t *), inout: info about all arguments (including varargs)
regs(regobjs_t *) buffer for register values
stkargs(relobj_t *) stack arguments
nfixed(int) number of fixed arguments
Return values
0not implemented
1ok
-1error
ev_adjust_argloc 

Adjust argloc according to its type/size and platform endianess.

Parameters
argloc(argloc_t *), inout
type(const tinfo_t *), may be NULL NULL means primitive type of given size
size(int) 'size' makes no sense if type != NULL (type->get_size() should be used instead)
Return values
0not implemented
1ok
-1error
ev_lower_func_type 

Get function arguments which should be converted to pointers when lowering function prototype.

Processor module can also modify 'fti' in order to make a non-standard convertion for some of the arguments.

Parameters
argnums(intvec_t *), out - numbers of arguments to be converted to pointers in acsending order
fti(func_type_data_t *), inout func type details (special values -1/-2 for return value - position of hidden 'retstr' argument: -1 - at the beginning, -2 - at the end)
Return values
0not implemented
1argnums was filled
2argnums was filled and made substantial changes to fti
ev_equal_reglocs 

Are 2 register arglocs the same?.

We need this callback for the pc module.

Parameters
a1(argloc_t *)
a2(argloc_t *)
Return values
1yes
-1no
0not implemented
ev_use_stkarg_type 

Use information about a stack argument.

Parameters
ea(ea_t) address of the push instruction which pushes the function argument into the stack
arg(const funcarg_t *) argument info
Return values
1ok
<=0failed, the kernel will create a comment with the argument name or type for the instruction
ev_use_regarg_type 

Use information about register argument.

Parameters
[out]idx(int *) pointer to the returned value, may contain:
  • idx of the used argument, if the argument is defined in the current instruction, a comment will be applied by the kernel
  • idx | REG_SPOIL - argument is spoiled by the instruction
  • -1 if the instruction doesn't change any registers
  • -2 if the instruction spoils all registers
ea(ea_t) address of the instruction
rargs(const funcargvec_t *) vector of register arguments (including regs extracted from scattered arguments)
Returns
1
0 not implemented
ev_use_arg_types 

Use information about callee arguments.

Parameters
ea(ea_t) address of the call instruction
fti(func_type_data_t *) info about function type
rargs(funcargvec_t *) array of register arguments
Returns
1 (and removes handled arguments from fti and rargs)
0 not implemented
ev_arg_addrs_ready 

Argument address info is ready.

Parameters
caller(ea_t)
n(int) number of formal arguments
tif(tinfo_t *) call prototype
addrs(ea_t *) argument intilization addresses
Returns
<0: do not save into idb; other values mean "ok to save"
ev_decorate_name 

Decorate/undecorate a C symbol name.

Parameters
outbuf(qstring *) output buffer
name(const char *) name of symbol
mangle(bool) true-mangle, false-unmangle
cc(cm_t) calling convention
type(const tinfo_t *) name type (NULL-unknown)
Returns
1 if success
0 not implemented or failed
ev_loader 

This code and higher ones are reserved for the loaders.

The arguments and the return values are defined by the loaders

Member Function Documentation

int processor_t::get_segm_bitness ( void  ) const
inline

Get segment bitness.

Return values
2PR_DEFSEG64
1PR_DEFSEG32
0none specified
int processor_t::get_stkvar_scale ( void  )
inline

Get the stack variable scaling factor.

Useful for processors who refer to the stack with implicit scaling factor. TMS320C55 for example: SP(#1) really refers to (SP+2)

bool processor_t::is_canon_insn ( uint16  itype) const
inline

Does the given value specify a valid instruction for this instruction set?.

See instruc_start and instruc_end

Member Data Documentation

int32 processor_t::cnbits

Number of bits in a byte for code segments (usually 8).

IDA supports values up to 32 bits

int32 processor_t::dnbits

Number of bits in a byte for non-code segments (usually 8).

IDA supports values up to 32 bits

const char* const* processor_t::psnames

short processor names (NULL terminated).

Each name should be shorter than 9 characters

const char* const* processor_t::plnames

long processor names (NULL terminated).

No restriction on name lengths.

const asm_t* const* processor_t::assemblers

pointer to array of target assembler definitions.

You may change this array when current processor is changed. (NULL terminated)

const bytes_t* processor_t::codestart

Array of typical code start sequences.

This array is used when a new file is loaded to find the beginnings of code sequences. This array is terminated with a zero length item.

const bytes_t* processor_t::retcodes

Array of 'return' instruction opcodes.

This array is used to determine form of autogenerated locret_... labels. The last item of it should be { 0, NULL } This array may be NULL Better way of handling return instructions is to define the is_ret_insn callback in the notify() function

char processor_t::real_width[4]

Number of digits in floating numbers after the decimal point.

If an element of this array equals 0, then the corresponding floating point data is not used for the processor. This array is used to align numbers in the output.

  • real_width[0] - number of digits for short floats (only PDP-11 has them)
  • real_width[1] - number of digits for "float"
  • real_width[2] - number of digits for "double"
  • real_width[3] - number of digits for "long double"

Example: IBM PC module has { 0,7,15,19 }


The documentation for this struct was generated from the following file: