summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pyoida/plugin.c88
-rw-r--r--plugins/python/exectracer/Makefile.am6
-rw-r--r--plugins/python/exectracer/__init__.py2
-rw-r--r--plugins/python/exectracer/exectracer.py18
4 files changed, 106 insertions, 8 deletions
diff --git a/plugins/pyoida/plugin.c b/plugins/pyoida/plugin.c
index d7deecb..9bcec8e 100644
--- a/plugins/pyoida/plugin.c
+++ b/plugins/pyoida/plugin.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* plugin.c - interactions avec un greffon Python
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -75,6 +75,11 @@ static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *, c
static bool g_python_plugin_execute(GPythonPlugin *, GOpenidaBinary *, PluginAction);
+/* Exécute une action relative à un débogueur. */
+static bool g_python_plugin_handle_debugger(const GPythonPlugin *, GBinaryDebugger *, PluginAction);
+
+
+
/* ------------------------- MODULE PYTHON POUR LES SCRIPTS ------------------------- */
@@ -108,6 +113,10 @@ static PyObject *pyoida_plugin_get_action(PyObject *, PyObject *);
static PyObject *pyoida_plugin_is_matching(PyObject *, PyObject *);
+/* Exécute une action relative à un débogueur. */
+static PyObject *pyoida_plugin_handle_debugger(PyObject *, PyObject *);
+
+
@@ -239,6 +248,7 @@ static void g_python_plugin_init(GPythonPlugin *plugin)
plugin_parent = G_PLUGIN_MODULE(plugin);
plugin_parent->exec_on_bin = (execute_action_on_binary_fc)g_python_plugin_execute;
+ plugin_parent->handle_debugger = (execute_on_debugger_fc)g_python_plugin_handle_debugger;
}
@@ -470,13 +480,6 @@ static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *plu
-
-
-
-
-
-
-
/******************************************************************************
* *
* Paramètres : plugin = greffon de prise en charge à utiliser. *
@@ -531,6 +534,48 @@ static bool g_python_plugin_execute(GPythonPlugin *plugin, GOpenidaBinary *binar
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à consulter. *
+* debugger = débogueur à l'origine de l'opération. *
+* action = action attendue. *
+* *
+* Description : Exécute une action relative à un débogueur. *
+* *
+* Retour : true si une action a été menée, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_python_plugin_handle_debugger(const GPythonPlugin *plugin, GBinaryDebugger *debugger, PluginAction action)
+{
+ bool result; /* Bilan à remonter */
+ PyObject *args; /* Arguments pour l'appel */
+ PyObject *value; /* Valeurs obtenues */
+
+ args = PyTuple_New(2);
+
+ PyTuple_SetItem(args, 0, Py_None);
+ PyTuple_SetItem(args, 1, PyInt_FromLong(action));
+
+ value = run_python_method(plugin->instance, "handle_debugger", args);
+
+ result = (value == Py_True);
+
+ Py_XDECREF(value);
+ Py_DECREF(args);
+
+ return result;
+
+}
+
+
+
+
+
+
+
/* ---------------------------------------------------------------------------------- */
/* MODULE PYTHON POUR LES SCRIPTS */
/* ---------------------------------------------------------------------------------- */
@@ -596,6 +641,12 @@ static bool pyoida_plugin_define_constants(PyObject *dict)
ret = PyDict_SetItemString(dict, "PGA_CODE_PROCESS", PyInt_FromLong(PGA_CODE_PROCESS));
if (ret == -1) return false;
+ ret = PyDict_SetItemString(dict, "PGA_DEBUGGER_ATTACH", PyInt_FromLong(PGA_DEBUGGER_ATTACH));
+ if (ret == -1) return false;
+
+ ret = PyDict_SetItemString(dict, "PGA_DEBUGGER_DETACH", PyInt_FromLong(PGA_DEBUGGER_DETACH));
+ if (ret == -1) return false;
+
/* PGA_FORMAT_MATCHER */
ret = PyDict_SetItemString(dict, "MFA_NONE", PyInt_FromLong(MFA_NONE));
@@ -662,6 +713,24 @@ static PyObject *pyoida_plugin_is_matching(PyObject *self, PyObject *args)
+/******************************************************************************
+* *
+* Paramètres : self = classe assurant le lien avec l'éditeur de messages. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Exécute une action relative à un débogueur. *
+* *
+* Retour : True en équivalent Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *pyoida_plugin_handle_debugger(PyObject *self, PyObject *args)
+{
+ Py_RETURN_TRUE;
+
+}
/******************************************************************************
@@ -712,6 +781,9 @@ static PyMethodDef pyoida_plugin_methods[] = {
{ "is_matching", (PyCFunction)pyoida_plugin_is_matching, METH_VARARGS,
"Define if the given file can be handled."
},
+ { "handle_debugger", (PyCFunction)pyoida_plugin_handle_debugger, METH_VARARGS,
+ "Be notify about debugger attaching or detaching."
+ },
{ "run", (PyCFunction)pyoida_plugin_run, METH_VARARGS,
"Run the plugin for a specific action."
},
diff --git a/plugins/python/exectracer/Makefile.am b/plugins/python/exectracer/Makefile.am
new file mode 100644
index 0000000..9f8eeb2
--- /dev/null
+++ b/plugins/python/exectracer/Makefile.am
@@ -0,0 +1,6 @@
+
+exectracerdir = $(datadir)/openida/plugins/python/exectracer
+
+exectracer_DATA = \
+ __init__.py \
+ exectracer.py
diff --git a/plugins/python/exectracer/__init__.py b/plugins/python/exectracer/__init__.py
new file mode 100644
index 0000000..abdaa6c
--- /dev/null
+++ b/plugins/python/exectracer/__init__.py
@@ -0,0 +1,2 @@
+
+from exectracer import ExecTracer as exectracer
diff --git a/plugins/python/exectracer/exectracer.py b/plugins/python/exectracer/exectracer.py
new file mode 100644
index 0000000..2773586
--- /dev/null
+++ b/plugins/python/exectracer/exectracer.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+from pyoida import Plugin
+
+
+class ExecTracer(Plugin):
+ """Trace and replay debug executions."""
+
+ def get_action(self):
+ """Register the plugin for given actions."""
+
+ return Plugin.PGA_DEBUGGER_ATTACH
+
+ def handle_debugger(self, debugger, action):
+ """Be notify about debugger attaching or detaching."""
+
+ print "Python Hello !"