summaryrefslogtreecommitdiff
path: root/src/binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary.c')
-rw-r--r--src/binary.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/binary.c b/src/binary.c
index eee4d2b..5f07703 100644
--- a/src/binary.c
+++ b/src/binary.c
@@ -35,6 +35,9 @@
#include "arch/processor.h"
+#include "format/elf/format_elf.h"
+
+
/* Charge en mémoire le contenu d'un fichier. */
@@ -116,6 +119,7 @@ void fill_snippet(GtkSnippet *snippet)
//uint8_t *data = "\x66\xbb\x00\x00\x00\x00\x66\xb8\x01\x00\x00\x00\xcd\x80\x90";
+ off_t start;
off_t pos;
off_t len;
@@ -133,11 +137,13 @@ void fill_snippet(GtkSnippet *snippet)
bin_data = map_binary_file("/tmp/hello", &length);
- printf(" ~~ bin_data ~~ :: %p\n", bin_data);
+ printf(" ~~ bin_data ~~ :: %p (%d)\n", bin_data, length);
+ if (bin_data != NULL)
+ find_text_data(bin_data, &pos, &len);
+
- ret = munmap(bin_data, length);
gtk_snippet_set_processor(snippet, proc);
@@ -146,6 +152,32 @@ void fill_snippet(GtkSnippet *snippet)
gtk_snippet_add_line(snippet, offset, NULL, "Simple HelloWorld !");
+#if 1
+
+ start = pos;
+ pos = 0;
+
+ while (pos < len)
+ {
+ offset = base + pos;
+
+ instr = decode_instruction(proc, &bin_data[start], &pos, len);
+
+ gtk_snippet_add_line(snippet, offset, instr, NULL);
+
+
+ }
+
+
+ ret = munmap(bin_data, length);
+
+
+#else
+
+ pos = 0;
+ len = 0x28;
+
+
while (pos < len)
{
offset = base + pos;
@@ -187,6 +219,7 @@ void fill_snippet(GtkSnippet *snippet)
}
+#endif
/*
gtk_snippet_build_content(snippet);