Module ida_idp
[frames] | no frames]

Module ida_idp

IDA Plugin SDK API wrapper: idp

Classes
  IDB_Hooks
Proxy of C++ IDB_Hooks class.
  IDP_Hooks
Proxy of C++ IDP_Hooks class.
  asm_t
Proxy of C++ asm_t class.
  processor_t
  reg_info_t
Proxy of C++ reg_info_t class.
Functions
PyObject *
AssembleLine(ea, cs, ip, use32, nonnul_line)
Assemble an instruction to a string (display a warning if an error is found)
bool
assemble(ea, cs, ip, use32, line)
Assemble an instruction into the database (display a warning if an error is found)
char const *
cfg_get_cc_header_path(compid)
char const *
cfg_get_cc_parm(compid, name)
char const *
cfg_get_cc_predefined_macros(compid)
bool
delay_slot_insn(ea, bexec, fexec)
Helper function to get the delay slot instruction.
 
gen_idb_event(code)
the kernel will use this function to generate idb_events
PyObject *
get_idb_notifier_addr(arg1)
PyObject *
get_idb_notifier_ud_addr(hooks)
str
get_idp_name()
Get name of the current processor module.
PyObject *
get_idp_notifier_addr(arg1)
PyObject *
get_idp_notifier_ud_addr(hooks)
char const *
get_reg_info(regname, bitrange)
Get register information - useful for registers like al, ah, dil, etc.
str
get_reg_name(reg, width, reghi=-1)
Get text representation of a register.
bool
has_cf_chg(feature, opnum)
Does an instruction with the specified feature modify the i-th operand?
bool
has_cf_use(feature, opnum)
Does an instruction with the specified feature use a value of the i-th operand?
bool
has_insn_feature(icode, bit)
Does the specified instruction have the specified feature?
int
is_align_insn(ea)
If the instruction at 'ea' looks like an alignment instruction, return its length in bytes.
bool
is_basic_block_end(insn, call_insn_stops_block)
Is the instruction the end of a basic block?
bool
is_call_insn(insn)
Is the instruction a "call"?
bool
is_indirect_jump_insn(insn)
Is the instruction an indirect jump?
bool
is_ret_insn(insn, strict=True)
Is the instruction a "return"?
bool
parse_reg_name(ri, regname)
Get register info by name.
 
ph_calcrel(ea)
ssize_t
ph_find_op_value(insn, op)
ssize_t
ph_find_reg_value(insn, reg)
size_t
ph_get_cnbits()
Returns the 'ph.cnbits'
size_t
ph_get_dnbits()
Returns the 'ph.dnbits'
size_t
ph_get_flag()
Returns the 'ph.flag'
size_t
ph_get_icode_return()
Returns the 'ph.icode_return'
size_t
ph_get_id()
Returns the 'ph.id' field
PyObject *
ph_get_instruc()
Returns a list of tuples (instruction_name, instruction_feature) containing the instructions list as defined in he processor module
size_t
ph_get_instruc_end()
Returns the 'ph.instruc_end'
size_t
ph_get_instruc_start()
Returns the 'ph.instruc_start'
PyObject *
ph_get_operand_info(ea, n)
Returns the operand information given an ea and operand number.
size_t
ph_get_reg_code_sreg()
Returns the 'ph.reg_code_sreg'
size_t
ph_get_reg_data_sreg()
Returns the 'ph.reg_data_sreg'
size_t
ph_get_reg_first_sreg()
Returns the 'ph.reg_first_sreg'
size_t
ph_get_reg_last_sreg()
Returns the 'ph.reg_last_sreg'
PyObject *
ph_get_regnames()
Returns the list of register names as defined in the processor module
size_t
ph_get_segreg_size()
Returns the 'ph.segreg_size'
size_t
ph_get_tbyte_size()
Returns the 'ph.tbyte_size' field as defined in he processor module
size_t
ph_get_version()
Returns the 'ph.version'
bool
set_processor_type(procname, level)
Set target processor type.
bool
set_target_assembler(asmnum)
Set target assembler.
size_t
sizeof_ldbl()
Get size of long double.
int
str2reg(p)
Get any reg number (-1 on error)
Variables
  AS2_BRACE = 1
  AS2_BYTE1CHAR = 4
  AS2_COLONSUF = 32
  AS2_IDEALDSCR = 8
  AS2_STRINV = 2
  AS2_TERSESTR = 16
  AS2_YWORD = 64
  ASB_BINF0 = 0
  ASB_BINF1 = 131072
  ASB_BINF2 = 262144
  ASB_BINF3 = 393216
  ASB_BINF4 = 524288
  ASB_BINF5 = 655360
  ASD_DECF0 = 0
  ASD_DECF1 = 4096
  ASD_DECF2 = 8192
  ASD_DECF3 = 12288
  ASH_HEXF0 = 0
  ASH_HEXF1 = 512
  ASH_HEXF2 = 1024
  ASH_HEXF3 = 1536
  ASH_HEXF4 = 2048
  ASH_HEXF5 = 2560
  ASO_OCTF0 = 0
  ASO_OCTF1 = 16384
  ASO_OCTF2 = 32768
  ASO_OCTF3 = 49152
  ASO_OCTF4 = 65536
  ASO_OCTF5 = 81920
  ASO_OCTF6 = 98304
  ASO_OCTF7 = 114688
  AS_1TEXT = 64
  AS_2CHRE = 8
  AS_ALIGN2 = 536870912
  AS_ASCIIC = 1073741824
  AS_ASCIIZ = 2147483648
  AS_BINFM = 917504
  AS_COLON = 2
  AS_DECFM = 12288
  AS_HEXFM = 3584
  AS_LALIGN = 33554432
  AS_N2CHR = 32
  AS_NCHRE = 16
  AS_NCMAS = 256
  AS_NHIAS = 128
  AS_NOCODECLN = 67108864
  AS_NOSPACE = 268435456
  AS_NOXRF = 4194304
  AS_OCTFM = 114688
  AS_OFFST = 1
  AS_ONEDUP = 2097152
  AS_RELSUP = 16777216
  AS_UDATA = 4
  AS_UNEQU = 1048576
  AS_XTRNTYPE = 8388608
  CF_CALL = 2
  CF_CHG1 = 4
  CF_CHG2 = 8
  CF_CHG3 = 16
  CF_CHG4 = 32
  CF_CHG5 = 64
  CF_CHG6 = 128
  CF_HLL = 65536
  CF_JUMP = 16384
  CF_SHFT = 32768
  CF_STOP = 1
  CF_USE1 = 256
  CF_USE2 = 512
  CF_USE3 = 1024
  CF_USE4 = 2048
  CF_USE5 = 4096
  CF_USE6 = 8192
  CUSTOM_INSN_ITYPE = 32768
  IDPOPT_BADKEY = 1
  IDPOPT_BADTYPE = 2
  IDPOPT_BADVALUE = 3
  IDPOPT_BIT = 3
  IDPOPT_BIT_BOOL = 50331648
  IDPOPT_BIT_UCHAR = 16777216
  IDPOPT_BIT_UINT = 0
  IDPOPT_BIT_USHORT = 33554432
  IDPOPT_CST = 6
  IDPOPT_CST_PARAMS = 16777216
  IDPOPT_FLT = 4
  IDPOPT_I64 = 5
  IDPOPT_I64_RANGES = 16777216
  IDPOPT_I64_UNS = 33554432
  IDPOPT_NUM = 2
  IDPOPT_NUM_CHAR = 16777216
  IDPOPT_NUM_INT = 0
  IDPOPT_NUM_RANGE = 67108864
  IDPOPT_NUM_SHORT = 33554432
  IDPOPT_NUM_UNS = 134217728
  IDPOPT_OK = 0
  IDPOPT_PRI_DEFAULT = 1
  IDPOPT_PRI_HIGH = 2
  IDPOPT_STR = 1
  IDPOPT_STR_LONG = 33554432
  IDPOPT_STR_QSTRING = 16777216
  IDP_INTERFACE_VERSION = 700
  OP_FP_BASED = 0
  OP_SP_ADD = 0
  OP_SP_BASED = 1
  OP_SP_SUB = 2
  PLFM_386 = 0
  PLFM_6502 = 5
  PLFM_65C816 = 61
  PLFM_6800 = 9
  PLFM_68K = 7
  PLFM_80196 = 16
  PLFM_8051 = 3
  PLFM_AD2106X = 68
  PLFM_AD218X = 48
  PLFM_ALPHA = 24
  PLFM_ARC = 63
  PLFM_ARM = 13
  PLFM_AVR = 20
  PLFM_C166 = 29
  PLFM_C39 = 51
  PLFM_CR16 = 52
  PLFM_DALVIK = 60
  PLFM_DSP56K = 28
  PLFM_DSP96K = 66
  PLFM_EBC = 57
  PLFM_F2MC = 33
  PLFM_FR = 43
  PLFM_H8 = 21
  PLFM_H8500 = 26
  PLFM_HPPA = 25
  PLFM_I860 = 2
  PLFM_I960 = 32
  PLFM_IA64 = 31
  PLFM_JAVA = 8
  PLFM_KR1878 = 47
  PLFM_M16C = 62
  PLFM_M32R = 37
  PLFM_M740 = 40
  PLFM_M7700 = 41
  PLFM_M7900 = 45
  PLFM_MC6812 = 11
  PLFM_MC6816 = 44
  PLFM_MIPS = 12
  PLFM_MN102L00 = 53
  PLFM_MSP430 = 58
  PLFM_NEC_78K0 = 38
  PLFM_NEC_78K0S = 39
  PLFM_NEC_V850X = 55
  PLFM_NET = 19
  PLFM_OAKDSP = 49
  PLFM_PDP = 6
  PLFM_PIC = 22
  PLFM_PIC16 = 69
  PLFM_PPC = 15
  PLFM_S390 = 70
  PLFM_SCR_ADPT = 56
  PLFM_SH = 18
  PLFM_SPARC = 23
  PLFM_SPC700 = 67
  PLFM_SPU = 59
  PLFM_ST20 = 30
  PLFM_ST7 = 10
  PLFM_ST9 = 42
  PLFM_TLCS900 = 50
  PLFM_TMS = 4
  PLFM_TMS320C1X = 54
  PLFM_TMS320C28 = 65
  PLFM_TMS320C3 = 46
  PLFM_TMS320C54 = 34
  PLFM_TMS320C55 = 35
  PLFM_TMSC6 = 14
  PLFM_TRICORE = 27
  PLFM_TRIMEDIA = 36
  PLFM_UNSP = 64
  PLFM_Z8 = 17
  PLFM_Z80 = 1
  PRN_BIN = 192
  PRN_DEC = 128
  PRN_HEX = 0
  PRN_OCT = 64
  PR_ADJSEGS = 32
  PR_ALIGN = 2048
  PR_ALIGN_INSN = 16777216
  PR_ASSEMBLE = 1024
  PR_BINMEM = 65536
  PR_CHK_XREF = 262144
  PR_CNDINSNS = 67108864
  PR_DEFNUM = 192
  PR_DEFSEG32 = 4
  PR_DEFSEG64 = 268435456
  PR_DELAYED = 8388608
  PR_NOCHANGE = 512
  PR_NO_SEGMOVE = 524288
  PR_PURGING = 33554432
  PR_RNAMESOK = 8
  PR_SCALE_STKVARS = 4194304
  PR_SEGS = 1
  PR_SEGTRANS = 131072
  PR_SGROTHER = 16384
  PR_STACK_UP = 32768
  PR_TYPEINFO = 4096
  PR_USE32 = 2
  PR_USE64 = 8192
  PR_USE_ARG_TYPES = 2097152
  PR_USE_TBYTE = 134217728
  PR_WORD_INS = 256
  REAL_ERROR_BADDATA = -3
  REAL_ERROR_FORMAT = -1
  REAL_ERROR_RANGE = -2
  REG_SPOIL = 2147483648
  SETPROC_IDB = 0
  SETPROC_LOADER = 1
  SETPROC_LOADER_NON_FATAL = 2
  SETPROC_USER = 3
  SWIG_PYTHON_LEGACY_BOOL = 1
  __package__ = None
  allsegs_moved = 62
  auto_empty = 3
  auto_empty_finally = 4
  bookmark_changed = 92
  byte_patched = 84
  callee_addr_changed = 91
  changing_cmt = 85
  changing_enum_bf = 24
  changing_enum_cmt = 26
  changing_op_ti = 15
  changing_op_type = 17
  changing_range_cmt = 87
  changing_segm_class = 58
  changing_segm_end = 54
  changing_segm_name = 56
  changing_segm_start = 52
  changing_struc_align = 34
  changing_struc_cmt = 47
  changing_struc_member = 45
  changing_ti = 13
  closebase = 0
  cmt_changed = 86
  compiler_changed = 12
  cvar = ??
  deleting_enum = 20
  deleting_enum_member = 29
  deleting_func = 67
  deleting_func_tail = 71
  deleting_segm = 50
  deleting_struc = 32
  deleting_struc_member = 41
  deleting_tryblks = 78
  destroyed_items = 82
  determined_main = 5
  enum_bf_changed = 25
  enum_cmt_changed = 27
  enum_created = 19
  enum_deleted = 21
  enum_member_created = 28
  enum_member_deleted = 30
  enum_renamed = 23
  expanding_struc = 38
  extlang_changed = 7
  extra_cmt_changed = 89
  flow_chart_created = 11
  frame_deleted = 68
  func_added = 63
  func_noret_changed = 74
  func_tail_appended = 70
  func_tail_deleted = 72
  func_updated = 64
  idasgn_loaded = 8
  item_color_changed = 90
  kernel_config_loaded = 9
  loader_finished = 10
  local_types_changed = 6
  make_code = 80
  make_data = 81
  op_ti_changed = 16
  op_type_changed = 18
  ph = <ida_idp.__ph object>
  range_cmt_changed = 88
  renamed = 83
  renaming_enum = 22
  renaming_struc = 36
  renaming_struc_member = 43
  savebase = 1
  segm_added = 49
  segm_attrs_updated = 60
  segm_class_changed = 59
  segm_deleted = 51
  segm_end_changed = 55
  segm_moved = 61
  segm_name_changed = 57
  segm_start_changed = 53
  set_func_end = 66
  set_func_start = 65
  sgr_changed = 79
  sgr_deleted = 93
  stkpnts_changed = 75
  struc_align_changed = 35
  struc_cmt_changed = 48
  struc_created = 31
  struc_deleted = 33
  struc_expanded = 39
  struc_member_changed = 46
  struc_member_created = 40
  struc_member_deleted = 42
  struc_member_renamed = 44
  struc_renamed = 37
  tail_owner_changed = 73
  thunk_func_created = 69
  ti_changed = 14
  tryblks_updated = 77
  updating_tryblks = 76
  upgraded = 2
Function Details

AssembleLine(ea, cs, ip, use32, nonnul_line)

 

Assemble an instruction to a string (display a warning if an error is found)

Parameters:
  • ea - linear address of instruction
  • cs - cs of instruction
  • ip - ip of instruction
  • use32 - is 32bit segment
  • line - line to assemble
Returns: PyObject *
  • None on failure
  • or a string containing the assembled instruction

assemble(ea, cs, ip, use32, line)

 

Assemble an instruction into the database (display a warning if an error is found)

Parameters:
  • ea - linear address of instruction
  • cs - cs of instruction
  • ip - ip of instruction
  • use32 - is 32bit segment?
  • line - line to assemble
Returns: bool
Boolean. True on success.

delay_slot_insn(ea, bexec, fexec)

 

Helper function to get the delay slot instruction.

Parameters:
  • ea, (C++ - ea_t *)
  • bexec, (C++ - bool *)
  • fexec, (C++ - bool *)
Returns: bool

gen_idb_event(code)

 

the kernel will use this function to generate idb_events

Parameters:
  • code, (C++ - idb_event::event_code_t)

get_idp_name()

 

Get name of the current processor module. The name is derived from the file name. For example, for IBM PC the module is named "pc.w32" (windows version), then the module name is "PC" (uppercase). If no processor module is loaded, this function will return NULL

Returns: str

get_reg_info(regname, bitrange)

 

Get register information - useful for registers like al, ah, dil, etc.

Parameters:
  • regname, (C++ - const char *)
  • bitrange, (C++ - bitrange_t *)
Returns: char const *
NULL no such register

get_reg_name(reg, width, reghi=-1)

 

Get text representation of a register. For most processors this function will just return \ph{reg_names}[reg]. If the processor module has implemented processor_t::get_reg_name, it will be used instead

Parameters:
  • reg - internal register number as defined in the processor module (C++: int)
  • width - register width in bytes (C++: size_t)
  • reghi - if specified, then this function will return the register pair (C++: int)
Returns: str
length of register name in bytes or -1 if failure

has_cf_chg(feature, opnum)

 

Does an instruction with the specified feature modify the i-th operand?

Parameters:
  • feature, (C++ - uint32)
  • opnum, (C++ - uint)
Returns: bool

has_cf_use(feature, opnum)

 

Does an instruction with the specified feature use a value of the i-th operand?

Parameters:
  • feature, (C++ - uint32)
  • opnum, (C++ - uint)
Returns: bool

has_insn_feature(icode, bit)

 

Does the specified instruction have the specified feature?

Parameters:
  • icode, (C++ - int)
  • bit, (C++ - uint32)
Returns: bool

is_align_insn(ea)

 

If the instruction at 'ea' looks like an alignment instruction, return its length in bytes. Otherwise return 0.

Parameters:
  • ea, (C++ - ea_t)
Returns: int

is_basic_block_end(insn, call_insn_stops_block)

 

Is the instruction the end of a basic block?

Parameters:
  • insn, (C++ - const insn_t &)
  • call_insn_stops_block, (C++ - bool)
Returns: bool

is_call_insn(insn)

 

Is the instruction a "call"?

Parameters:
  • insn, (C++ - const insn_t &)
Returns: bool

is_indirect_jump_insn(insn)

 

Is the instruction an indirect jump?

Parameters:
  • insn, (C++ - const insn_t &)
Returns: bool

is_ret_insn(insn, strict=True)

 

Is the instruction a "return"?

Parameters:
  • insn, (C++ - const insn_t &)
  • strict, (C++ - bool)
Returns: bool

parse_reg_name(ri, regname)

 

Get register info by name.

Parameters:
  • ri - result (C++: reg_info_t *)
  • regname - name of register (C++: const char *)
Returns: bool
success

ph_get_operand_info(ea, n)

 

Returns the operand information given an ea and operand number.

Parameters:
  • ea - address
  • n - operand number
Returns: PyObject *
Returns an idd_opinfo_t as a tuple: (modified, ea, reg_ival, regidx, value_size). Please refer to idd_opinfo_t structure in the SDK.

set_processor_type(procname, level)

 

Set target processor type. Once a processor module is loaded, it cannot be replaced until we close the idb.

Parameters:
  • procname - name of processor type (one of names present in \ph{psnames}) (C++: const char *)
  • level - SETPROC_ (C++: setproc_level_t)
Returns: bool
success

set_target_assembler(asmnum)

 

Set target assembler.

Parameters:
  • asmnum - number of assembler in the current processor module (C++: int)
Returns: bool
success

str2reg(p)

 

Get any reg number (-1 on error)

Parameters:
  • p, (C++ - const char *)
Returns: int