Skip to content

Commit c29e1ef

Browse files
author
elias.bachaalany
committed
- added ph_get_operand_info()
1 parent 2327aad commit c29e1ef

4 files changed

Lines changed: 91 additions & 15 deletions

File tree

swig/bytes.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static PyObject *py_get_many_bytes(ea_t ea, unsigned int size)
668668
{
669669
if ( size <= 0 )
670670
break;
671-
671+
672672
// Allocate memory via Python
673673
PyObject *py_buf = PyString_FromStringAndSize(NULL, Py_ssize_t(size));
674674
if ( py_buf == NULL )

swig/idp.i

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
%ignore ph;
3333
%ignore IDB_Callback;
3434
%ignore IDP_Callback;
35-
35+
%ignore _py_getreg;
3636
%ignore free_processor_module;
3737
%ignore read_config_file;
3838

@@ -66,10 +66,10 @@ def AssembleLine(ea, cs, ip, use32, line):
6666
#</pydoc>
6767
*/
6868
static PyObject *AssembleLine(
69-
ea_t ea,
70-
ea_t cs,
71-
ea_t ip,
72-
bool use32,
69+
ea_t ea,
70+
ea_t cs,
71+
ea_t ip,
72+
bool use32,
7373
const char *line)
7474
{
7575
int inslen;
@@ -99,10 +99,10 @@ def assemble(ea, cs, ip, use32, line):
9999
#</pydoc>
100100
*/
101101
bool assemble(
102-
ea_t ea,
103-
ea_t cs,
104-
ea_t ip,
105-
bool use32,
102+
ea_t ea,
103+
ea_t cs,
104+
ea_t ip,
105+
bool use32,
106106
const char *line)
107107
{
108108
int inslen;
@@ -389,6 +389,66 @@ static PyObject *ph_get_regnames()
389389
return py_result;
390390
}
391391

392+
//---------------------------------------------------------------------------
393+
static const regval_t *idaapi _py_getreg(
394+
const char *name,
395+
const regval_t *regvals);
396+
397+
/*
398+
#<pydoc>
399+
def ph_get_operand_info():
400+
"""
401+
Returns the operand information given an ea and operand number.
402+
403+
@param ea: address
404+
@param n: operand number
405+
406+
@return: Returns an idd_opinfo_t as a tuple: (modified, ea, reg_ival, regidx, value_size).
407+
Please refer to idd_opinfo_t structure in the SDK.
408+
"""
409+
pass
410+
#</pydoc>
411+
*/
412+
static PyObject *ph_get_operand_info(
413+
ea_t ea,
414+
int n)
415+
{
416+
do
417+
{
418+
if ( dbg == NULL || n == - 1 )
419+
break;
420+
421+
// Allocate register space
422+
thid_t tid = get_current_thread();
423+
regvals_t regvalues;
424+
regvalues.reserve(dbg->registers_size);
425+
426+
// Read registers
427+
if ( dbg->read_registers(tid, -1, regvalues.begin()) != 1 )
428+
break;
429+
430+
// Call the processor module
431+
idd_opinfo_t opinf;
432+
if ( ph.notify(ph.get_operand_info,
433+
ea,
434+
n,
435+
tid,
436+
_py_getreg,
437+
regvalues.begin(),
438+
&opinf) != 0 )
439+
{
440+
break;
441+
}
442+
return Py_BuildValue("(i" PY_FMT64 "Kii)",
443+
opinf.modified,
444+
opinf.ea,
445+
opinf.value.ival,
446+
opinf.debregidx,
447+
opinf.value_size);
448+
} while (false);
449+
Py_RETURN_NONE;
450+
}
451+
392452
//-------------------------------------------------------------------------
393453
/*
394454
#<pydoc>
@@ -1200,6 +1260,20 @@ int idaapi IDB_Callback(void *ud, int notification_code, va_list va)
12001260
return 0;
12011261
}
12021262

1263+
//-------------------------------------------------------------------------
1264+
static const regval_t *idaapi _py_getreg(
1265+
const char *name,
1266+
const regval_t *regvals)
1267+
{
1268+
for ( int i=dbg->registers_size - 1; i >= 0; i-- )
1269+
{
1270+
if ( stricmp(name, dbg->registers[i].name) == 0 )
1271+
return &regvals[i];
1272+
}
1273+
static regval_t rv;
1274+
return &rv;
1275+
}
1276+
12031277
//-------------------------------------------------------------------------
12041278
//</code(py_idp)>
12051279
%}

swig/kernwin.i

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ class UI_Hooks(object):
408408
(these names can be looked up in ida[tg]ui.cfg)
409409
@return: 0-ok, nonzero - a plugin has handled the command
410410
"""
411+
pass
411412
412413
def postprocess(self):
413414
"""
@@ -727,15 +728,15 @@ int idaapi UI_Callback(void *ud, int notification_code, va_list va)
727728
{
728729
switch (notification_code)
729730
{
730-
case ui_preprocess:
731+
case ui_preprocess:
731732
{
732733
const char *name = va_arg(va, const char *);
733734
return proxy->preprocess(name);
734735
}
735736

736-
case ui_postprocess:
737-
proxy->postprocess();
738-
break;
737+
case ui_postprocess:
738+
proxy->postprocess();
739+
break;
739740
}
740741
}
741742
catch (Swig::DirectorException &)

swig/netnode.i

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@
111111

112112
return py_str;
113113
}
114-
}
114+
}
115+

0 commit comments

Comments
 (0)