summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-07-07 21:46:38 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-07-07 21:46:38 (GMT)
commit24f4b449d22c918d8f0e6c8fc059e0fa1fa485ff (patch)
tree0652f6fc72996447cb050fefb9daf6da43de999a /src/format
parent13a879ebcf58f3868c0275d84dd9886673c9e614 (diff)
Added support for Android boot images.
Diffstat (limited to 'src/format')
-rw-r--r--src/format/Makefile.am2
-rw-r--r--src/format/known-int.h65
-rw-r--r--src/format/known.c260
-rw-r--r--src/format/known.h72
4 files changed, 399 insertions, 0 deletions
diff --git a/src/format/Makefile.am b/src/format/Makefile.am
index 1ab4825..dab4260 100644
--- a/src/format/Makefile.am
+++ b/src/format/Makefile.am
@@ -10,6 +10,8 @@ libformat_la_SOURCES = \
flat.h flat.c \
format-int.h \
format.h format.c \
+ known-int.h \
+ known.h known.c \
preload-int.h \
preload.h preload.c \
strsym.h strsym.c \
diff --git a/src/format/known-int.h b/src/format/known-int.h
new file mode 100644
index 0000000..e4d3bd6
--- /dev/null
+++ b/src/format/known-int.h
@@ -0,0 +1,65 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * known-int.h - prototypes utiles aux formats binaires reconnus
+ *
+ * Copyright (C) 2019 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_KNOWN_INT_H
+#define _FORMAT_KNOWN_INT_H
+
+
+#include "known.h"
+
+
+
+/* Indique la désignation interne du format. */
+typedef const char * (* known_get_name_fc) (const GKnownFormat *);
+
+/* Fournit une description humaine du format. */
+typedef const char * (* known_get_desc_fc) (const GKnownFormat *);
+
+/*Assure l'interprétation d'un format en différé. */
+typedef bool (* known_analyze_fc) (GKnownFormat *, wgroup_id_t, GtkStatusStack *);
+
+
+/* Format binaire générique (instance) */
+struct _GKnownFormat
+{
+ GObject parent; /* A laisser en premier */
+
+ GBinContent *content; /* Contenu binaire à étudier */
+
+};
+
+/* Format binaire générique (classe) */
+struct _GKnownFormatClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+ known_get_name_fc get_name; /* Désignation interne */
+ known_get_desc_fc get_desc; /* Désignation humaine */
+
+ known_analyze_fc analyze; /* Interprétation du format */
+
+};
+
+
+
+#endif /* _FORMAT_KNOWN_INT_H */
diff --git a/src/format/known.c b/src/format/known.c
new file mode 100644
index 0000000..9a3eef6
--- /dev/null
+++ b/src/format/known.c
@@ -0,0 +1,260 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * format.c - support des différents formats binaires reconnus
+ *
+ * Copyright (C) 2019 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "known.h"
+
+
+#include <assert.h>
+
+
+#include "known-int.h"
+#include "../plugins/pglist.h"
+
+
+
+/* Initialise la classe des formats binaires génériques. */
+static void g_known_format_class_init(GKnownFormatClass *);
+
+/* Initialise une instance de format binaire générique. */
+static void g_known_format_init(GKnownFormat *);
+
+/* Supprime toutes les références externes. */
+static void g_known_format_dispose(GKnownFormat *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_known_format_finalize(GKnownFormat *);
+
+
+
+/* Indique le type défini pour un format binaire générique. */
+G_DEFINE_TYPE(GKnownFormat, g_known_format, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des formats binaires génériques. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_known_format_class_init(GKnownFormatClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_known_format_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_known_format_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance à initialiser. *
+* *
+* Description : Initialise une instance de format binaire générique. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_known_format_init(GKnownFormat *format)
+{
+ format->content = NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_known_format_dispose(GKnownFormat *format)
+{
+ g_clear_object(&format->content);
+
+ G_OBJECT_CLASS(g_known_format_parent_class)->dispose(G_OBJECT(format));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_known_format_finalize(GKnownFormat *format)
+{
+ G_OBJECT_CLASS(g_known_format_parent_class)->finalize(G_OBJECT(format));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* content = contenu binaire à parcourir. *
+* *
+* Description : Définit le contenu binaire à analyser. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_known_format_set_content(GKnownFormat *format, GBinContent *content)
+{
+ assert(format->content == NULL);
+
+ g_object_ref_sink(G_OBJECT(content));
+
+ format->content = content;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Fournit une référence vers le contenu binaire analysé. *
+* *
+* Retour : Gestionnaire de contenu binaire en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinContent *g_known_format_get_content(const GKnownFormat *format)
+{
+ GBinContent *result; /* Instance à retourner */
+
+ result = format->content;
+
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Indique la désignation interne du format. *
+* *
+* Retour : Description du format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *g_known_format_get_name(const GKnownFormat *format)
+{
+ const char *result; /* Désignation à retourner */
+
+ result = G_KNOWN_FORMAT_GET_CLASS(format)->get_name(format);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Fournit une description humaine du format. *
+* *
+* Retour : Description du format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *g_known_format_get_description(const GKnownFormat *format)
+{
+ const char *result; /* Désignation à retourner */
+
+ result = G_KNOWN_FORMAT_GET_CLASS(format)->get_desc(format);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = format chargé dont l'analyse est lancée. *
+* gid = groupe de travail dédié. *
+* status = barre de statut à tenir informée. *
+* *
+* Description : Assure l'interprétation d'un format en différé. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_known_format_analyze(GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+{
+ bool result; /* Bilan à retourner */
+ GKnownFormatClass *class; /* Classe de l'instance */
+
+ handle_known_format_analysis(PGA_FORMAT_ANALYSIS_STARTED, format, gid, status);
+
+ class = G_KNOWN_FORMAT_GET_CLASS(format);
+
+ result = class->analyze(format, gid, status);
+
+ handle_known_format_analysis(PGA_FORMAT_ANALYSIS_ENDED, format, gid, status);
+
+ return result;
+
+}
diff --git a/src/format/known.h b/src/format/known.h
new file mode 100644
index 0000000..c89ba4a
--- /dev/null
+++ b/src/format/known.h
@@ -0,0 +1,72 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * format.h - prototypes pour le support des différents formats binaires reconnus
+ *
+ * Copyright (C) 2019 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_KNOWN_H
+#define _FORMAT_KNOWN_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "../analysis/content.h"
+#include "../glibext/delayed.h"
+
+
+
+#define G_TYPE_KNOWN_FORMAT g_known_format_get_type()
+#define G_KNOWN_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_KNOWN_FORMAT, GKnownFormat))
+#define G_IS_KNOWN_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_KNOWN_FORMAT))
+#define G_KNOWN_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_KNOWN_FORMAT, GKnownFormatClass))
+#define G_IS_KNOWN_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_KNOWN_FORMAT))
+#define G_KNOWN_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_KNOWN_FORMAT, GKnownFormatClass))
+
+
+/* Format binaire générique (instance) */
+typedef struct _GKnownFormat GKnownFormat;
+
+/* Format binaire générique (classe) */
+typedef struct _GKnownFormatClass GKnownFormatClass;
+
+
+/* Indique le type défini pour un format binaire générique. */
+GType g_known_format_get_type(void);
+
+/* Définit le contenu binaire à analyser. */
+void g_known_format_set_content(GKnownFormat *, GBinContent *);
+
+/* Fournit une référence vers le contenu binaire analysé. */
+GBinContent *g_known_format_get_content(const GKnownFormat *);
+
+/* Indique la désignation interne du format. */
+const char *g_known_format_get_name(const GKnownFormat *);
+
+/* Fournit une description humaine du format. */
+const char *g_known_format_get_description(const GKnownFormat *);
+
+/* Assure l'interprétation d'un format en différé. */
+bool g_known_format_analyze(GKnownFormat *, wgroup_id_t, GtkStatusStack *);
+
+
+
+#endif /* _FORMAT_KNOWN_H */