summaryrefslogtreecommitdiff
path: root/src/analysis/human
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/human')
-rwxr-xr-xsrc/analysis/human/Makefile.am19
-rwxr-xr-xsrc/analysis/human/asm/Makefile.am17
-rw-r--r--src/analysis/human/asm/lang.c221
-rw-r--r--src/analysis/human/asm/lang.h58
-rw-r--r--src/analysis/human/lang-int.h58
-rw-r--r--src/analysis/human/lang.c167
-rw-r--r--src/analysis/human/lang.h58
7 files changed, 598 insertions, 0 deletions
diff --git a/src/analysis/human/Makefile.am b/src/analysis/human/Makefile.am
new file mode 100755
index 0000000..0cfc4e3
--- /dev/null
+++ b/src/analysis/human/Makefile.am
@@ -0,0 +1,19 @@
+
+noinst_LTLIBRARIES = libanalysishuman.la
+
+
+libanalysishuman_la_SOURCES = \
+ lang-int.h \
+ lang.h lang.c
+
+libanalysishuman_la_LIBADD = \
+ asm/libanalysishumanasm.la
+
+libanalysishuman_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBARCHIVE_CFLAGS) $(LIBSQLITE_CFLAGS)
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS = asm
diff --git a/src/analysis/human/asm/Makefile.am b/src/analysis/human/asm/Makefile.am
new file mode 100755
index 0000000..da94071
--- /dev/null
+++ b/src/analysis/human/asm/Makefile.am
@@ -0,0 +1,17 @@
+
+noinst_LTLIBRARIES = libanalysishumanasm.la
+
+
+libanalysishumanasm_la_SOURCES = \
+ lang.h lang.c
+
+libanalysishumanasm_la_LIBADD =
+
+libanalysishumanasm_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBARCHIVE_CFLAGS) $(LIBSQLITE_CFLAGS)
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS =
diff --git a/src/analysis/human/asm/lang.c b/src/analysis/human/asm/lang.c
new file mode 100644
index 0000000..27a26dd
--- /dev/null
+++ b/src/analysis/human/asm/lang.c
@@ -0,0 +1,221 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.c - traduction en language d'assembleur classique
+ *
+ * Copyright (C) 2016 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 "lang.h"
+
+
+#include "../lang-int.h"
+#include "../../../common/extstr.h"
+
+
+
+/* Traduction d'éléments en language d'assembleur (instance) */
+struct _GAsmLanguage
+{
+ GCodingLanguage parent; /* A laisser en premier */
+
+};
+
+/* Traduction d'éléments en language d'assembleur (classe) */
+struct _GAsmLanguageClass
+{
+ GCodingLanguageClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des traductions en langage d'assembleur. */
+static void g_asm_language_class_init(GAsmLanguageClass *);
+
+/* Initialise une traduction d'éléments en langage d'assembleur. */
+static void g_asm_language_init(GAsmLanguage *);
+
+/* Supprime toutes les références externes. */
+static void g_asm_language_dispose(GAsmLanguage *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_asm_language_finalize(GAsmLanguage *);
+
+/* Complète du texte pour en faire un vrai commentaire. */
+static void g_asm_language_encapsulate_comment(const GAsmLanguage *, char **);
+
+/* Complète du texte pour en faire de vrais commentaires. */
+static void g_asm_language_encapsulate_comments(const GAsmLanguage *, char ***, size_t *);
+
+
+
+/* Indique le type défini pour une traduction en langage d'assembleur. */
+G_DEFINE_TYPE(GAsmLanguage, g_asm_language, G_TYPE_CODING_LANGUAGE);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des traductions en langage d'assembleur.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_class_init(GAsmLanguageClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GCodingLanguageClass *lang; /* Encore une autre vision... */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_asm_language_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_asm_language_finalize;
+
+ lang = G_CODING_LANGUAGE_CLASS(klass);
+
+ lang->encaps_comment = (encapsulate_comment_fc)g_asm_language_encapsulate_comment;
+ lang->encaps_comments = (encapsulate_comments_fc)g_asm_language_encapsulate_comments;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance à initialiser. *
+* *
+* Description : Initialise une traduction d'éléments en langage d'assembleur.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_init(GAsmLanguage *lang)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_dispose(GAsmLanguage *lang)
+{
+ G_OBJECT_CLASS(g_asm_language_parent_class)->dispose(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_finalize(GAsmLanguage *lang)
+{
+ G_OBJECT_CLASS(g_asm_language_parent_class)->finalize(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Crée une instance de traduction en langage d'assembleur. *
+* *
+* Retour : Instance mis en place et prête à emploi. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GCodingLanguage *g_asm_language_new(void)
+{
+ GAsmLanguage *result; /* Instance à retourner */
+
+ result = g_object_new(G_TYPE_ASM_LANGUAGE, NULL);
+
+ return G_CODING_LANGUAGE(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse de la ligne à compléter. [OUT] *
+* *
+* Description : Complète du texte pour en faire un vrai commentaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_encapsulate_comment(const GAsmLanguage *lang, char **text)
+{
+ *text = strprep(*text, "; ");
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse du tableau de lignes à conserver. [OUT] *
+* count = adresse de la taille du tableau fourni. [OUT] *
+* *
+* Description : Complète du texte pour en faire de vrais commentaires. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_encapsulate_comments(const GAsmLanguage *lang, char ***text, size_t *count)
+{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < *count; i++)
+ (*text)[i] = strprep((*text)[i], "; ");
+
+}
diff --git a/src/analysis/human/asm/lang.h b/src/analysis/human/asm/lang.h
new file mode 100644
index 0000000..7381048
--- /dev/null
+++ b/src/analysis/human/asm/lang.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.h - prototypes pour la traduction en language d'assembleur classique
+ *
+ * Copyright (C) 2016 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 _ANALYSIS_HUMAN_ASM_LANG_H
+#define _ANALYSIS_HUMAN_ASM_LANG_H
+
+
+#include <glib-object.h>
+
+
+#include "../lang.h"
+
+
+
+#define G_TYPE_ASM_LANGUAGE g_asm_language_get_type()
+#define G_ASM_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_asm_language_get_type(), GAsmLanguage))
+#define G_IS_ASM_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_asm_language_get_type()))
+#define G_ASM_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ASM_LANGUAGE, GAsmLanguageClass))
+#define G_IS_ASM_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ASM_LANGUAGE))
+#define G_ASM_LANGUAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ASM_LANGUAGE, GAsmLanguageClass))
+
+
+/* Traduction d'éléments en language d'assembleur (instance) */
+typedef struct _GAsmLanguage GAsmLanguage;
+
+/* Traduction d'éléments en language d'assembleur (classe) */
+typedef struct _GAsmLanguageClass GAsmLanguageClass;
+
+
+/* Indique le type défini pour une traduction en langage d'assembleur. */
+GType g_asm_language_get_type(void);
+
+/* Crée une instance de traduction en langage d'assembleur. */
+GCodingLanguage *g_asm_language_new(void);
+
+
+
+#endif /* _ANALYSIS_HUMAN_ASM_LANG_H */
diff --git a/src/analysis/human/lang-int.h b/src/analysis/human/lang-int.h
new file mode 100644
index 0000000..c20bc8a
--- /dev/null
+++ b/src/analysis/human/lang-int.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang-int.h - prototypes utiles aux traductions en langages de haut niveau
+ *
+ * Copyright (C) 2016 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 _ANALYSIS_HUMAN_LANG_INT_H
+#define _ANALYSIS_HUMAN_LANG_INT_H
+
+
+#include "lang.h"
+
+
+
+/* Complète du texte pour en faire un vrai commentaire. */
+typedef void (* encapsulate_comment_fc) (const GCodingLanguage *, char **);
+
+/* Complète du texte pour en faire de vrais commentaires. */
+typedef void (* encapsulate_comments_fc) (const GCodingLanguage *, char ***, size_t *);
+
+
+/* Traduction générique en langage humain (instance) */
+struct _GCodingLanguage
+{
+ GObject parent; /* A laisser en premier */
+
+};
+
+/* Traduction générique en langage humain (classe) */
+struct _GCodingLanguageClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+ encapsulate_comment_fc encaps_comment; /* Encadrement de commentaire */
+ encapsulate_comments_fc encaps_comments;/* Encadrement de commentaires */
+
+};
+
+
+
+#endif /* _ANALYSIS_HUMAN_LANG_INT_H */
diff --git a/src/analysis/human/lang.c b/src/analysis/human/lang.c
new file mode 100644
index 0000000..72002d3
--- /dev/null
+++ b/src/analysis/human/lang.c
@@ -0,0 +1,167 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.c - traduction en langages de haut niveau
+ *
+ * Copyright (C) 2016 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 "lang.h"
+
+
+#include "lang-int.h"
+
+
+
+/* Initialise la classe des traductions en langage humain. */
+static void g_coding_language_class_init(GCodingLanguageClass *);
+
+/* Initialise une instance de traduction en langage humain. */
+static void g_coding_language_init(GCodingLanguage *);
+
+/* Supprime toutes les références externes. */
+static void g_coding_language_dispose(GCodingLanguage *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_coding_language_finalize(GCodingLanguage *);
+
+
+
+/* Indique le type défini pour une traduction en langage humain. */
+G_DEFINE_TYPE(GCodingLanguage, g_coding_language, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des traductions en langage humain. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_class_init(GCodingLanguageClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_coding_language_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_coding_language_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance à initialiser. *
+* *
+* Description : Initialise une instance de traduction en langage humain. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_init(GCodingLanguage *lang)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_dispose(GCodingLanguage *lang)
+{
+ G_OBJECT_CLASS(g_coding_language_parent_class)->dispose(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_finalize(GCodingLanguage *lang)
+{
+ G_OBJECT_CLASS(g_coding_language_parent_class)->finalize(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse de la ligne à compléter. [OUT] *
+* *
+* Description : Complète du texte pour en faire un vrai commentaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_coding_language_encapsulate_comment(const GCodingLanguage *lang, char **text)
+{
+ G_CODING_LANGUAGE_GET_CLASS(lang)->encaps_comment(lang, text);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse du tableau de lignes à conserver. [OUT] *
+* count = adresse de la taille du tableau fourni. [OUT] *
+* *
+* Description : Complète du texte pour en faire de vrais commentaires. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_coding_language_encapsulate_comments(const GCodingLanguage *lang, char ***text, size_t *count)
+{
+ G_CODING_LANGUAGE_GET_CLASS(lang)->encaps_comments(lang, text, count);
+
+}
diff --git a/src/analysis/human/lang.h b/src/analysis/human/lang.h
new file mode 100644
index 0000000..dc8e398
--- /dev/null
+++ b/src/analysis/human/lang.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.h - prototypes pour les traductions en langages de haut niveau
+ *
+ * Copyright (C) 2016 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 _ANALYSIS_HUMAN_LANG_H
+#define _ANALYSIS_HUMAN_LANG_H
+
+
+#include <glib-object.h>
+
+
+
+#define G_TYPE_CODING_LANGUAGE g_coding_language_get_type()
+#define G_CODING_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_CODING_LANGUAGE, GCodingLanguage))
+#define G_IS_CODING_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_CODING_LANGUAGE))
+#define G_CODING_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_CODING_LANGUAGE, GCodingLanguageClass))
+#define G_IS_CODING_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_CODING_LANGUAGE))
+#define G_CODING_LANGUAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_CODING_LANGUAGE, GCodingLanguageClass))
+
+
+/* Traduction générique en langage humain (instance) */
+typedef struct _GCodingLanguage GCodingLanguage;
+
+/* Traduction générique en langage humain (classe) */
+typedef struct _GCodingLanguageClass GCodingLanguageClass;
+
+
+/* Indique le type défini pour une traduction en langage humain. */
+GType g_coding_language_get_type(void);
+
+/* Complète du texte pour en faire un vrai commentaire. */
+void g_coding_language_encapsulate_comment(const GCodingLanguage *, char **);
+
+/* Complète du texte pour en faire de vrais commentaires. */
+void g_coding_language_encapsulate_comments(const GCodingLanguage *, char ***, size_t *);
+
+
+
+#endif /* _ANALYSIS_HUMAN_LANG_H */