summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-07-12 11:32:03 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-07-12 11:32:03 (GMT)
commit254254db8c09eb4b4f8523e73551c13ec281d194 (patch)
tree730beb552a9d300e71f583fc40ef5a5b9dc40b42
parentba1d7ae3ae3c82ab2c3d23a900c16baff6f8ca26 (diff)
Only given access to instructions from a processor.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@547 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
-rw-r--r--ChangeLog11
-rw-r--r--plugins/androhelpers/params.c8
-rw-r--r--plugins/androhelpers/switch.c8
-rw-r--r--plugins/androhelpers/try_n_catch.c17
-rw-r--r--src/analysis/binary.c19
-rw-r--r--src/analysis/binary.h3
-rw-r--r--src/gui/menus/edition.c6
-rw-r--r--src/gui/panels/strings.c6
8 files changed, 47 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 0534fa0..bfe8fde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
15-07-12 Cyrille Bagard <nocbos@gmail.com>
+ * plugins/androhelpers/params.c:
+ * plugins/androhelpers/switch.c:
+ * plugins/androhelpers/try_n_catch.c:
+ * src/analysis/binary.c:
+ * src/analysis/binary.h:
+ * src/gui/menus/edition.c:
+ * src/gui/panels/strings.c:
+ Only give access to instructions from a processor.
+
+15-07-12 Cyrille Bagard <nocbos@gmail.com>
+
* plugins/androhelpers/switch.c:
* plugins/libcsem/exit.c:
* plugins/ropgadgets/finder.c:
diff --git a/plugins/androhelpers/params.c b/plugins/androhelpers/params.c
index 6993821..df56fca 100644
--- a/plugins/androhelpers/params.c
+++ b/plugins/androhelpers/params.c
@@ -180,8 +180,9 @@ static void visit_all_method_operands(const GDexMethod *method, GArchInstruction
bool replace_parameters(GLoadedBinary *binary)
{
- GArchInstruction *instrs; /* Instructions Dalvik */
GDexFormat *format; /* Format du binaire chargé */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
+ GArchInstruction *instrs; /* Instructions Dalvik */
size_t cls_count; /* Nombre de classes trouvées */
size_t i; /* Boucle de parcours #1 */
GDexClass *class; /* Classe à analyser */
@@ -189,8 +190,9 @@ bool replace_parameters(GLoadedBinary *binary)
size_t j; /* Boucle de parcours #2 */
GDexMethod *method; /* Méthode à parcourir */
- instrs = g_loaded_binary_get_instructions(binary);
format = G_DEX_FORMAT(g_loaded_binary_get_format(binary));
+ proc = g_loaded_binary_get_processor(binary);
+ instrs = g_arch_processor_get_disassembled_instructions(proc);
cls_count = g_dex_format_count_classes(format);
for (i = 0; i < cls_count; i++)
@@ -213,6 +215,8 @@ bool replace_parameters(GLoadedBinary *binary)
}
+ g_object_unref(G_OBJECT(proc));
+
return true;
}
diff --git a/plugins/androhelpers/switch.c b/plugins/androhelpers/switch.c
index f93c9e9..a5a8a75 100644
--- a/plugins/androhelpers/switch.c
+++ b/plugins/androhelpers/switch.c
@@ -383,8 +383,9 @@ static void look_for_switch_instructions(const GDexMethod *method, GArchInstruct
bool extract_switch_info(GLoadedBinary *binary, bool link)
{
- GArchInstruction *instrs; /* Instructions Dalvik */
GDexFormat *format; /* Format du binaire chargé */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
+ GArchInstruction *instrs; /* Instructions Dalvik */
size_t cls_count; /* Nombre de classes trouvées */
size_t i; /* Boucle de parcours #1 */
GDexClass *class; /* Classe à analyser */
@@ -392,8 +393,9 @@ bool extract_switch_info(GLoadedBinary *binary, bool link)
size_t j; /* Boucle de parcours #2 */
GDexMethod *method; /* Méthode à parcourir */
- instrs = g_loaded_binary_get_instructions(binary);
format = G_DEX_FORMAT(g_loaded_binary_get_format(binary));
+ proc = g_loaded_binary_get_processor(binary);
+ instrs = g_arch_processor_get_disassembled_instructions(proc);
cls_count = g_dex_format_count_classes(format);
for (i = 0; i < cls_count; i++)
@@ -416,6 +418,8 @@ bool extract_switch_info(GLoadedBinary *binary, bool link)
}
+ g_object_unref(G_OBJECT(proc));
+
return true;
}
diff --git a/plugins/androhelpers/try_n_catch.c b/plugins/androhelpers/try_n_catch.c
index 94be140..d2c6043 100644
--- a/plugins/androhelpers/try_n_catch.c
+++ b/plugins/androhelpers/try_n_catch.c
@@ -111,6 +111,7 @@ static void attach_caught_code(const GLoadedBinary *binary, const GBinRoutine *r
{
vmpa_t start; /* Début de la zone couverte */
vmpa_t end; /* Fin de la zone couverte */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
GArchInstruction *instrs; /* Instructions Dalvik */
GArchInstruction *first; /* Première instruction */
GArchInstruction *next; /* Dernière instruction + 1 */
@@ -123,12 +124,14 @@ static void attach_caught_code(const GLoadedBinary *binary, const GBinRoutine *r
end = start + try->insn_count * sizeof(uint16_t);
- instrs = g_loaded_binary_get_instructions(binary);
+ proc = g_loaded_binary_get_processor(binary);
+ instrs = g_arch_processor_get_disassembled_instructions(proc);
+
first = g_arch_instruction_find_by_address(instrs, start, true);
next = g_arch_instruction_find_by_address(instrs, end, true);
if (first == NULL || next == NULL)
- return;
+ goto acc_exit;
/* Si des détachements sont nécessaires... */
@@ -162,6 +165,10 @@ static void attach_caught_code(const GLoadedBinary *binary, const GBinRoutine *r
}
+ acc_exit:
+
+ g_object_unref(G_OBJECT(proc));
+
}
@@ -232,6 +239,7 @@ static caught_exception **build_all_destinations_list(const GLoadedBinary *binar
caught_exception **result; /* Liste de listes à retourner */
GDexFormat *format; /* Format du binaire chargé */
vmpa_t start; /* Début du code de la routine */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
GArchInstruction *instrs; /* Instructions Dalvik */
uleb128_t i; /* Boucle de parcours #1 */
encoded_catch_handler *handlers; /* Groupe de gestionnaires */
@@ -244,7 +252,8 @@ static caught_exception **build_all_destinations_list(const GLoadedBinary *binar
start = g_binary_routine_get_address(routine);
- instrs = g_loaded_binary_get_instructions(binary);
+ proc = g_loaded_binary_get_processor(binary);
+ instrs = g_arch_processor_get_disassembled_instructions(proc);
instrs = g_arch_instruction_find_by_address(instrs, start, true);
/* Création d'un espace mémoire pour les listes */
@@ -302,6 +311,8 @@ static caught_exception **build_all_destinations_list(const GLoadedBinary *binar
}
+ g_object_unref(G_OBJECT(proc));
+
return result;
}
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index b0712fd..7e16990 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -1008,25 +1008,6 @@ GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *binary)
* *
* Paramètres : binary = élément binaire à consulter. *
* *
-* Description : Fournit les instructions issues du désassemblage. *
-* *
-* Retour : Instructions issues du désassemblage. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GArchInstruction *g_loaded_binary_get_instructions(const GLoadedBinary *binary)
-{
- return binary->instrs;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
-* *
* Description : Fournit le tampon associé au contenu assembleur d'un binaire.*
* *
* Retour : Tampon mis en place ou NULL si aucun (!). *
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 6878fe4..163caaa 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -160,9 +160,6 @@ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *);
/* Fournit le processeur de l'architecture liée au binaire. */
GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *);
-/* Fournit les instructions issues du désassemblage. */
-GArchInstruction *g_loaded_binary_get_instructions(const GLoadedBinary *);
-
/* Fournit le tampon associé au contenu assembleur d'un binaire. */
GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *);
diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c
index c242a00..040c8ab 100644
--- a/src/gui/menus/edition.c
+++ b/src/gui/menus/edition.c
@@ -242,6 +242,7 @@ static void mcb_edition_list_xrefs(GtkMenuItem *menuitem, GMenuBar *bar)
GBufferLine *line; /* Ligne de position courante */
const mrange_t *range; /* Couverture en mémoire */
GLoadedBinary *binary; /* Représentation binaire */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
GArchInstruction *list; /* Ensemble des instructions */
GArchInstruction *instr; /* Point de croisements */
GObject *ref; /* Espace de référencements */
@@ -255,7 +256,8 @@ static void mcb_edition_list_xrefs(GtkMenuItem *menuitem, GMenuBar *bar)
range = g_buffer_line_get_range(line);
binary = g_editor_item_get_current_binary(G_EDITOR_ITEM(bar));
- list = g_loaded_binary_get_instructions(binary);
+ proc = g_loaded_binary_get_processor(binary);
+ list = g_arch_processor_get_disassembled_instructions(proc);
/**
* On ne peut pas se reposer sur l'espace couvert par une ligne, car il peut
@@ -287,6 +289,8 @@ static void mcb_edition_list_xrefs(GtkMenuItem *menuitem, GMenuBar *bar)
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(proc));
+
g_object_unref(G_OBJECT(line));
}
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index b8f5eca..825c510 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -1039,6 +1039,7 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa
GBinSymbol *symbol; /* Symbole sélectionné */
const mrange_t *range; /* Couverture en mémoire */
GLoadedBinary *binary; /* Représentation binaire */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
GArchInstruction *list; /* Ensemble des instructions */
GArchInstruction *instr; /* Point de croisements */
GObject *ref; /* Espace de référencements */
@@ -1052,7 +1053,8 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa
range = g_binary_symbol_get_range(symbol);
binary = g_editor_item_get_current_binary(G_EDITOR_ITEM(panel));
- list = g_loaded_binary_get_instructions(binary);
+ proc = g_loaded_binary_get_processor(binary);
+ list = g_arch_processor_get_disassembled_instructions(proc);
/**
* Se rapporter aux commentaires de mcb_edition_list_xrefs() pour les questions
@@ -1077,6 +1079,8 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(proc));
+
g_object_unref(G_OBJECT(symbol));
}