summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/disass/disassembler.c3
-rw-r--r--src/analysis/disass/fetch.c2
-rw-r--r--src/analysis/disass/output.c101
-rw-r--r--src/analysis/disass/output.h7
-rw-r--r--src/gtkext/gtkstatusstack.c5
5 files changed, 83 insertions, 35 deletions
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 7d8494f..1d62ab5 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -525,8 +525,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
proc = g_loaded_binary_get_processor(disass->binary);
- print_disassembled_instructions(disass->buffer, disass->format, proc, *disass->instrs,
- routines, routines_count, status, 0/*id*/);
+ print_disassembled_instructions(disass->buffer, disass->format, proc, status);
g_object_unref(G_OBJECT(proc));
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index f484f05..373b8dc 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -567,6 +567,8 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup
result = collect_instructions_from_mem_areas_v2(template.areas, template.count);
+ gtk_status_stack_remove_activity(status, template.id);
+
/* Libérations finales */
//g_object_unref(G_OBJECT(template.format));
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index dce5497..b2bfce7 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -35,15 +35,18 @@
+#define ROUTINE_INTRO_MSG "; --------------- BEGIN OF PROCEDURE ---------------"
+
+
+
/******************************************************************************
* *
-* Paramètres : buffer = tampon de récueil des résultats d'impression. *
-* format = format du binaire traité. *
-* instrs = ensemble d'instructions à traiter. *
-* routines = liste de routines intervenant dans le flot. *
-* count = quantité de ces routines. *
-* statusbar = barre de statut avec progression à mettre à jour.*
-* id = identifiant du message affiché à l'utilisateur. *
+* Paramètres : buffer = tampon de récueil des résultats d'impression. *
+* format = format du binaire traité. *
+* instrs = ensemble d'instructions à traiter. *
+* routines = liste de routines intervenant dans le flot. *
+* count = quantité de ces routines. *
+* status = barre de statut avec progression à mettre à jour. *
* *
* Description : Transcrit du code désassemblé en texte humainement lisible. *
* *
@@ -53,7 +56,7 @@
* *
******************************************************************************/
-void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, GArchProcessor *proc, const GArchInstruction *instrs, GBinRoutine * const *routines, size_t count, GtkExtStatusBar *statusbar, bstatus_id_t id)
+void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GArchProcessor *proc, GtkStatusStack *status)
{
GLangOutput *output; /* Modèle de sortie adéquat */
GPortionLayer *layer; /* Couche première de portions */
@@ -68,15 +71,14 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
MemoryDataSize msize; /* Taille du bus d'adresses */
const GBinContent *content; /* Contenu binaire global */
-#if 0
- const mrange_t *range; /* Cou
+ size_t count; /* Nombre total d'instructions */
+ activity_id_t id; /* Identifiant de progression */
+
- vmpa_t start; /* Adresse de départ */
- vmpa_t end; /* Adresse de fin */
-#endif
- const GArchInstruction *iter; /* Boucle de parcours #1 */
- size_t i; /* Boucle de parcours #2 */
+ size_t i; /* Boucle de parcours */
+ GArchInstruction *instr; /* Instruction à traiter */
+
const vmpa2t *iaddr; /* Adresse d'instruction */
const vmpa2t *saddr; /* Adresse de symbole */
@@ -86,7 +88,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
const vmpa2t *paddr; /* Adresse de portion */
int compared; /* Bilan d'une comparaison */
-
+ SymbolType stype; /* Type de symbole trouvé */
const char *label; /* Etiquette ciblant un symbole*/
mrange_t range; /* Couverture sans surface */
@@ -141,10 +143,17 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
g_arch_instruction_get_location(iter, NULL, NULL, &end);
#endif
- for (iter = instrs, i = 0;
- iter != NULL;
- iter = g_arch_instruction_get_next_iter(instrs, iter, VMPA_MAX))
+
+ count = g_arch_processor_count_disassembled_instructions(proc);
+
+ id = gtk_status_stack_add_activity(status, _("Printing all disassebled parts..."), count);
+
+ for (i = 0; i < count; i++)
{
+ instr = g_arch_processor_get_disassembled_instruction(proc, i);
+
+
+
#if 0
g_arch_instruction_get_location(iter, NULL, NULL, &iaddr);
@@ -160,7 +169,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
#endif
- iaddr = get_mrange_addr(g_arch_instruction_get_range(iter));
+ iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
while (portion_index < portions_count)
{
@@ -181,7 +190,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
if (sym_index < sym_count)
{
- iaddr = get_mrange_addr(g_arch_instruction_get_range(iter));
+ iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
/* On écarte les symboles qu'on ne sait pas réintroduire */
@@ -202,14 +211,49 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
if (compared == 0)
{
+ /* Ligne de séparation */
+
+ init_mrange(&range, get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index])), 0);
+
+ line = g_code_buffer_prepare_new_line(buffer, &range);
+ g_buffer_line_add_flag(line, BLF_IS_LABEL);
+ g_buffer_line_fill_mrange(line, msize, msize);
+
+ g_code_buffer_append_new_line(buffer, line);
+
+ /* Coupure pour une nouvelle routine */
+
+ stype = g_binary_symbol_get_target_type(symbols[sym_index]);
+
+ if (stype == STP_ROUTINE || stype == STP_FUNCTION || stype == STP_ENTRY_POINT)
+ {
+
+ line = g_code_buffer_prepare_new_line(buffer, &range);
+ g_buffer_line_add_flag(line, BLF_IS_LABEL);
+ g_buffer_line_fill_mrange(line, msize, msize);
+
+ g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD,
+ ROUTINE_INTRO_MSG, strlen(ROUTINE_INTRO_MSG), RTT_COMMENT);
+
+ g_code_buffer_append_new_line(buffer, line);
+
+ init_mrange(&range, get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index])), 0);
+
+ line = g_code_buffer_prepare_new_line(buffer, &range);
+ g_buffer_line_add_flag(line, BLF_IS_LABEL);
+ g_buffer_line_fill_mrange(line, msize, msize);
+
+ g_code_buffer_append_new_line(buffer, line);
+
+ }
+
/* Etiquette ? */
label = g_binary_symbol_get_label(symbols[sym_index]);
if (label != NULL)
{
- init_mrange(&range, get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index])), 0);
-
line = g_code_buffer_prepare_new_line(buffer, &range);
g_buffer_line_add_flag(line, BLF_IS_LABEL);
g_buffer_line_fill_mrange(line, msize, msize);
@@ -230,16 +274,16 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
- line = g_arch_instruction_print(iter, buffer, msize, content, ASX_INTEL);
+ line = g_arch_instruction_print(instr, buffer, msize, content, ASX_INTEL);
- if (g_arch_instruction_get_flags(iter) & AIF_RETURN_POINT)
+ if (g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT)
g_buffer_line_add_flag(line, BLF_BOOKMARK);
if (sym_index < sym_count)
{
- iaddr = get_mrange_addr(g_arch_instruction_get_range(iter));
+ iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
if (cmp_vmpa(iaddr, saddr) == 0)
@@ -286,11 +330,12 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
g_code_buffer_append_new_line(buffer, line);
-
- //gtk_extended_status_bar_update_activity(statusbar, id, (iaddr - start) * 1.0 / (end - start));
+ gtk_status_stack_update_activity_value(status, id, 1);
}
+ gtk_status_stack_remove_activity(status, id);
+
g_object_unref(G_OBJECT(content));
if (portions != NULL)
diff --git a/src/analysis/disass/output.h b/src/analysis/disass/output.h
index 549fa23..a79273c 100644
--- a/src/analysis/disass/output.h
+++ b/src/analysis/disass/output.h
@@ -25,16 +25,15 @@
#define _ANALYSIS_DISASS_OUTPUT_H
-#include "../routine.h"
-#include "../../arch/instruction.h"
#include "../../arch/processor.h"
+#include "../../format/executable.h"
#include "../../glibext/gcodebuffer.h"
-#include "../../gtkext/gtkextstatusbar.h"
+#include "../../gtkext/gtkstatusstack.h"
/* Transcrit du code désassemblé en texte humainement lisible. */
-void print_disassembled_instructions(GCodeBuffer *, const GExeFormat *, GArchProcessor *, const GArchInstruction *, GBinRoutine * const *, size_t, GtkExtStatusBar *, bstatus_id_t);
+void print_disassembled_instructions(GCodeBuffer *, GExeFormat *, GArchProcessor *, GtkStatusStack *);
diff --git a/src/gtkext/gtkstatusstack.c b/src/gtkext/gtkstatusstack.c
index 880f4ed..f8bb4e8 100644
--- a/src/gtkext/gtkstatusstack.c
+++ b/src/gtkext/gtkstatusstack.c
@@ -1059,7 +1059,10 @@ void gtk_status_stack_remove_activity(GtkStatusStack *stack, activity_id_t id)
info->count--;
if (info->count == 0)
- info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_instruction, stack);
+ {
+ info->tag = 0;
+ g_idle_add((GSourceFunc)gtk_status_stack_show_current_instruction, stack);
+ }
else
info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_activity, stack);