summaryrefslogtreecommitdiff
path: root/src/glibext/portion.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext/portion.h')
-rw-r--r--src/glibext/portion.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/glibext/portion.h b/src/glibext/portion.h
new file mode 100644
index 0000000..88d69b6
--- /dev/null
+++ b/src/glibext/portion.h
@@ -0,0 +1,121 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * portion.h - prototypes pour la représentation graphique de portions de binaire
+ *
+ * Copyright (C) 2013-2024 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 _GLIBEXT_PORTION_H
+#define _GLIBEXT_PORTION_H
+
+
+#include <stdbool.h>
+
+
+#include "helpers.h"
+#include "../arch/vmpa.h"
+
+
+
+/* ------------------------------- PORTION DE BINAIRE ------------------------------- */
+
+
+#define G_TYPE_BINARY_PORTION (g_binary_portion_get_type())
+
+DECLARE_GTYPE(GBinaryPortion, g_binary_portion, G, BINARY_PORTION);
+
+
+/* Crée une description de partie de code vierge. */
+GBinaryPortion *g_binary_portion_new(const vmpa2t *, phys_t);
+
+/* Etablit la comparaison ascendante entre deux portions. */
+int g_binary_portion_compare(const GBinaryPortion **, const GBinaryPortion **);
+
+/* Attribue une description humaine à une partie de code. */
+void g_binary_portion_set_desc(GBinaryPortion *, const char *);
+
+/* Fournit la description attribuée à une partie de code. */
+const char *g_binary_portion_get_desc(const GBinaryPortion *);
+
+/* Fournit l'emplacement d'une partie de code binaire. */
+const mrange_t *g_binary_portion_get_range(const GBinaryPortion *);
+
+/* Assure qu'une portion ne dépasse pas une position donnée. */
+bool g_binary_portion_limit_range(GBinaryPortion *, phys_t);
+
+/* Définit la nature de la portion en terme d'originalité. */
+void g_binary_portion_mark_as_continued(GBinaryPortion *, bool);
+
+/* Indique la nature de la portion en terme d'originalité. */
+bool g_binary_portion_is_continuation(const GBinaryPortion *);
+
+/* Droits d'accès à une portion */
+typedef enum _PortionAccessRights
+{
+ PAC_NONE = (0 << 0), /* Aucun */
+ PAC_READ = (1 << 0), /* Lecture */
+ PAC_WRITE = (1 << 1), /* Ecriture */
+ PAC_EXEC = (1 << 2) /* Exécution */
+
+} PortionAccessRights;
+
+#define PAC_ALL ((PortionAccessRights)(PAC_READ | PAC_WRITE | PAC_EXEC))
+
+/* Définit les droits associés à une partie de code. */
+void g_binary_portion_set_rights(GBinaryPortion *, PortionAccessRights);
+
+/* Fournit les droits associés à une partie de code. */
+PortionAccessRights g_binary_portion_get_rights(const GBinaryPortion *);
+
+/* Procède à l'inclusion d'une portion dans une autre. */
+bool g_binary_portion_include(GBinaryPortion *, GBinaryPortion *);
+
+/* Sens des visites */
+typedef enum _BinaryPortionVisit
+{
+ BPV_ENTER, /* Arrivée sur une branche */
+ BPV_SHOW, /* Visite d'une feuille */
+ BPV_EXIT /* Départ d'une branche */
+
+} BinaryPortionVisit;
+
+
+/* Fonction appelée à chaque visite de portion.*/
+typedef bool (* visit_portion_fc) (GBinaryPortion *, GBinaryPortion *, BinaryPortionVisit, void *);
+
+/* Parcourt un ensemble de portions binaires. */
+bool g_binary_portion_visit(GBinaryPortion *, visit_portion_fc, void *);
+
+
+
+/* ------------------------ PARCOURS D'ENSEMBLES DE PORTIONS ------------------------ */
+
+
+/* Recherche la portion présente à une adresse donnée. */
+GBinaryPortion *g_binary_portion_find_at_addr(GBinaryPortion *, const vmpa2t *);
+
+/* Fournit l'emplacement correspondant à une position physique. */
+bool g_binary_portion_translate_offset_into_vmpa(const GBinaryPortion *, phys_t, vmpa2t *);
+
+/* Fournit l'emplacement correspondant à une adresse virtuelle. */
+bool g_binary_portion_translate_address_into_vmpa(const GBinaryPortion *, virt_t, vmpa2t *);
+
+
+
+#endif /* _GLIBEXT_BINPORTION_H */