summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/pychrysalide/format/Makefile.am1
-rw-r--r--plugins/pychrysalide/format/executable.c6
-rw-r--r--plugins/pychrysalide/format/flat.c206
-rw-r--r--plugins/pychrysalide/format/flat.h42
-rw-r--r--plugins/pychrysalide/format/module.c2
-rw-r--r--src/format/Makefile.am2
-rw-r--r--src/format/executable.c15
-rw-r--r--src/format/flat-int.h54
-rw-r--r--src/format/flat.c385
-rw-r--r--src/format/flat.h65
-rw-r--r--src/format/format.c5
-rw-r--r--tests/format/flat.py32
12 files changed, 809 insertions, 6 deletions
diff --git a/plugins/pychrysalide/format/Makefile.am b/plugins/pychrysalide/format/Makefile.am
index 0dac280..f96bf81 100644
--- a/plugins/pychrysalide/format/Makefile.am
+++ b/plugins/pychrysalide/format/Makefile.am
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libpychrysaformat.la
libpychrysaformat_la_SOURCES = \
executable.h executable.c \
+ flat.h flat.c \
format.h format.c \
module.h module.c \
symbol.h symbol.c \
diff --git a/plugins/pychrysalide/format/executable.c b/plugins/pychrysalide/format/executable.c
index 9ae45ff..a3bcdd1 100644
--- a/plugins/pychrysalide/format/executable.c
+++ b/plugins/pychrysalide/format/executable.c
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * executable.c - équivalent Python du fichier "format/executable.h"
+ * executable.c - équivalent Python du fichier "format/executable.c"
*
* Copyright (C) 2012-2017 Cyrille Bagard
*
@@ -151,12 +151,12 @@ PyTypeObject *get_python_executable_format_type(void)
{
"translate_offset_into_vmpa", py_exe_format_translate_offset_into_vmpa,
METH_VARARGS,
- "translate_offset_into_vmpa($self, off, /)\n--\n\nTranslate a physical offset to a full location.."
+ "translate_offset_into_vmpa($self, off, /)\n--\n\nTranslate a physical offset to a full location."
},
{
"translate_address_into_vmpa", py_exe_format_translate_address_into_vmpa,
METH_VARARGS,
- "translate_address_into_vmpa($self, addr, /)\n--\n\nTranslate a physical offset to a full location.."
+ "translate_address_into_vmpa($self, addr, /)\n--\n\nTranslate a physical offset to a full location."
},
{ NULL }
};
diff --git a/plugins/pychrysalide/format/flat.c b/plugins/pychrysalide/format/flat.c
new file mode 100644
index 0000000..c85ee37
--- /dev/null
+++ b/plugins/pychrysalide/format/flat.c
@@ -0,0 +1,206 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * flat.c - équivalent Python du fichier "format/flat.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 "flat.h"
+
+
+#include <pygobject.h>
+
+
+#include <format/flat.h>
+
+
+#include "executable.h"
+#include "../helpers.h"
+#include "../analysis/content.h"
+
+
+
+/* Crée un nouvel objet Python de type 'FlatFormat'. */
+static PyObject *py_flat_format_new(PyTypeObject *, PyObject *, PyObject *);
+
+/* Indique le type d'architecture visée par le format. */
+static PyObject *py_flat_format_set_target_machine(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 'FlatFormat'. *
+* *
+* Retour : Instance Python mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_flat_format_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyObject *result; /* Instance à retourner */
+ PyObject *content_obj; /* Objet pour le contenu */
+ int ret; /* Bilan de lecture des args. */
+ GBinContent *content; /* Instance GLib du contenu */
+ GExeFormat *format; /* Création GLib à transmettre */
+
+ ret = PyArg_ParseTuple(args, "O!", get_python_binary_content_type(), &content_obj);
+ if (!ret) return NULL;
+
+ content = G_BIN_CONTENT(pygobject_get(content_obj));
+
+ format = g_flat_format_new(content);
+
+ if (format == NULL)
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ else
+ {
+ result = pygobject_new(G_OBJECT(format));
+ g_object_unref(format);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = description de l'exécutable à consulter. *
+* args = arguments accompagnant l'appel. *
+* *
+* Description : Indique le type d'architecture visée par le format. *
+* *
+* Retour : Rien, donc None en Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_flat_format_set_target_machine(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Instance à retourner */
+ GFlatFormat *format; /* Version GLib du format */
+ const char *machine; /* Identifiant d'architecture */
+ int ret; /* Bilan de lecture des args. */
+
+ format = G_FLAT_FORMAT(pygobject_get(self));
+ assert(format != NULL);
+
+ ret = PyArg_ParseTuple(args, "s", &machine);
+ if (!ret) return NULL;
+
+ g_flat_format_set_target_machine(format, machine);
+
+ 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_flat_format_type(void)
+{
+ static PyMethodDef py_flat_format_methods[] = {
+ {
+ "set_machine", py_flat_format_set_target_machine,
+ METH_VARARGS,
+ "set_machine($self, machine, /)\n--\n\nSet the architecture linked to the flat format."
+ },
+ { NULL }
+ };
+
+ static PyGetSetDef py_flat_format_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_flat_format_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.format.FlatFormat",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+
+ .tp_doc = "PyChrysalide flat format",
+
+ .tp_methods = py_flat_format_methods,
+ .tp_getset = py_flat_format_getseters,
+ .tp_new = (newfunc)py_flat_format_new
+
+ };
+
+ return &py_flat_format_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.format.FlatFormat'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_flat_format(PyObject *module)
+{
+ PyTypeObject *py_flat_format_type; /* Type Python 'FlatFormat' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_flat_format_type = get_python_flat_format_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_FLAT_FORMAT, py_flat_format_type, \
+ get_python_executable_format_type()))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/format/flat.h b/plugins/pychrysalide/format/flat.h
new file mode 100644
index 0000000..92e5f9e
--- /dev/null
+++ b/plugins/pychrysalide/format/flat.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * flat.h - prototypes pour l'équivalent Python du fichier "format/flat.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_FORMAT_FLAT_H
+#define _PLUGINS_PYCHRYSALIDE_FORMAT_FLAT_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_flat_format_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.format.FlatFormat'. */
+bool register_python_flat_format(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_FORMAT_FLAT_H */
diff --git a/plugins/pychrysalide/format/module.c b/plugins/pychrysalide/format/module.c
index 1daeb3f..9a88dcd 100644
--- a/plugins/pychrysalide/format/module.c
+++ b/plugins/pychrysalide/format/module.c
@@ -29,6 +29,7 @@
#include "executable.h"
+#include "flat.h"
#include "format.h"
#include "symbol.h"
#include "symiter.h"
@@ -84,6 +85,7 @@ bool add_format_module_to_python_module(PyObject *super)
result &= register_python_binary_format(module);
result &= register_python_executable_format(module);
+ result &= register_python_flat_format(module);
result &= register_python_binary_symbol(module);
result &= register_python_sym_iterator(module);
diff --git a/src/format/Makefile.am b/src/format/Makefile.am
index 1435695..504055d 100644
--- a/src/format/Makefile.am
+++ b/src/format/Makefile.am
@@ -6,6 +6,8 @@ libformat_la_SOURCES = \
debuggable.h debuggable.c \
executable-int.h executable-int.c \
executable.h executable.c \
+ flat-int.h \
+ flat.h flat.c \
format-int.h \
format.h format.c \
preload-int.h \
diff --git a/src/format/executable.c b/src/format/executable.c
index a2ee569..e70840b 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -302,6 +302,7 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
GBinFormat *base; /* Version basique du format */
vmpa2t addr; /* Emplacement vide de sens */
phys_t length; /* Taille de portion globale */
+ GExeFormatClass *class; /* Classe de l'instance */
base = G_BIN_FORMAT(format);
@@ -314,7 +315,10 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
format->portions = g_binary_portion_new(BPC_RAW, &addr, length);
- G_EXE_FORMAT_GET_CLASS(format)->refine_portions(format);
+ class = G_EXE_FORMAT_GET_CLASS(format);
+
+ if (class->refine_portions != NULL)
+ class->refine_portions(format);
}
@@ -518,8 +522,15 @@ bool g_exe_format_translate_address_into_vmpa(GExeFormat *format, virt_t addr, v
bool g_exe_format_get_section_range_by_name(const GExeFormat *format, const char *name, mrange_t *range)
{
bool result; /* Bilan à retourner */
+ GExeFormatClass *class; /* Classe de l'instance */
+
+ class = G_EXE_FORMAT_GET_CLASS(format);
- result = G_EXE_FORMAT_GET_CLASS(format)->get_range_by_name(format, name, range);
+ if (class->get_range_by_name == NULL)
+ result = false;
+
+ else
+ result = class->get_range_by_name(format, name, range);
return result;
diff --git a/src/format/flat-int.h b/src/format/flat-int.h
new file mode 100644
index 0000000..9a54e82
--- /dev/null
+++ b/src/format/flat-int.h
@@ -0,0 +1,54 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * flat-int.h - prototypes de code utile aux formats d'exécutables à plat
+ *
+ * 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_FLAT_INT_H
+#define _FORMAT_FLAT_INT_H
+
+
+#include "flat.h"
+
+
+#include "executable-int.h"
+
+
+
+/* Format d'exécutable à plat (instance) */
+struct _GFlatFormat
+{
+ GExeFormat parent; /* A laisser en premier */
+
+ SourceEndian endian; /* Boutisme imposé */
+ char *machine; /* Architecture imposée */
+
+};
+
+/* Format d'exécutable à plat (classe) */
+struct _GFlatFormatClass
+{
+ GExeFormatClass parent; /* A laisser en premier */
+
+};
+
+
+
+#endif /* _FORMAT_FLAT_INT_H */
diff --git a/src/format/flat.c b/src/format/flat.c
new file mode 100644
index 0000000..b165c18
--- /dev/null
+++ b/src/format/flat.c
@@ -0,0 +1,385 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * flat.c - support des formats à plat
+ *
+ * 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "flat.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include <i18n.h>
+
+
+#include "flat-int.h"
+
+
+
+/* Initialise la classe des formats d'exécutables à plat. */
+static void g_flat_format_class_init(GFlatFormatClass *);
+
+/* Initialise une instance de format d'exécutable à plat. */
+static void g_flat_format_init(GFlatFormat *);
+
+/* Supprime toutes les références externes. */
+static void g_flat_format_dispose(GFlatFormat *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_flat_format_finalize(GFlatFormat *);
+
+/* Indique la désignation interne du format. */
+static const char *g_flat_format_get_name(const GFlatFormat *);
+
+/* Fournit une description humaine du format. */
+static const char *g_flat_format_get_description(const GFlatFormat *);
+
+/* Assure l'interprétation d'un format en différé. */
+static bool g_flat_format_analyze(GFlatFormat *, wgroup_id_t, GtkStatusStack *);
+
+/* Informe quant au boutisme utilisé. */
+static SourceEndian g_flat_format_get_endianness(const GFlatFormat *);
+
+/* Indique le type d'architecture visée par le format. */
+static const char *g_flat_format_get_target_machine(const GFlatFormat *);
+
+/* Fournit l'adresse principale associée à un format à plat. */
+static bool g_flat_format_get_main_address(GFlatFormat *, vmpa2t *);
+
+
+
+/* Indique le type défini pour un format d'exécutable à plat. */
+G_DEFINE_TYPE(GFlatFormat, g_flat_format, G_TYPE_EXE_FORMAT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des formats d'exécutables à plat. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_flat_format_class_init(GFlatFormatClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GBinFormatClass *fmt; /* Version en format basique */
+ GExeFormatClass *exe; /* Version en exécutable */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_flat_format_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_flat_format_finalize;
+
+ fmt = G_BIN_FORMAT_CLASS(klass);
+
+ fmt->get_name = (format_get_name_fc)g_flat_format_get_name;
+ fmt->get_desc = (format_get_desc_fc)g_flat_format_get_description;
+ fmt->analyze = (format_analyze_fc)g_flat_format_analyze;
+ fmt->get_endian = (format_get_endian_fc)g_flat_format_get_endianness;
+
+ exe = G_EXE_FORMAT_CLASS(klass);
+
+ exe->get_machine = (get_target_machine_fc)g_flat_format_get_target_machine;
+ exe->get_main_addr = (get_main_addr_fc)g_flat_format_get_main_address;
+
+ exe->translate_phys = (translate_phys_fc)g_exe_format_without_virt_translate_offset_into_vmpa;
+ exe->translate_virt = (translate_virt_fc)g_exe_format_without_virt_translate_address_into_vmpa;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance à initialiser. *
+* *
+* Description : Initialise une instance de format d'exécutable à plat. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_flat_format_init(GFlatFormat *format)
+{
+ format->endian = SRE_LITTLE;
+ format->machine = NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_flat_format_dispose(GFlatFormat *format)
+{
+ G_OBJECT_CLASS(g_flat_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_flat_format_finalize(GFlatFormat *format)
+{
+ G_OBJECT_CLASS(g_flat_format_parent_class)->finalize(G_OBJECT(format));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à parcourir. *
+* *
+* Description : Prend en charge un nouveau format à plat. *
+* *
+* Retour : Adresse de la structure mise en place ou NULL en cas d'échec.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GExeFormat *g_flat_format_new(GBinContent *content)
+{
+ GFlatFormat *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_FLAT_FORMAT, NULL);
+
+ g_binary_format_set_content(G_BIN_FORMAT(result), content);
+
+ return G_EXE_FORMAT(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Indique la désignation interne du format. *
+* *
+* Retour : Description du format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static const char *g_flat_format_get_name(const GFlatFormat *format)
+{
+ const char *result; /* Désignation à retourner */
+
+ result = "flat";
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Fournit une description humaine du format. *
+* *
+* Retour : Description du format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static const char *g_flat_format_get_description(const GFlatFormat *format)
+{
+ const char *result; /* Désignation à retourner */
+
+ result = _("Flat executable 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 : - *
+* *
+******************************************************************************/
+
+static bool g_flat_format_analyze(GFlatFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ g_executable_format_setup_portions(G_EXE_FORMAT(format), status);
+
+ g_binary_format_register_code_point(G_BIN_FORMAT(format), 0, true);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* endian = boutisme à associer au format à plat. *
+* *
+* Description : Spécifie un boutisme à utiliser. *
+* *
+* Retour : Indicateur de boutisme. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_flat_format_set_endianness(GFlatFormat *format, SourceEndian endian)
+{
+ format->endian = endian;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* *
+* Description : Informe quant au boutisme utilisé. *
+* *
+* Retour : Indicateur de boutisme. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static SourceEndian g_flat_format_get_endianness(const GFlatFormat *format)
+{
+ return format->endian;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* machine = identifiant de l'architecture visée. *
+* *
+* Description : Indique le type d'architecture visée par le format. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_flat_format_set_target_machine(GFlatFormat *format, const char *machine)
+{
+ if (format->machine != NULL)
+ free(format->machine);
+
+ if (machine == NULL)
+ format->machine = NULL;
+
+ else
+ format->machine = strdup(machine);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* *
+* Description : Indique le type d'architecture visée par le format. *
+* *
+* Retour : Identifiant de l'architecture ciblée par le format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static const char *g_flat_format_get_target_machine(const GFlatFormat *format)
+{
+ const char *result; /* Identifiant à retourner */
+
+ result = format->machine;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* addr = adresse principale trouvée si possible. [OUT] *
+* *
+* Description : Fournit l'adresse principale associée à un format à plat. *
+* *
+* Retour : Bilan des recherches. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_flat_format_get_main_address(GFlatFormat *format, vmpa2t *addr)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ init_vmpa(addr, 0, VMPA_NO_VIRTUAL);
+
+ return result;
+
+}
diff --git a/src/format/flat.h b/src/format/flat.h
new file mode 100644
index 0000000..1a08d25
--- /dev/null
+++ b/src/format/flat.h
@@ -0,0 +1,65 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * flat.h - prototypes pour le support des formats à plat
+ *
+ * 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_FLAT_H
+#define _FORMAT_FLAT_H
+
+
+#include <glib-object.h>
+
+
+#include "executable.h"
+#include "../analysis/content.h"
+
+
+
+#define G_TYPE_FLAT_FORMAT g_flat_format_get_type()
+#define G_FLAT_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_FLAT_FORMAT, GFlatFormat))
+#define G_IS_FLAT_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_FLAT_FORMAT))
+#define G_FLAT_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_FLAT_FORMAT, GFlatFormatClass))
+#define G_IS_FLAT_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_FLAT_FORMAT))
+#define G_FLAT_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_FLAT_FORMAT, GFlatFormatClass))
+
+
+/* Format d'exécutable à plat (instance) */
+typedef struct _GFlatFormat GFlatFormat;
+
+/* Format d'exécutable à plat (classe) */
+typedef struct _GFlatFormatClass GFlatFormatClass;
+
+
+/* Indique le type défini pour un format d'exécutable à plat. */
+GType g_flat_format_get_type(void);
+
+/* Prend en charge un nouveau format à plat. */
+GExeFormat *g_flat_format_new(GBinContent *);
+
+/* Spécifie un boutisme à utiliser. */
+void g_flat_format_set_endianness(GFlatFormat *, SourceEndian);
+
+/* Indique le type d'architecture visée par le format. */
+void g_flat_format_set_target_machine(GFlatFormat *, const char *);
+
+
+
+#endif /* _FORMAT_FLAT_H */
diff --git a/src/format/format.c b/src/format/format.c
index e6cefc8..fa11663 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -321,8 +321,11 @@ const char *g_binary_format_get_description(const GBinFormat *format)
bool g_binary_format_analyze(GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à retourner */
+ GBinFormatClass *class; /* Classe de l'instance */
+
+ class = G_BIN_FORMAT_GET_CLASS(format);
- result = G_BIN_FORMAT_GET_CLASS(format)->analyze(format, gid, status);
+ result = class->analyze(format, gid, status);
return result;
diff --git a/tests/format/flat.py b/tests/format/flat.py
new file mode 100644
index 0000000..4ab5aa2
--- /dev/null
+++ b/tests/format/flat.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python3-dbg
+# -*- coding: utf-8 -*-
+
+
+# Tests minimalistes pour valider la gestion des erreurs relevées.
+
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.analysis import LoadedBinary
+from pychrysalide.analysis.contents import MemoryContent
+from pychrysalide.format import FlatFormat
+
+
+class TestFlatFormat(ChrysalideTestCase):
+ """TestCase for format.FlatFormat."""
+
+
+ def testSimpleFlatFormatContent(self):
+ """Load a simple content for a flat format."""
+
+ data = b'\x00\x00\x00\xef'
+
+ cnt = MemoryContent(data)
+
+ fmt = FlatFormat(cnt)
+ fmt.set_machine('armv7')
+
+ binary = LoadedBinary(fmt)
+
+ binary.analyze_and_wait()
+
+ self.assertTrue(list(binary.processor.instrs)[0].keyword == 'svc')