- added ph_get_operand_info()

This commit is contained in:
elias.bachaalany 2011-05-23 15:54:27 +00:00
parent 2327aada40
commit c29e1ef2da
4 changed files with 91 additions and 15 deletions

View File

@ -668,7 +668,7 @@ static PyObject *py_get_many_bytes(ea_t ea, unsigned int size)
{
if ( size <= 0 )
break;
// Allocate memory via Python
PyObject *py_buf = PyString_FromStringAndSize(NULL, Py_ssize_t(size));
if ( py_buf == NULL )

View File

@ -32,7 +32,7 @@
%ignore ph;
%ignore IDB_Callback;
%ignore IDP_Callback;
%ignore _py_getreg;
%ignore free_processor_module;
%ignore read_config_file;
@ -66,10 +66,10 @@ def AssembleLine(ea, cs, ip, use32, line):
#</pydoc>
*/
static PyObject *AssembleLine(
ea_t ea,
ea_t cs,
ea_t ip,
bool use32,
ea_t ea,
ea_t cs,
ea_t ip,
bool use32,
const char *line)
{
int inslen;
@ -99,10 +99,10 @@ def assemble(ea, cs, ip, use32, line):
#</pydoc>
*/
bool assemble(
ea_t ea,
ea_t cs,
ea_t ip,
bool use32,
ea_t ea,
ea_t cs,
ea_t ip,
bool use32,
const char *line)
{
int inslen;
@ -389,6 +389,66 @@ static PyObject *ph_get_regnames()
return py_result;
}
//---------------------------------------------------------------------------
static const regval_t *idaapi _py_getreg(
const char *name,
const regval_t *regvals);
/*
#<pydoc>
def ph_get_operand_info():
"""
Returns the operand information given an ea and operand number.
@param ea: address
@param n: operand number
@return: 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.
"""
pass
#</pydoc>
*/
static PyObject *ph_get_operand_info(
ea_t ea,
int n)
{
do
{
if ( dbg == NULL || n == - 1 )
break;
// Allocate register space
thid_t tid = get_current_thread();
regvals_t regvalues;
regvalues.reserve(dbg->registers_size);
// Read registers
if ( dbg->read_registers(tid, -1, regvalues.begin()) != 1 )
break;
// Call the processor module
idd_opinfo_t opinf;
if ( ph.notify(ph.get_operand_info,
ea,
n,
tid,
_py_getreg,
regvalues.begin(),
&opinf) != 0 )
{
break;
}
return Py_BuildValue("(i" PY_FMT64 "Kii)",
opinf.modified,
opinf.ea,
opinf.value.ival,
opinf.debregidx,
opinf.value_size);
} while (false);
Py_RETURN_NONE;
}
//-------------------------------------------------------------------------
/*
#<pydoc>
@ -1200,6 +1260,20 @@ int idaapi IDB_Callback(void *ud, int notification_code, va_list va)
return 0;
}
//-------------------------------------------------------------------------
static const regval_t *idaapi _py_getreg(
const char *name,
const regval_t *regvals)
{
for ( int i=dbg->registers_size - 1; i >= 0; i-- )
{
if ( stricmp(name, dbg->registers[i].name) == 0 )
return &regvals[i];
}
static regval_t rv;
return &rv;
}
//-------------------------------------------------------------------------
//</code(py_idp)>
%}

View File

@ -408,6 +408,7 @@ class UI_Hooks(object):
(these names can be looked up in ida[tg]ui.cfg)
@return: 0-ok, nonzero - a plugin has handled the command
"""
pass
def postprocess(self):
"""
@ -727,15 +728,15 @@ int idaapi UI_Callback(void *ud, int notification_code, va_list va)
{
switch (notification_code)
{
case ui_preprocess:
case ui_preprocess:
{
const char *name = va_arg(va, const char *);
return proxy->preprocess(name);
}
case ui_postprocess:
proxy->postprocess();
break;
case ui_postprocess:
proxy->postprocess();
break;
}
}
catch (Swig::DirectorException &)

View File

@ -111,4 +111,5 @@
return py_str;
}
}
}