summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-05-17 00:28:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-05-17 00:28:23 (GMT)
commit7adb4243ad629554e496de173977721a8a5d0110 (patch)
tree18f50fcdab35e057b3a1a10e7e0c1f141e89eb39 /src
parent118a668adbf6ca9d4c549618e54f58330f46ce58 (diff)
Given more details for each operand relative to one DEX pool.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@156 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/analysis/exporter.c7
-rw-r--r--src/analysis/variable.c109
-rw-r--r--src/analysis/variable.h18
-rw-r--r--src/arch/dalvik/operand.c34
-rw-r--r--src/arch/dalvik/operand.h4
-rw-r--r--src/arch/instruction.c2
-rw-r--r--src/arch/instruction.h2
-rw-r--r--src/format/dex/dex-int.c57
-rwxr-xr-xsrc/format/dex/dex-int.h4
-rwxr-xr-xsrc/format/dex/dex_def.h18
-rw-r--r--src/format/dex/pool.c97
-rw-r--r--src/format/dex/pool.h8
-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
21 files changed, 580 insertions, 7 deletions
diff --git a/src/analysis/exporter.c b/src/analysis/exporter.c
index edff9d8..676b101 100644
--- a/src/analysis/exporter.c
+++ b/src/analysis/exporter.c
@@ -148,8 +148,15 @@ static void g_content_exporter_class_init(GContentExporterClass *klass)
klass->attribs[RTT_SEGMENT] = pango_attr_list_new();
+ /* RTT_STRING */
+
klass->attribs[RTT_STRING] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(52224, 32256, 0);
+ pango_attr_list_insert(klass->attribs[RTT_STRING], attrib);
+
+ /* RTT_VAR_NAME */
+
klass->attribs[RTT_VAR_NAME] = pango_attr_list_new();
}
diff --git a/src/analysis/variable.c b/src/analysis/variable.c
index e24f7e1..87df60e 100644
--- a/src/analysis/variable.c
+++ b/src/analysis/variable.c
@@ -24,6 +24,9 @@
#include "variable.h"
+#include <string.h>
+
+
#include "../common/extstr.h"
@@ -39,6 +42,8 @@ struct _GBinVariable
GOpenidaType *type; /* Type de la variable */
char *name; /* Désignation humaine */
+ GOpenidaType *owner; /* Zone d'appartenance */
+
};
/* Variable typée (classe) */
@@ -128,6 +133,110 @@ GBinVariable *g_binary_variable_new(GOpenidaType *type)
}
+/******************************************************************************
+* *
+* Paramètres : var = variable à consulter. *
+* *
+* Description : Fournit le type d'une variable donnée. *
+* *
+* Retour : Type de la variable. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GOpenidaType *g_binary_variable_get_vtype(const GBinVariable *var)
+{
+ return var->type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : var = variable à consulter. *
+* *
+* Description : Fournit le nom d'une variable donnée. *
+* *
+* Retour : Nom de la variable ou NULL si non précisé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *g_binary_variable_get_name(const GBinVariable *var)
+{
+ return var->name;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : var = variable à consulter. *
+* name = désignation à associer à la variable, voire NULL. *
+* *
+* Description : Définit le nom d'une variable donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_variable_set_name(GBinVariable *var, const char *name)
+{
+ if (var->name != NULL)
+ free(var->name);
+
+ if (name == NULL) var->name = NULL;
+ else var->name = strdup(name);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : var = variable à consulter. *
+* *
+* Description : Fournit la zone d'appartenance d'une variable donnée. *
+* *
+* Retour : Zone d'appartenance de la variable ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GOpenidaType *g_binary_variable_get_owner(const GBinVariable *var)
+{
+ return var->owner;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : var = variable à consulter. *
+* owner = type identifiant la zone d'appartenance. *
+* *
+* Description : Définit la zone d'appartenance d'une variable donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_variable_set_owner(GBinVariable *var, GOpenidaType *owner)
+{
+ var->owner = owner;
+
+}
+
+
+
+
+
diff --git a/src/analysis/variable.h b/src/analysis/variable.h
index ab5a037..88e2b91 100644
--- a/src/analysis/variable.h
+++ b/src/analysis/variable.h
@@ -57,8 +57,26 @@ GType g_binary_variable_get_type(void);
/* Crée une représentation de variable de type donné. */
GBinVariable *g_binary_variable_new(GOpenidaType *);
+/* Fournit le type d'une variable donnée. */
+GOpenidaType *g_binary_variable_get_vtype(const GBinVariable *);
+/* Fournit le nom d'une variable donnée. */
+const char *g_binary_variable_get_name(const GBinVariable *);
+/* Définit le nom d'une variable donnée. */
+void g_binary_variable_set_name(GBinVariable *, const char *);
+
+/* Fournit la zone d'appartenance d'une variable donnée. */
+GOpenidaType *g_binary_variable_get_owner(const GBinVariable *);
+
+/* Définit la zone d'appartenance d'une variable donnée. */
+void g_binary_variable_set_owner(GBinVariable *, GOpenidaType *);
+
+
+
+
+
+/* TODO : remme */
/* Décrit la variable donnée sous forme de caractères. */
char *g_binary_variable_to_string(const GBinVariable *);
diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c
index cc36cb5..7b58b1d 100644
--- a/src/arch/dalvik/operand.c
+++ b/src/arch/dalvik/operand.c
@@ -788,8 +788,42 @@ static void g_dalvik_pool_operand_to_buffer(const GDalvikPoolOperand *operand, G
}
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Indique la nature de la table de constantes visée ici. *
+* *
+* Retour : Type de table constantes visée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+DalvikPoolType g_dalvik_pool_operand_get_pool_type(const GDalvikPoolOperand *operand)
+{
+ return operand->type;
+
+}
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Indique l'indice de l'élément dans la table de constantes. *
+* *
+* Retour : Indice de l'élément visé dans la table de constantes. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand)
+{
+ return operand->index;
+
+}
diff --git a/src/arch/dalvik/operand.h b/src/arch/dalvik/operand.h
index da14aa3..4045c5f 100644
--- a/src/arch/dalvik/operand.h
+++ b/src/arch/dalvik/operand.h
@@ -138,7 +138,11 @@ GType g_dalvik_pool_operand_get_type(void);
/* Crée un opérande visant un élément constant Dalvik. */
GArchOperand *g_dalvik_pool_operand_new(DalvikPoolType, const bin_t *, off_t *, off_t, MemoryDataSize, SourceEndian);
+/* Indique la nature de la table de constantes visée ici. */
+DalvikPoolType g_dalvik_pool_operand_get_pool_type(const GDalvikPoolOperand *);
+/* Indique l'indice de l'élément dans la table de constantes. */
+uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *);
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 14b0038..3bbd15c 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -322,7 +322,7 @@ const GArchOperand *g_arch_instruction_get_operand(GArchInstruction *instr, size
* new = nouvelle opérande à attacher. *
* old = ancienne opérande à détacher. *
* *
-* Description : Replace un opérande d'une instruction par un autre. *
+* Description : Remplace un opérande d'une instruction par un autre. *
* *
* Retour : - *
* *
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 0c51b93..2314a56 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -79,7 +79,7 @@ size_t g_arch_instruction_count_operands(const GArchInstruction *);
/* Fournit un opérande donné d'une instruction. */
const GArchOperand *g_arch_instruction_get_operand(GArchInstruction *, size_t);
-/* Replace un opérande d'une instruction par un autre. */
+/* Remplace un opérande d'une instruction par un autre. */
void g_arch_instruction_replace_operand(GArchInstruction *, GArchOperand *, const GArchOperand *);
/* Détache un opérande liée d'une instruction. */
diff --git a/src/format/dex/dex-int.c b/src/format/dex/dex-int.c
index be1c211..025429f 100644
--- a/src/format/dex/dex-int.c
+++ b/src/format/dex/dex-int.c
@@ -134,15 +134,72 @@ bool read_dex_type_id_item(const GDexFormat *format, off_t *pos, type_id_item *i
}
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* pos = position de début de lecture. [OUT] *
+* proto_id = structure lue à retourner. [OUT] *
+* *
+* Description : Procède à la lecture d'une description de prototype. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+bool read_dex_proto_id_item(const GDexFormat *format, off_t *pos, proto_id_item *proto_id)
+{
+ bool result; /* Bilan à retourner */
+ const bin_t *content; /* Contenu binaire à lire */
+ off_t length; /* Taille totale du contenu */
+ result = true;
+ content = G_BIN_FORMAT(format)->content;
+ length = G_BIN_FORMAT(format)->length;
+ result &= read_u32(&proto_id->shorty_idx, content, pos, length, SRE_LITTLE);
+ result &= read_u32(&proto_id->return_type_idx, content, pos, length, SRE_LITTLE);
+ result &= read_u32(&proto_id->parameters_off, content, pos, length, SRE_LITTLE);
+ return result;
+}
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* pos = position de début de lecture. [OUT] *
+* field_id = structure lue à retourner. [OUT] *
+* *
+* Description : Procède à la lecture d'une description de champ. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool read_dex_field_id_item(const GDexFormat *format, off_t *pos, field_id_item *field_id)
+{
+ bool result; /* Bilan à retourner */
+ const bin_t *content; /* Contenu binaire à lire */
+ off_t length; /* Taille totale du contenu */
+
+ result = true;
+ content = G_BIN_FORMAT(format)->content;
+ length = G_BIN_FORMAT(format)->length;
+
+ result &= read_u16(&field_id->class_idx, content, pos, length, SRE_LITTLE);
+ result &= read_u16(&field_id->type_idx, content, pos, length, SRE_LITTLE);
+ result &= read_u32(&field_id->name_idx, content, pos, length, SRE_LITTLE);
+
+ return result;
+
+}
/******************************************************************************
diff --git a/src/format/dex/dex-int.h b/src/format/dex/dex-int.h
index e34dbd3..2e3cc00 100755
--- a/src/format/dex/dex-int.h
+++ b/src/format/dex/dex-int.h
@@ -71,7 +71,11 @@ bool read_dex_string_data_item(const GDexFormat *, off_t *, string_data_item *);
/* Procède à la lecture d'un identifiant de type DEX. */
bool read_dex_type_id_item(const GDexFormat *, off_t *, type_id_item *);
+/* Procède à la lecture d'une description de prototype. */
+bool read_dex_proto_id_item(const GDexFormat *, off_t *, proto_id_item *);
+/* Procède à la lecture d'une description de champ. */
+bool read_dex_field_id_item(const GDexFormat *, off_t *, field_id_item *);
/* Procède à la lecture d'une description de méthode. */
bool read_dex_method_id_item(const GDexFormat *, off_t *, method_id_item *);
diff --git a/src/format/dex/dex_def.h b/src/format/dex/dex_def.h
index 9387a90..9faf050 100755
--- a/src/format/dex/dex_def.h
+++ b/src/format/dex/dex_def.h
@@ -54,8 +54,23 @@ typedef struct _type_id_item
} type_id_item;
+/* Description d'un prototype */
+typedef struct _proto_id_item
+{
+ uint32_t shorty_idx; /* Description version courte */
+ uint32_t return_type_idx; /* Type de retour */
+ uint32_t parameters_off; /* Position des arguments */
+} proto_id_item;
+/* Description d'un champ */
+typedef struct _field_id_item
+{
+ uint16_t class_idx; /* Classe d'appartenance */
+ uint16_t type_idx; /* Type du champ */
+ uint32_t name_idx; /* Nom du champ */
+
+} field_id_item;
/* Description d'une méthode */
typedef struct _method_id_item
@@ -151,6 +166,9 @@ typedef struct _code_item
#define ENDIAN_CONSTANT 0x12345678
#define REVERSE_ENDIAN_CONSTANT 0x78563412
+/* Indice non valide */
+#define NO_INDEX 0xffffffff
+
/* En-tête de tout programe Dex */
typedef struct _dex_header
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index 0a8bed3..dbcee52 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -34,6 +34,45 @@
* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index du type recherchée. *
* *
+* Description : Extrait une chaîne de caractères d'une table DEX. *
+* *
+* Retour : Chaîne de caractères trouvées ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)
+{
+ off_t pos; /* Tête de lecture */
+ string_id_item str_id; /* Identifiant de chaîne */
+ string_data_item str_data; /* Description de chaîne */
+
+ pos = format->header.string_ids_off + index * sizeof(string_id_item);
+
+ if (!read_dex_string_id_item(format, &pos, &str_id))
+ return NULL;
+
+ pos = str_id.string_data_off;
+
+ if (!read_dex_string_data_item(format, &pos, &str_data))
+ return NULL;
+
+ return (const char *)str_data.data;
+
+}
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
+* index = index du type recherchée. *
+* *
* Description : Extrait une représentation de type d'une table DEX. *
* *
* Retour : Composant GLib créé. *
@@ -119,6 +158,64 @@ GOpenidaType *get_class_from_dex_pool(const GDexFormat *format, uint16_t index)
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
+* index = index du champ recherché. *
+* *
+* Description : Extrait une représentation de champ d'une table DEX. *
+* *
+* Retour : Composant GLib créé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinVariable *get_field_from_dex_pool(const GDexFormat *format, uint32_t index)
+{
+ GBinVariable *result; /* Instance à retourner */
+ off_t pos; /* Tête de lecture */
+ field_id_item field_id; /* Description du champ */
+ GOpenidaType *type; /* Type du champ */
+ const char *name; /* Désignation humaine */
+ GOpenidaType *owner; /* Propriétaire du champ */
+
+ pos = format->header.field_ids_off + index * sizeof(field_id_item);
+
+ if (!read_dex_field_id_item(format, &pos, &field_id))
+ return NULL;
+
+ type = get_type_from_dex_pool(format, field_id.type_idx);
+
+ name = get_string_from_dex_pool(format, field_id.name_idx);
+ if (name == NULL) goto bad_name;
+
+ result = g_binary_variable_new(type);
+ g_binary_variable_set_name(result, name);
+
+ if (field_id.class_idx != NO_INDEX)
+ {
+ owner = get_type_from_dex_pool(format, field_id.class_idx);
+ if (owner == NULL) goto bad_owner;
+
+ g_binary_variable_set_owner(result, owner);
+
+ }
+
+ return result;
+
+ bad_owner:
+
+ g_object_ref(G_OBJECT(type));
+ g_object_unref(G_OBJECT(result));
+
+ bad_name:
+
+ g_object_unref(G_OBJECT(type));
+
+ return NULL;
+
+}
/******************************************************************************
diff --git a/src/format/dex/pool.h b/src/format/dex/pool.h
index a41a1da..263a807 100644
--- a/src/format/dex/pool.h
+++ b/src/format/dex/pool.h
@@ -31,6 +31,9 @@
+/* Extrait une chaîne de caractères d'une table DEX. */
+const char *get_string_from_dex_pool(const GDexFormat *, uint32_t);
+
/* Extrait une représentation de type d'une table DEX. */
GOpenidaType *get_type_from_dex_pool(const GDexFormat *, uint16_t);
@@ -40,6 +43,11 @@ GOpenidaType *get_class_from_dex_pool(const GDexFormat *, uint16_t);
+
+
+/* Extrait une représentation de champ d'une table DEX. */
+GBinVariable *get_field_from_dex_pool(const GDexFormat *, uint32_t);
+
/* Extrait une représentation de routine d'une table DEX. */
GBinRoutine *get_routine_from_dex_pool(const GDexFormat *, uleb128_t);
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é. */