diff --git a/python.cpp b/python.cpp index ef8d330..a7307bd 100644 --- a/python.cpp +++ b/python.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,15 @@ int tracefunc(PyObject *obj, _frame *frame, int what, PyObject *arg) } #endif +/* Simple Python statement runner function for IDC */ +static const char idc_runpythonstatement_args[] = { VT_STR, 0 }; +static error_t idaapi idc_runpythonstatement(value_t *argv, value_t *res) +{ + res->num = PyRun_SimpleString(argv[0].str); + return eOk; +} + + /* QuickFix for the FILE* incompatibility problem */ int ExecFile(char *FileName) { @@ -354,6 +364,9 @@ bool IDAPython_Init(void) (menu_item_callback_t *)IDAPython_Menu_Callback, (void *)IDAPYTHON_SCRIPTBOX); } + + /* Register a RunPythonStatement() function for IDC */ + set_idc_func("RunPythonStatement", idc_runpythonstatement, idc_runpythonstatement_args); initialized = 1;