diff options
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r-- | src/analysis/binary.c | 101 |
1 files changed, 34 insertions, 67 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 222bafc..89370b2 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -89,8 +89,7 @@ struct _GLoadedBinary size_t decbuf_count; /* Taille des tableaux */ size_t defsrc; /* Fichier source principal */ - bool col_display[BVW_COUNT][BLC_DISPLAY];/* Position et code binaire */ - bool lines_display; /* Affichage des lignes */ + GDisplayOptions *options[BVW_COUNT]; /* Options d'affichage */ }; @@ -173,10 +172,7 @@ static GtkWidget *g_loaded_binary_build_view(GLoadedBinary *, unsigned int); static unsigned int g_loaded_binary_get_view_index(GLoadedBinary *, GtkWidget *); /* Fournit toutes les options d'affichage pour un contenu. */ -bool * const g_loaded_binary_get_all_display_options(const GLoadedBinary *, unsigned int); - -/* Définit une option d'affichage pour un contenu chargé. */ -static bool g_loaded_binary_set_display_option(GLoadedBinary *, unsigned int, unsigned int, bool); +static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary *, unsigned int); @@ -242,14 +238,17 @@ static void g_loaded_binary_init(GLoadedBinary *binary) binary->collections = create_collections_list(); attach_binary_to_collections(binary->collections, binary); - binary->col_display[BVW_BLOCK][BLC_PHYSICAL] = true; - binary->col_display[BVW_BLOCK][BLC_VIRTUAL] = true; - binary->col_display[BVW_BLOCK][BLC_BINARY] = false; - binary->col_display[BVW_GRAPH][BLC_PHYSICAL] = false; - binary->col_display[BVW_GRAPH][BLC_VIRTUAL] = false; - binary->col_display[BVW_GRAPH][BLC_BINARY] = false; + binary->options[BVW_BLOCK] = g_display_options_new(); + + g_display_options_add(binary->options[BVW_BLOCK], _("Physical offset"), true); + g_display_options_add(binary->options[BVW_BLOCK], _("Virtual address"), true); + g_display_options_add(binary->options[BVW_BLOCK], _("Binary code"), false); + + binary->options[BVW_GRAPH] = g_display_options_new(); - binary->lines_display = true; + g_display_options_add(binary->options[BVW_GRAPH], _("Physical offset"), false); + g_display_options_add(binary->options[BVW_GRAPH], _("Virtual address"), false); + g_display_options_add(binary->options[BVW_GRAPH], _("Binary code"), false); } @@ -282,8 +281,7 @@ static void g_loaded_binary_interface_init(GLoadedContentInterface *iface) iface->build_view = (build_loaded_view_fc)g_loaded_binary_build_view; iface->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index; - iface->get_all_options = (get_all_loaded_options_fc)g_loaded_binary_get_all_display_options; - iface->set_option = (set_loaded_option_fc)g_loaded_binary_set_display_option; + iface->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options; } @@ -302,6 +300,8 @@ static void g_loaded_binary_interface_init(GLoadedContentInterface *iface) static void g_loaded_binary_dispose(GLoadedBinary *binary) { + BinaryView i; /* Boucle de parcours */ + if (binary->format != NULL) g_object_unref(G_OBJECT(binary->format)); @@ -310,6 +310,11 @@ static void g_loaded_binary_dispose(GLoadedBinary *binary) /* TODO... */ + + + for (i = 0; i < BVW_COUNT; i++) + g_object_unref(G_OBJECT(binary->options[i])); + G_OBJECT_CLASS(g_loaded_binary_parent_class)->dispose(G_OBJECT(binary)); } @@ -1379,25 +1384,6 @@ GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary, #endif -/****************************************************************************** -* * -* Paramètres : binary = élément binaire à consulter. * -* * -* Description : Indique si les lignes doivent apparaître dans le rendu. * -* * -* Retour : Consigne d'affichage. [OUT] * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool *g_loaded_binary_display_decomp_lines(GLoadedBinary *binary) -{ - return &binary->lines_display; - -} - - /* ---------------------------------------------------------------------------------- */ /* GESTION SOUS FORME DE CONTENU CHARGE */ @@ -1536,6 +1522,7 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS GBinFormat *format; /* Format lié au binaire */ const char *arch; /* Architecture d'exécution */ const char *desc; /* Description humaine associée*/ + bool has_virt; /* Présence de virtuel ? */ GProcContext *context; /* Contexte de suivi dédié */ GWidthTracker *tracker; /* Gestionnaire de largeur */ @@ -1567,7 +1554,10 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS goto glba_exit; } - binary->col_display[BVW_BLOCK][BLC_VIRTUAL] = g_arch_processor_has_virtual_space(binary->proc); + has_virt = g_arch_processor_has_virtual_space(binary->proc); + + g_display_options_set(binary->options[BVW_BLOCK], BLC_VIRTUAL, has_virt); + g_display_options_set(binary->options[BVW_GRAPH], BLC_VIRTUAL, has_virt); /* Phase de désassemblage pur */ @@ -1741,42 +1731,19 @@ static unsigned int g_loaded_binary_get_view_index(GLoadedBinary *binary, GtkWid * * ******************************************************************************/ -bool * const g_loaded_binary_get_all_display_options(const GLoadedBinary *binary, unsigned int index) +static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary *binary, unsigned int index) { - return binary->col_display[index]; - -} + GDisplayOptions *result; /* Instance à renvoyer */ + assert(index < BVW_COUNT); -/****************************************************************************** -* * -* Paramètres : binary = contenu chargé à consulter. * -* index = composant graphique à cibler. * -* option = type de paramètre à manipuler. * -* state = valeur dudit paramètre. * -* * -* Description : Définit une option d'affichage pour un contenu chargé. * -* * -* Retour : true si un changement a été effectué, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool g_loaded_binary_set_display_option(GLoadedBinary *binary, unsigned int index, unsigned int option, bool state) -{ - bool result; /* Variation à faire remonter */ - bool old; /* Ancien état à remplacer */ - - old = binary->col_display[index][option]; - - if (state != old) - { - binary->col_display[index][option] = state; - result = true; - } + if (index < BVW_COUNT) + result = binary->options[index]; + else + result = NULL; - else result = false; + if (result != NULL) + g_object_ref(G_OBJECT(result)); return result; |