summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/disass/area.c4
-rw-r--r--src/analysis/disass/fetch.c20
-rw-r--r--src/analysis/disass/output.c55
3 files changed, 53 insertions, 26 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index 130a7f0..f01b89c 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -1556,7 +1556,7 @@ static void g_area_collector_do_insert(GAreaCollector *collector, GtkStatusStack
for (i = collector->start; i < collector->stop; i++)
{
- instr = _g_preload_info_get_instruction(collector->info, i);
+ instr = _g_preload_info_grab_instruction(collector->info, i);
range = g_arch_instruction_get_range(instr);
addr = get_mrange_addr(range);
@@ -1651,6 +1651,8 @@ void populate_fresh_memory_areas(wgroup_id_t gid, GtkStatusStack *status, mem_ar
_g_preload_info_drain_instructions(info);
+ assert(_g_preload_info_count_instructions(info) == 0);
+
g_preload_info_unlock_instructions(info);
gtk_status_stack_remove_activity(status, id);
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index c5489d6..586c084 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -417,8 +417,6 @@ GArchInstruction **disassemble_binary_content(GLoadedBinary *binary, GProcContex
template.areas = collect_memory_areas(gid, status, binary, length, &template.count);
- populate_fresh_memory_areas(gid, status, template.areas, template.count, G_PRELOAD_INFO(ctx));
-
template.status = status;
/* Amorce des traitements */
@@ -432,7 +430,17 @@ GArchInstruction **disassemble_binary_content(GLoadedBinary *binary, GProcContex
g_proc_context_attach_counter(template.ctx, &remaining_counter);
/**
- * Première phase de désassemblage : suivi des chemins tracés.
+ * Première phase de désassemblage : intégration des infos du format.
+ */
+
+ g_binary_format_preload_disassembling_context(format, template.ctx, status);
+
+ populate_fresh_memory_areas(gid, status, template.areas, template.count, G_PRELOAD_INFO(ctx));
+
+ g_work_queue_wait_for_completion(queue, gid);
+
+ /**
+ * Seconde phase : suivi des chemins tracés.
*/
g_work_queue_set_extra_wait_callback(queue, gid,
@@ -445,12 +453,12 @@ GArchInstruction **disassemble_binary_content(GLoadedBinary *binary, GProcContex
_("Disassembling following the execution flow..."),
length);
- g_binary_format_setup_disassembling_context(format, template.ctx, status);
+ g_binary_format_activate_disassembling_context(format, template.ctx, status);
g_work_queue_wait_for_completion(queue, gid);
/**
- * Seconde phase : on comble les trous laissés.
+ * Troisième phase : on comble les trous laissés.
*/
gtk_status_stack_update_activity(status, template.id, _("Disassembling the remaining instructions..."));
@@ -466,7 +474,7 @@ GArchInstruction **disassemble_binary_content(GLoadedBinary *binary, GProcContex
gtk_status_stack_remove_activity(status, template.id);
/**
- * Troisième et dernière phase : récolte des fruits.
+ * Quatrième et dernière phase : récolte des fruits.
*/
result = collect_disassembled_instructions(gid, status, template.areas, template.count, count);
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 5a74d92..421cfb6 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -24,6 +24,9 @@
#include "output.h"
+#include <assert.h>
+
+
#include <i18n.h>
@@ -67,6 +70,8 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
bool expect_outro; /* Fin de zone de code définie */
+ size_t comment_count; /* Quantité de commentaires */
+ size_t comment_index; /* Indice du commantaire actif */
GDbComment *comment; /* Commentaire à ajouter */
const vmpa2t *caddr; /* Localisation du commentaire */
@@ -137,11 +142,22 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
expect_outro = false;
- comment = g_preload_info_pop_comment(info);
+ g_preload_info_lock_comments(info);
- if (comment != NULL)
+ comment_count = _g_preload_info_count_comments(info);
+ comment_index = 0;
+
+ if (comment_index < comment_count)
+ {
+ comment = _g_preload_info_grab_comment(info, comment_index);
caddr = g_db_comment_get_address(comment);
+ comment_index++;
+
+ }
+
+ else
+ comment = NULL;
/*
if (comment != NULL)
@@ -306,32 +322,29 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
{
compared = cmp_vmpa(iaddr, caddr);
- if (compared == 0)
+ if (compared >= 0)
{
- if (g_loaded_binary_add_to_collection(binary, G_DB_ITEM(comment)))
+ if (compared == 0)
g_db_item_apply(G_DB_ITEM(comment), binary);
else
- g_object_unref(G_OBJECT(comment));
-
- }
-
- else if (compared > 0)
- {
- log_variadic_message(LMT_BAD_BINARY,
- _("Unable to find a proper location for comment '%s' @ 0x%08x"),
- g_db_comment_get_text(comment), get_phy_addr(caddr));
+ log_variadic_message(LMT_BAD_BINARY,
+ _("Unable to find a proper location for comment '%s' @ 0x%08x"),
+ g_db_comment_get_text(comment), get_phy_addr(caddr));
g_object_unref(G_OBJECT(comment));
- }
+ if (comment_index < comment_count)
+ {
+ comment = _g_preload_info_grab_comment(info, comment_index);
+ caddr = g_db_comment_get_address(comment);
- if (compared >= 0)
- {
- comment = g_preload_info_pop_comment(info);
+ comment_index++;
- if (comment != NULL)
- caddr = g_db_comment_get_address(comment);
+ }
+
+ else
+ comment = NULL;
}
@@ -343,6 +356,10 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
}
+ assert(comment_index == comment_count);
+
+ g_preload_info_unlock_comments(info);
+
gtk_status_stack_remove_activity(status, id);
g_arch_processor_unlock(proc);