summaryrefslogtreecommitdiff
path: root/src/glibext/gbinarycursor.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-11-09 13:18:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-11-09 13:18:35 (GMT)
commitc301f7e77eaca632a491b5b4417c8e4b9dce2570 (patch)
tree501ccdd583e35ccad4f3a0592f2fb1b0870e0d5f /src/glibext/gbinarycursor.c
parent459b345d69532825f21bdcd3e4f92009b0a046dc (diff)
Introduced the first features of a hexadecimal viewer.
Diffstat (limited to 'src/glibext/gbinarycursor.c')
-rw-r--r--src/glibext/gbinarycursor.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/src/glibext/gbinarycursor.c b/src/glibext/gbinarycursor.c
index 9c4e82b..86f931f 100644
--- a/src/glibext/gbinarycursor.c
+++ b/src/glibext/gbinarycursor.c
@@ -39,6 +39,7 @@ struct _GBinaryCursor
{
GLineCursor parent; /* A laisser en premier */
+ bool raw; /* Position brute ? */
vmpa2t addr; /* Position mémoire du curseur */
};
@@ -162,6 +163,8 @@ static void g_binary_cursor_class_init(GBinaryCursorClass *class)
static void g_binary_cursor_init(GBinaryCursor *cursor)
{
+ cursor->raw = false;
+
init_vmpa(&cursor->addr, VMPA_NO_PHYSICAL, VMPA_NO_VIRTUAL);
}
@@ -246,6 +249,8 @@ static GLineCursor *g_binary_cursor_duplicate(const GBinaryCursor *cursor)
result = g_binary_cursor_new();
+ G_BINARY_CURSOR(result)->raw = cursor->raw;
+
g_binary_cursor_update(G_BINARY_CURSOR(cursor), &cursor->addr);
return result;
@@ -344,6 +349,9 @@ static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusSt
{
GLoadedBinary *binary; /* Binaire chargé et analysé */
GArchProcessor *proc; /* Architecture du binaire */
+ mrange_t tmp; /* Emplacement réduit */
+ const mrange_t *range; /* Emplacement d'instruction */
+ const char *encoding; /* Encodage à présenter */
GArchInstruction *instr; /* Instruction présente */
if (g_binary_cursor_is_valid(cursor))
@@ -352,21 +360,56 @@ static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusSt
binary = G_LOADED_BINARY(content);
- proc = g_loaded_binary_get_processor(binary);
+ if (cursor->raw)
+ {
+ init_mrange(&tmp, &cursor->addr, VMPA_NO_PHYSICAL);
+
+ gtk_status_stack_update_current_location(stack, binary, &tmp, NULL);
+
+ }
+
+ else
+ {
+ proc = g_loaded_binary_get_processor(binary);
+
+ instr = _g_arch_processor_find_instr_by_address(proc, &cursor->addr, true);
+ assert(instr != NULL);
- instr = _g_arch_processor_find_instr_by_address(proc, &cursor->addr, true);
- assert(instr != NULL);
+ range = g_arch_instruction_get_range(instr);
+ encoding = g_arch_instruction_get_encoding(instr);
- gtk_status_stack_update_current_instruction(stack, binary, instr);
+ gtk_status_stack_update_current_location(stack, binary, range, encoding);
- g_object_unref(G_OBJECT(instr));
+ g_object_unref(G_OBJECT(instr));
- g_object_unref(G_OBJECT(proc));
+ g_object_unref(G_OBJECT(proc));
+
+ }
}
else
- gtk_status_stack_reset_current_instruction(stack);
+ gtk_status_stack_reset_current_location(stack);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : cursor = suivi de positions à mettre à jour. *
+* raw = nature de la représentation de l'emplacement visé. *
+* *
+* Description : Précise la représentation de l'emplacement. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_cursor_set_raw(GBinaryCursor *cursor, bool raw)
+{
+ cursor->raw = raw;
}