summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am2
-rw-r--r--plugins/dex/core.c2
-rwxr-xr-xplugins/dex/format.c5
-rw-r--r--plugins/dex/pool.c5
-rw-r--r--plugins/dexbnf/Makefile.am27
-rw-r--r--plugins/dexbnf/context.c209
-rw-r--r--plugins/dexbnf/context.h52
-rw-r--r--plugins/dexbnf/core.c64
-rw-r--r--plugins/dexbnf/core.h38
-rw-r--r--plugins/dexbnf/demangler.c174
-rw-r--r--plugins/dexbnf/demangler.h58
-rw-r--r--plugins/dexbnf/python/Makefile.am15
-rw-r--r--plugins/dexbnf/python/demangler.c145
-rw-r--r--plugins/dexbnf/python/demangler.h42
-rw-r--r--plugins/dexbnf/python/module.c61
-rw-r--r--plugins/dexbnf/python/module.h38
-rw-r--r--plugins/dexbnf/shorty.c227
-rw-r--r--plugins/dexbnf/shorty.h38
-rw-r--r--plugins/dexbnf/simple.c163
-rw-r--r--plugins/dexbnf/simple.h37
-rw-r--r--plugins/dexbnf/type.c316
-rw-r--r--plugins/dexbnf/type.h38
-rw-r--r--plugins/pychrysalide/Makefile.am5
-rw-r--r--plugins/pychrysalide/analysis/Makefile.am3
-rw-r--r--plugins/pychrysalide/analysis/module.c2
-rw-r--r--plugins/pychrysalide/analysis/routine.c36
-rw-r--r--plugins/pychrysalide/analysis/type.c145
-rw-r--r--plugins/pychrysalide/analysis/type.h42
-rw-r--r--plugins/pychrysalide/core/Makefile.am1
-rw-r--r--plugins/pychrysalide/core/demanglers.c160
-rw-r--r--plugins/pychrysalide/core/demanglers.h42
-rw-r--r--plugins/pychrysalide/core/formats.c2
-rw-r--r--plugins/pychrysalide/core/logs.c2
-rw-r--r--plugins/pychrysalide/core/module.c2
-rw-r--r--plugins/pychrysalide/mangling/Makefile.am18
-rw-r--r--plugins/pychrysalide/mangling/demangler.c219
-rw-r--r--plugins/pychrysalide/mangling/demangler.h42
-rw-r--r--plugins/pychrysalide/mangling/module.c91
-rw-r--r--plugins/pychrysalide/mangling/module.h39
-rw-r--r--plugins/pychrysalide/pychrysa.c2
40 files changed, 2600 insertions, 9 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 6bb44fa..25774db 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -4,4 +4,4 @@ if HAVE_PYTHON3_CONFIG
endif
# androhelpers
-SUBDIRS = arm dalvik devdbg dex elf fmtp libcsem mobicore $(PYTHON3_SUBDIRS) readdex readelf readmc ropgadgets
+SUBDIRS = arm dalvik devdbg dex dexbnf elf fmtp libcsem mobicore $(PYTHON3_SUBDIRS) readdex readelf readmc ropgadgets
diff --git a/plugins/dex/core.c b/plugins/dex/core.c
index b163be9..c7f9aa4 100644
--- a/plugins/dex/core.c
+++ b/plugins/dex/core.c
@@ -34,7 +34,7 @@
DEFINE_CHRYSALIDE_PLUGIN("dex", "Add suport for the DEX format", "0.1.0",
- RL("PyChrysalide"), AL(PGA_PLUGIN_INIT));
+ RL("PyChrysalide", "dexbnf"), AL(PGA_PLUGIN_INIT));
diff --git a/plugins/dex/format.c b/plugins/dex/format.c
index 72d0dd5..fc49a15 100755
--- a/plugins/dex/format.c
+++ b/plugins/dex/format.c
@@ -24,10 +24,12 @@
#include "format.h"
+#include <assert.h>
#include <string.h>
#include <i18n.h>
+#include <core/demanglers.h>
#include <core/global.h>
#include <plugins/pglist.h>
@@ -189,6 +191,9 @@ static void g_dex_format_init(GDexFormat *format)
bin_format = G_BIN_FORMAT(format);
+ bin_format->demangler = get_compiler_demangler_for_type("dex");
+ assert(bin_format->demangler != NULL);
+
bin_format->decompile = (format_decompile_fc)g_dex_format_decompile;
}
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index 19e9e36..46c431e 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -31,7 +31,6 @@
#include <i18n.h>
#include <core/global.h>
#include <mangling/demangler.h>
-#include <mangling/dex/context.h>
#include "dex-int.h"
@@ -235,6 +234,7 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
type_id_item type_id; /* Définition de la classe */
string_id_item str_id; /* Identifiant de chaîne */
string_data_item str_data; /* Description de chaîne */
+ GCompDemangler *demangler; /* Accès plus lisible */
result = NULL;
@@ -261,7 +261,8 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
if (!read_dex_string_data_item(format, &addr, &str_data))
goto gtfdp_error;
- format->types[index] = demangle_type(G_TYPE_DEX_DEMANGLER, (char *)str_data.data);
+ demangler = G_BIN_FORMAT(format)->demangler;
+ format->types[index] = g_compiler_demangler_decode_type(demangler, (char *)str_data.data);
}
diff --git a/plugins/dexbnf/Makefile.am b/plugins/dexbnf/Makefile.am
new file mode 100644
index 0000000..08e0680
--- /dev/null
+++ b/plugins/dexbnf/Makefile.am
@@ -0,0 +1,27 @@
+
+lib_LTLIBRARIES = libdexbnf.la
+
+libdir = $(pluginsdir)
+
+libdexbnf_la_SOURCES = \
+ context.h context.c \
+ core.h core.c \
+ demangler.h demangler.c \
+ simple.h simple.c \
+ shorty.h shorty.c \
+ type.h type.c
+
+libdexbnf_la_CFLAGS = $(AM_CFLAGS)
+
+libdexbnf_la_LIBADD = \
+ python/libdexbnfpython.la
+
+libdexbnf_la_LDFLAGS = \
+ $(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS)
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS = python
diff --git a/plugins/dexbnf/context.c b/plugins/dexbnf/context.c
new file mode 100644
index 0000000..9a6037a
--- /dev/null
+++ b/plugins/dexbnf/context.c
@@ -0,0 +1,209 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * context.c - fourniture de contexte aux phases de décodage Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "context.h"
+
+
+#include <mangling/context-int.h>
+
+
+#include "shorty.h"
+#include "type.h"
+
+
+
+/* Contexte de décodage Dex (instance) */
+struct _GDexDemangling
+{
+ GDemanglingContext parent; /* A laisser en premier */
+
+};
+
+/* Contexte de décodage Dex (classe) */
+struct _GDexDemanglingClass
+{
+ GDemanglingContextClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des contextes de décodage. */
+static void g_dex_demangling_class_init(GDexDemanglingClass *);
+
+/* Initialise une instance de contexte pour décodage. */
+static void g_dex_demangling_init(GDexDemangling *);
+
+/* Supprime toutes les références externes. */
+static void g_dex_demangling_dispose(GDexDemangling *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_dex_demangling_finalize(GDexDemangling *);
+
+/* Décode une définition de type pour Dex. */
+static GDataType *g_dex_demangling_decode_type(GDexDemangling *);
+
+/* Décode une définition de routine pour Dex. */
+static GBinRoutine *g_dex_demangling_decode_routine(GDexDemangling *);
+
+
+
+/* Indique le type défini pour un contexte de décodage. */
+G_DEFINE_TYPE(GDexDemangling, g_dex_demangling, G_TYPE_DEMANGLING_CONTEXT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des contextes de décodage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangling_class_init(GDexDemanglingClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GDemanglingContextClass *context; /* Version de base du contexte */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_dex_demangling_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_dex_demangling_finalize;
+
+ context = G_DEMANGLING_CONTEXT_CLASS(klass);
+
+ context->decode_type = (decode_type_fc)g_dex_demangling_decode_type;
+ context->decode_routine = (decode_routine_fc)g_dex_demangling_decode_routine;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : context = instance à initialiser. *
+* *
+* Description : Initialise une instance de contexte pour décodage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangling_init(GDexDemangling *context)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangling_dispose(GDexDemangling *context)
+{
+ G_OBJECT_CLASS(g_dex_demangling_parent_class)->dispose(G_OBJECT(context));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangling_finalize(GDexDemangling *context)
+{
+ G_OBJECT_CLASS(g_dex_demangling_parent_class)->finalize(G_OBJECT(context));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : context = environnement de décodage à manipuler. *
+* *
+* Description : Décode une définition de type pour Dex. *
+* *
+* Retour : Nouvelle instance créée ou NULL en cas d'erreur fatale. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GDataType *g_dex_demangling_decode_type(GDexDemangling *context)
+{
+ GDataType *result; /* Type construit à retourner */
+ GDemanglingContext *base; /* Autre version du contexte */
+
+ base = G_DEMANGLING_CONTEXT(context);
+
+ result = dtd_type_descriptor(&base->buffer);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : context = environnement de décodage à manipuler. *
+* *
+* Description : Décode une définition de routine pour Dex. *
+* *
+* Retour : Nouvelle instance créée ou NULL en cas d'erreur fatale. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBinRoutine *g_dex_demangling_decode_routine(GDexDemangling *context)
+{
+ GBinRoutine *result; /* Routine en place à retourner */
+ GDemanglingContext *base; /* Autre version du contexte */
+
+ base = G_DEMANGLING_CONTEXT(context);
+
+ result = dsd_shorty_descriptor(&base->buffer);
+
+ return result;
+
+}
diff --git a/plugins/dexbnf/context.h b/plugins/dexbnf/context.h
new file mode 100644
index 0000000..6ac8674
--- /dev/null
+++ b/plugins/dexbnf/context.h
@@ -0,0 +1,52 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * context.h - prototypes pour la fourniture de contexte aux phases de décodage Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_CONTEXT_H
+#define _PLUGINS_DEXBNF_CONTEXT_H
+
+
+#include <glib-object.h>
+
+
+
+#define G_TYPE_DEX_DEMANGLING g_dex_demangling_get_type()
+#define G_DEX_DEMANGLING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DEX_DEMANGLING, GDexDemangling))
+#define G_IS_DEX_DEMANGLING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DEX_DEMANGLING))
+#define G_DEX_DEMANGLING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DEX_DEMANGLING, GDexDemanglingClass))
+#define G_IS_DEX_DEMANGLING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DEX_DEMANGLING))
+#define G_DEX_DEMANGLING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DEX_DEMANGLING, GDexDemanglingClass))
+
+
+/* Contexte de décodage Dex (instance) */
+typedef struct _GDexDemangling GDexDemangling;
+
+/* Contexte de décodage Dex (classe) */
+typedef struct _GDexDemanglingClass GDexDemanglingClass;
+
+
+/* Indique le type défini pour un contexte de décodage Dex. */
+GType g_dex_demangling_get_type(void);
+
+
+
+#endif /* _PLUGINS_DEXBNF_CONTEXT_H */
diff --git a/plugins/dexbnf/core.c b/plugins/dexbnf/core.c
new file mode 100644
index 0000000..837c4c1
--- /dev/null
+++ b/plugins/dexbnf/core.c
@@ -0,0 +1,64 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * core.c - intégration du décodage pour symboles Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "core.h"
+
+
+#include <core/demanglers.h>
+#include <plugins/plugin-def.h>
+
+
+#include "demangler.h"
+#include "python/module.h"
+
+
+
+DEFINE_CHRYSALIDE_PLUGIN("dexbnf", "Symbol demangler for Dex", "0.1.0",
+ RL("PyChrysalide"), AL(PGA_PLUGIN_INIT));
+
+
+
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à manipuler. *
+* *
+* Description : Prend acte du chargement du greffon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
+{
+ bool result; /* Bilan à retourner */
+
+ result = register_demangler_type("dex", G_TYPE_DEX_DEMANGLER);
+
+ if (result)
+ result = add_mangling_dexbnf_module_to_python_module();
+
+ return result;
+
+}
diff --git a/plugins/dexbnf/core.h b/plugins/dexbnf/core.h
new file mode 100644
index 0000000..9e26faf
--- /dev/null
+++ b/plugins/dexbnf/core.h
@@ -0,0 +1,38 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * core.h - prototypes pour l'intégration du décodage pour symboles Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_CORE_H
+#define _PLUGINS_DEXBNF_CORE_H
+
+
+#include <plugins/plugin.h>
+#include <plugins/plugin-int.h>
+
+
+
+/* Prend acte du chargement du greffon. */
+G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *);
+
+
+
+#endif /* _PLUGINS_DEXBNF_CORE_H */
diff --git a/plugins/dexbnf/demangler.c b/plugins/dexbnf/demangler.c
new file mode 100644
index 0000000..e021b45
--- /dev/null
+++ b/plugins/dexbnf/demangler.c
@@ -0,0 +1,174 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler.c - décodage des noms d'éléments
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "demangler.h"
+
+
+#include <mangling/demangler-int.h>
+
+
+#include "context.h"
+
+
+
+/* Décodeur de désignations Dex (instance) */
+struct _GDexDemangler
+{
+ GCompDemangler parent; /* A laisser en premier */
+
+};
+
+/* Décodeur de désignations Dex (classe) */
+struct _GDexDemanglerClass
+{
+ GCompDemanglerClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des décodeurs de désignations. */
+static void g_dex_demangler_class_init(GDexDemanglerClass *);
+
+/* Initialise une instance de décodeur de désignations. */
+static void g_dex_demangler_init(GDexDemangler *);
+
+/* Supprime toutes les références externes. */
+static void g_dex_demangler_dispose(GDexDemangler *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_dex_demangler_finalize(GDexDemangler *);
+
+
+
+/* Indique le type défini pour un décodeur de désignations. */
+G_DEFINE_TYPE(GDexDemangler, g_dex_demangler, G_TYPE_COMP_DEMANGLER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des décodeurs de désignations Dex. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangler_class_init(GDexDemanglerClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GCompDemanglerClass *demangler; /* Version parente basique */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_dex_demangler_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_dex_demangler_finalize;
+
+ demangler = G_COMP_DEMANGLER_CLASS(klass);
+
+ demangler->can_demangle = (can_be_demangled_fc)NULL;
+
+ demangler->context_type = G_TYPE_DEX_DEMANGLING;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance à initialiser. *
+* *
+* Description : Initialise une instance de décodeur de désignations Dex. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangler_init(GDexDemangler *demangler)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangler_dispose(GDexDemangler *demangler)
+{
+ G_OBJECT_CLASS(g_dex_demangler_parent_class)->dispose(G_OBJECT(demangler));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_demangler_finalize(GDexDemangler *demangler)
+{
+ G_OBJECT_CLASS(g_dex_demangler_parent_class)->finalize(G_OBJECT(demangler));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Met en place un nouveau décodeur de symboles pour Dex. *
+* *
+* Retour : Instance obtenue ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GCompDemangler *g_dex_demangler_new(void)
+{
+ GDexDemangler *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_DEX_DEMANGLER, NULL);
+
+ return G_COMP_DEMANGLER(result);
+
+}
diff --git a/plugins/dexbnf/demangler.h b/plugins/dexbnf/demangler.h
new file mode 100644
index 0000000..9d997da
--- /dev/null
+++ b/plugins/dexbnf/demangler.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler.h - prototypes pour le décodage des noms d'éléments Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_DEMANGLER_H
+#define _PLUGINS_DEXBNF_DEMANGLER_H
+
+
+#include <glib-object.h>
+
+
+#include <mangling/demangler.h>
+
+
+
+#define G_TYPE_DEX_DEMANGLER g_dex_demangler_get_type()
+#define G_DEX_DEMANGLER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DEX_DEMANGLER, GDexDemangler))
+#define G_IS_DEX_DEMANGLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DEX_DEMANGLER))
+#define G_DEX_DEMANGLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DEX_DEMANGLER, GDexDemanglerClass))
+#define G_IS_DEX_DEMANGLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DEX_DEMANGLER))
+#define G_DEX_DEMANGLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DEX_DEMANGLER, GDexDemanglerClass))
+
+
+/* Décodeur de désignations Dex (instance) */
+typedef struct _GDexDemangler GDexDemangler;
+
+/* Décodeur de désignations Dex (classe) */
+typedef struct _GDexDemanglerClass GDexDemanglerClass;
+
+
+/* Indique le type défini pour un décodeur de désignations Dex. */
+GType g_dex_demangler_get_type(void);
+
+/* Met en place un nouveau décodeur de symboles pour Dex. */
+GCompDemangler *g_dex_demangler_new(void);
+
+
+
+#endif /* _PLUGINS_DEXBNF_DEMANGLER_H */
diff --git a/plugins/dexbnf/python/Makefile.am b/plugins/dexbnf/python/Makefile.am
new file mode 100644
index 0000000..4d60a1c
--- /dev/null
+++ b/plugins/dexbnf/python/Makefile.am
@@ -0,0 +1,15 @@
+
+noinst_LTLIBRARIES = libdexbnfpython.la
+
+libdexbnfpython_la_SOURCES = \
+ demangler.h demangler.c \
+ module.h module.c
+
+
+libdexbnfpython_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I$(top_srcdir)/src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/dexbnf/python/demangler.c b/plugins/dexbnf/python/demangler.c
new file mode 100644
index 0000000..f47eefe
--- /dev/null
+++ b/plugins/dexbnf/python/demangler.c
@@ -0,0 +1,145 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler.c - équivalent Python du fichier "plugins/dexbnf/demangler.c"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "demangler.h"
+
+
+#include <pygobject.h>
+
+
+#include <plugins/pychrysalide/helpers.h>
+#include <plugins/pychrysalide/mangling/demangler.h>
+
+
+#include "../demangler.h"
+
+
+
+/* Crée un nouvel objet Python de type 'DexDemangler'. */
+static PyObject *py_dex_demangler_new(PyTypeObject *, PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type de l'objet à instancier. *
+* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
+* *
+* Description : Crée un nouvel objet Python de type 'DexDemangler'. *
+* *
+* Retour : Instance Python mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_demangler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyObject *result; /* Instance à retourner */
+ GCompDemangler *demangler; /* Instance à transposer */
+
+ demangler = g_dex_demangler_new();
+
+ result = pygobject_new(G_OBJECT(demangler));
+
+ g_object_unref(G_OBJECT(demangler));
+
+ return (PyObject *)result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_dex_demangler_type(void)
+{
+ static PyMethodDef py_dex_demangler_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_dex_demangler_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_dex_demangler_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.mangling.DexDemangler",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "PyChrysalide Dex demangler",
+
+ .tp_methods = py_dex_demangler_methods,
+ .tp_getset = py_dex_demangler_getseters,
+ .tp_new = (newfunc)py_dex_demangler_new
+
+ };
+
+ return &py_dex_demangler_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.mangling.DexDemangler'.*
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_dex_demangler(PyObject *module)
+{
+ PyTypeObject *py_dex_demangler_type; /* Type Python 'ElfFormat' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_dex_demangler_type = get_python_dex_demangler_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_DEX_DEMANGLER,
+ py_dex_demangler_type, get_python_compiler_demangler_type()))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/dexbnf/python/demangler.h b/plugins/dexbnf/python/demangler.h
new file mode 100644
index 0000000..af56289
--- /dev/null
+++ b/plugins/dexbnf/python/demangler.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler.h - prototypes pour l'équivalent Python du fichier "plugins/dexbnf/demangler.h"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_PYTHON_DEMANGLER_H
+#define _PLUGINS_DEXBNF_PYTHON_DEMANGLER_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_dex_demangler_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. */
+bool register_python_dex_demangler(PyObject *);
+
+
+
+#endif /* _PLUGINS_DEXBNF_PYTHON_DEMANGLER_H */
diff --git a/plugins/dexbnf/python/module.c b/plugins/dexbnf/python/module.c
new file mode 100644
index 0000000..07c6ad6
--- /dev/null
+++ b/plugins/dexbnf/python/module.c
@@ -0,0 +1,61 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire dexbnf en tant que module
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "module.h"
+
+
+#include <Python.h>
+
+
+#include <plugins/pychrysalide/access.h>
+
+
+#include "demangler.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Etend le module 'mangling' avec des compléments pour Dex. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_mangling_dexbnf_module_to_python_module(void)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *super; /* Module à compléter */
+
+ super = get_access_to_python_module("pychrysalide.mangling");
+
+ result = register_python_dex_demangler(super);
+
+ return result;
+
+}
diff --git a/plugins/dexbnf/python/module.h b/plugins/dexbnf/python/module.h
new file mode 100644
index 0000000..bfc3525
--- /dev/null
+++ b/plugins/dexbnf/python/module.h
@@ -0,0 +1,38 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire dexbnf en tant que module
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_PYTHON_MODULE_H
+#define _PLUGINS_DEXBNF_PYTHON_MODULE_H
+
+
+#include <stdbool.h>
+
+
+
+/* Etend le module 'mangling' avec des compléments pour Dex. */
+bool add_mangling_dexbnf_module_to_python_module(void);
+
+
+
+#endif /* _PLUGINS_DEXBNF_PYTHON_MODULE_H */
diff --git a/plugins/dexbnf/shorty.c b/plugins/dexbnf/shorty.c
new file mode 100644
index 0000000..0b452df
--- /dev/null
+++ b/plugins/dexbnf/shorty.c
@@ -0,0 +1,227 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * shorty.c - décodage de routines pour Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "shorty.h"
+
+
+#include <analysis/types/basic.h>
+#include <analysis/types/cse.h>
+
+
+
+/* Extrait un type particulier dans un décodage Dex. */
+static GDataType *dsd_shorty_return_type(input_buffer *);
+
+/* Extrait un type particulier dans un décodage Dex. */
+static GDataType *dsd_shorty_field_type(input_buffer *, char);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* *
+* Description : Extrait un routine particulière depuis un codage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinRoutine *dsd_shorty_descriptor(input_buffer *buffer)
+{
+ GBinRoutine *result; /* Type à retourner */
+ GDataType *type; /* Description de type obtenue */
+ char ahead; /* Caractère déterminant lu */
+ GBinVariable *var; /* Argument de routine */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * ShortyDescriptor →
+ * ShortyReturnType (ShortyFieldType)*
+ *
+ */
+
+ result = g_binary_routine_new();
+
+ /* Retour */
+
+ type = dsd_shorty_return_type(buffer);
+
+ if (type == NULL)
+ goto dsd_error;
+
+ else
+ g_binary_routine_set_return_type(result, type);
+
+ /* Arguments */
+
+ for (ahead = text_input_buffer_next_char(buffer);
+ ahead != '\0';
+ ahead = text_input_buffer_next_char(buffer))
+ {
+ type = dsd_shorty_field_type(buffer, ahead);
+
+ if (type == NULL)
+ goto dsd_error;
+
+ else
+ {
+ var = g_binary_variable_new(type);
+ g_binary_routine_add_arg(result, var);
+ }
+
+ }
+
+ return result;
+
+ dsd_error:
+
+ g_object_unref(G_OBJECT(result));
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* *
+* Description : Extrait un type particulier dans un décodage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GDataType *dsd_shorty_return_type(input_buffer *buffer)
+{
+ GDataType *result; /* Type à retourner */
+ char ahead; /* Caractère déterminant lu */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * ShortyReturnType →
+ * 'V'
+ * | ShortyFieldType
+ *
+ */
+
+ ahead = text_input_buffer_next_char(buffer);
+
+ if (ahead == 'V')
+ result = g_basic_type_new(BTP_VOID);
+
+ else
+ result = dsd_shorty_field_type(buffer, ahead);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* ahead = caractère déjà dépilé de ces données. *
+* *
+* Description : Extrait un type particulier dans un décodage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GDataType *dsd_shorty_field_type(input_buffer *buffer, char ahead)
+{
+ GDataType *result; /* Type à retourner */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * ShortyFieldType →
+ * 'Z'
+ * | 'B'
+ * | 'S'
+ * | 'C'
+ * | 'I'
+ * | 'J'
+ * | 'F'
+ * | 'D'
+ * | 'L'
+ *
+ */
+
+ switch (ahead)
+ {
+ case 'Z':
+ result = g_basic_type_new(BTP_BOOL);
+ break;
+
+ case 'B':
+ result = g_basic_type_new(BTP_UCHAR);
+ break;
+
+ case 'S':
+ result = g_basic_type_new(BTP_SHORT);
+ break;
+
+ case 'C':
+ result = g_basic_type_new(BTP_CHAR);
+ break;
+
+ case 'I':
+ result = g_basic_type_new(BTP_INT);
+ break;
+
+ case 'J':
+ result = g_basic_type_new(BTP_LONG);
+ break;
+
+ case 'F':
+ result = g_basic_type_new(BTP_FLOAT);
+ break;
+
+ case 'D':
+ result = g_basic_type_new(BTP_DOUBLE);
+ break;
+
+ case 'L':
+ result = g_class_enum_type_new(CET_CLASS, NULL);
+ break;
+
+ default:
+ result = NULL;
+ break;
+
+ }
+
+ return result;
+
+}
diff --git a/plugins/dexbnf/shorty.h b/plugins/dexbnf/shorty.h
new file mode 100644
index 0000000..0f91a79
--- /dev/null
+++ b/plugins/dexbnf/shorty.h
@@ -0,0 +1,38 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * shorty.h - prototypes pour le décodage de routines pour Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_SHORTY_H
+#define _PLUGINS_DEXBNF_SHORTY_H
+
+
+#include <analysis/routine.h>
+#include <common/ibuf.h>
+
+
+
+/* Extrait un routine particulière depuis un codage Dex. */
+GBinRoutine *dsd_shorty_descriptor(input_buffer *);
+
+
+
+#endif /* _PLUGINS_DEXBNF_SHORTY_H */
diff --git a/plugins/dexbnf/simple.c b/plugins/dexbnf/simple.c
new file mode 100644
index 0000000..43bd467
--- /dev/null
+++ b/plugins/dexbnf/simple.c
@@ -0,0 +1,163 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * simple.c - décodage de simples chaînes de caractères Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "simple.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include <common/utf8.h>
+
+
+
+/* Extrait un simple caractère depuis un codage Dex. */
+static size_t dcd_simple_name_char(input_buffer *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* *
+* Description : Extrait une simple chaîne de caractères depuis un codage Dex.*
+* *
+* Retour : Chaîne MUTF-8 terminée par un octet nul ou NULL si erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+char *dcd_simple_name(input_buffer *buffer)
+{
+ char *result; /* Nom extrait à renvoyer */
+ const char *start; /* Conservation du départ */
+ size_t count; /* Taille du nom constitué */
+ size_t extra; /* Taille de nouveau caractère */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * SimpleName →
+ * SimpleNameChar (SimpleNameChar)*
+ *
+ */
+
+ start = get_input_buffer_text_access(buffer);
+
+ count = 0;
+
+ do
+ {
+ extra = dcd_simple_name_char(buffer);
+ count += extra;
+ }
+ while (extra > 0);
+
+ if (count == 0)
+ result = NULL;
+
+ else
+ {
+ result = malloc((count + 1) * sizeof(char));
+
+ memcpy(result, start, count);
+ result[count] = '\0';
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* *
+* Description : Extrait un simple caractère depuis un codage Dex. *
+* *
+* Retour : quantité de données consommées, 0 en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static size_t dcd_simple_name_char(input_buffer *buffer)
+{
+ size_t result; /* Avancée à retourner */
+ const char *text; /* Accès au texte à relire */
+ size_t remaining; /* Quantité restante */
+ unichar_t wc; /* Caractère étendu lu */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * SimpleNameChar →
+ * 'A' … 'Z'
+ * | 'a' … 'z'
+ * | '0' … '9'
+ * | '$'
+ * | '-'
+ * | '_'
+ * | U+00a1 … U+1fff
+ * | U+2010 … U+2027
+ * | U+2030 … U+d7ff
+ * | U+e000 … U+ffef
+ * | U+10000 … U+10ffff
+ *
+ */
+
+ text = get_input_buffer_text_access(buffer);
+ remaining = count_input_buffer_remaining(buffer);
+
+ wc = decode_utf8_char(text, remaining, &result);
+
+ if (IS_UTF8_ERROR(wc))
+ return 0;
+
+ switch (wc)
+ {
+ case 'A' ... 'Z':
+ case 'a' ... 'z':
+ case '0' ... '9':
+ case '$':
+ case '-':
+ case '_':
+ case 0x00a1 ... 0x1fff:
+ case 0x2010 ... 0x2027:
+ case 0x2030 ... 0xd7ff:
+ case 0xe000 ... 0xffef:
+ case 0x10000 ... 0x10ffff:
+ advance_input_buffer(buffer, result);
+ break;
+
+ default:
+ result = 0;
+
+ }
+
+ return result;
+
+}
diff --git a/plugins/dexbnf/simple.h b/plugins/dexbnf/simple.h
new file mode 100644
index 0000000..d583515
--- /dev/null
+++ b/plugins/dexbnf/simple.h
@@ -0,0 +1,37 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * simple.h - prototypes pour le décodage de simples chaînes de caractères Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_SIMPLE_H
+#define _PLUGINS_DEXBNF_SIMPLE_H
+
+
+#include <common/ibuf.h>
+
+
+
+/* Extrait une simple chaîne de caractères depuis un codage Dex. */
+char *dcd_simple_name(input_buffer *);
+
+
+
+#endif /* _PLUGINS_DEXBNF_SIMPLE_H */
diff --git a/plugins/dexbnf/type.c b/plugins/dexbnf/type.c
new file mode 100644
index 0000000..f77f0e5
--- /dev/null
+++ b/plugins/dexbnf/type.c
@@ -0,0 +1,316 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * type.c - décodage de types pour Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "type.h"
+
+
+#include <analysis/types/basic.h>
+#include <analysis/types/cse.h>
+#include <analysis/types/encaps.h>
+
+
+#include "simple.h"
+
+
+
+/* Extrait un type particulier dans un décodage Dex. */
+static GDataType *dtd_full_class_name(input_buffer *);
+
+/* Extrait un type particulier dans un décodage Dex. */
+static GDataType *dtd_field_type_descriptor(input_buffer *, char);
+
+/* Extrait un type particulier dans un décodage Dex. */
+static GDataType *dtd_non_array_field_type_descriptor(input_buffer *, char);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* *
+* Description : Extrait un type particulier dans un décodage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GDataType *dtd_full_class_name(input_buffer *buffer)
+{
+ GDataType *result; /* Classe à retourner */
+ char *name; /* Désignation récupérée */
+ size_t saved; /* Point de sauvegarde */
+ char next; /* Prochain caractère obtenu */
+ GDataType *ns; /* Espace de nom à attribuer */
+
+ /**
+ * Les règles traitées sont les suivantes :
+ *
+ * FullClassName →
+ * OptionalPackagePrefix SimpleName
+ * OptionalPackagePrefix →
+ * (SimpleName '/')*
+ *
+ */
+
+ /* Premier étage... */
+
+ name = dcd_simple_name(buffer);
+
+ if (name == NULL)
+ {
+ result = NULL;
+ goto dfcn_exit;
+ }
+
+ else
+ result = g_class_enum_type_new(CET_CLASS, name);
+
+ /* Eventuels autres étages précédents */
+
+ do
+ {
+ save_input_buffer_pos(buffer, &saved);
+
+ next = text_input_buffer_next_char(buffer);
+
+ if (next != '/')
+ {
+ restore_input_buffer_pos(buffer, saved);
+ goto dfcn_exit;
+ }
+
+ name = dcd_simple_name(buffer);
+
+ if (name == NULL)
+ {
+ restore_input_buffer_pos(buffer, saved);
+ goto dfcn_exit;
+ }
+
+ ns = result;
+
+ result = g_class_enum_type_new(CET_CLASS, name);
+
+ g_data_type_set_namespace(result, ns);
+ g_object_unref(ns);
+
+ }
+ while (1);
+
+ dfcn_exit:
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* *
+* Description : Extrait un type particulier dans un décodage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDataType *dtd_type_descriptor(input_buffer *buffer)
+{
+ GDataType *result; /* Type à retourner */
+ char ahead; /* Caractère déterminant lu */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * TypeDescriptor →
+ * 'V'
+ * | FieldTypeDescriptor
+ *
+ */
+
+ ahead = text_input_buffer_next_char(buffer);
+
+ if (ahead == 'V')
+ result = g_basic_type_new(BTP_VOID);
+
+ else
+ result = dtd_field_type_descriptor(buffer, ahead);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* ahead = caractère déjà dépilé de ces données. *
+* *
+* Description : Extrait un type particulier dans un décodage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GDataType *dtd_field_type_descriptor(input_buffer *buffer, char ahead)
+{
+ GDataType *result; /* Type à retourner */
+ size_t dim; /* Dimension éventuelle */
+ GDataType *descriptor; /* (Sous-)type à charger */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * FieldTypeDescriptor →
+ * NonArrayFieldTypeDescriptor
+ * | ('[' * 1…255) NonArrayFieldTypeDescriptor
+ *
+ */
+
+ dim = 0;
+
+ while (ahead == '[')
+ {
+ dim++;
+ ahead = text_input_buffer_next_char(buffer);
+ }
+
+ descriptor = dtd_non_array_field_type_descriptor(buffer, ahead);
+
+ if (dim == 0)
+ result = descriptor;
+
+ else
+ {
+ result = g_encapsulated_type_new(ECT_ARRAY, descriptor);
+
+ g_encapsulated_type_set_dimension(G_ENCAPSULATED_TYPE(result), dim);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon contenant les données utiles. *
+* ahead = caractère déjà dépilé de ces données. *
+* *
+* Description : Extrait un type particulier dans un décodage Dex. *
+* *
+* Retour : Nouveau type mis en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GDataType *dtd_non_array_field_type_descriptor(input_buffer *buffer, char ahead)
+{
+ GDataType *result; /* Type à retourner */
+ char check; /* Vérification de conformité */
+
+ /**
+ * La règle traitée est la suivante :
+ *
+ * NonArrayFieldTypeDescriptor →
+ * 'Z'
+ * | 'B'
+ * | 'S'
+ * | 'C'
+ * | 'I'
+ * | 'J'
+ * | 'F'
+ * | 'D'
+ * | 'L' FullClassName ';'
+ *
+ */
+
+ switch (ahead)
+ {
+ case 'Z':
+ result = g_basic_type_new(BTP_BOOL);
+ break;
+
+ case 'B':
+ result = g_basic_type_new(BTP_UCHAR);
+ break;
+
+ case 'S':
+ result = g_basic_type_new(BTP_SHORT);
+ break;
+
+ case 'C':
+ result = g_basic_type_new(BTP_CHAR);
+ break;
+
+ case 'I':
+ result = g_basic_type_new(BTP_INT);
+ break;
+
+ case 'J':
+ result = g_basic_type_new(BTP_LONG);
+ break;
+
+ case 'F':
+ result = g_basic_type_new(BTP_FLOAT);
+ break;
+
+ case 'D':
+ result = g_basic_type_new(BTP_DOUBLE);
+ break;
+
+ case 'L':
+
+ result = dtd_full_class_name(buffer);
+
+ if (result != NULL)
+ {
+ check = text_input_buffer_next_char(buffer);
+
+ if (check != ';')
+ {
+ g_object_unref(G_OBJECT(result));
+ result = NULL;
+ }
+
+ }
+
+ break;
+
+ default:
+ result = NULL;
+ break;
+
+ }
+
+ return result;
+
+}
diff --git a/plugins/dexbnf/type.h b/plugins/dexbnf/type.h
new file mode 100644
index 0000000..045a5fe
--- /dev/null
+++ b/plugins/dexbnf/type.h
@@ -0,0 +1,38 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * type.h - prototypes pour le décodage de types pour Dex
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_DEXBNF_TYPE_H
+#define _PLUGINS_DEXBNF_TYPE_H
+
+
+#include <analysis/type.h>
+#include <common/ibuf.h>
+
+
+
+/* Extrait un type particulier dans un décodage Dex. */
+GDataType *dtd_type_descriptor(input_buffer *);
+
+
+
+#endif /* _PLUGINS_DEXBNF_TYPE_H */
diff --git a/plugins/pychrysalide/Makefile.am b/plugins/pychrysalide/Makefile.am
index 0648bb3..3e6f0cd 100644
--- a/plugins/pychrysalide/Makefile.am
+++ b/plugins/pychrysalide/Makefile.am
@@ -20,7 +20,8 @@ pychrysalide_la_LIBADD = \
format/libpychrysaformat.la \
glibext/libpychrysaglibext.la \
gtkext/libpychrysagtkext.la \
- gui/libpychrysagui.la
+ gui/libpychrysagui.la \
+ mangling/libpychrysamangling.la
pychrysalide_la_LDFLAGS = -module -avoid-version \
$(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS) \
@@ -33,4 +34,4 @@ AM_CPPFLAGS = $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) $(LIBGTK_CFLAGS) $(LIBX
AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
-SUBDIRS = analysis arch common core debug format glibext gtkext gui
+SUBDIRS = analysis arch common core debug format glibext gtkext gui mangling
diff --git a/plugins/pychrysalide/analysis/Makefile.am b/plugins/pychrysalide/analysis/Makefile.am
index c1639e7..2379b19 100644
--- a/plugins/pychrysalide/analysis/Makefile.am
+++ b/plugins/pychrysalide/analysis/Makefile.am
@@ -7,7 +7,8 @@ libpychrysaanalysis_la_SOURCES = \
content.h content.c \
loaded.h loaded.c \
module.h module.c \
- routine.h routine.c
+ routine.h routine.c \
+ type.h type.c
libpychrysaanalysis_la_LIBADD = \
contents/libpychrysaanalysiscontents.la \
diff --git a/plugins/pychrysalide/analysis/module.c b/plugins/pychrysalide/analysis/module.c
index f4a0f5b..c9a9276 100644
--- a/plugins/pychrysalide/analysis/module.c
+++ b/plugins/pychrysalide/analysis/module.c
@@ -33,6 +33,7 @@
#include "content.h"
#include "loaded.h"
#include "routine.h"
+#include "type.h"
#include "contents/module.h"
#include "db/module.h"
#include "../access.h"
@@ -91,6 +92,7 @@ bool add_analysis_module_to_python_module(PyObject *super)
result &= register_python_instr_block(module);
//result &= register_python_binary_content(module);
result &= register_python_binary_routine(module);
+ result &= register_python_data_type(module);
result &= add_analysis_contents_module_to_python_module(module);
result &= add_analysis_db_module_to_python_module(module);
diff --git a/plugins/pychrysalide/analysis/routine.c b/plugins/pychrysalide/analysis/routine.c
index 37f36a7..d0abd72 100644
--- a/plugins/pychrysalide/analysis/routine.c
+++ b/plugins/pychrysalide/analysis/routine.c
@@ -42,6 +42,9 @@
+/* Décrit la routine fournie sous forme de caractères. */
+static PyObject *py_binary_routine_to_str(PyObject *);
+
/* Crée un nouvel objet Python de type 'BinRoutine'. */
static PyObject *py_binary_routine_new(PyTypeObject *, PyObject *, PyObject *);
@@ -58,6 +61,37 @@ static PyObject *py_binary_routine_get_basic_blocks(PyObject *, void *);
/******************************************************************************
* *
+* Paramètres : self = instance d'une routine version Python à traiter. *
+* *
+* Description : Décrit la routine fournie sous forme de caractères. *
+* *
+* Retour : Chaîne de caractère construite pour l'occasion. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_binary_routine_to_str(PyObject *self)
+{
+ PyObject *result; /* Représentation à retourner */
+ GBinRoutine *routine; /* Version native de l'objet */
+ char *desc; /* Description du type */
+
+ routine = G_BIN_ROUTINE(pygobject_get(self));
+
+ desc = g_binary_routine_to_string(routine);
+
+ result = PyUnicode_FromString(desc);
+
+ free(desc);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = type de l'objet à instancier. *
* args = arguments fournis à l'appel. *
* kwds = arguments de type key=val fournis. *
@@ -250,6 +284,8 @@ PyTypeObject *get_python_binary_routine_type(void)
.tp_name = "pychrysalide.analysis.BinRoutine",
+ .tp_str = py_binary_routine_to_str,
+
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "PyChrysalide binary routine",
diff --git a/plugins/pychrysalide/analysis/type.c b/plugins/pychrysalide/analysis/type.c
new file mode 100644
index 0000000..eea9596
--- /dev/null
+++ b/plugins/pychrysalide/analysis/type.c
@@ -0,0 +1,145 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * type.c - équivalent Python du fichier "analysis/type.c"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "type.h"
+
+
+#include <malloc.h>
+#include <pygobject.h>
+
+
+#include <analysis/type.h>
+
+
+#include "../helpers.h"
+
+
+
+/* Décrit le type fourni sous forme de caractères. */
+static PyObject *py_data_type_to_str(PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = instance d'un type version Python à traiter. *
+* *
+* Description : Décrit le type fourni sous forme de caractères. *
+* *
+* Retour : Chaîne de caractère construite pour l'occasion. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_data_type_to_str(PyObject *self)
+{
+ PyObject *result; /* Représentation à retourner */
+ GDataType *type; /* Version native de l'objet */
+ char *desc; /* Description du type */
+
+ type = G_DATA_TYPE(pygobject_get(self));
+
+ desc = g_data_type_to_string(type);
+
+ result = PyUnicode_FromString(desc);
+
+ free(desc);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_data_type_type(void)
+{
+ static PyMethodDef py_data_type_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_data_type_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_data_type_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.analysis.DataType",
+
+ .tp_str = py_data_type_to_str,
+
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+
+ .tp_doc = "PyChrysalide data type",
+
+ .tp_methods = py_data_type_methods,
+ .tp_getset = py_data_type_getseters
+
+ };
+
+ return &py_data_type_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.analysis.DataType'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_data_type(PyObject *module)
+{
+ PyTypeObject *py_data_type_type; /* Type Python 'DataType' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_data_type_type = get_python_data_type_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_DATA_TYPE, py_data_type_type, &PyGObject_Type))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/analysis/type.h b/plugins/pychrysalide/analysis/type.h
new file mode 100644
index 0000000..b6b8b95
--- /dev/null
+++ b/plugins/pychrysalide/analysis/type.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * type.h - prototypes pour l'équivalent Python du fichier "analysis/type.h"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_PYOIDA_ANALYSIS_TYPE_H
+#define _PLUGINS_PYOIDA_ANALYSIS_TYPE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_data_type_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.analysis.DataType'. */
+bool register_python_data_type(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYOIDA_ANALYSIS_TYPE_H */
diff --git a/plugins/pychrysalide/core/Makefile.am b/plugins/pychrysalide/core/Makefile.am
index 71abfa4..d5fdb9f 100644
--- a/plugins/pychrysalide/core/Makefile.am
+++ b/plugins/pychrysalide/core/Makefile.am
@@ -2,6 +2,7 @@
noinst_LTLIBRARIES = libpychrysacore.la
libpychrysacore_la_SOURCES = \
+ demanglers.h demanglers.c \
formats.h formats.c \
logs.h logs.c \
module.h module.c \
diff --git a/plugins/pychrysalide/core/demanglers.c b/plugins/pychrysalide/core/demanglers.c
new file mode 100644
index 0000000..c3c1881
--- /dev/null
+++ b/plugins/pychrysalide/core/demanglers.c
@@ -0,0 +1,160 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demanglers.c - équivalent Python du fichier "core/demanglers.c"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "demanglers.h"
+
+
+#include <pygobject.h>
+
+
+#include <core/demanglers.h>
+
+
+#include "../helpers.h"
+
+
+
+/* Fournit le décodeur de désignations correspondant à un type. */
+static PyObject *py_demanglers_get_for_type(PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* key = nom technique du décodeur recherché. *
+* *
+* Description : Fournit le décodeur de désignations correspondant à un type. *
+* *
+* Retour : Décodeur trouvé et mis en place ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_demanglers_get_for_type(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *key; /* Nom court du format */
+ int ret; /* Bilan de lecture des args. */
+ GCompDemangler *demangler; /* Décodeur mis en place */
+
+ ret = PyArg_ParseTuple(args, "s", &key);
+ if (!ret) return NULL;
+
+ demangler = get_compiler_demangler_for_type(key);
+
+ if (demangler != NULL)
+ {
+ result = pygobject_new(G_OBJECT(demangler));
+ Py_INCREF(result);
+
+ g_object_unref(G_OBJECT(demangler));
+
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_demanglers_type(void)
+{
+ static PyMethodDef py_demanglers_methods[] = {
+
+ { "get_for_type", py_demanglers_get_for_type,
+ METH_VARARGS | METH_STATIC,
+ "get_for_type(key, /)\n--\n\nCreate a new demangler for a given type of encoding."
+ },
+ { NULL }
+
+ };
+
+ static PyTypeObject py_demanglers_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.core.demanglers",
+ .tp_basicsize = sizeof(PyObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "Access to the code demanglers",
+
+ .tp_methods = py_demanglers_methods
+
+ };
+
+ return &py_demanglers_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.core.demanglers'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_demanglers(PyObject *module)
+{
+ PyTypeObject *py_demanglers_type; /* Type Python de 'demanglers' */
+ int ret; /* Bilan d'un appel */
+
+ py_demanglers_type = get_python_demanglers_type();
+
+ py_demanglers_type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(py_demanglers_type) != 0)
+ return false;
+
+ Py_INCREF(py_demanglers_type);
+ ret = PyModule_AddObject(module, "demanglers", (PyObject *)py_demanglers_type);
+
+ return (ret == 0);
+
+}
diff --git a/plugins/pychrysalide/core/demanglers.h b/plugins/pychrysalide/core/demanglers.h
new file mode 100644
index 0000000..b17c4cb
--- /dev/null
+++ b/plugins/pychrysalide/core/demanglers.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demanglers.h - prototypes pour l'équivalent Python du fichier "core/demanglers.h"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_PYCHRYSALIDE_CORE_DEMANGLERS_H
+#define _PLUGINS_PYCHRYSALIDE_CORE_DEMANGLERS_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_demanglers_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.core.demanglers'. */
+bool register_python_demanglers(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_CORE_DEMANGLERS_H */
diff --git a/plugins/pychrysalide/core/formats.c b/plugins/pychrysalide/core/formats.c
index 621277a..4f7c33a 100644
--- a/plugins/pychrysalide/core/formats.c
+++ b/plugins/pychrysalide/core/formats.c
@@ -115,7 +115,7 @@ PyTypeObject *get_python_formats_type(void)
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = "Python object for parameters",
+ .tp_doc = "Access to the code formats",
.tp_methods = py_formats_methods
diff --git a/plugins/pychrysalide/core/logs.c b/plugins/pychrysalide/core/logs.c
index 8a922c1..6476ed0 100644
--- a/plugins/pychrysalide/core/logs.c
+++ b/plugins/pychrysalide/core/logs.c
@@ -201,7 +201,7 @@ PyTypeObject *get_python_logs_type(void)
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = "Python object for logs",
+ .tp_doc = "Access to the core log facilities",
.tp_methods = py_logs_methods,
.tp_getset = py_logs_getseters
diff --git a/plugins/pychrysalide/core/module.c b/plugins/pychrysalide/core/module.c
index ff7f828..dd89ea0 100644
--- a/plugins/pychrysalide/core/module.c
+++ b/plugins/pychrysalide/core/module.c
@@ -28,6 +28,7 @@
#include <assert.h>
+#include "demanglers.h"
#include "formats.h"
#include "logs.h"
#include "params.h"
@@ -81,6 +82,7 @@ bool add_core_module_to_python_module(PyObject *super)
result = true;
+ result &= register_python_demanglers(module);
result &= register_python_formats(module);
result &= register_python_logs(module);
result &= register_python_params(module);
diff --git a/plugins/pychrysalide/mangling/Makefile.am b/plugins/pychrysalide/mangling/Makefile.am
new file mode 100644
index 0000000..e4f5db6
--- /dev/null
+++ b/plugins/pychrysalide/mangling/Makefile.am
@@ -0,0 +1,18 @@
+
+noinst_LTLIBRARIES = libpychrysamangling.la
+
+libpychrysamangling_la_SOURCES = \
+ demangler.h demangler.c \
+ module.h module.c
+
+libpychrysamangling_la_LIBADD =
+
+libpychrysamangling_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I$(top_srcdir)/src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS =
diff --git a/plugins/pychrysalide/mangling/demangler.c b/plugins/pychrysalide/mangling/demangler.c
new file mode 100644
index 0000000..37935c9
--- /dev/null
+++ b/plugins/pychrysalide/mangling/demangler.c
@@ -0,0 +1,219 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler.c - équivalent Python du fichier "mangling/demangler.c"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "demangler.h"
+
+
+#include <pygobject.h>
+
+
+#include <mangling/demangler.h>
+
+
+#include "../helpers.h"
+
+
+
+/* Tente de décoder une chaîne de caractères donnée en type. */
+static PyObject *py_compiler_demangler_decode_type(PyObject *, PyObject *);
+
+/* Tente de décoder une chaîne de caractères donnée en routine. */
+static PyObject *py_compiler_demangler_decode_routine(PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = décodeur à solliciter pour l'opération. *
+* args = chaîne de caractères à décoder. *
+* *
+* Description : Tente de décoder une chaîne de caractères donnée en type. *
+* *
+* Retour : Instance obtenue ou None en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_compiler_demangler_decode_type(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *desc; /* Description à traiter */
+ int ret; /* Bilan de lecture des args. */
+ GCompDemangler *demangler; /* Décodeur mis en place */
+ GDataType *type; /* Type de données obtenu */
+
+ ret = PyArg_ParseTuple(args, "s", &desc);
+ if (!ret) return NULL;
+
+ demangler = G_COMP_DEMANGLER(pygobject_get(self));
+
+ type = g_compiler_demangler_decode_type(demangler, desc);
+
+ if (type != NULL)
+ {
+ result = pygobject_new(G_OBJECT(type));
+ Py_INCREF(result);
+
+ g_object_unref(G_OBJECT(type));
+
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = décodeur à solliciter pour l'opération. *
+* args = chaîne de caractères à décoder. *
+* *
+* Description : Tente de décoder une chaîne de caractères donnée en routine. *
+* *
+* Retour : Instance obtenue ou None en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_compiler_demangler_decode_routine(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *desc; /* Description à traiter */
+ int ret; /* Bilan de lecture des args. */
+ GCompDemangler *demangler; /* Décodeur mis en place */
+ GBinRoutine *routine; /* Routine obtenue */
+
+ ret = PyArg_ParseTuple(args, "s", &desc);
+ if (!ret) return NULL;
+
+ demangler = G_COMP_DEMANGLER(pygobject_get(self));
+
+ routine = g_compiler_demangler_decode_routine(demangler, desc);
+
+ if (routine != NULL)
+ {
+ result = pygobject_new(G_OBJECT(routine));
+ Py_INCREF(result);
+
+ g_object_unref(G_OBJECT(routine));
+
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_compiler_demangler_type(void)
+{
+ static PyMethodDef py_comp_demangler_methods[] = {
+ {
+ "decode_type", py_compiler_demangler_decode_type,
+ METH_VARARGS,
+ "decode_type(self, desc/)\n--\n\nDemangle a type definition from its string mangled description."
+ },
+ {
+ "decode_routine", py_compiler_demangler_decode_routine,
+ METH_VARARGS,
+ "decode_routine(self, desc/)\n--\n\nDemangle a routine definition from its string mangled description."
+ },
+ { NULL }
+ };
+
+ static PyGetSetDef py_comp_demangler_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_comp_demangler_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.mangling.CompDemangler",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "PyChrysalide generic demangler",
+
+ .tp_methods = py_comp_demangler_methods,
+ .tp_getset = py_comp_demangler_getseters,
+
+ };
+
+ return &py_comp_demangler_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.mangling.DexDemangler'.*
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_compiler_demangler(PyObject *module)
+{
+ PyTypeObject *py_comp_demangler_type; /* Type Python 'CompDemangler' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_comp_demangler_type = get_python_compiler_demangler_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_COMP_DEMANGLER, py_comp_demangler_type, &PyGObject_Type))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/mangling/demangler.h b/plugins/pychrysalide/mangling/demangler.h
new file mode 100644
index 0000000..c2094b7
--- /dev/null
+++ b/plugins/pychrysalide/mangling/demangler.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler.h - prototypes pour l'équivalent Python du fichier "mangling/demangler.h"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_PYCHRYSALIDE_MANGLING_DEMANGLER_H
+#define _PLUGINS_PYCHRYSALIDE_MANGLING_DEMANGLER_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_compiler_demangler_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. */
+bool register_python_compiler_demangler(PyObject *);
+
+
+
+#endif /* _PLUGINS_DEXBNF_PYTHON_DEMANGLER_H */
diff --git a/plugins/pychrysalide/mangling/module.c b/plugins/pychrysalide/mangling/module.c
new file mode 100644
index 0000000..a462e3e
--- /dev/null
+++ b/plugins/pychrysalide/mangling/module.c
@@ -0,0 +1,91 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire mangling en tant que module
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "module.h"
+
+
+#include <assert.h>
+
+
+#include "demangler.h"
+#include "../access.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'mangling' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_mangling_module_to_python_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+ int ret; /* Bilan d'un appel */
+
+ static PyModuleDef py_chrysalide_mangling_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.mangling",
+ .m_doc = "Python module for Chrysalide.mangling",
+
+ .m_size = -1,
+
+ };
+
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_mangling_module);
+ if (module == NULL) return false;
+
+ ret = PyState_AddModule(super, &py_chrysalide_mangling_module);
+ if (ret != 0) goto loading_failed;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.mangling");
+ if (ret != 0) goto loading_failed;
+
+ Py_INCREF(module);
+ ret = PyModule_AddObject(super, "mangling", module);
+ if (ret != 0) goto loading_failed;
+
+ result = register_python_compiler_demangler(module);
+
+ if (result)
+ register_access_to_python_module("pychrysalide.mangling", module);
+
+ loading_failed:
+
+ assert(result);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/mangling/module.h b/plugins/pychrysalide/mangling/module.h
new file mode 100644
index 0000000..126aa7e
--- /dev/null
+++ b/plugins/pychrysalide/mangling/module.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire mangling en tant que module
+ *
+ * Copyright (C) 2012-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_PYCHRYSALIDE_MANGLING_MODULE_H
+#define _PLUGINS_PYCHRYSALIDE_MANGLING_MODULE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'mangling' au module Python. */
+bool add_mangling_module_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_MANGLING_MODULE_H */
diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c
index 35d14f4..70cce2a 100644
--- a/plugins/pychrysalide/pychrysa.c
+++ b/plugins/pychrysalide/pychrysa.c
@@ -55,6 +55,7 @@
#include "glibext/module.h"
#include "gtkext/module.h"
#include "gui/module.h"
+#include "mangling/module.h"
@@ -403,6 +404,7 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
if (status) status = add_debug_module_to_python_module(result);
if (status) status = add_gtkext_module_to_python_module(result);
if (status) status = add_gui_module_to_python_module(result);
+ if (status) status = add_mangling_module_to_python_module(result);
if (!status)
{