diff options
Diffstat (limited to 'src/binary.c')
-rw-r--r-- | src/binary.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/binary.c b/src/binary.c index 427ad4e..5093335 100644 --- a/src/binary.c +++ b/src/binary.c @@ -35,7 +35,7 @@ #include <sys/types.h> - +#include "analysis/prototype.h" #include "arch/processor.h" @@ -435,6 +435,9 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) asm_processor *proc; asm_instr *instr; + bin_routine **routines; /* Liste des routines trouvées */ + size_t routines_count; /* Nombre de ces routines */ + bin_part **parts; size_t parts_count; @@ -464,6 +467,10 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) size_t k; + uint64_t routine_offset; /* Point de départ de routine */ + char *routine_desc; /* Prototype d'une routine */ + + disass_options options; proc = create_x86_processor(); @@ -497,21 +504,27 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) + options.show_address = true; options.show_code = true; options.format = format; options.proc = proc; + routines = get_all_exe_routines(format, &routines_count); + parts = get_elf_default_code_parts(format, &parts_count); + qsort(parts, parts_count, sizeof(bin_part *), compare_bin_parts); + + for (i = 0; i < parts_count; i++) { get_bin_part_values(parts[i], &pos, &len, &base); - + /* Décodage des instructions */ start = pos; pos = 0; @@ -524,19 +537,27 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) instr = decode_instruction(proc, &bin_data[start], &pos, len, start, offset); - line = create_code_line(instr, &options); + line = create_code_line(instr, offset, &options); add_line_to_rendering_lines(&lines, line); } + /* Ajout des prototypes de fonctions */ - /**** - ret = munmap(bin_data, length); - ****/ + for (k = 0; k < routines_count; k++) + { + routine_offset = get_binary_routine_offset(routines[k]); - /* - gtk_snippet_build_content(snippet); - */ + if (!(base <= routine_offset && routine_offset < (base + len))) continue; + + routine_desc = routine_to_string(routines[k]); + + line = create_comment_line(routine_offset, RLT_PROTOTYPE, routine_desc, &options); + insert_line_into_rendering_lines(&lines, line, true); + + free(routine_desc); + + } } @@ -547,6 +568,7 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) + gtk_snippet_set_rendering_lines(snippet, lines); handle_new_exe_on_symbols_panel(panel, format); |