summaryrefslogtreecommitdiff
path: root/src/analysis/disass/disassembler.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-04-02 07:47:13 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-04-02 07:47:13 (GMT)
commit36a5b2577d67ab7c9f2c5817f6dba7a9601d1f20 (patch)
tree8b326546f84c5ca82bbff2b41ef967ba3b0c0745 /src/analysis/disass/disassembler.c
parent33906ce366efc053dee0b76d5bd668797b99071e (diff)
Handled all routines disassembling processing in one place.
Diffstat (limited to 'src/analysis/disass/disassembler.c')
-rw-r--r--src/analysis/disass/disassembler.c114
1 files changed, 87 insertions, 27 deletions
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 0fcc7f3..4e6a13c 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -39,6 +39,7 @@
#include "macro.h"
#include "output.h"
#include "rank.h"
+#include "routines.h"
#include "../../decomp/lang/asm.h"
#include "../../format/format.h"
#include "../../glibext/delayed-int.h"
@@ -196,15 +197,11 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
GArchProcessor *proc; /* Architecture du binaire */
- unsigned int valid; /* Instructions traduites */
- unsigned int db; /* Instructions non décodées */
- unsigned int valid_sum; /* Instructions traduites */
- unsigned int instr_sum; /* Instructions totales */
- size_t i; /* Boucle de parcours */
+ //size_t i; /* Boucle de parcours */
GBinRoutine **routines; /* Liste des routines trouvées */
size_t routines_count; /* Nombre de ces routines */
- bstatus_id_t id; /* Identifiant de statut */
+ activity_id_t id; /* Identifiant de statut */
//GArchProcessor *proc; /* Architecture du binaire */
@@ -341,9 +338,9 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
//qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare);
- limit_all_routines(disass->format, proc, routines, routines_count, gid, id);
+ limit_all_routines(disass->format, proc, routines, routines_count, gid, 0/*id*/);
- gtk_extended_status_bar_remove(statusbar, id);
+ gtk_extended_status_bar_remove(statusbar, 0/*id*/);
//run_plugins_on_binary(disass->binary, PGA_BINARY_BOUNDED, true);
@@ -354,9 +351,6 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
-
-
-
/* Troisième étape */
id = gtk_extended_status_bar_push(statusbar, _("Establishing links..."), true);
@@ -372,9 +366,9 @@ G_BIN_FORMAT(g_loaded_binary_get_format(disass->binary)
*/
- establish_links_between_instructions(*disass->instrs, G_BIN_FORMAT(disass->format), statusbar, id);
+ establish_links_between_instructions(*disass->instrs, G_BIN_FORMAT(disass->format), statusbar, 0/*id*/);
- gtk_extended_status_bar_remove(statusbar, id);
+ gtk_extended_status_bar_remove(statusbar, 0/*id*/);
//run_plugins_on_binary(disass->binary, PGA_BINARY_LINKED, true);
@@ -389,16 +383,82 @@ G_BIN_FORMAT(g_loaded_binary_get_format(disass->binary)
/* Quatrième étape */
- id = gtk_extended_status_bar_push(statusbar, _("Detecting loops..."), true);
+ // -- old -- id = gtk_extended_status_bar_push(statusbar, _("Detecting loops..."), true);
- detect_loops_in_code(proc, routines, routines_count, statusbar, id);
+ // -- old -- detect_loops_in_code(proc, routines, routines_count, statusbar, 0/*id*/);
- gtk_extended_status_bar_remove(statusbar, id);
+ // -- old -- gtk_extended_status_bar_remove(statusbar, 0/*id*/);
///
// plugins //////////////////////////
- process_disassembly_event(PGA_DISASSEMBLY_LOOPS, disass->binary);
+ // -- old -- process_disassembly_event(PGA_DISASSEMBLY_LOOPS, disass->binary);
+
+
+
+
+
+
+
+
+
+
+ //////////////////////////////////////
+
+
+ // Control-flow analysis...
+
+
+
+
+
+
+
+
+ mrange_t *exe_ranges; /* Liste de zones exécutables */
+ size_t exe_count; /* Nombre de ces zones */
+ guint runs_count; /* Qté d'exécutions parallèles */
+ size_t run_size; /* Volume réparti par exécution*/
+ GWorkQueue *queue; /* Gestionnaire de différés */
+ guint i; /* Boucle de parcours */
+ size_t begin; /* Début de bloc de traitement */
+ size_t end; /* Fin d'un bloc de traitement */
+ GRoutinesStudy *study; /* Tâche d'étude à programmer */
+
+ exe_ranges = g_exe_format_get_x_ranges(disass->format, &exe_count);
+
+ runs_count = g_get_num_processors();
+
+ run_size = routines_count / runs_count;
+
+ queue = get_work_queue();
+
+ for (i = 0; i < runs_count; i++)
+ {
+ begin = i * run_size;
+
+ if ((i + 1) < runs_count)
+ end = routines_count - begin;
+ else
+ end = begin + run_size;
+
+ study = g_routines_study_new(proc, exe_ranges, exe_count, routines, routines_count, begin, end, id);
+
+ g_work_queue_schedule_work(queue, G_DELAYED_WORK(study), gid);
+
+ }
+
+ g_work_queue_wait_for_completion(queue, gid);
+
+ if (exe_ranges != NULL)
+ free(exe_ranges);
+
+
+
+
+
+
+
@@ -406,18 +466,18 @@ G_BIN_FORMAT(g_loaded_binary_get_format(disass->binary)
/* Cinquième étape */
- id = gtk_extended_status_bar_push(statusbar, _("Grouping routines instructions..."), true);
+ // -- old -- id = gtk_extended_status_bar_push(statusbar, _("Grouping routines instructions..."), true);
//qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare);
- group_routines_instructions(proc, routines, routines_count, statusbar, id);
+ // -- old -- group_routines_instructions(proc, routines, routines_count, statusbar, 0/*id*/);
- gtk_extended_status_bar_remove(statusbar, id);
+ // -- old -- gtk_extended_status_bar_remove(statusbar, 0/*id*/);
//run_plugins_on_binary(disass->binary, PGA_BINARY_GROUPED, true);
- process_disassembly_event(PGA_DISASSEMBLY_GROUPED, disass->binary);
+ // -- old -- process_disassembly_event(PGA_DISASSEMBLY_GROUPED, disass->binary);
@@ -425,18 +485,18 @@ G_BIN_FORMAT(g_loaded_binary_get_format(disass->binary)
/* Sixième étape */
- id = gtk_extended_status_bar_push(statusbar, _("Ranking each instructions block..."), true);
+ // -- old -- id = gtk_extended_status_bar_push(statusbar, _("Ranking each instructions block..."), true);
//qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare);
- rank_routines_blocks(routines, routines_count, statusbar, id);
+ // -- old -- rank_routines_blocks(routines, routines_count, statusbar, 0/*id*/);
- gtk_extended_status_bar_remove(statusbar, id);
+ // -- old -- gtk_extended_status_bar_remove(statusbar, 0/*id*/);
//run_plugins_on_binary(disass->binary, PGA_BINARY_GROUPED, true);
- process_disassembly_event(PGA_DISASSEMBLY_RANKED, disass->binary);
+ // -- old -- process_disassembly_event(PGA_DISASSEMBLY_RANKED, disass->binary);
@@ -450,7 +510,7 @@ G_BIN_FORMAT(g_loaded_binary_get_format(disass->binary)
proc = g_loaded_binary_get_processor(disass->binary);
print_disassembled_instructions(disass->buffer, disass->format, proc, *disass->instrs,
- routines, routines_count, statusbar, id);
+ routines, routines_count, statusbar, 0/*id*/);
g_object_unref(G_OBJECT(proc));
@@ -464,7 +524,7 @@ G_BIN_FORMAT(g_loaded_binary_get_format(disass->binary)
printf("---fin\n");
- //gtk_extended_status_bar_remove(statusbar, id);
+ //gtk_extended_status_bar_remove(statusbar, 0/*id*/);
//run_plugins_on_binary(disass->binary, PGA_BINARY_PRINTED, true);