summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/db/items/comment.c2
-rw-r--r--src/analysis/db/items/switcher.c6
-rw-r--r--src/analysis/disass/disassembler.c6
-rw-r--r--src/analysis/disass/dragon.c51
-rw-r--r--src/analysis/disass/dragon.h2
-rw-r--r--src/analysis/disass/instructions.c32
-rw-r--r--src/analysis/disass/limit.c4
-rw-r--r--src/analysis/disass/limit.h2
-rw-r--r--src/analysis/disass/links.c5
-rw-r--r--src/analysis/disass/links.h2
-rw-r--r--src/analysis/disass/output.c10
-rw-r--r--src/analysis/disass/routines.c4
-rw-r--r--src/analysis/disass/routines.h2
13 files changed, 93 insertions, 35 deletions
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index 45331b8..55893d1 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -638,6 +638,8 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap
}
+ g_object_unref(G_OBJECT(instr));
+
g_object_unref(G_OBJECT(proc));
}
diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c
index 15354e9..748c934 100644
--- a/src/analysis/db/items/switcher.c
+++ b/src/analysis/db/items/switcher.c
@@ -527,7 +527,7 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO
}
result = G_IS_IMM_OPERAND(op);
- if (!result) goto exit_instr;
+ if (!result) goto exit_operand;
/* Traitement au niveau du rendu graphique */
@@ -559,6 +559,10 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO
/* TODO g_object_unref(G_OBJECT(buffer));*/
+ exit_operand:
+
+ g_object_unref(G_OBJECT(proc));
+
exit_instr:
g_object_unref(G_OBJECT(proc));
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 813701e..f210bd1 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -262,7 +262,11 @@ static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, co
runs_count = g_get_num_processors();
- ins_count = g_arch_processor_count_disassembled_instructions(proc);
+ g_arch_processor_lock(proc);
+
+ ins_count = g_arch_processor_count_instructions(proc);
+
+ g_arch_processor_unlock(proc);
run_size = ins_count / runs_count;
diff --git a/src/analysis/disass/dragon.c b/src/analysis/disass/dragon.c
index 01e985d..cc1346c 100644
--- a/src/analysis/disass/dragon.c
+++ b/src/analysis/disass/dragon.c
@@ -49,7 +49,7 @@ struct _dragon_node
/* Dénombre le nombre de noeuds présents dans une routine. */
-static dragon_node *create_dragon_nodes(const GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *, size_t *);
+static dragon_node *create_dragon_nodes(GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *, size_t *);
/* Supprime de la mémoire tous les noeuds détectés. */
static void delete_dragon_nodes(dragon_node *, size_t);
@@ -93,13 +93,14 @@ struct _dragon_knight
* *
******************************************************************************/
-static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start, size_t *count)
+static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start, size_t *count)
{
dragon_node *result; /* Liste à créer et renvoyer */
size_t allocated; /* Dimensionnement en mémoire */
bool need_alloc; /* Besoin d'une extension ? */
GArchInstruction *last; /* Mémorisation du passé */
- GArchInstruction *iter; /* Boucle de parcours */
+ instr_iter_t *iter; /* Boucle de parcours */
+ GArchInstruction *instr; /* Instruction analysée */
const mrange_t *irange; /* Emplacement d'instruction */
instr_link_t *sources; /* Liste des instructions liées*/
size_t scount; /* Nombre de liens de source */
@@ -115,16 +116,22 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
allocated = 0;
need_alloc = true;
- for (last = NULL, iter = g_arch_processor_find_covered_instr_by_address(proc, coverage, start);
- iter != NULL;
- last = iter, iter = g_arch_instruction_get_next_iter(iter /* FIXME : list*/, iter, ~0))
+ iter = g_arch_processor_get_covered_iter_from_address(proc, coverage, start);
+ if (iter == NULL) goto cdn_no_coverage;
+
+ for (last = NULL, instr = get_instruction_iterator_current(iter);
+ instr != NULL;
+ last = instr, instr = get_instruction_iterator_next(iter))
{
/* L'instruction sort-elle des clous ? */
- irange = g_arch_instruction_get_range(iter);
+ irange = g_arch_instruction_get_range(instr);
if (!mrange_contains_mrange(range, irange))
+ {
+ g_object_unref(G_OBJECT(instr));
break;
+ }
/* Découpage en blocs */
@@ -142,7 +149,7 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
new = &result[*count - 1];
- new->first = iter;
+ new->first = instr;
}
@@ -165,8 +172,8 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
{
/* Analyse des sources */
- g_arch_instruction_rlock_src(iter);
- scount = g_arch_instruction_get_sources(iter, &sources);
+ g_arch_instruction_rlock_src(instr);
+ scount = g_arch_instruction_get_sources(instr, &sources);
cut = false;
@@ -192,7 +199,7 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
new = &result[*count - 1];
- new->first = iter;
+ new->first = instr;
cut = true;
@@ -203,14 +210,14 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
}
- g_arch_instruction_runlock_src(iter);
+ g_arch_instruction_runlock_src(instr);
}
/* Analyse des destinations */
- g_arch_instruction_rlock_dest(iter);
- dcount = g_arch_instruction_get_destinations(iter, &dests);
+ g_arch_instruction_rlock_dest(instr);
+ dcount = g_arch_instruction_get_destinations(instr, &dests);
cut = false;
@@ -219,7 +226,7 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
{
case ILT_JUMP:
- result[*count - 1].last = iter;
+ result[*count - 1].last = instr;
cut = true;
@@ -232,21 +239,27 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
}
- g_arch_instruction_runlock_dest(iter);
+ g_arch_instruction_runlock_dest(instr);
- if (!need_alloc && g_arch_instruction_get_flags(iter) & AIF_RETURN_POINT)
+ if (!need_alloc && g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT)
{
- result[*count - 1].last = iter;
+ result[*count - 1].last = instr;
need_alloc = true;
}
+ g_object_unref(G_OBJECT(instr));
+
}
if (*count > 0)
result[*count - 1].last = last;
+ delete_instruction_iterator(iter);
+
+ cdn_no_coverage:
+
return result;
}
@@ -623,7 +636,7 @@ const bitfield_t *get_domination_bits(const dragon_node *node)
* *
******************************************************************************/
-dragon_knight *begin_dragon_knight(const GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start)
+dragon_knight *begin_dragon_knight(GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start)
{
dragon_knight *result; /* Données à retourner */
dragon_node *nodes; /* Noeuds mis en place */
diff --git a/src/analysis/disass/dragon.h b/src/analysis/disass/dragon.h
index 095281b..897e21b 100644
--- a/src/analysis/disass/dragon.h
+++ b/src/analysis/disass/dragon.h
@@ -72,7 +72,7 @@ typedef struct _dragon_knight dragon_knight;
/* Attaque la complexité d'un code en créant des noeuds. */
-dragon_knight *begin_dragon_knight(const GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *);
+dragon_knight *begin_dragon_knight(GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *);
/* Supprime de la mémoire les données d'une complexité de code. */
void end_dragon_knight(dragon_knight *);
diff --git a/src/analysis/disass/instructions.c b/src/analysis/disass/instructions.c
index 799d196..d83536d 100644
--- a/src/analysis/disass/instructions.c
+++ b/src/analysis/disass/instructions.c
@@ -251,10 +251,16 @@ void g_instructions_study_do_link_operation(GInstructionsStudy *study, size_t in
{
GArchInstruction *instr; /* Instruction en traitement */
- instr = g_arch_processor_get_disassembled_instruction(study->proc, index);
+ g_arch_processor_lock(study->proc);
+
+ instr = g_arch_processor_get_instruction(study->proc, index);
+
+ g_arch_processor_unlock(study->proc);
g_arch_instruction_call_hook(instr, IPH_LINK, study->proc, study->ctx, study->format);
+ g_object_unref(G_OBJECT(instr));
+
}
@@ -275,10 +281,16 @@ void g_instructions_study_do_post_operation(GInstructionsStudy *study, size_t in
{
GArchInstruction *instr; /* Instruction en traitement */
- instr = g_arch_processor_get_disassembled_instruction(study->proc, index);
+ g_arch_processor_lock(study->proc);
+
+ instr = g_arch_processor_get_instruction(study->proc, index);
+
+ g_arch_processor_unlock(study->proc);
g_arch_instruction_call_hook(instr, IPH_POST, study->proc, study->ctx, study->format);
+ g_object_unref(G_OBJECT(instr));
+
}
@@ -300,16 +312,28 @@ void g_instructions_study_establish_links(GInstructionsStudy *study, size_t inde
GArchInstruction *instr; /* Instruction en traitement */
GArchInstruction *prev; /* Instruction précédente */
- instr = g_arch_processor_get_disassembled_instruction(study->proc, index);
+ g_arch_processor_lock(study->proc);
+
+ instr = g_arch_processor_get_instruction(study->proc, index);
+
+ g_arch_processor_unlock(study->proc);
if (index > 0)
{
- prev = g_arch_processor_get_disassembled_instruction(study->proc, index - 1);
+ g_arch_processor_lock(study->proc);
+
+ prev = g_arch_processor_get_instruction(study->proc, index - 1);
+
+ g_arch_processor_unlock(study->proc);
establish_natural_link(instr, prev);
+ g_object_unref(G_OBJECT(prev));
+
}
establish_links_for_instruction(instr, G_BIN_FORMAT(study->format), study->proc);
+ g_object_unref(G_OBJECT(instr));
+
}
diff --git a/src/analysis/disass/limit.c b/src/analysis/disass/limit.c
index c7a9524..28a8264 100644
--- a/src/analysis/disass/limit.c
+++ b/src/analysis/disass/limit.c
@@ -76,7 +76,7 @@ static const mrange_t *find_x_range_for_addr(const mrange_t *ranges, size_t coun
* *
******************************************************************************/
-void compute_routine_limit(GBinRoutine *routine, GBinRoutine *prev, const GArchProcessor *proc, mrange_t *exe_ranges, size_t exe_count)
+void compute_routine_limit(GBinRoutine *routine, GBinRoutine *prev, GArchProcessor *proc, mrange_t *exe_ranges, size_t exe_count)
{
const mrange_t *range; /* Emplacement courant */
vmpa2t addr; /* Adresse à conserver */
@@ -100,6 +100,8 @@ void compute_routine_limit(GBinRoutine *routine, GBinRoutine *prev, const GArchP
g_arch_instruction_set_flag(start, AIF_ROUTINE_START);
+ g_object_unref(G_OBJECT(start));
+
/* Si on peut se raccrocher à la routine suivante... */
if (prev != NULL)
{
diff --git a/src/analysis/disass/limit.h b/src/analysis/disass/limit.h
index 431c642..7aba8a6 100644
--- a/src/analysis/disass/limit.h
+++ b/src/analysis/disass/limit.h
@@ -32,7 +32,7 @@
/* S'assure qu'une routine est bien bornée. */
-void compute_routine_limit(GBinRoutine *, GBinRoutine *, const GArchProcessor *, mrange_t *, size_t);
+void compute_routine_limit(GBinRoutine *, GBinRoutine *, GArchProcessor *, mrange_t *, size_t);
diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c
index 82da37d..18bbeb3 100644
--- a/src/analysis/disass/links.c
+++ b/src/analysis/disass/links.c
@@ -178,7 +178,7 @@ static void convert_immediate_into_target(GArchInstruction *instr, size_t index,
* *
******************************************************************************/
-void establish_links_for_instruction(GArchInstruction *instr, GBinFormat *format, const GArchProcessor *proc)
+void establish_links_for_instruction(GArchInstruction *instr, GBinFormat *format, GArchProcessor *proc)
{
bool skip; /* Saut des conversions */
size_t count; /* Nombre d'opérandes présents */
@@ -209,7 +209,10 @@ void establish_links_for_instruction(GArchInstruction *instr, GBinFormat *format
target = g_arch_processor_find_instr_by_address(proc, &addr);
if (target != NULL)
+ {
g_arch_instruction_link_with(instr, target, ILT_REF);
+ g_object_unref(G_OBJECT(target));
+ }
}
diff --git a/src/analysis/disass/links.h b/src/analysis/disass/links.h
index 8cdf663..bfa68db 100644
--- a/src/analysis/disass/links.h
+++ b/src/analysis/disass/links.h
@@ -35,7 +35,7 @@
void establish_natural_link(GArchInstruction *, GArchInstruction *);
/* Complète un désassemblage accompli pour une instruction. */
-void establish_links_for_instruction(GArchInstruction *, GBinFormat *, const GArchProcessor *);
+void establish_links_for_instruction(GArchInstruction *, GBinFormat *, GArchProcessor *);
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index f5decb7..0d85870 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -112,7 +112,9 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
content = g_binary_format_get_content(G_BIN_FORMAT(format));
- count = g_arch_processor_count_disassembled_instructions(proc);
+ g_arch_processor_lock(proc);
+
+ count = g_arch_processor_count_instructions(proc);
id = gtk_status_stack_add_activity(status, _("Printing all disassebled parts..."), count);
@@ -120,7 +122,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
for (i = 0; i < count; i++)
{
- instr = g_arch_processor_get_disassembled_instruction(proc, i);
+ instr = g_arch_processor_get_instruction(proc, i);
iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
@@ -322,12 +324,16 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
g_code_buffer_append_new_line(buffer, line);
+ g_object_unref(G_OBJECT(instr));
+
gtk_status_stack_update_activity_value(status, id, 1);
}
gtk_status_stack_remove_activity(status, id);
+ g_arch_processor_unlock(proc);
+
g_object_unref(G_OBJECT(content));
if (portions != NULL)
diff --git a/src/analysis/disass/routines.c b/src/analysis/disass/routines.c
index 04ef123..a9414fc 100644
--- a/src/analysis/disass/routines.c
+++ b/src/analysis/disass/routines.c
@@ -38,7 +38,7 @@ struct _GRoutinesStudy
{
GDelayedWork parent; /* A laisser en premier */
- const GArchProcessor *proc; /* Processeurs avec ses instr. */
+ GArchProcessor *proc; /* Processeurs avec ses instr. */
mrange_t *exe_ranges; /* Liste de zones exécutables */
size_t exe_count; /* Nombre de ces zones */
@@ -189,7 +189,7 @@ static void g_routines_study_finalize(GRoutinesStudy *study)
* *
******************************************************************************/
-GRoutinesStudy *g_routines_study_new(const GArchProcessor *proc, mrange_t *exe_ranges, size_t exe_count, GBinRoutine **routines, size_t count, size_t begin, size_t end, activity_id_t id, rtn_fallback_cb fallback)
+GRoutinesStudy *g_routines_study_new(GArchProcessor *proc, mrange_t *exe_ranges, size_t exe_count, GBinRoutine **routines, size_t count, size_t begin, size_t end, activity_id_t id, rtn_fallback_cb fallback)
{
GRoutinesStudy *result; /* Tâche à retourner */
diff --git a/src/analysis/disass/routines.h b/src/analysis/disass/routines.h
index 4b4e530..72df309 100644
--- a/src/analysis/disass/routines.h
+++ b/src/analysis/disass/routines.h
@@ -52,7 +52,7 @@ typedef void (* rtn_fallback_cb) (GRoutinesStudy *, size_t);
/* Crée une tâche d'étude de routines différée. */
-GRoutinesStudy *g_routines_study_new(const GArchProcessor *, mrange_t *, size_t, GBinRoutine **, size_t, size_t, size_t, activity_id_t, rtn_fallback_cb);
+GRoutinesStudy *g_routines_study_new(GArchProcessor *, mrange_t *, size_t, GBinRoutine **, size_t, size_t, size_t, activity_id_t, rtn_fallback_cb);
/* Détermine si besoin est les bornes des routines. */
void g_routines_study_compute_limits(GRoutinesStudy *, size_t);