summaryrefslogtreecommitdiff
path: root/src/format/program.h
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2024-11-15 10:01:42 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2024-11-15 10:01:42 (GMT)
commit671f61ec87f5e8d762ea890aabbc62c777e1c4f9 (patch)
tree1517f5fc5d00c8fd04872b35571556b021866f14 /src/format/program.h
parent3e21278480a25552401644cd0dc168e3588508dd (diff)
Restore a skeleton of support for file formats.
Diffstat (limited to 'src/format/program.h')
-rw-r--r--src/format/program.h116
1 files changed, 60 insertions, 56 deletions
diff --git a/src/format/program.h b/src/format/program.h
index f9aa430..51b7860 100644
--- a/src/format/program.h
+++ b/src/format/program.h
@@ -1,8 +1,8 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * format.h - prototypes pour le support des différents formats binaires
+ * program.h - prototypes pour le support des différents formats de programmes
*
- * Copyright (C) 2009-2020 Cyrille Bagard
+ * Copyright (C) 2009-2024 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -21,10 +21,29 @@
*/
-#ifndef _FORMAT_FORMAT_H
-#define _FORMAT_FORMAT_H
+#ifndef _FORMAT_PROGRAM_H
+#define _FORMAT_PROGRAM_H
+#include "../common/datatypes.h"
+#include "../glibext/helpers.h"
+
+
+
+#define G_TYPE_PROGRAM_FORMAT (g_program_format_get_type())
+
+DECLARE_GTYPE(GProgramFormat, g_program_format, G, PROGRAM_FORMAT);
+
+
+/* Indique le boutisme employé par le format binaire analysé. */
+SourceEndian g_program_format_get_endianness(const GProgramFormat *);
+
+
+
+
+
+#if 0
+
#include <glib-object.h>
#include <stdbool.h>
#include <sys/types.h>
@@ -52,47 +71,31 @@ typedef enum _FormatFlag
} FormatFlag;
-#define G_TYPE_BIN_FORMAT g_binary_format_get_type()
-#define G_BIN_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BIN_FORMAT, GBinFormat))
-#define G_IS_BIN_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_BIN_FORMAT))
-#define G_BIN_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BIN_FORMAT, GBinFormatClass))
-#define G_IS_BIN_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BIN_FORMAT))
-#define G_BIN_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BIN_FORMAT, GBinFormatClass))
-
-/* Format binaire générique (instance) */
-typedef struct _GBinFormat GBinFormat;
-
-/* Format binaire générique (classe) */
-typedef struct _GBinFormatClass GBinFormatClass;
-
-
-/* Indique le type défini pour un format binaire générique. */
-GType g_binary_format_get_type(void);
/* Ajoute une information complémentaire à un format. */
-bool g_binary_format_set_flag(GBinFormat *, FormatFlag);
+bool g_program_format_set_flag(GProgramFormat *, FormatFlag);
/* Retire une information complémentaire à un format. */
-bool g_binary_format_unset_flag(GBinFormat *, FormatFlag);
+bool g_program_format_unset_flag(GProgramFormat *, FormatFlag);
/* Détermine si un format possède un fanion particulier. */
-bool g_binary_format_has_flag(const GBinFormat *, FormatFlag);
+bool g_program_format_has_flag(const GProgramFormat *, FormatFlag);
/* Fournit les particularités du format. */
-FormatFlag g_binary_format_get_flags(const GBinFormat *);
+FormatFlag g_program_format_get_flags(const GProgramFormat *);
/* Indique le boutisme employé par le format binaire analysé. */
-SourceEndian g_binary_format_get_endianness(const GBinFormat *);
+//SourceEndian g_program_format_get_endianness(const GProgramFormat *);
/* Enregistre une adresse comme début d'une zone de code. */
-void g_binary_format_register_code_point(GBinFormat *, virt_t, DisassPriorityLevel);
+void g_program_format_register_code_point(GProgramFormat *, virt_t, DisassPriorityLevel);
/* Intègre dans un contexte les informations tirées d'un format. */
-void g_binary_format_preload_disassembling_context(GBinFormat *, GProcContext *, GtkStatusStack *);
+void g_program_format_preload_disassembling_context(GProgramFormat *, GProcContext *, GtkStatusStack *);
/* Définit les points de départ d'un contexte de désassemblage. */
-void g_binary_format_activate_disassembling_context(GBinFormat *, GProcContext *, GtkStatusStack *);
+void g_program_format_activate_disassembling_context(GProgramFormat *, GProcContext *, GtkStatusStack *);
@@ -100,7 +103,7 @@ void g_binary_format_activate_disassembling_context(GBinFormat *, GProcContext *
/* Fournit le décodeur de symboles privilégié pour un format. */
-GCompDemangler *g_binary_format_get_demangler(const GBinFormat *);
+GCompDemangler *g_program_format_get_demangler(const GProgramFormat *);
@@ -108,60 +111,60 @@ GCompDemangler *g_binary_format_get_demangler(const GBinFormat *);
/* Protège ou lève la protection de l'accès aux symboles. */
-void g_binary_format_lock_unlock_symbols_rd(GBinFormat *, bool);
+void g_program_format_lock_unlock_symbols_rd(GProgramFormat *, bool);
-#define g_binary_format_lock_symbols_rd(f) g_binary_format_lock_unlock_symbols_rd(f, true)
-#define g_binary_format_unlock_symbols_rd(f) g_binary_format_lock_unlock_symbols_rd(f, false)
+#define g_program_format_lock_symbols_rd(f) g_program_format_lock_unlock_symbols_rd(f, true)
+#define g_program_format_unlock_symbols_rd(f) g_program_format_lock_unlock_symbols_rd(f, false)
/* Protège ou lève la protection de l'accès aux symboles. */
-void g_binary_format_lock_unlock_symbols_wr(GBinFormat *, bool);
+void g_program_format_lock_unlock_symbols_wr(GProgramFormat *, bool);
-#define g_binary_format_lock_symbols_wr(f) g_binary_format_lock_unlock_symbols_wr(f, true)
-#define g_binary_format_unlock_symbols_wr(f) g_binary_format_lock_unlock_symbols_wr(f, false)
+#define g_program_format_lock_symbols_wr(f) g_program_format_lock_unlock_symbols_wr(f, true)
+#define g_program_format_unlock_symbols_wr(f) g_program_format_lock_unlock_symbols_wr(f, false)
/* Assure qu'un verrou est bien posé pour l'accès aux symboles. */
#ifndef NDEBUG
-void g_binary_format_check_for_symbols_lock(const GBinFormat *);
+void g_program_format_check_for_symbols_lock(const GProgramFormat *);
#endif
/* Fournit la marque de dernière modification des symboles. */
-unsigned int g_binary_format_get_symbols_stamp(const GBinFormat *);
+unsigned int g_program_format_get_symbols_stamp(const GProgramFormat *);
/* Compte le nombre de symboles représentés. */
-size_t g_binary_format_count_symbols(const GBinFormat *);
+size_t g_program_format_count_symbols(const GProgramFormat *);
/* Fournit un symbole lié à un format. */
-GBinSymbol *g_binary_format_get_symbol(const GBinFormat *, size_t);
+GBinSymbol *g_program_format_get_symbol(const GProgramFormat *, size_t);
/* Ajoute un symbole à la collection du format binaire. */
-bool g_binary_format_add_symbol(GBinFormat *, GBinSymbol *);
+bool g_program_format_add_symbol(GProgramFormat *, GBinSymbol *);
/* Ajoute plusieurs symboles à la collection du format binaire. */
-bool g_binary_format_add_symbols(GBinFormat *, GBinSymbol **, size_t);
+bool g_program_format_add_symbols(GProgramFormat *, GBinSymbol **, size_t);
/* Retire un symbole de la collection du format binaire. */
-void g_binary_format_remove_symbol(GBinFormat *, GBinSymbol *);
+void g_program_format_remove_symbol(GProgramFormat *, GBinSymbol *);
/* Recherche le symbole correspondant à une étiquette. */
-bool g_binary_format_find_symbol_by_label(GBinFormat *, const char *, GBinSymbol **);
+bool g_program_format_find_symbol_by_label(GProgramFormat *, const char *, GBinSymbol **);
/* Recherche l'indice du symbole correspondant à une adresse. */
-bool g_binary_format_find_symbol_index_at(GBinFormat *, const vmpa2t *, size_t *);
+bool g_program_format_find_symbol_index_at(GProgramFormat *, const vmpa2t *, size_t *);
/* Recherche le symbole correspondant à une adresse. */
-bool g_binary_format_find_symbol_at(GBinFormat *, const vmpa2t *, GBinSymbol **);
+bool g_program_format_find_symbol_at(GProgramFormat *, const vmpa2t *, GBinSymbol **);
/* Recherche le symbole contenant une adresse. */
-bool g_binary_format_find_symbol_for(GBinFormat *, const vmpa2t *, GBinSymbol **);
+bool g_program_format_find_symbol_for(GProgramFormat *, const vmpa2t *, GBinSymbol **);
/* Recherche le symbole suivant celui lié à une adresse. */
-bool g_binary_format_find_next_symbol_at(GBinFormat *, const vmpa2t *, GBinSymbol **);
+bool g_program_format_find_next_symbol_at(GProgramFormat *, const vmpa2t *, GBinSymbol **);
/* Recherche le premier symbole inclus dans une zone mémoire. */
-bool g_binary_format_find_first_symbol_inside(GBinFormat *, const mrange_t *, size_t *);
+bool g_program_format_find_first_symbol_inside(GProgramFormat *, const mrange_t *, size_t *);
/* Recherche le symbole correspondant à une adresse. */
-bool g_binary_format_resolve_symbol(GBinFormat *, const vmpa2t *, bool, GBinSymbol **, phys_t *);
+bool g_program_format_resolve_symbol(GProgramFormat *, const vmpa2t *, bool, GBinSymbol **, phys_t *);
@@ -181,20 +184,21 @@ typedef enum _BinaryFormatError
/* Protège ou lève la protection de l'accès aux erreurs. */
-void g_binary_format_lock_unlock_errors(GBinFormat *, bool);
+void g_program_format_lock_unlock_errors(GProgramFormat *, bool);
-#define g_binary_format_lock_errors(f) g_binary_format_lock_unlock_errors(f, true)
-#define g_binary_format_unlock_errors(f) g_binary_format_lock_unlock_errors(f, false)
+#define g_program_format_lock_errors(f) g_program_format_lock_unlock_errors(f, true)
+#define g_program_format_unlock_errors(f) g_program_format_lock_unlock_errors(f, false)
/* Etend la liste des soucis détectés avec de nouvelles infos. */
-void g_binary_format_add_error(GBinFormat *, BinaryFormatError, const vmpa2t *, const char *);
+void g_program_format_add_error(GProgramFormat *, BinaryFormatError, const vmpa2t *, const char *);
/* Indique le nombre d'erreurs relevées au niveau assembleur. */
-size_t g_binary_format_count_errors(GBinFormat *);
+size_t g_program_format_count_errors(GProgramFormat *);
/* Fournit les éléments concernant un soucis détecté. */
-bool g_binary_format_get_error(GBinFormat *, size_t, BinaryFormatError *, vmpa2t *, char **);
+bool g_program_format_get_error(GProgramFormat *, size_t, BinaryFormatError *, vmpa2t *, char **);
+#endif
-#endif /* _FORMAT_FORMAT_H */
+#endif /* _FORMAT_PROGRAM_H */