summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Makefile.am2
-rw-r--r--src/plugins/context-int.h49
-rw-r--r--src/plugins/context.c77
-rw-r--r--src/plugins/context.h53
-rw-r--r--src/plugins/pglist.c2
-rw-r--r--src/plugins/plugin-def.h12
-rw-r--r--src/plugins/plugin-int.h3
-rw-r--r--src/plugins/plugin.c27
-rw-r--r--src/plugins/plugin.h2
9 files changed, 222 insertions, 5 deletions
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 9a76f74..4e4a312 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -2,6 +2,8 @@
lib_LTLIBRARIES = libplugins.la
libplugins_la_SOURCES = \
+ context-int.h \
+ context.h context.c \
pglist.h pglist.c \
plugin-def.h \
plugin-int.h \
diff --git a/src/plugins/context-int.h b/src/plugins/context-int.h
new file mode 100644
index 0000000..fc03df8
--- /dev/null
+++ b/src/plugins/context-int.h
@@ -0,0 +1,49 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * context-int.h - prototypes pour les structures internes des instances de greffon
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * 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 _FORMAT_PLUGINS_CONTEXT_INT_H
+#define _FORMAT_PLUGINS_CONTEXT_INT_H
+
+
+#include <glib-object.h>
+
+
+
+/* Instance de greffon pour OpenIDA (instance) */
+struct _GPluginContext
+{
+ GObject parent; /* A laisser en premier */
+
+};
+
+
+/* Instance de greffon pour OpenIDA (classe) */
+struct _GPluginContextClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+};
+
+
+
+#endif /* _FORMAT_PLUGINS_CONTEXT_INT_H */
diff --git a/src/plugins/context.c b/src/plugins/context.c
new file mode 100644
index 0000000..06fd17e
--- /dev/null
+++ b/src/plugins/context.c
@@ -0,0 +1,77 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * context.c - instances d'actions d'un greffon donné
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "context.h"
+
+
+#include "context-int.h"
+
+
+
+/* Initialise la classe des instances de greffon. */
+static void g_plugin_context_class_init(GPluginContextClass *);
+
+/* Initialise une instance d'instance de greffon. */
+static void g_plugin_context_init(GPluginContext *);
+
+
+
+/* Indique le type défini pour une instance de greffon. */
+G_DEFINE_TYPE(GPluginContext, g_plugin_context, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des instances de greffon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_plugin_context_class_init(GPluginContextClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : context = instance à initialiser. *
+* *
+* Description : Initialise une instance d'instance de greffon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_plugin_context_init(GPluginContext *context)
+{
+
+}
diff --git a/src/plugins/context.h b/src/plugins/context.h
new file mode 100644
index 0000000..f4348e1
--- /dev/null
+++ b/src/plugins/context.h
@@ -0,0 +1,53 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * context.h - prototypes pour les instances d'actions d'un greffon donné
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_CONTEXT_H
+#define _PLUGINS_CONTEXT_H
+
+
+#include <glib-object.h>
+
+
+
+/* Instance de greffon pour OpenIDA (instance) */
+typedef struct _GPluginContext GPluginContext;
+
+/* Instance de greffon pour OpenIDA (classe) */
+typedef struct _GPluginContextClass GPluginContextClass;
+
+
+#define G_TYPE_PLUGIN_CONTEXT (g_plugin_context_get_type())
+#define G_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_PLUGIN_CONTEXT, GPluginContext))
+#define G_IS_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_PLUGIN_CONTEXT))
+#define G_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_PLUGIN_CONTEXT, GPluginContextClass))
+#define G_IS_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_PLUGIN_CONTEXT))
+#define G_PLUGIN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_PLUGIN_CONTEXT, GPluginContextClass))
+
+
+/* Indique le type défini pour une instance de greffon. */
+GType g_plugin_context_get_type(void);
+
+
+
+#endif /* _PLUGINS_CONTEXT_H */
diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c
index 8139e08..f242cba 100644
--- a/src/plugins/pglist.c
+++ b/src/plugins/pglist.c
@@ -130,7 +130,7 @@ void browse_directory_for_plugins(plugins_list *list, const char *dir)
int ret; /* Bilan du parcours */
char *filename; /* Elément à ausculter */
GPluginModule *plugin; /* Greffon à intégrer ou pas */
- return;
+
ret = scandir(dir, &namelist, filter_dirs_or_mods, alphasort);
if (ret < 0)
{
diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h
index adbabd4..50b8df2 100644
--- a/src/plugins/plugin-def.h
+++ b/src/plugins/plugin-def.h
@@ -30,6 +30,15 @@
+/* Types de greffon */
+typedef enum _PluginType
+{
+ PGT_BINARY = (1 << 0) /* Actions sur un binaire */
+
+
+} PluginType;
+
+
/* Action(s) menée(s) par le greffon */
typedef enum _PluginAction
{
@@ -41,6 +50,9 @@ typedef enum _PluginAction
+/* Fournit une indication sur le(s) type(s) du greffon présent. */
+typedef PluginType (* get_plugin_type_fc) (void);
+
/* Fournit une indication sur le type d'opération(s) menée(s). */
typedef PluginAction (* get_plugin_action_fc) (void);
diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h
index 7e2703b..929dbf9 100644
--- a/src/plugins/plugin-int.h
+++ b/src/plugins/plugin-int.h
@@ -1,6 +1,6 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
- * elf-int.h - prototypes pour les structures internes du format ELF
+ * plugin-int.h - prototypes pour les structures internes des greffons
*
* Copyright (C) 2008 Cyrille Bagard
*
@@ -45,6 +45,7 @@ struct _GPluginModule
GModule *module; /* Abstration de manipulation */
+ PluginType type; /* Type(s) du greffon */
PluginAction action; /* Opération(s) menée(s) */
init_plugin_fc init; /* Procédure d'initialisation */
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 42bef63..2443768 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -41,7 +41,7 @@ static void g_plugin_module_init(GPluginModule *);
-/* Indique le type définit pour un greffon. */
+/* Indique le type défini pour un greffon. */
G_DEFINE_TYPE(GPluginModule, g_plugin_module, G_TYPE_OBJECT);
@@ -98,7 +98,8 @@ static void g_plugin_module_init(GPluginModule *line)
GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
{
GPluginModule *result; /* Structure à retourner */
- get_plugin_action_fc __get_action; /* Actions du greffon */
+ get_plugin_action_fc __get_type; /* Type(s) de greffon */
+ get_plugin_action_fc __get_action; /* Actions du greffon */
result = g_object_new(G_TYPE_PLUGIN_MODULE, NULL);
@@ -107,6 +108,21 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
result->module = g_module_open(filename, G_MODULE_BIND_LAZY);
+
+ if (!g_module_symbol(result->module, "get_plugin_type", (gpointer *)&__get_type))
+ {
+ printf("No 'get_plugin_type' symbol found in the plugin '%s'\n", filename);
+ goto bad_plugin;
+ }
+
+ result->type = __get_type();
+
+
+ printf("Plugin type :: 0x%08x\n", result->type);
+
+
+
+
#if 1
if (!g_module_symbol(result->module, "get_plugin_action", (gpointer *)&__get_action))
{
@@ -148,6 +164,13 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
return result;
+
+ bad_plugin:
+
+ g_object_unref(G_OBJECT(result));
+
+ return NULL;
+
}
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index ddfb0c6..d17cee5 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -48,7 +48,7 @@ typedef struct _GPluginModuleClass GPluginModuleClass;
#define G_PLUGIN_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_PLUGIN_MODULE, GPluginModuleClass))
-/* Indique le type définit pour un greffon. */
+/* Indique le type défini pour un greffon. */
GType g_plugin_module_get_type(void);
/* Crée un module pour un greffon donné. */