summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r--src/analysis/binary.c486
1 files changed, 167 insertions, 319 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 19b46a2..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
@@ -63,19 +67,13 @@
/* Description de fichier binaire (instance) */
struct _GLoadedBinary
{
- GObject parent; /* A laisser en premier */
-
- char *username; /* Identifiant de l'utilisateur*/
- bool username_changed; /* Mémorise les changements */
+ GLoadedContent parent; /* A laisser en premier */
bool use_remote; /* Enregistrements distants ? */
char *remote_host; /* Nom du serveur distant */
char *remote_port; /* Port du serveur distant */
+ GAnalystClient *client; /* Enregistrements courants */
- GAnalystClient *local; /* Enregistrements locaux */
- GAnalystClient *remote; /* Enregistrements distants */
-
- DBStorage storages[DBF_COUNT]; /* Lieux d'enregistrement */
GList *collections; /* Ensemble de modifications */
GExeFormat *format; /* Format du binaire */
@@ -97,7 +95,7 @@ struct _GLoadedBinary
/* Description de fichier binaire (classe) */
struct _GLoadedBinaryClass
{
- GObjectClass parent; /* A laisser en premier */
+ GLoadedContentClass parent; /* A laisser en premier */
};
@@ -108,9 +106,6 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *);
/* Initialise une description de fichier binaire. */
static void g_loaded_binary_init(GLoadedBinary *);
-/* Procède à l'initialisation de l'interface de contenu chargé. */
-static void g_loaded_binary_interface_init(GLoadedContentInterface *);
-
/* Supprime toutes les références externes. */
static void g_loaded_binary_dispose(GLoadedBinary *);
@@ -165,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 *);
@@ -177,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 *);
@@ -195,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
+
/* ---------------------------------------------------------------------------------- */
@@ -203,9 +202,7 @@ static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary
/* Indique le type défini pour une description de fichier binaire. */
-G_DEFINE_TYPE_WITH_CODE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(G_TYPE_LOADED_CONTENT, g_loaded_binary_interface_init)
- G_IMPLEMENT_INTERFACE(G_TYPE_NAMED_WIDGET, g_loaded_content_named_interface_init));
+G_DEFINE_TYPE(GLoadedBinary, g_loaded_binary, G_TYPE_LOADED_CONTENT);
/******************************************************************************
@@ -223,12 +220,37 @@ G_DEFINE_TYPE_WITH_CODE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT,
static void g_loaded_binary_class_init(GLoadedBinaryClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
+ GLoadedContentClass *loaded; /* Forme parente de la classe */
object = G_OBJECT_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_binary_dispose;
object->finalize = (GObjectFinalizeFunc)g_loaded_binary_finalize;
+ loaded = G_LOADED_CONTENT_CLASS(klass);
+
+ loaded->restore = (restore_content_fc)g_loaded_binary_restore;
+ loaded->save = (save_content_fc)g_loaded_binary_save;
+
+ loaded->get_content = (get_content_fc)g_loaded_binary_get_content;
+ 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;
+ loaded->build_view = (build_loaded_view_fc)g_loaded_binary_build_view;
+ loaded->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index;
+
+ loaded->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options;
+
+#endif
+
}
@@ -246,17 +268,10 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *klass)
static void g_loaded_binary_init(GLoadedBinary *binary)
{
- binary->username = strdup("default");
-
binary->use_remote = false;
binary->remote_host = strdup("localhost");
binary->remote_port = strdup("1337");
- binary->storages[DBF_BOOKMARKS] = DBS_ALL_LOCAL;
- binary->storages[DBF_COMMENTS] = DBS_ALL_LOCAL;
- binary->storages[DBF_MOVES] = DBS_ALL_LOCAL;
- binary->storages[DBF_DISPLAY_SWITCHERS] = DBS_ALL_LOCAL;
-
binary->collections = create_collections_list();
attach_binary_to_collections(binary->collections, binary);
@@ -283,41 +298,6 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : iface = interface GLib à initialiser. *
-* *
-* Description : Procède à l'initialisation de l'interface de contenu chargé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_loaded_binary_interface_init(GLoadedContentInterface *iface)
-{
- iface->restore = (restore_content_fc)g_loaded_binary_restore;
- iface->save = (save_content_fc)g_loaded_binary_save;
-
- iface->get_content = (get_content_fc)g_loaded_binary_get_content;
- iface->get_format_name = (get_format_name_fc)g_loaded_binary_get_format_name;
-
- iface->analyze = (analyze_loaded_fc)g_loaded_binary_analyze;
-
- iface->describe = (describe_loaded_fc)g_loaded_binary_describe;
-
- iface->count_views = (count_loaded_views_fc)g_loaded_binary_count_views;
- iface->get_view_name = (get_loaded_view_name_fc)g_loaded_binary_get_view_name;
- iface->build_def_view = (build_loaded_def_view_fc)g_loaded_binary_build_default_view;
- 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_options = (get_loaded_options_fc)g_loaded_binary_get_display_options;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : binary = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
@@ -332,8 +312,7 @@ static void g_loaded_binary_dispose(GLoadedBinary *binary)
{
BinaryView i; /* Boucle de parcours */
- g_clear_object(&binary->local);
- g_clear_object(&binary->remote);
+ g_clear_object(&binary->client);
delete_collections_list(&binary->collections);
@@ -366,9 +345,8 @@ static void g_loaded_binary_dispose(GLoadedBinary *binary)
static void g_loaded_binary_finalize(GLoadedBinary *binary)
{
- free(binary->username);
-
free(binary->remote_host);
+ free(binary->remote_port);
G_OBJECT_CLASS(g_loaded_binary_parent_class)->finalize(G_OBJECT(binary));
@@ -390,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);
}
@@ -427,7 +433,6 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
char *value; /* Valeur lue à partie du XML */
char *access; /* Chemin d'accès à un élément */
char *port; /* Port de communication */
- DBFeatures i; /* Boucle de parcours */
result = true;
@@ -441,21 +446,6 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
free(value);
- /* Nom d'utilisateur */
-
- access = strdup(storage_path);
- access = stradd(access, "/Username");
-
- value = get_node_text_value(context, access);
-
- if (value != NULL)
- {
- g_loaded_binary_set_username(binary, value);
- free(value);
- }
-
- free(access);
-
/* Serveur distant */
access = strdup(storage_path);
@@ -483,46 +473,6 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
free(access);
- /* Fonctionnalités */
-
- for (i = 0; i < DBF_COUNT; i++)
- {
- access = strdup(storage_path);
- access = stradd(access, "/Features/");
-
- switch (i)
- {
- case DBF_BOOKMARKS:
- access = stradd(access, "Bookmarks");
- break;
- case DBF_COMMENTS:
- access = stradd(access, "Comments");
- break;
- case DBF_MOVES:
- access = stradd(access, "Moves");
- break;
- case DBF_DISPLAY_SWITCHERS:
- access = stradd(access, "Segments");
- break;
- default:
- /* Pour GCC */
- assert(false);
- break;
- }
-
- value = get_node_text_value(context, access);
-
- if (value != NULL)
- {
- if (atoi(value) <= DBS_MAX)
- g_loaded_binary_set_storage(binary, i, atoi(value));
-
- }
-
- free(access);
-
- }
-
if (binary->use_remote)
g_loaded_binary_set_remote_storage_usage(binary, true);
@@ -555,7 +505,6 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
bool result; /* Bilan à faire remonter */
char *storage_path; /* Partie "Enregistrement" */
char *access; /* Chemin d'accès à un élément */
- DBFeatures i; /* Boucle de parcours */
result = true;
@@ -565,15 +514,6 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
result &= add_string_attribute_to_node(xdoc, context, storage_path, "remote",
binary->use_remote ? "true" : "false");
- /* Nom d'utilisateur */
-
- access = strdup(storage_path);
- access = stradd(access, "/Username");
-
- result &= add_content_to_node(xdoc, context, access, binary->username);
-
- free(access);
-
/* Serveur distant */
access = strdup(storage_path);
@@ -585,39 +525,6 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
free(access);
- /* Fonctionnalités */
-
- for (i = 0; i < DBF_COUNT; i++)
- {
- access = strdup(storage_path);
- access = stradd(access, "/Features/");
-
- switch (i)
- {
- case DBF_BOOKMARKS:
- access = stradd(access, "Bookmarks");
- break;
- case DBF_COMMENTS:
- access = stradd(access, "Comments");
- break;
- case DBF_MOVES:
- access = stradd(access, "Moves");
- break;
- case DBF_DISPLAY_SWITCHERS:
- access = stradd(access, "Segments");
- break;
- default:
- /* Pour GCC */
- assert(false);
- break;
- }
-
- result &= add_uint_content_to_node(xdoc, context, access, binary->storages[i]);
-
- free(access);
-
- }
-
free(storage_path);
return result;
@@ -629,52 +536,6 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
* *
* Paramètres : binary = élément binaire à consulter. *
* *
-* Description : Identifie l'utilisateur analysant le binaire courant. *
-* *
-* Retour : Nom de l'utilisateur manipulant le binaire. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-const char *g_loaded_binary_get_username(const GLoadedBinary *binary)
-{
- return binary->username;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
-* username = nom de l'utilisateur manipulant le binaire. *
-* *
-* Description : Définit l'utilisateur analysant le binaire courant. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_loaded_binary_set_username(GLoadedBinary *binary, const char *username)
-{
- bool changed; /* Note les changements */
-
- changed = (strcmp(binary->username, username) != 0);
-
- free(binary->username);
- binary->username = strdup(username);
-
- binary->username_changed = changed;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
-* *
* Description : Détermine si tous les enregistrements sont locaux ou non. *
* *
* Retour : Statut de l'utilisation du serveur local. *
@@ -707,7 +568,7 @@ void g_loaded_binary_set_remote_storage_usage(GLoadedBinary *binary, bool use)
{
binary->use_remote = use;
- g_clear_object(&binary->remote);
+ g_clear_object(&binary->client);
if (use)
g_loaded_binary_connect_remote(binary);
@@ -764,47 +625,6 @@ void g_loaded_binary_set_remote_server(GLoadedBinary *binary, const char *host,
/******************************************************************************
* *
-* Paramètres : binary = élément binaire à consulter. *
-* feature = fonctionnalité visée par la requête. *
-* *
-* Description : Indique la forme d'enregistrement d'une fonctionnalité. *
-* *
-* Retour : Type d'enregistrement sélectionné. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-DBStorage g_loaded_binary_get_storage(const GLoadedBinary *binary, DBFeatures feature)
-{
- return binary->storages[feature];
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
-* feature = fonctionnalité visée par la requête. *
-* storage = type d'enregistrement sélectionné. *
-* *
-* Description : Définit la forme d'enregistrement d'une fonctionnalité. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_loaded_binary_set_storage(GLoadedBinary *binary, DBFeatures feature, DBStorage storage)
-{
- binary->storages[feature] = storage;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : binary = élément binaire à manipuler. *
* *
* Description : Etablit une connexion au serveur interne en tant que client. *
@@ -829,9 +649,9 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary)
/* Tentative de connexion */
- binary->local = 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->local));
+ result = g_hub_client_start_internal(G_HUB_CLIENT(binary->client));
return result;
@@ -856,7 +676,7 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
GBinContent *content; /* Contenu bianire manipulé */
const gchar *checksum; /* Identifiant de binaire */
- assert(binary->remote == NULL);
+ assert(binary->client == NULL);
/* Détermination de l'identifiant */
@@ -866,9 +686,9 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
/* Tentative de connexion */
- binary->remote = 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->remote),
+ result = g_hub_client_start_remote(G_HUB_CLIENT(binary->client),
binary->remote_host, binary->remote_port, true);
if (!result)
@@ -876,7 +696,7 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
log_variadic_message(LMT_ERROR, _("Failed to connect to remote host '%s:%s'"),
binary->remote_host, binary->remote_port);
- g_clear_object(&binary->remote);
+ g_clear_object(&binary->client);
}
@@ -940,8 +760,7 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : binary = élément binaire à consulter. *
-* internal = sélectionne le client à renvoyer selon sa nature. *
+* Paramètres : binary = élément binaire à consulter. *
* *
* Description : Fournit un client assurant la liaison avec un serveur. *
* *
@@ -951,14 +770,11 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *binary)
* *
******************************************************************************/
-GAnalystClient *g_loaded_binary_get_client(const GLoadedBinary *binary, bool internal)
+GAnalystClient *g_loaded_binary_get_client(const GLoadedBinary *binary)
{
GAnalystClient *result; /* Instance à retourner */
- if (internal)
- result = binary->local;
- else
- result = binary->remote;
+ result = binary->client;
if (result != NULL)
g_object_ref(G_OBJECT(result));
@@ -1054,15 +870,9 @@ GDbCollection *g_loaded_binary_find_collection(const GLoadedBinary *binary, DBFe
bool g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item)
{
bool result; /* Bilan à faire remonter */
- DBFeatures feature; /* Domaine de fonctionnalité */
- DBStorage storage; /* Forme d'enregistrement */
GAnalystClient *client; /* Liaison à utiliser */
- feature = g_db_item_get_feature(item);
-
- storage = g_loaded_binary_get_storage(binary, feature);
-
- client = g_loaded_binary_get_client(binary, storage == DBS_ALL_LOCAL);
+ client = g_loaded_binary_get_client(binary);
if (client == NULL)
{
@@ -1099,24 +909,13 @@ bool g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item)
bool g_loaded_binary_set_last_active(GLoadedBinary *binary, timestamp_t timestamp)
{
bool result; /* Bilan à retourner */
- bool done; /* Suivi des actions menées */
result = true;
- done = false;
-
- if (binary->local != NULL)
- {
- result = g_analyst_client_set_last_active(binary->local, timestamp);
- done = true;
- }
- if (result && binary->remote != NULL)
- {
- result = g_analyst_client_set_last_active(binary->remote, timestamp);
- done = true;
- }
+ if (binary->client != NULL)
+ result = g_analyst_client_set_last_active(binary->client, timestamp);
- if (!done)
+ else
{
log_simple_message(LMT_ERROR, _("No connection to a server found in order to set timestamp"));
result = false;
@@ -1530,6 +1329,9 @@ static bool g_loaded_binary_restore(GLoadedBinary *binary, xmlDoc *xdoc, xmlXPat
static bool g_loaded_binary_save(GLoadedBinary *binary, xmlDoc *xdoc, xmlXPathContext *context, const char *path)
{
bool result; /* Bilan à faire remonter */
+ GBinContent *content; /* Contenu brut à manipuler */
+ const gchar *hash; /* Empreinte d'un contenu */
+ char *key; /* Support associé au contenu */
/* Mise en cache des instructions */
@@ -1538,6 +1340,33 @@ static bool g_loaded_binary_save(GLoadedBinary *binary, xmlDoc *xdoc, xmlXPathCo
/* Elément divers associés au binaire */
if (result)
+ {
+ content = g_loaded_content_get_content(G_LOADED_CONTENT(binary));
+
+ hash = g_binary_content_get_checksum(content);
+ result = add_string_attribute_to_node(xdoc, context, path, "hash", hash);
+
+ g_object_unref(G_OBJECT(content));
+
+ }
+
+ /*
+ if (result)
+ {
+ key = g_loaded_content_get_content_class(G_LOADED_CONTENT(binary));
+ result = add_string_attribute_to_node(xdoc, context, path, "format", key);
+ free(key);
+ }
+
+ if (result)
+ {
+ key = g_arch_processor_get_key(binary->proc);
+ 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);
if (result)
@@ -1546,7 +1375,7 @@ static bool g_loaded_binary_save(GLoadedBinary *binary, xmlDoc *xdoc, xmlXPathCo
/* Sauvegarde côté serveur */
if (result)
- g_analyst_client_save(binary->local);
+ g_analyst_client_save(binary->client);
return result;
@@ -1579,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;
@@ -1619,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);
@@ -1688,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));
@@ -1837,6 +1679,9 @@ static char *g_loaded_binary_describe(const GLoadedBinary *binary, bool full)
}
+#ifdef INCLUDE_GTK_SUPPORT
+
+
/******************************************************************************
* *
* Paramètres : binary = contenu chargé à consulter. *
@@ -2048,3 +1893,6 @@ static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary
return result;
}
+
+
+#endif