summaryrefslogtreecommitdiff
path: root/src/analysis
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/analysis
parent459b345d69532825f21bdcd3e4f92009b0a046dc (diff)
Introduced the first features of a hexadecimal viewer.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c24
-rw-r--r--src/analysis/binary.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 61dbbf1..1ba54e6 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -53,6 +53,7 @@
#include "../gtkext/gtkblockdisplay.h"
#include "../gtkext/gtkdisplaypanel.h"
#include "../gtkext/gtkgraphdisplay.h"
+#include "../gtkext/hexdisplay.h"
@@ -255,6 +256,10 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
binary->collections = create_collections_list();
attach_binary_to_collections(binary->collections, binary);
+ binary->options[BVW_HEX] = g_display_options_new();
+
+ g_display_options_add(binary->options[BVW_HEX], _("Physical offset"), true);
+
binary->options[BVW_BLOCK] = g_display_options_new();
g_display_options_add(binary->options[BVW_BLOCK], _("Physical offset"), true);
@@ -1685,6 +1690,7 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca
has_virt = g_arch_processor_has_virtual_space(binary->proc);
+ g_display_options_set(binary->options[BVW_HEX], 0, false);
g_display_options_set(binary->options[BVW_BLOCK], BLC_VIRTUAL, has_virt);
g_display_options_set(binary->options[BVW_GRAPH], BLC_VIRTUAL, has_virt);
@@ -1884,6 +1890,10 @@ static const char *g_loaded_binary_get_view_name(const GLoadedBinary *binary, un
switch (index)
{
+ case BVW_HEX:
+ result = _("Hex view");
+ break;
+
case BVW_BLOCK:
result = _("Text view");
break;
@@ -1919,12 +1929,19 @@ static const char *g_loaded_binary_get_view_name(const GLoadedBinary *binary, un
static GtkWidget *g_loaded_binary_build_view(GLoadedBinary *binary, unsigned int index)
{
GtkWidget *result; /* Support à retourner */
+ GBinContent *content; /* Contenu à représenter */
+ GtkWidget *display; /* Composant d'affichage */
GBufferCache *cache; /* Tampon par défaut */
GBufferView *view; /* Vue sur ce même tampon */
- GtkWidget *display; /* Composant d'affichage */
switch (index)
{
+ case BVW_HEX:
+ content = g_binary_format_get_content(G_BIN_FORMAT(binary->format));
+ display = gtk_hex_display_new(content);
+ g_object_unref(G_OBJECT(content));
+ break;
+
case BVW_BLOCK:
cache = g_loaded_binary_get_disassembled_cache(binary);
view = g_buffer_view_new(cache, NULL);
@@ -1970,7 +1987,10 @@ static unsigned int g_loaded_binary_get_view_index(GLoadedBinary *binary, GtkWid
{
unsigned int result; /* Indice à retourner */
- if (GTK_IS_BLOCK_DISPLAY(view))
+ if (GTK_IS_HEX_DISPLAY(view))
+ result = BVW_HEX;
+
+ else if (GTK_IS_BLOCK_DISPLAY(view))
result = BVW_BLOCK;
else if (GTK_IS_GRAPH_DISPLAY(view))
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 1f94e34..65291f1 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -163,6 +163,7 @@ vmpa2t *g_loaded_binary_get_old_gotos(GLoadedBinary *, size_t *);
/* Type de représentations */
typedef enum _BinaryView
{
+ BVW_HEX, /* Contenu en hexadécimal */
BVW_BLOCK, /* Version basique */
BVW_GRAPH, /* Affichage en graphique */