diff options
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r-- | src/analysis/binary.c | 141 |
1 files changed, 101 insertions, 40 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index ddd2e30..f8b17d2 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -43,17 +43,21 @@ #include "../common/cpp.h" #include "../common/xdg.h" #include "../core/collections.h" +#include "../core/columns.h" #include "../core/logs.h" #include "../core/params.h" #include "../core/processors.h" #include "../format/known.h" #include "../glibext/gbinarycursor.h" -#include "../glibext/gloadedpanel.h" -#include "../gtkext/easygtk.h" -#include "../gtkext/gtkblockdisplay.h" -#include "../gtkext/gtkdisplaypanel.h" -#include "../gtkext/gtkgraphdisplay.h" -#include "../gtkext/hexdisplay.h" +#ifdef INCLUDE_GTK_SUPPORT +# include "../glibext/gloadedpanel.h" +# include "../gtkext/easygtk.h" +# include "../gtkext/gtkblockdisplay.h" +# include "../gtkext/gtkdisplaypanel.h" +# include "../gtkext/gtkgraphdisplay.h" +# include "../gtkext/gtkstatusstack.h" +# include "../gtkext/hexdisplay.h" +#endif @@ -156,8 +160,8 @@ static bool g_loaded_binary_save(GLoadedBinary *, xmlDoc *, xmlXPathContext *, c /* Fournit le contenu représenté de l'élément chargé. */ static GBinContent *g_loaded_binary_get_content(const GLoadedBinary *); -/* Fournit le contenu représenté de l'élément chargé. */ -static char *g_loaded_binary_get_format_name(const GLoadedBinary *); +/* Décrit la nature du contenu reconnu pour l'élément chargé. */ +static char *g_loaded_binary_get_content_class(const GLoadedBinary *, bool); /* Assure le désassemblage en différé. */ static bool g_loaded_binary_analyze(GLoadedBinary *, bool, bool, wgroup_id_t, GtkStatusStack *); @@ -168,6 +172,8 @@ static void on_binary_processor_changed(GArchProcessor *, GArchInstruction *, gb /* Fournit le désignation associée à l'élément chargé. */ static char *g_loaded_binary_describe(const GLoadedBinary *, bool); +#ifdef INCLUDE_GTK_SUPPORT + /* Détermine le nombre de vues disponibles pour un contenu. */ static unsigned int g_loaded_binary_count_views(const GLoadedBinary *); @@ -186,6 +192,8 @@ static unsigned int g_loaded_binary_get_view_index(GLoadedBinary *, GtkWidget *) /* Fournit toutes les options d'affichage pour un contenu. */ static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary *, unsigned int); +#endif + /* ---------------------------------------------------------------------------------- */ @@ -225,12 +233,14 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *klass) loaded->save = (save_content_fc)g_loaded_binary_save; loaded->get_content = (get_content_fc)g_loaded_binary_get_content; - loaded->get_format_name = (get_format_name_fc)g_loaded_binary_get_format_name; + loaded->get_content_class = (get_content_class_fc)g_loaded_binary_get_content_class; loaded->analyze = (analyze_loaded_fc)g_loaded_binary_analyze; loaded->describe = (describe_loaded_fc)g_loaded_binary_describe; +#ifdef INCLUDE_GTK_SUPPORT + loaded->count_views = (count_loaded_views_fc)g_loaded_binary_count_views; loaded->get_view_name = (get_loaded_view_name_fc)g_loaded_binary_get_view_name; loaded->build_def_view = (build_loaded_def_view_fc)g_loaded_binary_build_default_view; @@ -239,6 +249,8 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *klass) loaded->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options; +#endif + } @@ -356,11 +368,39 @@ static void g_loaded_binary_finalize(GLoadedBinary *binary) GLoadedContent *g_loaded_binary_new(GExeFormat *format) { GLoadedBinary *result; /* Adresse à retourner */ + const char *arch; /* Architecture d'exécution */ + GArchProcessor *proc; /* Architecture du binaire */ + + result = NULL; + + /* Architecture visée */ + + arch = g_exe_format_get_target_machine(format); + + if (arch == NULL) + { + log_simple_message(LMT_INFO, _("Unknown architecture")); + goto exit; + } + + proc = get_arch_processor_for_key(arch); + + if (proc == NULL) + { + log_variadic_message(LMT_ERROR, _("Unable to load the required processor (%s)"), arch); + goto exit; + } + + /* Mise en place complète */ result = g_object_new(G_TYPE_LOADED_BINARY, NULL); result->format = format; + result->proc = proc; + + exit: + return G_LOADED_CONTENT(result); } @@ -609,7 +649,7 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary) /* Tentative de connexion */ - binary->client = g_analyst_client_new(checksum, binary->collections); + binary->client = g_analyst_client_new(checksum, "NULL", binary->collections, NULL); result = g_hub_client_start_internal(G_HUB_CLIENT(binary->client)); @@ -646,7 +686,7 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary) /* Tentative de connexion */ - binary->client = g_analyst_client_new(checksum, binary->collections); + binary->client = g_analyst_client_new(checksum, "NULL", binary->collections, NULL); result = g_hub_client_start_remote(G_HUB_CLIENT(binary->client), binary->remote_host, binary->remote_port, true); @@ -1310,9 +1350,10 @@ static bool g_loaded_binary_save(GLoadedBinary *binary, xmlDoc *xdoc, xmlXPathCo } + /* if (result) { - key = g_loaded_content_get_format_name(G_LOADED_CONTENT(binary)); + key = g_loaded_content_get_content_class(G_LOADED_CONTENT(binary)); result = add_string_attribute_to_node(xdoc, context, path, "format", key); free(key); } @@ -1323,6 +1364,7 @@ static bool g_loaded_binary_save(GLoadedBinary *binary, xmlDoc *xdoc, xmlXPathCo result = add_string_attribute_to_node(xdoc, context, path, "arch", key); free(key); } + */ if (result) result = g_loaded_binary_save_storage(binary, xdoc, context, path); @@ -1366,20 +1408,47 @@ static GBinContent *g_loaded_binary_get_content(const GLoadedBinary *binary) /****************************************************************************** * * * Paramètres : binary = élément chargé à manipuler. * +* human = description humaine attendue ? * * * -* Description : Fournit le contenu représenté de l'élément chargé. * +* Description : Décrit la nature du contenu reconnu pour l'élément chargé. * * * -* Retour : Contenu représenté. * +* Retour : Classe de contenu associée à l'élément chargé. * * * * Remarques : - * * * ******************************************************************************/ -static char *g_loaded_binary_get_format_name(const GLoadedBinary *binary) +static char *g_loaded_binary_get_content_class(const GLoadedBinary *binary, bool human) { char *result; /* Désignation à retourner */ + char *part; /* Partie à intégrer */ + + if (human) + { + result = g_known_format_get_description(G_KNOWN_FORMAT(binary->format)); - result = g_known_format_get_key(G_KNOWN_FORMAT(binary->format)); + result = stradd(result, ", "); + + part = g_arch_processor_get_desc(binary->proc); + + result = stradd(result, part); + + free(part); + + } + else + { + result = g_known_format_get_key(G_KNOWN_FORMAT(binary->format)); + + result = stradd(result, "-"); + + part = g_arch_processor_get_key(binary->proc); + + result = stradd(result, part); + + free(part); + + } return result; @@ -1406,49 +1475,31 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca { bool result; /* Bilan à retourner */ GBinFormat *format; /* Format lié au binaire */ - const char *arch; /* Architecture d'exécution */ char *desc; /* Description humaine associée*/ bool has_virt; /* Présence de virtuel ? */ GProcContext *context; /* Contexte de suivi dédié */ +#ifdef INCLUDE_GTK_SUPPORT GWidthTracker *tracker; /* Gestionnaire de largeur */ +#endif /* Interprétation du format associé */ format = G_BIN_FORMAT(binary->format); desc = g_known_format_get_description(G_KNOWN_FORMAT(format)); + assert(desc != NULL); - if (desc == NULL) - log_simple_message(LMT_WARNING, _("Unnamed format")); - else - log_variadic_message(LMT_INFO, _("Selected format: %s"), desc); + log_variadic_message(LMT_INFO, _("Selected format: %s"), desc); free(desc); result = g_known_format_analyze(G_KNOWN_FORMAT(format), gid, status); if (!result) goto glba_exit; - /* Architecture visée */ - - arch = g_exe_format_get_target_machine(binary->format); - - if (arch == NULL) - { - log_simple_message(LMT_INFO, _("Unknown architecture")); - result = false; - goto glba_exit; - } - - binary->proc = get_arch_processor_for_key(arch); - - if (binary->proc == NULL) - { - log_variadic_message(LMT_ERROR, _("Unable to load the required processor (%s)"), arch); - result = false; - goto glba_exit; - } + /* Interprétation de l'architecture associée */ desc = g_arch_processor_get_desc(binary->proc); + assert(desc != NULL); log_variadic_message(LMT_INFO, _("Detected architecture: %s"), desc); @@ -1475,12 +1526,16 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca { output_disassembly(binary, context, status, &binary->disass_cache); +#ifdef INCLUDE_GTK_SUPPORT + tracker = g_buffer_cache_get_width_tracker(binary->disass_cache); g_width_tracker_build_initial_cache(tracker, gid, status); g_object_unref(G_OBJECT(tracker)); +#endif + } g_object_unref(G_OBJECT(context)); @@ -1624,6 +1679,9 @@ static char *g_loaded_binary_describe(const GLoadedBinary *binary, bool full) } +#ifdef INCLUDE_GTK_SUPPORT + + /****************************************************************************** * * * Paramètres : binary = contenu chargé à consulter. * @@ -1835,3 +1893,6 @@ static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary return result; } + + +#endif |