summaryrefslogtreecommitdiff
path: root/src/glibext/gbinarycursor.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-09-10 22:36:39 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-09-11 00:04:06 (GMT)
commitdca1d8cefde54fa6f23c2963aef61d211fc1d7d0 (patch)
treee44894c936c4d55fed4cde1fc545a325f41154d8 /src/glibext/gbinarycursor.c
parentb370370a9e35f9dd2357102b17338d3d93bb62aa (diff)
Fix the compilation when GTK support is enabled.
Diffstat (limited to 'src/glibext/gbinarycursor.c')
-rw-r--r--src/glibext/gbinarycursor.c97
1 files changed, 95 insertions, 2 deletions
diff --git a/src/glibext/gbinarycursor.c b/src/glibext/gbinarycursor.c
index 76975a7..d42b5a5 100644
--- a/src/glibext/gbinarycursor.c
+++ b/src/glibext/gbinarycursor.c
@@ -25,10 +25,15 @@
#include <assert.h>
+#include <malloc.h>
+
+
+#include <i18n.h>
#include "glinecursor-int.h"
#include "../analysis/binary.h"
+#include "../common/extstr.h"
@@ -77,6 +82,9 @@ 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. */
+static void prepare_and_show_status_from_binary_cursor(const mrange_t *, const char *, const GLoadedBinary *, GtkStatusStack *);
+
/* Affiche une position dans une barre de statut. */
static void g_binary_cursor_show_status(const GBinaryCursor *, GtkStatusStack *, GLoadedContent *);
@@ -334,6 +342,91 @@ 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 : - *
+* *
+******************************************************************************/
+
+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);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : cursor = emplacement du curseur à afficher. *
* stack = pile de statuts à mettre à jour. *
* content = contenu contenant le curseur à représenter. *
@@ -365,7 +458,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);
}
@@ -379,7 +472,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));