summaryrefslogtreecommitdiff
path: root/src/mangling
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-03-11 21:57:05 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-03-11 21:57:05 (GMT)
commit8088f1cbb4304c686ff41520099707a333084a4e (patch)
tree147411c3f90097dc1ae950ec390df2dfccf07ad7 /src/mangling
parenta33dd28e763e3a8b04145fb549aca9320e100a4b (diff)
Defined a new Dex demangler with MUTF-8 support as plugin.
Diffstat (limited to 'src/mangling')
-rw-r--r--src/mangling/Makefile.am4
-rw-r--r--src/mangling/context-int.h20
-rw-r--r--src/mangling/context.c86
-rw-r--r--src/mangling/context.h6
-rw-r--r--src/mangling/demangler-int.h57
-rw-r--r--src/mangling/demangler.c189
-rw-r--r--src/mangling/demangler.h46
-rw-r--r--src/mangling/dex/Makefile.am46
-rw-r--r--src/mangling/dex/context.c154
-rw-r--r--src/mangling/dex/context.h52
-rw-r--r--src/mangling/dex/shorty_gram.y138
-rw-r--r--src/mangling/dex/shorty_tok.l28
-rw-r--r--src/mangling/dex/type_gram.y159
-rw-r--r--src/mangling/dex/type_tok.l150
14 files changed, 400 insertions, 735 deletions
diff --git a/src/mangling/Makefile.am b/src/mangling/Makefile.am
index 63b25c7..075a634 100644
--- a/src/mangling/Makefile.am
+++ b/src/mangling/Makefile.am
@@ -8,13 +8,13 @@ noinst_LTLIBRARIES = libjavamangling.la libmangling.la
libmangling_la_SOURCES = \
context-int.h \
context.h context.c \
+ demangler-int.h \
demangler.h demangler.c
libmangling_la_LDFLAGS =
libmangling_la_LIBADD = \
libjavamangling.la \
- dex/libmanglingdex.la \
itanium/libmanglingitanium.la
@@ -40,4 +40,4 @@ AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
# Automake fait les choses à moitié
CLEANFILES = java_gram.h java_gram.c libjavamangling_la-java_tok.c
-SUBDIRS = dex itanium
+SUBDIRS = itanium
diff --git a/src/mangling/context-int.h b/src/mangling/context-int.h
index d361ff7..e34842c 100644
--- a/src/mangling/context-int.h
+++ b/src/mangling/context-int.h
@@ -21,23 +21,34 @@
*/
-#ifndef _FORMAT_MANGLING_CONTEXT_INT_H
-#define _FORMAT_MANGLING_CONTEXT_INT_H
+#ifndef _MANGLING_CONTEXT_INT_H
+#define _MANGLING_CONTEXT_INT_H
#include "context.h"
+#include "../common/ibuf.h"
+
+
/* Procède au décodage d'une chaîne de caractères. */
typedef bool (* demangle_fc) (GDemanglingContext *, const char *);
+/* Décode une définition de routine. */
+typedef GBinRoutine * (* decode_routine_fc) (GDemanglingContext *);
+
+/* Décode une définition de type. */
+typedef GDataType * (* decode_type_fc) (GDemanglingContext *);
+
/* Contexte de décodage (instance) */
struct _GDemanglingContext
{
GObject parent; /* A laisser en premier */
+ input_buffer buffer; /* Tampon de lecture */
+
union
{
GObject *gobj; /* Utile pour le nettoyage ! */
@@ -55,8 +66,11 @@ struct _GDemanglingContextClass
demangle_fc demangle_type; /* Décodage de type */
demangle_fc demangle_routine; /* Décodage de routine */
+ decode_type_fc decode_type; /* Décodage de type */
+ decode_routine_fc decode_routine; /* Décodage de routine */
+
};
-#endif /* _FORMAT_MANGLING_CONTEXT_INT_H */
+#endif /* _MANGLING_CONTEXT_INT_H */
diff --git a/src/mangling/context.c b/src/mangling/context.c
index 7a798ac..65a8874 100644
--- a/src/mangling/context.c
+++ b/src/mangling/context.c
@@ -24,6 +24,9 @@
#include "context.h"
+#include <assert.h>
+
+
#include "context-int.h"
@@ -165,6 +168,7 @@ GBinRoutine *g_demangling_context_get_decoded_routine(GDemanglingContext *contex
/******************************************************************************
* *
* Paramètres : context = instance à consulter. *
+* desc = chaîne de caractères à décoder. *
* *
* Description : Fournit le type créé à l'issue du codage. *
* *
@@ -190,3 +194,85 @@ GDataType *g_demangling_context_get_decoded_type(GDemanglingContext *context, co
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : context = environnement de décodage à manipuler. *
+* desc = chaîne de caractères à décoder. *
+* *
+* Description : Décode une définition de type. *
+* *
+* Retour : Nouvelle instance créée ou NULL en cas d'erreur fatale. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDataType *g_demangling_context_decode_type(GDemanglingContext *context, const char *desc)
+{
+ GDataType *result; /* Construction à remonter */
+
+ if (context->type != NULL)
+ result = context->type;
+
+ else
+ {
+ assert(context->buffer.text == NULL);
+
+ init_text_input_buffer(&context->buffer, desc);
+
+ result = G_DEMANGLING_CONTEXT_GET_CLASS(context)->decode_type(context);
+
+ if (result != NULL)
+ context->type = result;
+
+ }
+
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : context = environnement de décodage à manipuler. *
+* desc = chaîne de caractères à décoder. *
+* *
+* Description : Décode une définition de routine. *
+* *
+* Retour : Nouvelle instance créée ou NULL en cas d'erreur fatale. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinRoutine *g_demangling_context_decode_routine(GDemanglingContext *context, const char *desc)
+{
+ GBinRoutine *result; /* Construction à remonter */
+
+ if (context->routine != NULL)
+ result = context->routine;
+
+ else
+ {
+ assert(context->buffer.text == NULL);
+
+ init_text_input_buffer(&context->buffer, desc);
+
+ result = G_DEMANGLING_CONTEXT_GET_CLASS(context)->decode_routine(context);
+
+ if (result != NULL)
+ context->routine = result;
+
+ }
+
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
diff --git a/src/mangling/context.h b/src/mangling/context.h
index 705ef83..1f516d3 100644
--- a/src/mangling/context.h
+++ b/src/mangling/context.h
@@ -56,6 +56,12 @@ GBinRoutine *g_demangling_context_get_decoded_routine(GDemanglingContext *, cons
/* Fournit le type créé à l'issue du codage. */
GDataType *g_demangling_context_get_decoded_type(GDemanglingContext *, const char *);
+/* Décode une définition de type. */
+GDataType *g_demangling_context_decode_type(GDemanglingContext *, const char *);
+
+/* Décode une définition de routine. */
+GBinRoutine *g_demangling_context_decode_routine(GDemanglingContext *, const char *);
+
#endif /* _FORMAT_MANGLING_CONTEXT_H */
diff --git a/src/mangling/demangler-int.h b/src/mangling/demangler-int.h
new file mode 100644
index 0000000..55fb27d
--- /dev/null
+++ b/src/mangling/demangler-int.h
@@ -0,0 +1,57 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * demangler-int.h - prototypes internes utiles aux décodeurs de désignations de symboles
+ *
+ * Copyright (C) 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _MANGLING_DEMANGLER_INT_H
+#define _MANGLING_DEMANGLER_INT_H
+
+
+#include "context.h"
+#include "demangler.h"
+
+
+
+/* Indique si une chaîne peut être traitée par le décodeur. */
+typedef bool (* can_be_demangled_fc) (const char *);
+
+
+/* Décodeur de désignations générique (instance) */
+struct _GCompDemangler
+{
+ GObject parent; /* A laisser en premier */
+
+};
+
+/* Décodeur de désignations générique (classe) */
+struct _GCompDemanglerClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+ can_be_demangled_fc can_demangle; /* Possibilité de traitement */
+
+ GType context_type; /* Contexte de décodage */
+
+};
+
+
+
+#endif /* _FORMAT_MANGLING_DEMANGLER_H */
diff --git a/src/mangling/demangler.c b/src/mangling/demangler.c
index f673a01..299da9c 100644
--- a/src/mangling/demangler.c
+++ b/src/mangling/demangler.c
@@ -24,6 +24,195 @@
#include "demangler.h"
+#include "demangler-int.h"
+
+
+
+/* Initialise la classe des décodeurs de désignations. */
+static void g_compiler_demangler_class_init(GCompDemanglerClass *);
+
+/* Initialise une instance de décodeur de désignations. */
+static void g_compiler_demangler_init(GCompDemangler *);
+
+/* Supprime toutes les références externes. */
+static void g_compiler_demangler_dispose(GCompDemangler *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_compiler_demangler_finalize(GCompDemangler *);
+
+
+
+/* Indique le type défini pour un décodeur de désignations. */
+G_DEFINE_TYPE(GCompDemangler, g_compiler_demangler, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des décodeurs de désignations. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_compiler_demangler_class_init(GCompDemanglerClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_compiler_demangler_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_compiler_demangler_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance à initialiser. *
+* *
+* Description : Initialise une instance de décodeur de désignations. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_compiler_demangler_init(GCompDemangler *demangler)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_compiler_demangler_dispose(GCompDemangler *demangler)
+{
+ G_OBJECT_CLASS(g_compiler_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_compiler_demangler_finalize(GCompDemangler *demangler)
+{
+ G_OBJECT_CLASS(g_compiler_demangler_parent_class)->finalize(G_OBJECT(demangler));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = décodeur à solliciter pour l'opération. *
+* desc = 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 NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDataType *g_compiler_demangler_decode_type(const GCompDemangler *demangler, const char *desc)
+{
+ GDataType *result; /* Construction à remonter */
+ GType ctx_type; /* Type de contexte adapté */
+ GDemanglingContext *context; /* Espace de travail dédié */
+
+ ctx_type = G_COMP_DEMANGLER_GET_CLASS(demangler)->context_type;
+
+ context = g_object_new(ctx_type, NULL);
+
+ result = g_demangling_context_decode_type(context, desc);
+
+ g_object_unref(G_OBJECT(context));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : demangler = décodeur à solliciter pour l'opération. *
+* desc = 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 NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinRoutine *g_compiler_demangler_decode_routine(const GCompDemangler *demangler, const char *desc)
+{
+ GBinRoutine *result; /* Construction à remonter */
+ GType ctx_type; /* Type de contexte adapté */
+ GDemanglingContext *context; /* Espace de travail dédié */
+
+ ctx_type = G_COMP_DEMANGLER_GET_CLASS(demangler)->context_type;
+
+ context = g_object_new(ctx_type, NULL);
+
+ result = g_demangling_context_decode_routine(context, desc);
+
+ g_object_unref(G_OBJECT(context));
+
+ return result;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////
+
+
+
+
+
#include <malloc.h>
#include <string.h>
diff --git a/src/mangling/demangler.h b/src/mangling/demangler.h
index 00218e4..4a4b9fa 100644
--- a/src/mangling/demangler.h
+++ b/src/mangling/demangler.h
@@ -21,14 +21,54 @@
*/
-#ifndef _FORMAT_MANGLING_DEMANGLER_H
-#define _FORMAT_MANGLING_DEMANGLER_H
+#ifndef _MANGLING_DEMANGLER_H
+#define _MANGLING_DEMANGLER_H
#include "../analysis/routine.h"
+#define G_TYPE_COMP_DEMANGLER g_compiler_demangler_get_type()
+#define G_COMP_DEMANGLER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_COMP_DEMANGLER, GCompDemangler))
+#define G_IS_COMP_DEMANGLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_COMP_DEMANGLER))
+#define G_COMP_DEMANGLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_COMP_DEMANGLER, GCompDemanglerClass))
+#define G_IS_COMP_DEMANGLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_COMP_DEMANGLER))
+#define G_COMP_DEMANGLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_COMP_DEMANGLER, GCompDemanglerClass))
+
+
+/* Décodeur de désignations générique (instance) */
+typedef struct _GCompDemangler GCompDemangler;
+
+/* Décodeur de désignations générique (classe) */
+typedef struct _GCompDemanglerClass GCompDemanglerClass;
+
+
+/* Indique le type défini pour un décodeur de désignations. */
+GType g_compiler_demangler_get_type(void);
+
+/* Tente de décoder une chaîne de caractères donnée en type. */
+GDataType *g_compiler_demangler_decode_type(const GCompDemangler *, const char *);
+
+/* Tente de décoder une chaîne de caractères donnée en routine. */
+GBinRoutine *g_compiler_demangler_decode_routine(const GCompDemangler *, const char *);
+
+
+
+
+
+
+
+
+
+
+
+/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////
+
+
/* Tente de décoder une chaîne de caractères donnée. */
GBinRoutine *try_to_demangle_routine(const char *);
@@ -47,4 +87,4 @@ void test_itanium_demangling(void);
-#endif /* _FORMAT_MANGLING_DEMANGLER_H */
+#endif /* _MANGLING_DEMANGLER_H */
diff --git a/src/mangling/dex/Makefile.am b/src/mangling/dex/Makefile.am
deleted file mode 100644
index 547d686..0000000
--- a/src/mangling/dex/Makefile.am
+++ /dev/null
@@ -1,46 +0,0 @@
-
-BUILT_SOURCES = libmanglingdexshorty_la-shorty_gram.h libmanglingdextype_la-type_gram.h
-
-AM_YFLAGS = -d
-
-noinst_LTLIBRARIES = libmanglingdex.la libmanglingdexshorty.la libmanglingdextype.la
-
-libmanglingdex_la_SOURCES = \
- context.h context.c
-
-libmanglingdex_la_LDFLAGS =
-
-libmanglingdex_la_LIBADD = \
- libmanglingdexshorty.la \
- libmanglingdextype.la
-
-
-libmanglingdexshorty_la_SOURCES = \
- shorty_gram.y \
- shorty_tok.l
-
-libmanglingdexshorty_la_YFLAGS = -d -p shorty_ -o y.tab.c
-
-libmanglingdexshorty_la_LFLAGS = -P shorty_ -o lex.yy.c
-
-
-libmanglingdextype_la_SOURCES = \
- type_gram.y \
- type_tok.l
-
-libmanglingdextype_la_YFLAGS = -d -p type_ -o y.tab.c
-
-libmanglingdextype_la_LFLAGS = -P type_ -o lex.yy.c
-
-
-AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
-
-AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
-
-
-# Automake fait les choses à moitié
-CLEANFILES = \
- libmanglingdexshorty_la-shorty_gram.h libmanglingdexshorty_la-shorty_gram.c \
- libmanglingdexshorty_la-shorty_tok.c \
- libmanglingdextype_la-type_gram.h libmanglingdextype_la-type_gram.c \
- libmanglingdextype_la-type_tok.c
diff --git a/src/mangling/dex/context.c b/src/mangling/dex/context.c
deleted file mode 100644
index 9dd9b9c..0000000
--- a/src/mangling/dex/context.c
+++ /dev/null
@@ -1,154 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * context.c - contextes de décodage DEX
- *
- * Copyright (C) 2015-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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "context.h"
-
-
-#include "../context-int.h"
-
-
-
-/* Contexte de décodage DEX (instance) */
-struct _GDexDemangler
-{
- GDemanglingContext parent; /* A laisser en premier */
-
-};
-
-/* Contexte de décodage DEX (classe) */
-struct _GDexDemanglerClass
-{
- GDemanglingContextClass parent; /* A laisser en premier */
-
-};
-
-
-/* Initialise la classe des contextes de décodage DEX. */
-static void g_dex_demangler_class_init(GDexDemanglerClass *);
-
-/* Initialise une instance de contexte pour décodage DEX. */
-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 *);
-
-
-/* Procède au décodage d'une chaîne de caractères. */
-extern bool demangle_dex_routine(GDexDemangler *, const char *);
-
-/* Procède au décodage d'une chaîne de caractères. */
-extern bool demangle_dex_type(GDexDemangler *, const char *);
-
-
-
-/* Indique le type défini pour un contexte de décodage DEX. */
-G_DEFINE_TYPE(GDexDemangler, g_dex_demangler, G_TYPE_DEMANGLING_CONTEXT);
-
-
-/******************************************************************************
-* *
-* Paramètres : klass = classe à initialiser. *
-* *
-* Description : Initialise la classe des contextes de décodage DEX. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_dex_demangler_class_init(GDexDemanglerClass *klass)
-{
- GObjectClass *object; /* Autre version de la classe */
- GDemanglingContextClass *context; /* Version parente */
-
- object = G_OBJECT_CLASS(klass);
-
- object->dispose = (GObjectFinalizeFunc/* ! */)g_dex_demangler_dispose;
- object->finalize = (GObjectFinalizeFunc)g_dex_demangler_finalize;
-
- context = G_DEMANGLING_CONTEXT_CLASS(klass);
-
- context->demangle_type = (demangle_fc)demangle_dex_type;
- context->demangle_routine = (demangle_fc)demangle_dex_routine;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : demangler = instance à initialiser. *
-* *
-* Description : Initialise une instance de contexte pour décodage 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));
-
-}
diff --git a/src/mangling/dex/context.h b/src/mangling/dex/context.h
deleted file mode 100644
index 1af7a9d..0000000
--- a/src/mangling/dex/context.h
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * context.h - prototypes internes liés aux contextes de décodage DEX
- *
- * Copyright (C) 2015-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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _FORMAT_MANGLING_DEX_CONTEXT_H
-#define _FORMAT_MANGLING_DEX_CONTEXT_H
-
-
-#include <glib-object.h>
-
-
-
-#define G_TYPE_DEX_DEMANGLER g_dex_demangler_get_type()
-#define G_DEX_DEMANGLER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dex_demangler_get_type(), GDexDemangler))
-#define G_IS_DEX_DEMANGLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dex_demangler_get_type()))
-#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))
-
-
-/* Contexte de décodage DEX (instance) */
-typedef struct _GDexDemangler GDexDemangler;
-
-/* Contexte de décodage DEX (classe) */
-typedef struct _GDexDemanglerClass GDexDemanglerClass;
-
-
-/* Indique le type défini pour un contexte de décodage DEX. */
-GType g_dex_demangler_get_type(void);
-
-
-
-#endif /* _FORMAT_MANGLING_DEX_CONTEXT_H */
diff --git a/src/mangling/dex/shorty_gram.y b/src/mangling/dex/shorty_gram.y
deleted file mode 100644
index b688896..0000000
--- a/src/mangling/dex/shorty_gram.y
+++ /dev/null
@@ -1,138 +0,0 @@
-
-%{
-
-#include <stdbool.h>
-
-
-#include "context.h"
-#include "../context-int.h"
-
-
-
-/* Affiche un message d'erreur concernant l'analyse. */
-static int shorty_error(GDexDemangler *, char *);
-
-/* Procède au décodage d'une chaîne de caractères. */
-bool demangle_dex_routine(GDexDemangler *, const char *);
-
-
-%}
-
-
-%code requires {
-
-#include "../../analysis/types/basic.h"
-#include "../../analysis/types/cse.h"
-
-}
-
-%union {
-
- GDataType *type; /* Type reconstruit */
-
-}
-
-
-%parse-param { GDexDemangler *demangler }
-
-%token V Z B S C I J F D L
-
-%type <type> shorty_return_type shorty_field_type
-
-
-%{
-
-/* Déclarations issues de l'analyseur syntaxique... */
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern YY_BUFFER_STATE shorty__scan_string(const char *);
-extern void shorty__delete_buffer(YY_BUFFER_STATE);
-extern int shorty_lex(void);
-
-%}
-
-
-%%
-
-
-shorty_descriptor:
- shorty_return_type shorty_field_type_list {
- GBinRoutine *routine;
- routine = G_DEMANGLING_CONTEXT(demangler)->routine;
- g_binary_routine_set_return_type(routine, $1);
- }
-
-shorty_field_type_list:
- /* empty */
- | shorty_field_type shorty_field_type_list {
- GBinRoutine *routine;
- GBinVariable *var;
- routine = G_DEMANGLING_CONTEXT(demangler)->routine;
- var = g_binary_variable_new($1);
- g_binary_routine_add_arg(routine, var);
- }
-
-shorty_return_type:
- V { $$ = g_basic_type_new(BTP_VOID); }
- | shorty_field_type { $$ = $1; }
-
-shorty_field_type:
- Z { $$ = g_basic_type_new(BTP_BOOL); }
- | B { $$ = g_basic_type_new(BTP_UCHAR); }
- | S { $$ = g_basic_type_new(BTP_SHORT); }
- | C { $$ = g_basic_type_new(BTP_CHAR); }
- | I { $$ = g_basic_type_new(BTP_INT); }
- | J { $$ = g_basic_type_new(BTP_LONG); }
- | F { $$ = g_basic_type_new(BTP_FLOAT); }
- | D { $$ = g_basic_type_new(BTP_DOUBLE); }
- | L { $$ = g_class_enum_type_new(CET_CLASS, ""); }
-
-
-%%
-
-
-/******************************************************************************
-* *
-* Paramètres : demangler = contexte associé à la procédure de décodage. *
-* msg = indications humaines sur l'événement. *
-* *
-* Description : Affiche un message d'erreur concernant l'analyse. *
-* *
-* Retour : Valeur historique, ignorée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-static int shorty_error(GDexDemangler *demangler, char *msg)
-{
- return -1;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : demangler = contexte de décodage à utiliser. *
-* desc = chaîne de caractères à décoder. *
-* *
-* Description : Procède au décodage d'une chaîne de caractères. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool demangle_dex_routine(GDexDemangler *demangler, const char *desc)
-{
- YY_BUFFER_STATE buffer; /* Tampon pour bison */
- int ret; /* Bilan de l'appel */
-
- buffer = shorty__scan_string(desc);
- ret = yyparse(demangler);
- shorty__delete_buffer(buffer);
-
- return (ret == 0);
-
-}
diff --git a/src/mangling/dex/shorty_tok.l b/src/mangling/dex/shorty_tok.l
deleted file mode 100644
index a3545a2..0000000
--- a/src/mangling/dex/shorty_tok.l
+++ /dev/null
@@ -1,28 +0,0 @@
-
-%{
-
-#include "context.h"
-#include "libmanglingdexshorty_la-shorty_gram.h"
-
-%}
-
-
-%option noyywrap
-%option yylineno
-%option nounput
-%option noinput
-
-%%
-
-"V" { return V; }
-"Z" { return Z; }
-"B" { return B; }
-"S" { return S; }
-"C" { return C; }
-"I" { return I; }
-"J" { return J; }
-"F" { return F; }
-"D" { return D; }
-"L" { return L; }
-
-%%
diff --git a/src/mangling/dex/type_gram.y b/src/mangling/dex/type_gram.y
deleted file mode 100644
index 79c9320..0000000
--- a/src/mangling/dex/type_gram.y
+++ /dev/null
@@ -1,159 +0,0 @@
-
-%{
-
-#include <stdbool.h>
-
-
-#include "context.h"
-#include "../context-int.h"
-
-typedef void *yyscan_t;
-
-/* Affiche un message d'erreur concernant l'analyse. */
-static int type_error(GDexDemangler *, yyscan_t, char *);
-
-/* Procède au décodage d'une chaîne de caractères. */
-bool demangle_dex_type(GDexDemangler *, const char *);
-
-
-%}
-
-
-%code requires {
-
-#include "../../analysis/types/basic.h"
-#include "../../analysis/types/cse.h"
-#include "../../common/extstr.h"
-
-}
-
-%union {
-
- GDataType *type; /* Type reconstruit */
- size_t adeep; /* Dimension d'un tableau */
- char *text; /* Chaîne de caractères */
-
-}
-
-
-
-%define api.pure full
-%parse-param { GDexDemangler *demangler } { yyscan_t scanner }
-%lex-param { yyscan_t scanner }
-
-
-%token V Z B S C I J F D
-%token ARRAY
-%token L SEMICOLON
-%token SLASH DOLLAR
-%token TEXT
-
-%type <type> type_descriptor field_type_descriptor non_array_field_type_descriptor full_class_name
-
-%type <text> TEXT simple_name
-
-
-%{
-
-/* Déclarations issues de l'analyseur syntaxique... */
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int type_lex_init(yyscan_t *scanner);
-extern YY_BUFFER_STATE type__scan_string(const char *, yyscan_t);
-extern void type__delete_buffer(YY_BUFFER_STATE, yyscan_t);
-extern int type_lex(YYSTYPE *, yyscan_t);
-extern int type_lex_destroy(yyscan_t);
-
-%}
-
-
-%%
-
-
-input:
- type_descriptor { G_DEMANGLING_CONTEXT(demangler)->type = $1; }
-
-type_descriptor:
- V { $$ = g_basic_type_new(BTP_VOID); }
- | field_type_descriptor { $$ = $1; }
-
-field_type_descriptor:
- non_array_field_type_descriptor { $$ = $1; }
- | ARRAY non_array_field_type_descriptor { $$ = $2; }
-
-non_array_field_type_descriptor:
- Z { $$ = g_basic_type_new(BTP_BOOL); }
- | B { $$ = g_basic_type_new(BTP_UCHAR); }
- | S { $$ = g_basic_type_new(BTP_SHORT); }
- | C { $$ = g_basic_type_new(BTP_CHAR); }
- | I { $$ = g_basic_type_new(BTP_INT); }
- | J { $$ = g_basic_type_new(BTP_LONG); }
- | F { $$ = g_basic_type_new(BTP_FLOAT); }
- | D { $$ = g_basic_type_new(BTP_DOUBLE); }
- | L full_class_name SEMICOLON { $$ = $2; }
-
-full_class_name:
- simple_name { $$ = g_class_enum_type_new(CET_CLASS, $1); }
- | full_class_name SLASH simple_name {
- $$ = g_class_enum_type_new(CET_CLASS, $3);
- g_data_type_set_namespace($$, $1);
- g_object_unref($1);
- }
-simple_name:
- TEXT { $$ = strdup($1); }
- | simple_name TEXT { $$ = stradd($1, $2); }
-
-%%
-
-
-/******************************************************************************
-* *
-* Paramètres : demangler = contexte associé à la procédure de décodage. *
-* scanner = données internes aux analyseurs. *
-* msg = indications humaines sur l'événement. *
-* *
-* Description : Affiche un message d'erreur concernant l'analyse. *
-* *
-* Retour : Valeur historique, ignorée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-static int type_error(GDexDemangler *demangler, yyscan_t scanner, char *msg)
-{
- return -1;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : demangler = contexte de décodage à utiliser. *
-* desc = chaîne de caractères à décoder. *
-* *
-* Description : Procède au décodage d'une chaîne de caractères. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool demangle_dex_type(GDexDemangler *demangler, const char *desc)
-{
- yyscan_t scanner; /* Données internes */
- YY_BUFFER_STATE buffer; /* Tampon pour bison */
- int ret; /* Bilan de l'appel */
-
- type_lex_init(&scanner);
-
- buffer = type__scan_string(desc, scanner);
- ret = yyparse(demangler, scanner);
- type__delete_buffer(buffer, scanner);
-
- type_lex_destroy(scanner);
-
- return (ret == 0);
-
-}
diff --git a/src/mangling/dex/type_tok.l b/src/mangling/dex/type_tok.l
deleted file mode 100644
index 7e85d43..0000000
--- a/src/mangling/dex/type_tok.l
+++ /dev/null
@@ -1,150 +0,0 @@
-
-%{
-
-#include "context.h"
-#include "libmanglingdextype_la-type_gram.h"
-
-/* See lemoda.net/c/reentrant-parser */
-
-%}
-
-
-%option noyywrap
-%option yylineno
-%option nounput
-/*%option noinput*/
-%option reentrant
-%option bison-bridge
-
-%x string
-
-ASCII [A-Za-z0-9]
-SIMPLE {ASCII}|"$"|"-"|"_"
-
-%%
-
-"V" { return V; }
-"Z" { return Z; }
-"B" { return B; }
-"S" { return S; }
-"C" { return C; }
-"I" { return I; }
-"J" { return J; }
-"F" { return F; }
-"D" { return D; }
-"L" { BEGIN(string); return L; }
-"["* { yylval->adeep = strlen(yytext); return ARRAY; }
-<string>"/" { return SLASH; }
-<string>";" { BEGIN(INITIAL); return SEMICOLON; }
-
-<string>{SIMPLE}* { yylval->text = yytext; return TEXT; }
-
-<string>. {
- unsigned char next;
- char mutf8[4];
-
- switch ((unsigned char)yytext[0])
- {
- /* U+00a1 ... U+1fff */
- case 0x00 ... 0x1f:
-
- next = input(yyscanner);
-
- if (yytext[0] == 0x00 && next < 0xa1)
- {
- REJECT;
- }
-
- else
- {
- mutf8[0] = yytext[0];
- mutf8[1] = next;
- mutf8[2] = '\0';
-
- strcpy(yylval->text, mutf8); return TEXT;
-
- }
-
- break;
-
- /* U+2010 ... U+2027 / U+2030 ... U+d7ff */
- case 0x20:
-
- next = input(yyscanner);
-
- switch (next)
- {
- case 0x10 ... 0x27:
- case 0x30 ... 0xff:
-
- mutf8[0] = yytext[0];
- mutf8[1] = next;
- mutf8[2] = '\0';
-
- strcpy(yylval->text, mutf8); return TEXT;
- break;
-
- default:
- REJECT;
- break;
-
- }
-
- break;
-
- /* ~ U+2030 ... U+d7ff */
- case 0x21 ... 0xd7:
-
- next = input(yyscanner);
-
- mutf8[0] = yytext[0];
- mutf8[1] = next;
- mutf8[2] = '\0';
-
- strcpy(yylval->text, mutf8); return TEXT;
- break;
-
- /* U+e000 ... U+ffef */
- case 0xe0 ... 0xff:
-
- next = input(yyscanner);
-
- if (yytext[0] == 0xff && next > 0xef)
- {
- REJECT;
- }
-
- else
- {
- mutf8[0] = yytext[0];
- mutf8[1] = next;
- mutf8[2] = '\0';
-
- strcpy(yylval->text, mutf8); return TEXT;
-
- }
-
- break;
-
- /* U+10000 ... U+10ffff */
- /*
- case 0x10:
-
- mutf8[0] = yytext[0];
- mutf8[1] = input(yyscanner);
- mutf8[2] = input(yyscanner);
- mutf8[3] = '\0';
-
- strcpy(yylval->text, mutf8); return TEXT;
- break;
- */
-
- default:
- REJECT;
- break;
-
- }
-
- }
-
-%%