summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-10-14 16:24:34 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-10-14 16:24:34 (GMT)
commit722539ffc6005c6cd9c8ebd37f93999014ae6d24 (patch)
tree5f78dce6057f904d689c9ff073cc69f33d057abf /src/analysis
parent8dff3daac4d2dc98b90adaecea834fb65db4fb10 (diff)
Handled Dalvik simple switch cases without fallthrough.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c16
-rw-r--r--src/analysis/binary.h6
-rw-r--r--src/analysis/db/item-int.h2
-rw-r--r--src/analysis/db/item.c20
-rw-r--r--src/analysis/db/item.h4
-rw-r--r--src/analysis/db/items/bookmark.c2
-rw-r--r--src/analysis/db/items/comment.c2
-rw-r--r--src/analysis/db/items/move.c2
-rw-r--r--src/analysis/db/items/switcher.c2
-rw-r--r--src/analysis/disass/disassembler.c44
-rw-r--r--src/analysis/disass/fetch.c10
-rw-r--r--src/analysis/disass/fetch.h2
-rw-r--r--src/analysis/disass/instructions.c9
-rw-r--r--src/analysis/disass/instructions.h2
14 files changed, 88 insertions, 35 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 75c6e14..96d61c2 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -1230,10 +1230,9 @@ GDbCollection *g_loaded_binary_find_collection(const GLoadedBinary *binary, DBFe
/******************************************************************************
* *
-* Paramètres : binary = élément binaire à consulter. *
-* feature = fonctionnalité visée par la requête. *
-* item = élémnent à pousser vers un serveur de collection. *
-* lock = indique si le verrou d'écriture doit être posé. *
+* Paramètres : binary = élément binaire à consulter. *
+* item = élémnent à pousser vers un serveur de collection. *
+* lock = indique si le verrou d'écriture doit être posé. *
* *
* Description : Demande l'intégration d'une modification dans une collection.*
* *
@@ -1243,14 +1242,17 @@ GDbCollection *g_loaded_binary_find_collection(const GLoadedBinary *binary, DBFe
* *
******************************************************************************/
-bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, DBFeatures feature, GDbItem *item, bool lock)
+bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item, bool lock)
{
bool result; /* Bilan à faire remonter */
+ DBFeatures feature; /* Domaine de fonctionnalité */
GDbCollection *collec; /* Collection visée au final */
DBStorage storage; /* Forme d'enregistrement */
GDbClient *client; /* Liaison à utiliser */
int fd; /* Identifiant du canal de com.*/
+ feature = g_db_item_get_feature(item);
+
collec = g_loaded_binary_find_collection(binary, feature);
if (collec == NULL) return false;
@@ -1373,6 +1375,8 @@ void g_loaded_binary_analyse(GLoadedBinary *binary)
// Déconnexion...
+ g_loaded_binary_connect_internal(binary);
+
disassemble_binary(binary, &binary->instrs, &binary->disass_buffer, ack_completed_disassembly);
@@ -1634,7 +1638,7 @@ void ack_completed_disassembly(GDelayedDisassembly *disass, GLoadedBinary *binar
g_object_unref(G_OBJECT(disass));
- /* ... = */g_loaded_binary_connect_internal(binary);
+ /* ... = *///g_loaded_binary_connect_internal(binary);
/* Décompilation... */
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 8d87bf0..d39a961 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -142,10 +142,10 @@ GList *g_loaded_binary_get_all_collections(const GLoadedBinary *);
GDbCollection *g_loaded_binary_find_collection(const GLoadedBinary *, DBFeatures);
/* Demande l'intégration d'une modification dans une collection. */
-bool _g_loaded_binary_add_to_collection(GLoadedBinary *, DBFeatures, GDbItem *, bool);
+bool _g_loaded_binary_add_to_collection(GLoadedBinary *, GDbItem *, bool);
-#define g_loaded_binary_add_to_collection(b, f, i) \
- _g_loaded_binary_add_to_collection(b, f, i, true)
+#define g_loaded_binary_add_to_collection(b, i) \
+ _g_loaded_binary_add_to_collection(b, i, true)
/* Demande la suppression de modification dans une collection. */
bool _g_loaded_binary_remove_from_collection(GLoadedBinary *, DBFeatures, GDbItem *, bool);
diff --git a/src/analysis/db/item-int.h b/src/analysis/db/item-int.h
index c2c8b31..d907100 100644
--- a/src/analysis/db/item-int.h
+++ b/src/analysis/db/item-int.h
@@ -80,6 +80,8 @@ struct _GDbItemClass
{
GObjectClass parent; /* A laisser en premier */
+ DBFeatures feature; /* Fonctionnalité représentée */
+
cmp_db_item_fc cmp; /* Comparaison entre éléments */
recv_db_item_fc recv; /* Réception depuis le réseau */
diff --git a/src/analysis/db/item.c b/src/analysis/db/item.c
index 013703d..62e8ce9 100644
--- a/src/analysis/db/item.c
+++ b/src/analysis/db/item.c
@@ -174,6 +174,26 @@ static void g_db_item_finalize(GDbItem *item)
}
+
+/******************************************************************************
+* *
+* Paramètres : item = élément de collection à consulter. *
+* *
+* Description : Indique la fonctionnalité représentée par l'élément. *
+* *
+* Retour : Identifiant valide pour le protocole. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+DBFeatures g_db_item_get_feature(const GDbItem *item)
+{
+ return G_DB_ITEM_GET_CLASS(item)->feature;
+
+}
+
+
/******************************************************************************
* *
* Paramètres : item = élément de collection à traiter. *
diff --git a/src/analysis/db/item.h b/src/analysis/db/item.h
index 2edf594..f8bb707 100644
--- a/src/analysis/db/item.h
+++ b/src/analysis/db/item.h
@@ -29,6 +29,7 @@
#include <stdbool.h>
+#include "protocol.h"
#include "misc/timestamp.h"
#include "../../common/sqlite.h"
@@ -56,6 +57,9 @@ typedef struct _GDbItemClass GDbItemClass;
/* Indique le type défini pour une base d'élément de collection générique. */
GType g_db_item_get_type(void);
+/* Indique la fonctionnalité représentée par l'élément. */
+DBFeatures g_db_item_get_feature(const GDbItem *);
+
/* Indique à l'élément qu'il se trouve du côté serveur. */
void g_db_item_set_server_side(GDbItem *);
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c
index 747053c..231e461 100644
--- a/src/analysis/db/items/bookmark.c
+++ b/src/analysis/db/items/bookmark.c
@@ -175,6 +175,8 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass)
item = G_DB_ITEM_CLASS(klass);
+ item->feature = DBF_BOOKMARKS;
+
item->cmp = (cmp_db_item_fc)g_db_bookmark_cmp;
item->recv = (recv_db_item_fc)g_db_bookmark_recv_from_fd;
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index f601bd6..6ce3d05 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -188,6 +188,8 @@ static void g_db_comment_class_init(GDbCommentClass *klass)
item = G_DB_ITEM_CLASS(klass);
+ item->feature = DBF_COMMENTS;
+
item->cmp = (cmp_db_item_fc)g_db_comment_cmp;
item->recv = (recv_db_item_fc)g_db_comment_recv_from_fd;
diff --git a/src/analysis/db/items/move.c b/src/analysis/db/items/move.c
index ad574b0..cf54c9b 100644
--- a/src/analysis/db/items/move.c
+++ b/src/analysis/db/items/move.c
@@ -181,6 +181,8 @@ static void g_db_move_class_init(GDbMoveClass *klass)
item = G_DB_ITEM_CLASS(klass);
+ item->feature = DBF_MOVES;
+
item->cmp = (cmp_db_item_fc)g_db_move_cmp;
item->recv = (recv_db_item_fc)g_db_move_recv_from_fd;
diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c
index e9182b4..a67040f 100644
--- a/src/analysis/db/items/switcher.c
+++ b/src/analysis/db/items/switcher.c
@@ -181,6 +181,8 @@ static void g_db_switcher_class_init(GDbSwitcherClass *klass)
item = G_DB_ITEM_CLASS(klass);
+ item->feature = DBF_DISPLAY_SWITCHERS;
+
item->cmp = (cmp_db_item_fc)g_db_switcher_cmp;
item->recv = (recv_db_item_fc)g_db_switcher_recv_from_fd;
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 2cfa6a5..364348a 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -79,7 +79,7 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *);
static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GArchInstruction **, GCodeBuffer *);
/* Opère sur toutes les instructions. */
-static void process_all_instructions(wgroup_id_t, GtkStatusStack *, const char *, ins_fallback_cb, GArchProcessor *, GExeFormat *);
+static void process_all_instructions(wgroup_id_t, GtkStatusStack *, const char *, ins_fallback_cb, GArchProcessor *, GProcContext *, GExeFormat *);
/* Opère sur toutes les routines. */
static void process_all_routines(wgroup_id_t, GtkStatusStack *, const char *, rtn_fallback_cb, GArchProcessor *, GExeFormat *);
@@ -182,10 +182,11 @@ static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GAr
/******************************************************************************
* *
* Paramètres : gid = groupe de travail impliqué. *
- status = barre de statut à tenir informée. *
+* status = barre de statut à tenir informée. *
* msg = message à faire paraître pour la patience. *
* fallback = routine de traitements particuliers. *
* proc = ensemble d'instructions désassemblées. *
+* ctx = contexte fourni pour suivre le désassemblage. *
* format = accès aux données du binaire d'origine. *
* *
* Description : Opère sur toutes les instructions. *
@@ -196,7 +197,7 @@ static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GAr
* *
******************************************************************************/
-static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, const char *msg, ins_fallback_cb fallback, GArchProcessor *proc, GExeFormat *format)
+static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, const char *msg, ins_fallback_cb fallback, GArchProcessor *proc, GProcContext *ctx, GExeFormat *format)
{
guint runs_count; /* Qté d'exécutions parallèles */
size_t ins_count; /* Quantité d'instructions */
@@ -227,7 +228,7 @@ static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, co
else
end = begin + run_size;
- study = g_instructions_study_new(proc, G_BIN_FORMAT(format), begin, end, id, fallback);
+ study = g_instructions_study_new(proc, ctx, G_BIN_FORMAT(format), begin, end, id, fallback);
g_work_queue_schedule_work(queue, G_DELAYED_WORK(study), gid);
@@ -329,24 +330,26 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
//GBinFormat *format; /* Format du fichier binaire */
GArchProcessor *proc; /* Architecture du binaire */
-
+ GProcContext *ctx; /* Contexte de suivi dédié */
//size_t i; /* Boucle de parcours */
+ _curbin = disass->binary;
+ //format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
+ proc = g_loaded_binary_get_processor(disass->binary);
+ ctx = g_arch_processor_get_context(proc);
- gid = g_work_queue_define_work_group(get_work_queue());
+ gid = g_work_queue_define_work_group(get_work_queue());
- //format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
- proc = g_loaded_binary_get_processor(disass->binary);
@@ -361,7 +364,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
- *disass->instrs = disassemble_binary_content(disass->binary, gid, status);
+ *disass->instrs = disassemble_binary_content(disass->binary, ctx, gid, status);
g_arch_processor_set_disassembled_instructions(proc, *disass->instrs);
@@ -374,7 +377,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
process_all_instructions(gid, status, _("Calling 'link' hook on all instructions..."),
g_instructions_study_do_link_operation,
- proc, disass->format);
+ proc, ctx, disass->format);
// plugins //////////////////////////
@@ -390,7 +393,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
process_all_instructions(gid, status, _("Calling 'post' hook on all instructions..."),
g_instructions_study_do_post_operation,
- proc, disass->format);
+ proc, ctx, disass->format);
@@ -426,7 +429,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
process_all_instructions(gid, status, _("Establishing links betweek all instructions..."),
g_instructions_study_establish_links,
- proc, disass->format);
+ proc, ctx, disass->format);
@@ -515,16 +518,29 @@ 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, status);
- g_object_unref(G_OBJECT(proc));
+ /* Rajout de tous les éléments mis en place automatiquement */
+
+ void add_to_collection(GDbItem *item, GLoadedBinary *binary)
+ {
+ g_object_ref(G_OBJECT(item));
+ g_loaded_binary_add_to_collection(binary, item);
+
+ }
+ g_proc_context_foreach_db_item(ctx, (GFunc)add_to_collection, disass->binary);
+
+ /* Nettoyage final et sortie ! */
+
+ g_object_unref(G_OBJECT(ctx));
+
+ g_object_unref(G_OBJECT(proc));
process_disassembly_event(PGA_DISASSEMBLY_ENDED, disass->binary);
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index 4b162e8..7d8161a 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -480,6 +480,7 @@ static GDelayedFetching template; /* Patron des tâches à venir
/******************************************************************************
* *
* Paramètres : binary = représentation de binaire chargé. *
+* ctx = contexte fourni pour suivre le désassemblage. *
* gid = identifiant du groupe de travail à utiliser. *
* status = barre de statut avec progression à mettre à jour. *
* *
@@ -491,12 +492,11 @@ static GDelayedFetching template; /* Patron des tâches à venir
* *
******************************************************************************/
-GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup_id_t gid, GtkStatusStack *status)
+GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GProcContext *ctx, wgroup_id_t gid, GtkStatusStack *status)
{
GArchInstruction *result; /* Instruction désassemblées */
//GDelayedFetching template; /* Patron des tâches à venir */
GBinFormat *format; /* Format du fichier binaire */
- GArchProcessor *proc; /* Architecture du binaire */
GBinContent *content; /* Contenu binaire à manipuler */
phys_t length; /* Taille des données à lire */
GWorkQueue *queue; /* Gestionnaire de différés */
@@ -509,9 +509,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup
template.format = g_loaded_binary_get_format(binary);
format = G_BIN_FORMAT(template.format);
- proc = g_loaded_binary_get_processor(binary);
- template.ctx = g_arch_processor_get_context(proc);
- g_object_unref(G_OBJECT(proc));
+ template.ctx = ctx;
content = g_binary_format_get_content(format);
length = g_binary_content_compute_size(content);
@@ -577,8 +575,6 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup
//g_object_unref(G_OBJECT(template.format));
- g_object_unref(G_OBJECT(template.ctx));
-
/* TODO / del(areas); */
return result;
diff --git a/src/analysis/disass/fetch.h b/src/analysis/disass/fetch.h
index 3ebb4d8..eb1d0d3 100644
--- a/src/analysis/disass/fetch.h
+++ b/src/analysis/disass/fetch.h
@@ -32,7 +32,7 @@
/* Procède au désassemblage basique d'un contenu binaire. */
-GArchInstruction *disassemble_binary_content(const GLoadedBinary *, wgroup_id_t, GtkStatusStack *);
+GArchInstruction *disassemble_binary_content(const GLoadedBinary *, GProcContext *, wgroup_id_t, GtkStatusStack *);
diff --git a/src/analysis/disass/instructions.c b/src/analysis/disass/instructions.c
index b88d69f..47633d0 100644
--- a/src/analysis/disass/instructions.c
+++ b/src/analysis/disass/instructions.c
@@ -39,6 +39,7 @@ struct _GInstructionsStudy
GDelayedWork parent; /* A laisser en premier */
GArchProcessor *proc; /* Processeurs avec ses instr. */
+ GProcContext *ctx; /* Suivi du désassemblage */
GBinFormat *format; /* Format binaire à manipuler */
ins_fallback_cb fallback; /* Routine de traitement finale*/
@@ -169,6 +170,7 @@ static void g_instructions_study_finalize(GInstructionsStudy *study)
/******************************************************************************
* *
* Paramètres : proc = ensemble d'instructions désassemblées. *
+* ctx = contexte fourni pour suivre le désassemblage. *
* format = accès aux données du binaire d'origine. *
* begin = point de départ du parcours de liste. *
* end = point d'arrivée exclu du parcours. *
@@ -183,13 +185,14 @@ static void g_instructions_study_finalize(GInstructionsStudy *study)
* *
******************************************************************************/
-GInstructionsStudy *g_instructions_study_new(GArchProcessor *proc, GBinFormat *format, size_t begin, size_t end, activity_id_t id, ins_fallback_cb fallback)
+GInstructionsStudy *g_instructions_study_new(GArchProcessor *proc, GProcContext *ctx, GBinFormat *format, size_t begin, size_t end, activity_id_t id, ins_fallback_cb fallback)
{
GInstructionsStudy *result; /* Tâche à retourner */
result = g_object_new(G_TYPE_INSTRUCTIONS_STUDY, NULL);
result->proc = proc;
+ result->ctx = ctx;
result->format = format;
result->fallback = fallback;
@@ -250,7 +253,7 @@ void g_instructions_study_do_link_operation(GInstructionsStudy *study, size_t in
instr = g_arch_processor_get_disassembled_instruction(study->proc, index);
- g_arch_instruction_call_hook(instr, IPH_LINK, study->proc, NULL, study->format);
+ g_arch_instruction_call_hook(instr, IPH_LINK, study->proc, study->ctx, study->format);
}
@@ -274,7 +277,7 @@ void g_instructions_study_do_post_operation(GInstructionsStudy *study, size_t in
instr = g_arch_processor_get_disassembled_instruction(study->proc, index);
- g_arch_instruction_call_hook(instr, IPH_POST, study->proc, NULL, study->format);
+ g_arch_instruction_call_hook(instr, IPH_POST, study->proc, study->ctx, study->format);
}
diff --git a/src/analysis/disass/instructions.h b/src/analysis/disass/instructions.h
index 20b853d..c18322c 100644
--- a/src/analysis/disass/instructions.h
+++ b/src/analysis/disass/instructions.h
@@ -52,7 +52,7 @@ typedef void (* ins_fallback_cb) (GInstructionsStudy *, size_t);
/* Crée une tâche d'étude de instructions différée. */
-GInstructionsStudy *g_instructions_study_new(GArchProcessor *, GBinFormat *, size_t, size_t, activity_id_t, ins_fallback_cb);
+GInstructionsStudy *g_instructions_study_new(GArchProcessor *, GProcContext *, GBinFormat *, size_t, size_t, activity_id_t, ins_fallback_cb);
/* Réalise l'appel de type IPH_LINK sur une instruction. */
void g_instructions_study_do_link_operation(GInstructionsStudy *, size_t);