summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am2
-rw-r--r--plugins/devdbg/Makefile.am12
-rw-r--r--plugins/devdbg/speed.c121
-rw-r--r--plugins/devdbg/speed.h63
-rw-r--r--plugins/pychrysa/debug/debugger.c2
-rw-r--r--plugins/pychrysa/debug/debugger.h4
-rw-r--r--plugins/pychrysa/debug/module.c2
-rw-r--r--plugins/pychrysa/plugin.c17
8 files changed, 211 insertions, 12 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 4a6a852..84336ca 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = androhelpers pychrysa python stackvars
+SUBDIRS = androhelpers devdbg pychrysa python stackvars
diff --git a/plugins/devdbg/Makefile.am b/plugins/devdbg/Makefile.am
new file mode 100644
index 0000000..bd686d3
--- /dev/null
+++ b/plugins/devdbg/Makefile.am
@@ -0,0 +1,12 @@
+
+lib_LTLIBRARIES = libspeed.la
+
+libspeed_la_SOURCES = \
+ speed.h speed.c
+
+libspeed_la_CFLAGS = $(AM_CFLAGS)
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/devdbg/speed.c b/plugins/devdbg/speed.c
new file mode 100644
index 0000000..7f9705d
--- /dev/null
+++ b/plugins/devdbg/speed.c
@@ -0,0 +1,121 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * speed.c - mesure de temps d'exécution internes
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "speed.h"
+
+
+#include <malloc.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+#include <plugins/plugin-def.h>
+#include <plugins/plugin-int.h>
+
+
+
+DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("Speed Measure", "Tracks to time spent for disassembling code", "0.1.0",
+ PGA_DISASSEMBLY_STARTED, PGA_DISASSEMBLY_ENDED);
+
+
+/* Mémorisation des résultats de chronométrages */
+typedef struct _speed_measure
+{
+ clock_t points[2]; /* Points de mesure successifs */
+ unsigned long usages[2]; /* Taux d'utilisation du CPU */
+
+} speed_measure;
+
+
+
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à manipuler. *
+* action = type d'action attendue. *
+* binary = binaire dont le contenu est en cours de traitement. *
+* *
+* Description : Exécute une action pendant un désassemblage de binaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary)
+{
+ speed_measure *measure; /* Suivi des progressions */
+
+ void take_measure(clock_t *point, unsigned long *usage)
+ {
+ struct rusage rusage; /* Notification des usages */
+
+ *point = clock();
+
+ getrusage(RUSAGE_THREAD, &rusage);
+
+ *usage = rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec;
+ *usage += rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec;
+
+ }
+
+
+ switch (action)
+ {
+ case PGA_DISASSEMBLY_STARTED:
+
+ measure = (speed_measure *)calloc(1, sizeof(speed_measure));
+ g_object_set_data(G_OBJECT(binary), "speed_measure", measure);
+
+ take_measure(&measure->points[0], &measure->usages[0]);
+
+ break;
+
+
+ case PGA_DISASSEMBLY_ENDED:
+
+ measure = (speed_measure *)g_object_get_data(G_OBJECT(binary), "speed_measure");
+
+ take_measure(&measure->points[1], &measure->usages[1]);
+
+#define SHOW_SPEED(pg, sm, title, p0, p1) \
+ g_plugin_module_log_variadic_message(pg, LMT_INFO, title " : %.2g (%.2g)", \
+ (double)(sm->points[p1] - sm->points[p0]) / CLOCKS_PER_SEC, \
+ (sm->usages[p1] - sm->usages[p0]) / 1000000.0);
+
+ SHOW_SPEED(plugin, measure, "Whole elapsed time for disassembly", 0, 1);
+
+ g_object_set_data(G_OBJECT(binary), "speed_measure", NULL);
+ free(measure);
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ printf("##########\n\nPassage 0x%08x !!!\n\n################\n", action);
+
+}
diff --git a/plugins/devdbg/speed.h b/plugins/devdbg/speed.h
new file mode 100644
index 0000000..bad7ba5
--- /dev/null
+++ b/plugins/devdbg/speed.h
@@ -0,0 +1,63 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * speed.h - prototypes pour la mesure de temps d'exécution internes
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_DEVDBG_SPEED_H
+#define _PLUGINS_DEVDBG_SPEED_H
+
+
+#include <gmodule.h>
+
+#include <analysis/binary.h>
+#include <plugins/plugin.h>
+#include <plugins/plugin-def.h>
+
+
+
+
+/* Exécute une action pendant un désassemblage de binaire. */
+G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *, PluginAction , GLoadedBinary *);
+
+
+
+
+
+#if 0
+#include <glib-object.h>
+#include <gmodule.h>
+#include <stdbool.h>
+
+
+
+
+/* Initialise le greffon pour les bornes de routine. */
+G_MODULE_EXPORT bool init_plugin(GObject *);
+
+/* Fournit une indication sur le type d'opération(s) menée(s). */
+G_MODULE_EXPORT PluginAction get_plugin_action(void);
+
+/* Exécute une action définie sur un binaire chargé. */
+G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction);
+#endif
+
+
+#endif /* _PLUGINS_DEVDBG_SPEED_H */
diff --git a/plugins/pychrysa/debug/debugger.c b/plugins/pychrysa/debug/debugger.c
index c829385..dde6639 100644
--- a/plugins/pychrysa/debug/debugger.c
+++ b/plugins/pychrysa/debug/debugger.c
@@ -25,6 +25,7 @@
#include "debugger.h"
+#if 0
#include <malloc.h>
#include <pygobject.h>
@@ -276,3 +277,4 @@ bool register_python_binary_debugger(PyObject *module)
return (ret == 0);
}
+#endif
diff --git a/plugins/pychrysa/debug/debugger.h b/plugins/pychrysa/debug/debugger.h
index 378c675..1f7098a 100644
--- a/plugins/pychrysa/debug/debugger.h
+++ b/plugins/pychrysa/debug/debugger.h
@@ -29,7 +29,7 @@
#include <Python.h>
#include <stdbool.h>
-
+#if 0
#include <debug/debugger.h>
@@ -39,7 +39,7 @@ PyObject *py_binary_debugger_from_c(GBinaryDebugger *debugger);
/* Ajoute l'objet 'pychrysalide.debug.BinaryDebugger' au module. */
bool register_python_binary_debugger(PyObject *);
-
+#endif
#endif /* _PLUGINS_PYOIDA_DEBUG_DEBUGGER_H */
diff --git a/plugins/pychrysa/debug/module.c b/plugins/pychrysa/debug/module.c
index 302ca38..9241ee0 100644
--- a/plugins/pychrysa/debug/module.c
+++ b/plugins/pychrysa/debug/module.c
@@ -59,7 +59,7 @@ bool add_debug_module_to_python_module(PyObject *super)
result = (ret == 0);
- result &= register_python_binary_debugger(module);
+ //result &= register_python_binary_debugger(module);
return result;
diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c
index 9a93642..60a9ad7 100644
--- a/plugins/pychrysa/plugin.c
+++ b/plugins/pychrysa/plugin.c
@@ -36,7 +36,7 @@
#include "helpers.h"
#include "analysis/binary.h"
-#include "debug/debugger.h"
+//#include "debug/debugger.h"
@@ -85,7 +85,7 @@ static bool g_python_plugin_execute_on_binary(GPythonPlugin *, GLoadedBinary *,
/* Exécute une action relative à un débogueur. */
-static bool g_python_plugin_handle_debugger(const GPythonPlugin *, GBinaryDebugger *, PluginAction);
+//static bool g_python_plugin_handle_debugger(const GPythonPlugin *, GBinaryDebugger *, PluginAction);
@@ -126,7 +126,7 @@ static PyObject *pychrysa_plugin_is_matching(PyObject *, PyObject *);
/* Exécute une action relative à un débogueur. */
-static PyObject *pychrysa_plugin_handle_debugger(PyObject *, PyObject *);
+//static PyObject *pychrysa_plugin_handle_debugger(PyObject *, PyObject *);
@@ -184,7 +184,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_on_binary;
- plugin_parent->handle_debugger = (execute_on_debugger_fc)g_python_plugin_handle_debugger;
+ //plugin_parent->handle_debugger = (execute_on_debugger_fc)g_python_plugin_handle_debugger;
}
@@ -241,9 +241,9 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename)
result = g_object_new(G_TYPE_PYTHON_PLUGIN, NULL);
- G_PLUGIN_MODULE(result)->name = strdup(modname);
- G_PLUGIN_MODULE(result)->name = stradd(G_PLUGIN_MODULE(result)->name, ".py");
- G_PLUGIN_MODULE(result)->filename = strdup(G_PLUGIN_MODULE(result)->name);
+ //G_PLUGIN_MODULE(result)->name = strdup(modname);
+ //G_PLUGIN_MODULE(result)->name = stradd(G_PLUGIN_MODULE(result)->name, ".py");
+ //G_PLUGIN_MODULE(result)->filename = strdup(G_PLUGIN_MODULE(result)->name);
G_PLUGIN_MODULE(result)->init = (init_plugin_fc)g_python_plugin_do_init;
G_PLUGIN_MODULE(result)->get_action = (get_plugin_action_fc)g_python_plugin_get_action;
@@ -484,7 +484,7 @@ static bool g_python_plugin_execute_on_binary(GPythonPlugin *plugin, GLoadedBina
-
+#if 0
/******************************************************************************
* *
* Paramètres : plugin = greffon à consulter. *
@@ -520,6 +520,7 @@ static bool g_python_plugin_handle_debugger(const GPythonPlugin *plugin, GBinary
return result;
}
+#endif