- added GetInstructionList() and GetRegisterList() to idautils.py

- ignored processor_t and ph global variable
This commit is contained in:
elias.bachaalany 2010-03-22 14:21:43 +00:00
parent 729084a1ff
commit ab81000187
3 changed files with 62 additions and 44 deletions

View File

@ -451,6 +451,13 @@ class Strings(object):
return Strings.StringItem(self._si) return Strings.StringItem(self._si)
return None return None
def GetRegisterList():
"""Returns the register list"""
return idaapi.ph_get_regnames()
def GetInstructionList():
"""Returns the instruction list of the current processor module"""
return [i[0] for i in idaapi.ph_get_instruc() if i[0]]
def _Assemble(ea, line): def _Assemble(ea, line):
""" """

View File

@ -805,7 +805,7 @@ def MakePackReal(ea):
@return: 1-ok, 0-failure @return: 1-ok, 0-failure
""" """
return idaapi.doPackReal(ea, idaapi.cvar.ph.tbyte_size) return idaapi.doPackReal(ea, idaapi.ph_get_tbyte_size())
def MakeTbyte(ea): def MakeTbyte(ea):
@ -816,7 +816,7 @@ def MakeTbyte(ea):
@return: 1-ok, 0-failure @return: 1-ok, 0-failure
""" """
return idaapi.doTbyt(ea, idaapi.cvar.ph.tbyte_size) return idaapi.doTbyt(ea, idaapi.ph_get_tbyte_size())
def MakeStructEx(ea, size, strname): def MakeStructEx(ea, size, strname):

View File

@ -2,6 +2,9 @@
%ignore WorkReg; %ignore WorkReg;
%ignore AbstractRegister; %ignore AbstractRegister;
%ignore rginfo; %ignore rginfo;
%ignore insn_t::get_canon_mnem;
%ignore insn_t::get_canon_feature;
%ignore insn_t::is_canon_insn;
%ignore bytes_t; %ignore bytes_t;
%ignore IDPOPT_STR; %ignore IDPOPT_STR;
%ignore IDPOPT_NUM; %ignore IDPOPT_NUM;
@ -14,7 +17,6 @@
%ignore IDPOPT_BADVALUE; %ignore IDPOPT_BADVALUE;
%ignore set_options_t; %ignore set_options_t;
%ignore read_user_config_file; %ignore read_user_config_file;
%ignore instruc_t;
%ignore s_preline; %ignore s_preline;
%ignore ca_operation_t; %ignore ca_operation_t;
@ -25,43 +27,16 @@
%ignore asm_t::func_header; %ignore asm_t::func_header;
%ignore asm_t::func_footer; %ignore asm_t::func_footer;
%ignore asm_t::get_type_name; %ignore asm_t::get_type_name;
%ignore processor_t::notify; %ignore instruc_t;
%ignore processor_t::header; %ignore processor_t;
%ignore processor_t::footer; %ignore ph;
%ignore processor_t::segstart;
%ignore processor_t::segend;
%ignore processor_t::assumes;
%ignore processor_t::u_ana;
%ignore processor_t::u_emu;
%ignore processor_t::u_out;
%ignore processor_t::u_outop;
%ignore processor_t::d_out;
%ignore processor_t::cmp_opnd;
%ignore processor_t::can_have_type;
%ignore processor_t::getreg;
%ignore processor_t::is_far_jump;
%ignore processor_t::translate;
%ignore processor_t::realcvt;
%ignore processor_t::is_switch;
%ignore processor_t::gen_map_file;
%ignore processor_t::extract_address;
%ignore processor_t::is_sp_based;
%ignore processor_t::create_func_frame;
%ignore processor_t::get_frame_retsize;
%ignore processor_t::gen_stkvar_def;
%ignore processor_t::u_outspec;
%ignore processor_t::is_align_insn;
%ignore IDB_Callback; %ignore IDB_Callback;
%ignore processor_t::idp_notify;
%ignore processor_t::notify;
%ignore processor_t::set_idp_options;
%ignore free_processor_module; %ignore free_processor_module;
%ignore read_config_file; %ignore read_config_file;
%ignore gen_idb_event; %ignore gen_idb_event;
%include "idp.hpp" %include "idp.hpp"
%feature("director") IDB_Hooks; %feature("director") IDB_Hooks;
@ -306,6 +281,10 @@ inline const int assemble(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *lin
return 0; return 0;
} }
//<inline(py_idp)>
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Assemble an instruction to a buffer (display a warning if an error is found) // Assemble an instruction to a buffer (display a warning if an error is found)
// args: // args:
// ea_t ea - linear address of instruction // ea_t ea - linear address of instruction
@ -314,7 +293,7 @@ inline const int assemble(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *lin
// bool use32 - is 32bit segment? // bool use32 - is 32bit segment?
// const char *line - line to assemble // const char *line - line to assemble
// returns: 1: success, 0: failure // returns: 1: success, 0: failure
inline const PyObject *AssembleLine(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *line) static PyObject *AssembleLine(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *line)
{ {
int inslen; int inslen;
char buf[MAXSTR]; char buf[MAXSTR];
@ -325,4 +304,36 @@ inline const PyObject *AssembleLine(ea_t ea, ea_t cs, ea_t ip, bool use32, const
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }
//-------------------------------------------------------------------------
static size_t ph_get_tbyte_size()
{
return ph.tbyte_size;
}
//-------------------------------------------------------------------------
static PyObject *ph_get_instruc()
{
Py_ssize_t i = 0;
PyObject *py_result = PyTuple_New(ph.instruc_end - ph.instruc_start);
for ( instruc_t *p = ph.instruc + ph.instruc_start, *end = ph.instruc + ph.instruc_end;
p != end;
++p )
{
PyTuple_SetItem(py_result, i++, Py_BuildValue("(sI)", p->name, p->feature));
}
return py_result;
}
//-------------------------------------------------------------------------
static PyObject *ph_get_regnames()
{
Py_ssize_t i = 0;
PyObject *py_result = PyList_New(ph.regsNum);
for ( Py_ssize_t i=0; i<ph.regsNum; i++ )
PyList_SetItem(py_result, i, PyString_FromString(ph.regNames[i]));
return py_result;
}
//</inline(py_idp)>
%} %}