summaryrefslogtreecommitdiff
path: root/src/glibext/gbinarycursor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext/gbinarycursor.c')
-rw-r--r--src/glibext/gbinarycursor.c105
1 files changed, 102 insertions, 3 deletions
diff --git a/src/glibext/gbinarycursor.c b/src/glibext/gbinarycursor.c
index 5308fdf..d62abfb 100644
--- a/src/glibext/gbinarycursor.c
+++ b/src/glibext/gbinarycursor.c
@@ -25,9 +25,15 @@
#include <assert.h>
+#include <malloc.h>
+
+
+#include <i18n.h>
#include "glinecursor-int.h"
+#include "../analysis/binary.h"
+#include "../common/extstr.h"
@@ -76,6 +82,11 @@ static bool g_binary_cursor_is_valid(const GBinaryCursor *);
/* Construit une étiquette de représentation d'un suivi. */
static char *g_binary_cursor_build_label(const GBinaryCursor *);
+/* Extrait des détails complémentaires et actualise le statut. */
+#ifdef INCLUDE_GTK_SUPPORT
+static void prepare_and_show_status_from_binary_cursor(const mrange_t *, const char *, const GLoadedBinary *, GtkStatusStack *);
+#endif
+
/* Affiche une position dans une barre de statut. */
static void g_binary_cursor_show_status(const GBinaryCursor *, GtkStatusStack *, GLoadedContent *);
@@ -333,6 +344,93 @@ static char *g_binary_cursor_build_label(const GBinaryCursor *cursor)
/******************************************************************************
* *
+* Paramètres : range = emplacement à mettre en valeur. *
+* encoding = encodage d'une éventuelle instruction ou NULL. *
+* binary = binaire chargé rassemblant l'ensemble des infos. *
+* stack = barre de statut à actualiser. *
+* *
+* Description : Extrait des détails complémentaires et actualise le statut. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+#ifdef INCLUDE_GTK_SUPPORT
+static void prepare_and_show_status_from_binary_cursor(const mrange_t *range, const char *encoding, const GLoadedBinary *binary, GtkStatusStack *stack)
+{
+ GExeFormat *format; /* Format de binaire à traiter */
+ const vmpa2t *addr; /* Localisation de départ */
+ GBinPortion *portions; /* Couche première de portions */
+ GBinPortion *portion; /* Zone mémoire d'appartenance */
+ const char *text; /* Texte au contenu à copier */
+ const char *segment; /* Désignation d'un segment */
+ GBinSymbol *symbol; /* Symbole présent à l'adresse */
+ phys_t diff; /* Décalage de l'adresse */
+ char *label; /* Description d'un symbole */
+ vmpa2t tmp; /* Zone de construction temp. */
+ VMPA_BUFFER(offset); /* Décalage physique */
+ char *sym_name; /* Position selon un symbole */
+
+ /* Préparations utiles */
+
+ format = g_loaded_binary_get_format(binary);
+
+ addr = get_mrange_addr(range);
+
+ /* Zone d'appartenance */
+
+ portions = g_exe_format_get_portions(format);
+
+ portion = g_binary_portion_find_at_addr(portions, addr);
+
+ text = g_binary_portion_get_desc(portion);
+
+ segment = (text != NULL ? text : _("Binary"));
+
+ g_object_unref(G_OBJECT(portion));
+
+ g_object_unref(G_OBJECT(portions));
+
+ /* Symbole concerné */
+
+ sym_name = NULL;
+
+ if (g_binary_format_resolve_symbol(G_BIN_FORMAT(format), addr, false, &symbol, &diff))
+ {
+ label = g_binary_symbol_get_label(symbol);
+
+ if (label != NULL)
+ {
+ sym_name = label;
+
+ sym_name = stradd(sym_name, "+");
+
+ init_vmpa(&tmp, diff, VMPA_NO_VIRTUAL);
+ vmpa2_phys_to_string(&tmp, MDS_UNDEFINED, offset, NULL);
+
+ sym_name = stradd(sym_name, offset);
+
+ }
+
+ g_object_unref(G_OBJECT(symbol));
+
+ }
+
+ /* Demande d'affichage final */
+
+ gtk_status_stack_update_current_location(stack, range, segment, sym_name, encoding);
+
+ if (sym_name != NULL)
+ free(sym_name);
+
+}
+#endif
+
+
+/******************************************************************************
+* *
* Paramètres : cursor = emplacement du curseur à afficher. *
* stack = pile de statuts à mettre à jour. *
* content = contenu contenant le curseur à représenter. *
@@ -347,6 +445,7 @@ static char *g_binary_cursor_build_label(const GBinaryCursor *cursor)
static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusStack *stack, GLoadedContent *content)
{
+#ifdef INCLUDE_GTK_SUPPORT
GLoadedBinary *binary; /* Binaire chargé et analysé */
GArchProcessor *proc; /* Architecture du binaire */
mrange_t tmp; /* Emplacement réduit */
@@ -364,7 +463,7 @@ static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusSt
{
init_mrange(&tmp, &cursor->addr, VMPA_NO_PHYSICAL);
- gtk_status_stack_update_current_location(stack, binary, &tmp, NULL);
+ prepare_and_show_status_from_binary_cursor(&tmp, NULL, binary, stack);
}
@@ -378,7 +477,7 @@ static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusSt
range = g_arch_instruction_get_range(instr);
encoding = g_arch_instruction_get_encoding(instr);
- gtk_status_stack_update_current_location(stack, binary, range, encoding);
+ prepare_and_show_status_from_binary_cursor(range, encoding, binary, stack);
g_object_unref(G_OBJECT(instr));
@@ -390,7 +489,7 @@ static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusSt
else
gtk_status_stack_reset_current_location(stack);
-
+#endif
}